2005-09-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mono / dis / main.c
index 33f842895bbd79de5f141dbe6a5ff44a7807b372..8242bb9970b8f51f8fb0f8458abd215f8a2e4892 100644 (file)
@@ -211,6 +211,7 @@ dis_directive_assemblyref (MonoImage *m)
                         cols [MONO_ASSEMBLYREF_MAJOR_VERSION], cols [MONO_ASSEMBLYREF_MINOR_VERSION], 
                         cols [MONO_ASSEMBLYREF_BUILD_NUMBER], cols [MONO_ASSEMBLYREF_REV_NUMBER]
                        );
+               dump_cattrs (m, MONO_TOKEN_ASSEMBLY_REF | (i + 1), "  ");
                if (cols [MONO_ASSEMBLYREF_CULTURE]){
                        fprintf (output, "  .locale %s\n", mono_metadata_string_heap (m, cols [MONO_ASSEMBLYREF_CULTURE]));
                }
@@ -257,17 +258,22 @@ dis_directive_moduleref (MonoImage *m)
 
        for (i = 0; i < t->rows; i++){
                guint32 cols [MONO_MODULEREF_SIZE];
-               char *esc;
                
                mono_metadata_decode_row (t, i, cols, MONO_MODULEREF_SIZE);
 
-               esc = get_escaped_name (mono_metadata_string_heap (m, cols [MONO_MODULEREF_NAME]));
-               fprintf (output, ".module extern %s\n", esc);
-               g_free (esc);
+               fprintf (output, ".module extern '%s'\n", mono_metadata_string_heap (m, cols [MONO_MODULEREF_NAME]));
        }
        
 }
 
+static void
+dis_nt_header (MonoImage *m)
+{
+       MonoCLIImageInfo *image_info = m->image_info;
+       if (image_info && image_info->cli_header.nt.pe_stack_reserve != 0x100000)
+               fprintf (output, ".stackreserve 0x%x\n", image_info->cli_header.nt.pe_stack_reserve);
+}
+
 static void
 dis_directive_file (MonoImage *m)
 {
@@ -1374,6 +1380,7 @@ struct {
        { "--methodspec",  MONO_TABLE_METHODSPEC,       dump_table_methodspec },
        { "--moduleref",   MONO_TABLE_MODULEREF,        dump_table_moduleref },
        { "--module",      MONO_TABLE_MODULE,           dump_table_module },
+       { "--mresources",  0,   dis_mresource },
        { "--nested",      MONO_TABLE_NESTEDCLASS,      dump_table_nestedclass },
        { "--param",       MONO_TABLE_PARAM,            dump_table_param },
        { "--parconst",    MONO_TABLE_GENERICPARAMCONSTRAINT, dump_table_parconstraint },
@@ -1422,6 +1429,7 @@ disassemble_file (const char *file)
                dis_directive_mresource (img);
                dis_directive_module (img);
                dis_directive_moduleref (img);
+               dis_nt_header (img);
                 if (dump_managed_resources)
                        dis_mresource (img);
                if (dump_forward_decls) {
@@ -1710,7 +1718,7 @@ usage (void)
                if (((i-2) % 5) == 0)
                        g_string_append_c (args, '\n');
        }
-       g_string_append (args, "[--forward-decls]\n[--mresources]");
+       g_string_append (args, "[--forward-decls]");
        fprintf (stderr,
                 "monodis -- Mono Common Intermediate Language Dissassembler\n" 
                 "Usage is: monodis %s file ..\n", args->str);
@@ -1747,6 +1755,7 @@ main (int argc, char *argv [])
                                                 argv [i]+9, strerror (errno));
                                        exit (1);
                                }
+                               dump_managed_resources = TRUE;
                                continue;
                        } else if (strncmp (argv [i], "--filter=", 9) == 0) {
                                load_filter (argv [i]+9);
@@ -1754,9 +1763,6 @@ main (int argc, char *argv [])
                        } else if (strcmp (argv [i], "--forward-decls") == 0) {
                                dump_forward_decls = TRUE;
                                continue;
-                       } else if (strcmp (argv [i], "--mresources") == 0) {
-                               dump_managed_resources = TRUE;
-                               continue;
                        } else if (strcmp (argv [i], "--help") == 0)
                                usage ();
                        for (j = 0; table_list [j].name != NULL; j++) {