[jit] Allocate the thunks area next to the method code if the backend can compute...
[mono.git] / mono / mini / debug-mini.c
index c031f323137986eb34fb7d33049a3821e37db4f8..92ff7d8ce1f1fdeaa03cf1e759b33b5e0b1dcf2f 100644 (file)
@@ -16,9 +16,7 @@
 #include <mono/metadata/appdomain.h>
 #include <mono/metadata/threads-types.h>
 
-#define _IN_THE_MONO_DEBUGGER
 #include <mono/metadata/mono-debug-debugger.h>
-#include "debug-mini.h"
 
 #include <mono/utils/valgrind.h>
 
@@ -35,64 +33,6 @@ typedef struct
        guint32 breakpoint_id;
 } MiniDebugMethodInfo;
 
-typedef struct {
-       MonoObject *last_exception;
-       guint32 stopped_on_exception : 1;
-       guint32 stopped_on_unhandled : 1;
-} MonoDebuggerExceptionState;
-
-typedef enum {
-       MONO_DEBUGGER_THREAD_FLAGS_NONE         = 0,
-       MONO_DEBUGGER_THREAD_FLAGS_INTERNAL     = 1,
-       MONO_DEBUGGER_THREAD_FLAGS_THREADPOOL   = 2
-} MonoDebuggerThreadFlags;
-
-typedef enum {
-       MONO_DEBUGGER_INTERNAL_THREAD_FLAGS_NONE                = 0,
-       MONO_DEBUGGER_INTERNAL_THREAD_FLAGS_IN_RUNTIME_INVOKE   = 1,
-       MONO_DEBUGGER_INTERNAL_THREAD_FLAGS_ABORT_REQUESTED     = 2
-} MonoDebuggerInternalThreadFlags;
-
-struct _MonoDebuggerThreadInfo {
-       guint64 tid;
-       guint64 lmf_addr;
-       guint64 end_stack;
-
-       guint64 extended_notifications;
-
-       /* Next pointer. */
-       MonoDebuggerThreadInfo *next;
-
-       /*
-        * The stack bounds are only used when reading a core file.
-        */
-       guint64 stack_start;
-       guint64 signal_stack_start;
-       guint32 stack_size;
-       guint32 signal_stack_size;
-
-       guint32 thread_flags;
-
-       /*
-        * The debugger doesn't access anything beyond this point.
-        */
-       MonoDebuggerExceptionState exception_state;
-
-       guint32 internal_flags;
-
-       MonoJitTlsData *jit_tls;
-       MonoInternalThread *thread;
-};
-
-typedef struct {
-       gpointer stack_pointer;
-       MonoObject *exception_obj;
-       guint32 stop;
-       guint32 stop_unhandled;
-} MonoDebuggerExceptionInfo;
-
-MonoDebuggerThreadInfo *mono_debugger_thread_table = NULL;
-
 static inline void
 record_line_number (MiniDebugMethodInfo *info, guint32 address, guint32 offset)
 {
@@ -110,7 +50,7 @@ mono_debug_init_method (MonoCompile *cfg, MonoBasicBlock *start_block, guint32 b
 {
        MiniDebugMethodInfo *info;
 
-       if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
+       if (!mono_debug_enabled ())
                return;
 
        info = g_new0 (MiniDebugMethodInfo, 1);
@@ -280,7 +220,6 @@ mono_debug_close_method (MonoCompile *cfg)
        MonoDebugMethodJitInfo *jit;
        MonoMethodHeader *header;
        MonoMethodSignature *sig;
-       MonoDebugMethodAddress *debug_info;
        MonoMethod *method;
        int i;
 
@@ -330,12 +269,10 @@ mono_debug_close_method (MonoCompile *cfg)
        for (i = 0; i < jit->num_line_numbers; i++)
                jit->line_numbers [i] = g_array_index (info->line_numbers, MonoDebugLineNumberEntry, i);
 
-       debug_info = mono_debug_add_method (cfg->method_to_register, jit, cfg->domain);
+       mono_debug_add_method (cfg->method_to_register, jit, cfg->domain);
 
        mono_debug_add_vg_method (method, jit);
 
-       mono_debugger_check_breakpoints (method, debug_info);
-
        mono_debug_free_method_jit_info (jit);
        mono_debug_free_method (cfg);
 }
@@ -486,10 +423,10 @@ serialize_variable (MonoDebugVarInfo *var, guint8 *p, guint8 **endbuf)
                break;
        case MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET:
        case MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET_INDIR:
+       case MONO_DEBUG_VAR_ADDRESS_MODE_VTADDR:
                encode_value (var->offset, p, &p);
                break;
        case MONO_DEBUG_VAR_ADDRESS_MODE_GSHAREDVT_LOCAL:
-       case MONO_DEBUG_VAR_ADDRESS_MODE_VTADDR:
        case MONO_DEBUG_VAR_ADDRESS_MODE_DEAD:
                break;
        default:
@@ -569,10 +506,10 @@ deserialize_variable (MonoDebugVarInfo *var, guint8 *p, guint8 **endbuf)
                break;
        case MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET:
        case MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET_INDIR:
+       case MONO_DEBUG_VAR_ADDRESS_MODE_VTADDR:
                var->offset = decode_value (p, &p);
                break;
        case MONO_DEBUG_VAR_ADDRESS_MODE_GSHAREDVT_LOCAL:
-       case MONO_DEBUG_VAR_ADDRESS_MODE_VTADDR:
        case MONO_DEBUG_VAR_ADDRESS_MODE_DEAD:
                break;
        default:
@@ -651,7 +588,7 @@ mono_debug_add_aot_method (MonoDomain *domain, MonoMethod *method, guint8 *code_
 {
        MonoDebugMethodJitInfo *jit;
 
-       if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
+       if (!mono_debug_enabled ())
                return;
 
        if ((method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
@@ -673,15 +610,6 @@ mono_debug_add_aot_method (MonoDomain *domain, MonoMethod *method, guint8 *code_
        mono_debug_free_method_jit_info (jit);
 }
 
-void
-mono_debug_add_icall_wrapper (MonoMethod *method, MonoJitICallInfo* callinfo)
-{
-       if (mono_debug_format == MONO_DEBUG_FORMAT_NONE)
-               return;
-
-       // mono_debug_add_wrapper (method, callinfo->wrapper, callinfo->func);
-}
-
 static void
 print_var_info (MonoDebugVarInfo *info, int idx, const char *name, const char *type)
 {
@@ -759,9 +687,9 @@ mono_debug_print_vars (gpointer ip, gboolean only_arguments)
  * breakpoint when the method is JITed.
  */
 
-static GPtrArray *breakpoints = NULL;
+static GPtrArray *breakpoints;
 
-int
+static int
 mono_debugger_insert_breakpoint_full (MonoMethodDesc *desc)
 {
        static int last_breakpoint_id = 0;
@@ -779,29 +707,7 @@ mono_debugger_insert_breakpoint_full (MonoMethodDesc *desc)
        return info->index;
 }
 
-int
-mono_debugger_remove_breakpoint (int breakpoint_id)
-{
-       int i;
-
-       if (!breakpoints)
-               return 0;
-
-       for (i = 0; i < breakpoints->len; i++) {
-               MiniDebugBreakpointInfo *info = g_ptr_array_index (breakpoints, i);
-
-               if (info->index != breakpoint_id)
-                       continue;
-
-               mono_method_desc_free (info->desc);
-               g_ptr_array_remove (breakpoints, info);
-               g_free (info);
-               return 1;
-       }
-
-       return 0;
-}
-
+/*FIXME This is part of the public API by accident, remove it from there when possible. */
 int
 mono_debugger_insert_breakpoint (const gchar *method_name, gboolean include_namespace)
 {
@@ -814,6 +720,7 @@ mono_debugger_insert_breakpoint (const gchar *method_name, gboolean include_name
        return mono_debugger_insert_breakpoint_full (desc);
 }
 
+/*FIXME This is part of the public API by accident, remove it from there when possible. */
 int
 mono_debugger_method_has_breakpoint (MonoMethod *method)
 {
@@ -833,9 +740,3 @@ mono_debugger_method_has_breakpoint (MonoMethod *method)
 
        return 0;
 }
-
-void
-mono_debugger_breakpoint_callback (MonoMethod *method, guint32 index)
-{
-       mono_debugger_event (MONO_DEBUGGER_EVENT_JIT_BREAKPOINT, (guint64) (gsize) method, index);
-}