2003-04-23 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Wed, 23 Apr 2003 15:02:13 +0000 (15:02 -0000)
committerMartin Baulig <martin@novell.com>
Wed, 23 Apr 2003 15:02:13 +0000 (15:02 -0000)
* tramp-x86.c, tramp-ppc.c: Reenable the debugger breakpoint interface.

* driver.c: Added `--debug' command line argument to enable
debugging support.

svn path=/trunk/mono/; revision=13930

mono/mini/ChangeLog
mono/mini/Makefile.am
mono/mini/debug-mini.c
mono/mini/driver.c
mono/mini/exceptions-x86.c
mono/mini/mini.c
mono/mini/tramp-ppc.c
mono/mini/tramp-x86.c

index bfef94d1e317a3f912128a2fdecc9d0419e4db4c..77b415341f581a56bb990e7892fa90f09e265647 100644 (file)
@@ -1,3 +1,10 @@
+2003-04-23  Martin Baulig  <martin@ximian.com>
+
+       * tramp-x86.c, tramp-ppc.c: Reenable the debugger breakpoint interface.
+
+       * driver.c: Added `--debug' command line argument to enable
+       debugging support.
+
 2003-04-23  Martin Baulig  <martin@ximian.com>
 
        * debug.[ch]: Removed.  The code is now in
index 7ac9b78a6fe549c0aa2d053da3569a5e86f0e20a..35cc6f0c74ba9b6203ee749dce3b515547fd5ada 100644 (file)
@@ -57,9 +57,6 @@ libmini_la_SOURCES = \
        liveness.c      \
        ssa.c           \
        driver.c        \
-       debug.c         \
-       debug-stabs.c   \
-       debug-dwarf2.c  \
        debug-mini.c    \
        linear-scan.c   \
        aot.c           \
index 2774bc1294f11c4b30d2c55cf9dee74510457b3f..62882f47cb0ca6ab2fa18f515dbf4c3f9d89aba5 100644 (file)
@@ -9,23 +9,37 @@
 
 #include "mini.h"
 #include "mini-x86.h"
-#include "debug-private.h"
+#include <mono/metadata/mono-debug.h>
+#include <mono/metadata/mono-debug-debugger.h>
 
-void
-mono_debug_codegen_breakpoint (guint8 **buf)
+gpointer
+mono_debugger_create_notification_function (gpointer *notification_address)
 {
-       x86_breakpoint (*buf);
+       guint8 *ptr, *buf;
+
+       ptr = buf = g_malloc0 (16);
+       x86_breakpoint (buf);
+       if (notification_address)
+               *notification_address = buf;
+       x86_ret (buf);
+
+       return ptr;
 }
 
-void
-mono_debug_codegen_ret (guint8 **buf)
+static void
+record_line_number (MonoDebugMethodJitInfo *jit, guint32 address, guint32 offset)
 {
-       x86_ret (*buf);
+       MonoDebugLineNumberEntry *lne = g_new0 (MonoDebugLineNumberEntry, 1);
+
+       lne->address = address;
+       lne->offset = offset;
+
+       g_array_append_val (jit->line_numbers, *lne);
 }
 
 typedef struct
 {
-       MonoDebugMethodInfo *minfo;
+       MonoDebugMethodJitInfo *jit;
        guint32 has_line_numbers;
 } MiniDebugMethodInfo;
 
@@ -35,9 +49,6 @@ mono_debug_init_method (MonoCompile *cfg, MonoBasicBlock *start_block)
        MonoMethod *method = cfg->method;
        MiniDebugMethodInfo *info;
 
