2004-08-02 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Mon, 2 Aug 2004 03:52:29 +0000 (03:52 -0000)
committerMartin Baulig <martin@novell.com>
Mon, 2 Aug 2004 03:52:29 +0000 (03:52 -0000)
* dump.c (dump_stream_blob): Format this nicely.
(dump_table_standalonesig): New public function.

* main.c (dis_locals): If --show-tokens was requested, print the
standalone signature token.
(table_list): Added "--standalonesig".

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

mono/dis/ChangeLog
mono/dis/dump.c
mono/dis/dump.h
mono/dis/main.c

index 26f8fdb75c6986909ed442869874781bae505573..e3e808cfe358cecfb8f733e0907f85fbbfc98dc0 100644 (file)
@@ -1,3 +1,12 @@
+2004-08-02  Martin Baulig  <martin@ximian.com>
+
+       * dump.c (dump_stream_blob): Format this nicely.
+       (dump_table_standalonesig): New public function.
+
+       * main.c (dis_locals): If --show-tokens was requested, print the
+       standalone signature token.
+       (table_list): Added "--standalonesig".
+
 2004-07-09  Jackson Harper  <jackson@ximian.com>
 
        * get.c: Make "class" the default so only valuetypes get the
index db25520d2e08796666446831db7151508bbb69cf..210fa91ad445121fff004b88c37c0c2a5eb851a6 100644 (file)
@@ -1124,11 +1124,42 @@ dump_stream_blob (MonoImage *m)
        fprintf (output, "Blob heap contents\n");
 
        for (i = 0; i < m->heap_blob.size; i++) {
-               fprintf (output, "%x ", m->heap_blob.data [i]);
-               if (i > 0 && (i % 25) == 0)
-                       fprintf (output, "\n");
+               if (i > 0) {
+                       if ((i % 16) == 0)
+                               fprintf (output, "\n");
+                       else if ((i % 8) == 0)
+                               fprintf (output, "- ");
+               }
+               fprintf (output, "%02x ", m->heap_blob.data [i] & 0xff);
        }
 
        fprintf (output, "\n");
 }
 
+void
+dump_table_standalonesig (MonoImage *m)
+{
+       MonoTableInfo *t = &m->tables [MONO_TABLE_STANDALONESIG];
+       guint32 cols [MONO_STAND_ALONE_SIGNATURE_SIZE];
+       int i;
+       
+       fprintf (output, "Stand alone signature (1..%d)\n", t->rows);
+
+       for (i = 1; i <= t->rows; i++) {
+                char *sig;
+               const char *locals_ptr;
+               int j, bsize;
+
+               mono_metadata_decode_row (t, i - 1, cols, MONO_STAND_ALONE_SIGNATURE_SIZE);
+
+               locals_ptr = mono_metadata_blob_heap (m, cols [MONO_STAND_ALONE_SIGNATURE]);
+               bsize = mono_metadata_decode_blob_size (locals_ptr, &locals_ptr);
+
+               fprintf (output, "%d: blob[0x%x] = ", i, cols [MONO_STAND_ALONE_SIGNATURE]);
+
+               for (j = 0; j < bsize; j++) {
+                       fprintf (output, "%02x ", locals_ptr [j]);
+               }
+               fprintf (output, "\n");
+       }
+}
index 687d525a8caa6fa67a000881c266ae00523ef989..44f95be3f7a8a8fe3e04ae4ac18aeea7add7456f 100644 (file)
@@ -30,4 +30,5 @@ void dump_table_genericpar   (MonoImage *m);
 void dump_table_methodspec   (MonoImage *m);
 void dump_table_parconstraint(MonoImage *m);
 void dump_table_implmap      (MonoImage *m);
+void dump_table_standalonesig (MonoImage *m);
 void dump_stream_blob        (MonoImage *m);
index c6688cd364a68e2be64e2256318c21170edf8be8..d56736932eb966fa3bb44f86893a0fa7dbb6b5ed 100644 (file)
@@ -452,11 +452,38 @@ method_impl_flags (guint32 f)
 }
 
 static void
-dis_locals (MonoImage *m, MonoMethodHeader *mh) 
+dis_locals (MonoImage *m, MonoMethodHeader *mh, const char *ptr
 {
        int i;
 
-       fprintf(output, "\t.locals %s(\n", mh->init_locals ? "init " : "");
+       if (show_tokens) {
+               unsigned char flags = *(const unsigned char *) ptr;
+               unsigned char format = flags & METHOD_HEADER_FORMAT_MASK;
+               guint16 fat_flags;
+               guint32 local_var_sig_tok, max_stack, code_size, init_locals;
+               int hsize;
+
+               g_assert (format == METHOD_HEADER_FAT_FORMAT);
+               fat_flags = read16 (ptr);
+               ptr += 2;
+               hsize = (fat_flags >> 12) & 0xf;
+               max_stack = read16 (ptr);
+               ptr += 2;
+               code_size = read32 (ptr);
+               ptr += 4;
+               local_var_sig_tok = read32 (ptr);
+               ptr += 4;
+
+               if (fat_flags & METHOD_HEADER_INIT_LOCALS)
+                       init_locals = 1;
+               else
+                       init_locals = 0;
+
+               fprintf(output, "\t.locals /*%08x*/ %s(\n",
+                       local_var_sig_tok, init_locals ? "init " : "");
+       } else
+               fprintf(output, "\t.locals %s(\n", mh->init_locals ? "init " : "");
+
        for (i=0; i < mh->num_locals; ++i) {
                char * desc;
                if (i)
@@ -490,7 +517,7 @@ dis_code (MonoImage *m, guint32 rva)
        fprintf (output, "\t// Code size %d (0x%x)\n", mh->code_size, mh->code_size);
        fprintf (output, "\t.maxstack %d\n", mh->max_stack);
        if (mh->num_locals)
-               dis_locals (m, mh);
+               dis_locals (m, mh, ptr);
        dissasemble_cil (m, mh);
        
 /*
@@ -1157,6 +1184,7 @@ struct {
        { "--typeref",     MONO_TABLE_TYPEREF,          dump_table_typeref },
        { "--typespec",    MONO_TABLE_TYPESPEC,         dump_table_typespec },
        { "--implmap",     MONO_TABLE_IMPLMAP,          dump_table_implmap },
+       { "--standalonesig", MONO_TABLE_STANDALONESIG,  dump_table_standalonesig },
        { "--blob",        NULL,                        dump_stream_blob },
        { NULL, -1 }
 };