2008-04-21 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Mon, 21 Apr 2008 14:50:43 +0000 (14:50 -0000)
committerMartin Baulig <martin@novell.com>
Mon, 21 Apr 2008 14:50:43 +0000 (14:50 -0000)
* mini.h (MonoDebugOptions): Added `mdb_optimizations'.

* mini.c
(mini_method_compile): In the fp elimination check, check
`debug_options.mdb_optimizations' in addition to
mono_debug_using_mono_debugger().

* driver.c (mono_main): Added `--debug=mdb-optimizations' option to
disable some JIT optimizations which are only disabled when
running inside the debugger.
Added `--help-debug' option to describe the debugging options.
(parse_debug_options): New static function to parse the `--debug'
options, so we can easily add more stuff in future.

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

mono/mini/ChangeLog
mono/mini/driver.c
mono/mini/mini.c
mono/mini/mini.h

index f618a3492ed1f1b45a6043498eccc2b5e511e4a7..c8e3dacfd385201c5e25c72b281204af470f5c9a 100644 (file)
@@ -1,3 +1,19 @@
+2008-04-21  Martin Baulig  <martin@ximian.com>
+
+       * mini.h (MonoDebugOptions): Added `mdb_optimizations'.
+
+       * mini.c
+       (mini_method_compile): In the fp elimination check, check
+       `debug_options.mdb_optimizations' in addition to
+       mono_debug_using_mono_debugger().       
+
+       * driver.c (mono_main): Added `--debug=mdb-optimizations' option to
+       disable some JIT optimizations which are only disabled when
+       running inside the debugger.
+       Added `--help-debug' option to describe the debugging options.
+       (parse_debug_options): New static function to parse the `--debug'
+       options, so we can easily add more stuff in future.
+
 2008-04-20  Zoltan Varga  <vargaz@gmail.com>
 
        * mini.c (set_exception_type_from_invalid_il): Avoid reading invalid memory when
index 80de88f281830c4d4c08b3c53eeb9765393c3f82..38cd1cf071296585d7d6adc7c73b434406ae43d5 100644 (file)
@@ -192,6 +192,40 @@ parse_optimizations (const char* p)
        return opt;
 }
 
+static gboolean
+parse_debug_options (const char* p)
+{
+       MonoDebugOptions *opt = mini_get_debug_options ();
+
+       do {
+               if (!*p) {
+                       fprintf (stderr, "Syntax error; expected debug option name\n");
+                       return FALSE;
+               }
+
+               if (!strncmp (p, "casts", 5)) {
+                       opt->better_cast_details = TRUE;
+                       p += 5;
+               } else if (!strncmp (p, "mdb-optimizations", 17)) {
+                       opt->mdb_optimizations = TRUE;
+                       p += 17;
+               } else {
+                       fprintf (stderr, "Invalid debug option `%s', use --help-debug for details\n", p);
+                       return FALSE;
+               }
+
+               if (*p == ',') {
+                       p++;
+                       if (!*p) {
+                               fprintf (stderr, "Syntax error; expected debug option name\n");
+                               return FALSE;
+                       }
+               }
+       } while (*p);
+
+       return TRUE;
+}
+
 typedef struct {
        const char name [6];
        const char desc [18];
@@ -942,7 +976,7 @@ mini_usage (void)
                "\n"
                "Development:\n"
                "    --aot                  Compiles the assembly to native code\n"
-               "    --debug[=<options>]    Enable debugging support. The only valid option is 'casts' which enables more detailed InvalidCastException messages.\n"
+               "    --debug[=<options>]    Enable debugging support, use --help-debug for details\n"
                "    --profile[=profiler]   Runs in profiling mode with the specified profiler module\n"
                "    --trace[=EXPR]         Enable tracing, use --help-trace for details\n"
                "    --help-devel           Shows more options available to developers\n"
@@ -979,6 +1013,23 @@ mini_trace_usage (void)
                 "    disabled             Don't print any output until toggled via SIGUSR2\n");
 }
 
+static void
+mini_debug_usage (void)
+{
+       fprintf (stdout,
+                "Debugging options:\n"
+                "   --debug[=OPTIONS]     Enable debugging support, optional OPTIONS is a comma\n"
+                "                         separated list of options\n"
+                "\n"
+                "OPTIONS is composed of:\n"
+                "    casts                Enable more detailed InvalidCastException messages.\n"
+                "    mdb-optimizations    Disable some JIT optimizations which are normally\n"
+                "                         disabled when running inside the debugger.\n"
+                "                         This is useful if you plan to attach to the running\n"
+                "                         process with the debugger.\n");
+}
+
+
 static const char info[] =
 #ifdef HAVE_KW_THREAD
        "\tTLS:           __thread\n"
@@ -1097,6 +1148,9 @@ mono_main (int argc, char* argv[])
                } else if (strcmp (argv [i], "--help-devel") == 0){
                        mini_usage_jitdeveloper ();
                        return 0;
+               } else if (strcmp (argv [i], "--help-debug") == 0){
+                       mini_debug_usage ();
+                       return 0;
                } else if (strcmp (argv [i], "--list-opt") == 0){
                        mini_usage_list_opt ();
                        return 0;
@@ -1216,12 +1270,8 @@ mono_main (int argc, char* argv[])
                        enable_debugging = TRUE;
                } else if (strncmp (argv [i], "--debug=", 8) == 0) {
                        enable_debugging = TRUE;
-                       if (strcmp (argv [i] + 8, "casts") == 0)
-                               mini_get_debug_options ()->better_cast_details = TRUE;
-                       else {
-                               fprintf (stderr, "Invalid debug option '%s'. The following options are supported: 'casts'.\n", argv [i] + 8);
+                       if (!parse_debug_options (argv [i] + 8))
                                return 1;
-                       }
                } else if (strcmp (argv [i], "--security") == 0) {
                        /* fixme enable verifiable code when the verifier works with 2.0
                        * mini_verifier_set_mode (MINI_VERIFIER_MODE_VERIFIABLE);
index f4e849b124ba2722e45b6e43030e250a09457689..a7406d300f7e82b48e3c3f5165a4da30b4ce0f10 100644 (file)
@@ -11859,7 +11859,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
        cfg->token_info_hash = g_hash_table_new (NULL, NULL);
 
        /* The debugger has no liveness information, so avoid sharing registers/stack slots */
-       if (mono_debug_using_mono_debugger ()) {
+       if (mono_debug_using_mono_debugger () || debug_options.mdb_optimizations) {
                cfg->disable_reuse_registers = TRUE;
                cfg->disable_reuse_stack_slots = TRUE;
                /* 
index 902f2a09f69eaa9dbd277c848e2525b4afd5819f..497c6a68f8051e3f6227e01f0a72868ad58c581b 100644 (file)
@@ -999,6 +999,7 @@ typedef struct {
        gboolean collect_pagefault_stats;
        gboolean break_on_unverified;
        gboolean better_cast_details;
+       gboolean mdb_optimizations;
 } MonoDebugOptions;
 
 enum {