-       if (!mono_debug_handle)
-               return;
-
        if ((method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
            (method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) ||
            (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
@@ -63,16 +74,10 @@ mono_debug_open_method (MonoCompile *cfg)
 
        mono_class_init (cfg->method->klass);
 
-       info->minfo = _mono_debug_lookup_method (cfg->method);
-       if (!info->minfo || info->minfo->jit)
-               return;
+       g_assert (((MonoMethodNormal*)cfg->method)->header);
+       header = ((MonoMethodNormal*)cfg->method)->header;
 
-       mono_debug_handle->dirty = TRUE;
-
-       g_assert (((MonoMethodNormal*)info->minfo->method)->header);
-       header = ((MonoMethodNormal*)info->minfo->method)->header;
-
-       info->minfo->jit = jit = g_new0 (MonoDebugMethodJitInfo, 1);
+       info->jit = jit = g_new0 (MonoDebugMethodJitInfo, 1);
        jit->line_numbers = g_array_new (FALSE, TRUE, sizeof (MonoDebugLineNumberEntry));
        jit->num_locals = header->num_locals;
        jit->locals = g_new0 (MonoDebugVarInfo, jit->num_locals);
@@ -95,26 +100,24 @@ void
 mono_debug_close_method (MonoCompile *cfg)
 {
        MiniDebugMethodInfo *info;
-       MonoDebugMethodInfo *minfo;
        MonoDebugMethodJitInfo *jit;
        MonoMethodHeader *header;
        MonoMethod *method;
        int i;
 
        info = (MiniDebugMethodInfo *) cfg->debug_info;
-       if (!info || !info->minfo)
+       if (!info || !info->jit)
                return;
 
-       minfo = info->minfo;
-       method = minfo->method;
+       method = cfg->method;
        header = ((MonoMethodNormal*)method)->header;
 
-       jit = minfo->jit;
+       jit = info->jit;
        jit->code_start = cfg->native_code;
        jit->epilogue_begin = cfg->epilog_begin;
        jit->code_size = cfg->code_len;
 
-       _mono_debug_generate_line_number (minfo, jit->epilogue_begin, header->code_size, 0);
+       record_line_number (jit, jit->epilogue_begin, header->code_size);
 
        jit->num_params = method->signature->param_count;
        jit->params = g_new0 (MonoDebugVarInfo, jit->num_params);
@@ -130,10 +133,7 @@ mono_debug_close_method (MonoCompile *cfg)
        for (i = 0; i < jit->num_params; i++)
                write_variable (cfg->varinfo [i + method->signature->hasthis], &jit->params [i]);
 
-       if (minfo->symfile) {
-               mono_debug_symfile_add_method (minfo->symfile, minfo->method);
-               mono_debugger_event (MONO_DEBUGGER_EVENT_METHOD_ADDED, minfo->symfile, minfo->method);
-       }
+       mono_debug_add_method (method, jit);
 }
 
 void
@@ -144,11 +144,11 @@ mono_debug_record_line_number (MonoCompile *cfg, MonoInst *ins, guint32 address)
        guint32 offset;
 
        info = (MiniDebugMethodInfo *) cfg->debug_info;
-       if (!info || !info->minfo || !ins->cil_code)
+       if (!info || !info->jit || !ins->cil_code)
                return;
 
-       g_assert (((MonoMethodNormal*)info->minfo->method)->header);
-       header = ((MonoMethodNormal*)info->minfo->method)->header;
+       g_assert (((MonoMethodNormal*)cfg->method)->header);
+       header = ((MonoMethodNormal*)cfg->method)->header;
 
        if ((ins->cil_code < header->code) ||
            (ins->cil_code > header->code + header->code_size))
@@ -156,9 +156,9 @@ mono_debug_record_line_number (MonoCompile *cfg, MonoInst *ins, guint32 address)
 
        offset = ins->cil_code - header->code;
        if (!info->has_line_numbers) {
-               info->minfo->jit->prologue_end = address;
+               info->jit->prologue_end = address;
                info->has_line_numbers = TRUE;
        }
 
-       _mono_debug_generate_line_number (info->minfo, address, offset, 0);
+       record_line_number (info->jit, address, offset);
 }
index dd2b72dac4e6f14229d8623037038680bd819db5..8f1dbf97ad6ded12683ff4f1eb081b410109fcf3 100644 (file)
 #include <mono/metadata/profiler-private.h>
 #include <mono/metadata/mono-config.h>
 #include <mono/metadata/environment.h>
+#include <mono/metadata/mono-debug.h>
+#include <mono/metadata/mono-debug-debugger.h>
 
 #include "mini.h"
 #include <string.h>
 #include <ctype.h>
 #include "inssel.h"
-#include "debug.h"
 
 static FILE *mini_stats_fd = NULL;
 
@@ -476,6 +477,7 @@ mini_usage (void)
                "    --compile-all          Compiles all the methods in the assembly\n"
                "    --breakonex            Inserts a breakpoint on exceptions\n"
                "    --break METHOD         Inserts a breakpoint at METHOD entry\n"
+               "    --debug                Enable debugging support\n"
                "\n"
                "Development:\n"
                "    --statfile FILE        Sets the stat file to FILE\n"
@@ -511,6 +513,7 @@ mini_main (int argc, char* argv[]) {
        const char* aname, *mname = NULL;
        char *config_file = NULL;
        int i, count = 1;
+       int enable_debugging = FALSE;
        guint32 opt, action = DO_EXEC;
        MonoGraphOptions mono_graph_options = 0;
        int mini_verbose = 0;
@@ -543,7 +546,7 @@ mini_main (int argc, char* argv[]) {
                } else if (strcmp (argv [i], "--breakonex") == 0) {
                        mono_break_on_exc = TRUE;
                } else if (strcmp (argv [i], "--break") == 0) {
-                       if (!mono_insert_breakpoint (argv [++i], FALSE))
+                       if (!mono_debugger_insert_breakpoint (argv [++i], FALSE))
                                g_error ("Invalid method name '%s'", argv [i]);
                } else if (strcmp (argv [i], "--print-vtable") == 0) {
                        mono_print_vtable = TRUE;
@@ -569,6 +572,8 @@ mini_main (int argc, char* argv[]) {
                        mname = argv [++i];
                        mono_graph_options = MONO_GRAPH_CFG;
                        action = DO_DRAW;
+               } else if (strcmp (argv [i], "--debug") == 0) {
+                       enable_debugging = TRUE;
                } else {
                        fprintf (stderr, "Unknown command line option: %s\n", argv [i]);
                        return 1;
@@ -621,6 +626,9 @@ mini_main (int argc, char* argv[]) {
                break;
        }
 
+       if (enable_debugging)
+               mono_debug_init (MONO_DEBUG_FORMAT_MONO);
+
        assembly = mono_assembly_open (aname, NULL);
        if (!assembly) {
                fprintf (stderr, "cannot open assembly %s\n", aname);
@@ -628,6 +636,9 @@ mini_main (int argc, char* argv[]) {
                return 2;
        }
 
+       if (enable_debugging)
+               mono_debug_init_2 (assembly);
+
        if (mono_compile_aot || action == DO_EXEC) {
                g_set_prgname (aname);
                mono_config_parse (config_file);
index bef1b13dc0c8922c57612c2e8a257d061d7db204..8c80d7f94f685f764e4dca2e29ce5b17f2be20c1 100644 (file)
 #include <mono/metadata/threads.h>
 #include <mono/metadata/debug-helpers.h>
 #include <mono/metadata/exception.h>
+#include <mono/metadata/mono-debug.h>
 
 #include "mini.h"
 #include "mini-x86.h"
-#include "debug-private.h"
 
 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
 # define SC_EAX sc_eax
@@ -600,13 +600,10 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf
                                *managed = TRUE;
 
                if (trace) {
-                       if (mono_debug_format != MONO_DEBUG_FORMAT_NONE)
-                               mono_debug_make_symbols ();
+                       mono_debug_update ();
 
                        source_location = mono_debug_source_location_from_address (ji->method, address, NULL);
                        iloffset = mono_debug_il_offset_from_address (ji->method, address);
-                       source_location = NULL;
-                       iloffset = -1;
 
                        if (iloffset < 0)
                                tmpaddr = g_strdup_printf ("<0x%05x>", address);
@@ -863,8 +860,7 @@ mono_arch_handle_exception (MonoContext *ctx, gpointer obj, gboolean test_only)
                        g_print ("EXCEPTION handling: %s\n", mono_object_class (obj)->name);
                if (!mono_arch_handle_exception (&ctx_cp, obj, TRUE)) {
                        if (mono_break_on_exc) {
-                               if (mono_debug_format != MONO_DEBUG_FORMAT_NONE)
-                                       mono_debug_make_symbols ();
+                               mono_debug_update ();
                                G_BREAKPOINT ();
                        }
                        mono_unhandled_exception (obj);
index 38de19fdcdd93846681cdd058bc9fb1118fbdc3c..66610b19a5bc2555c1948fc4f68ec57e5fe67ede 100644 (file)
 #include <mono/metadata/profiler-private.h>
 #include <mono/metadata/mono-config.h>
 #include <mono/metadata/environment.h>
+#include <mono/metadata/mono-debug.h>
+#include <mono/metadata/mono-debug-debugger.h>
 
 #include "mini.h"
 #include <string.h>
 #include <ctype.h>
 #include "inssel.h"
-#include "debug.h"
 
 #include "jit-icalls.c"
 
@@ -2143,7 +2144,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
        ADD_BBLOCK (cfg, bbhash, bblock);
 
        if (cfg->method == method) {
-               if (mono_method_has_breakpoint (method, FALSE)) {
+               if (mono_debugger_method_has_breakpoint (method, FALSE)) {
                        MONO_INST_NEW (cfg, ins, CEE_BREAK);
                        MONO_ADD_INS (bblock, ins);
                }
index ed3258af2b06306a0768afc6260431a7db4244b3..1fff9776d1b38a07c05547bdd94d97a3a72fd129 100644 (file)
 #include <mono/metadata/appdomain.h>
 #include <mono/metadata/tabledefs.h>
 #include <mono/arch/ppc/ppc-codegen.h>
+#include <mono/metadata/mono-debug-debugger.h>
 
 #include "mini.h"
 #include "mini-ppc.h"
 
-/* 
- * define for the (broken) debugger breakpoint interface:
- * The debugger should use the hw registers to set the breakpoints.
- */
-#define mono_method_has_breakpoint(a,b) (0)
-#define mono_remove_breakpoint(a)
-
 /* adapt to mini later... */
 #define mono_jit_share_code (1)
 
@@ -564,7 +558,7 @@ x86_magic_trampoline (int eax, int ecx, int edx, int esi, int edi,
                        reg = code [1] & 0x07;
                        disp = *((gint32*)(code + 2));
                } else if ((code [1] == 0xe8)) {
-                       breakpoint_id = mono_method_has_breakpoint (m, TRUE);
+                       breakpoint_id = mono_debugger_method_has_breakpoint (m, TRUE);
                        if (breakpoint_id) {
                                mono_remove_breakpoint (breakpoint_id);
                                trampoline = get_breakpoint_trampoline (m, breakpoint_id, addr);
@@ -618,9 +612,9 @@ x86_magic_trampoline (int eax, int ecx, int edx, int esi, int edi,
                trampoline = *((gpointer *)o) = addr;
        }
 
-       breakpoint_id = mono_method_has_breakpoint (m, TRUE);
+       breakpoint_id = mono_debugger_method_has_breakpoint (m, TRUE);
        if (breakpoint_id) {
-               mono_remove_breakpoint (breakpoint_id);
+               mono_debugger_remove_breakpoint (breakpoint_id);
                return get_breakpoint_trampoline (m, breakpoint_id, trampoline);
        } else {
                return trampoline;
index 38569e73f1a2d9e9afc2b202deaad8e5200000e4..eed6c03dff65d5dc5d4bab4218dd14eb820abea8 100644 (file)
 #include <mono/metadata/marshal.h>
 #include <mono/metadata/tabledefs.h>
 #include <mono/arch/x86/x86-codegen.h>
+#include <mono/metadata/mono-debug-debugger.h>
 
 #include "mini.h"
 #include "mini-x86.h"
 
-/* 
- * define for the (broken) debugger breakpoint interface:
- * The debugger should use the hw registers to set the breakpoints.
- */
-#define mono_method_has_breakpoint(a,b) (0)
-#define mono_remove_breakpoint(a)
-
 /* adapt to mini later... */
 #define mono_jit_share_code (1)
 
@@ -150,9 +144,9 @@ x86_magic_trampoline (int eax, int ecx, int edx, int esi, int edi,
                        reg = code [1] & 0x07;
                        disp = *((gint32*)(code + 2));
                } else if ((code [1] == 0xe8)) {
-                       breakpoint_id = mono_method_has_breakpoint (m, TRUE);
+                       breakpoint_id = mono_debugger_method_has_breakpoint (m, TRUE);
                        if (breakpoint_id) {
-                               mono_remove_breakpoint (breakpoint_id);
+                               mono_debugger_remove_breakpoint (breakpoint_id);
                                trampoline = get_breakpoint_trampoline (m, breakpoint_id, addr);
                        } else
                                trampoline = addr;
@@ -204,9 +198,9 @@ x86_magic_trampoline (int eax, int ecx, int edx, int esi, int edi,
                trampoline = *((gpointer *)o) = addr;
        }
 
-       breakpoint_id = mono_method_has_breakpoint (m, TRUE);
+       breakpoint_id = mono_debugger_method_has_breakpoint (m, TRUE);
        if (breakpoint_id) {
-               mono_remove_breakpoint (breakpoint_id);
+               mono_debugger_remove_breakpoint (breakpoint_id);
                return get_breakpoint_trampoline (m, breakpoint_id, trampoline);
        } else {
                return trampoline;