Wed Jul 11 18:52:15 CEST 2001 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Wed, 11 Jul 2001 17:03:57 +0000 (17:03 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Wed, 11 Jul 2001 17:03:57 +0000 (17:03 -0000)
* dis-cil.c: output real name of local var.
* dump.c: output more info about fields (flags and type). Properly decode
Property signatures. Decode also method table.
* main.c: Fix local variable info. Hopefully fix field and property list.

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

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

index 02a09ff7e346c237841cfab1b6890c5e30acbd03..f2a5eac804f068adaa29aaed0675697a2af122f0 100644 (file)
@@ -1,3 +1,10 @@
+Wed Jul 11 18:52:15 CEST 2001 Paolo Molaro <lupus@ximian.com>
+
+       * dis-cil.c: output real name of local var.
+       * dump.c: output more info about fields (flags and type). Properly decode
+       Property signatures. Decode also method table.
+       * main.c: Fix local variable info. Hopefully fix field and property list.
+
 Mon Jul  9 16:39:41 CEST 2001 Paolo Molaro <lupus@ximian.com>
 
        * dump.c: write stuff to output, not stderr. Give more info for properties.
index 6374d68fba4ee851efa4938d907d879bf0c98586..6c4fe95f4a11a5769bd681ab40347321034c8d34 100644 (file)
@@ -228,7 +228,7 @@ dissasemble_cil (metadata_t *m, const unsigned char *start, int size)
                case ShortInlineVar: {
                        signed char x = *ptr;
 
-                       fprintf (output, "Varidx-%d", (int) x);
+                       fprintf (output, "V_%d", (int) x);
                        ptr++;
                        break;
                }
index 6c6c4f8b4659186b2be662b2711c97d73ee4fe77..4356a29e85edcf5bad904e93f2bf034497121635 100644 (file)
@@ -139,12 +139,18 @@ dump_table_field (metadata_t *m)
        
        for (i = 0; i < t->rows; i++){
                guint32 cols [3];
+               char *sig, *flags;
 
                expand (t, i, cols, CSIZE (cols));
-               fprintf (output, "%d: 0x%02x %s\n",
+               sig = get_field_signature (m, cols [2]);
+               flags = field_flags (cols [0]);
+               fprintf (output, "%d: %s %s: %s\n",
                         i,
-                        cols [0], 
-                        mono_metadata_string_heap (m, cols [1]));
+                        sig,
+                        mono_metadata_string_heap (m, cols [1]),
+                        flags);
+               g_free (sig);
+               g_free (flags);
        }
        fprintf (output, "\n");
 }
@@ -247,6 +253,7 @@ dump_table_property (metadata_t *m)
        for (i = 0; i < t->rows; i++){
                guint32 cols [3];
                char *type;
+               int bsize;
                
                expand (t, i, cols, CSIZE (cols));
                flags [0] = 0;
@@ -258,11 +265,11 @@ dump_table_property (metadata_t *m)
                        strcat (flags, "hasdefault ");
 
                ptr = mono_metadata_blob_heap (m, cols [2]);
-               /*
-                * The data in the blob doesn't follow the specs:
-                * there are 3 nibbles first (we skip also the 0x8 signature).
-                */
-               ptr+=2;
+               ptr = get_blob_encoded_size (ptr, &bsize);
+               /* ECMA claims 0x08 ... */
+               if (*ptr != 0x28 && *ptr != 0x08)
+                               g_warning("incorrect signature in propert blob: 0x%x", *ptr);
+               ptr++;
                ptr = get_encoded_value (ptr, &pcount);
                ptr = get_type (m, ptr, &type);
                fprintf (output, "%d: %s %s (",
@@ -339,3 +346,22 @@ dump_table_moduleref (metadata_t *m)
        
 }
 
+void
+dump_table_method (metadata_t *m)
+{
+       metadata_tableinfo_t *t = &m->tables [META_TABLE_METHOD];
+       int i;
+       fprintf (output, "Method Table (0..%d)\n", t->rows);
+
+       for (i = 0; i < t->rows; i++){
+               guint32 cols [6];
+               const char *name;
+               
+               expand (t, i, cols, CSIZE (cols));
+
+               name = mono_metadata_string_heap (m, cols[3]);
+               fprintf (output, "%d: %s\n", i, name);
+       }
+       
+}
+
index c65137476ddf6de12ef50ef49026ac96df661ef1..8f37c9941135ff7162d4bf1b24e19ba7e6fc27ef 100644 (file)
@@ -8,6 +8,7 @@ void dump_table_property     (metadata_t *m);
 void dump_table_event        (metadata_t *m);
 void dump_table_file         (metadata_t *m);
 void dump_table_moduleref    (metadata_t *m);
+void dump_table_method       (metadata_t *m);
 void dump_table_field        (metadata_t *m);
 void dump_table_memberref    (metadata_t *m);
 void dump_table_param        (metadata_t *m);
index 63d25513b5498ef22d0698dcc98deecefe609037..51458a77b8a03c5fbecc8d315321fe4be63a5ec1 100644 (file)
@@ -291,11 +291,15 @@ dis_locals (metadata_t *m, guint32 token)
 {
        metadata_tableinfo_t *t = &m->tables [META_TABLE_STANDALONESIG];
        const char *ptr;
-       int len, i;
-
-       /*fprintf(stderr, "rows: %d\n", t->rows);*/
-       expand (t, token&0xffffff, &len, 1);
-       ptr = mono_metadata_blob_heap (m, len);
+       guint32 cols[1];
+       int len=0, i, bsize;
+
+       expand (t, (token&0xffffff)-1, cols, CSIZE(cols));
+       ptr = mono_metadata_blob_heap (m, cols[0]);
+       ptr = get_blob_encoded_size (ptr, &bsize);
+       if (*ptr != 0x07)
+                       g_warning("wrong signature for locals blob");
+       ptr++;
        ptr = get_encoded_value (ptr, &len);
        fprintf(output, "\t.locals ( // %d\n", len);
        for (i=0; i < len; ++i) {
@@ -313,7 +317,7 @@ dis_locals (metadata_t *m, guint32 token)
                        p = ptr;
                }
                ptr = get_type(m, p, &desc);
-               fprintf(output, "\t\t%s\tlocal%d\n", desc, i);
+               fprintf(output, "\t\t%s\tV_%d\n", desc, i);
                g_free(desc);
        }
        fprintf(output, "\t)\n");
@@ -403,7 +407,7 @@ free_method_signature (MethodSignature *ms)
 }
 
 /**
- * dis_field_list:
+ * dis_method_list:
  * @m: metadata context
  * @start: starting index into the Method Table.
  * @end: ending index into Method table.
@@ -493,7 +497,7 @@ dis_type (metadata_t *m, cli_image_info_t *ii, int n)
        
        expand (t, n, cols, CSIZE (cols));
 
-       if (t->rows > n){
+       if (t->rows > n+1){
                expand (t, n + 1, cols_next, CSIZE (cols_next));
                next_is_valid = 1;
        } else
@@ -516,13 +520,17 @@ dis_type (metadata_t *m, cli_image_info_t *ii, int n)
         * The value in the table is always valid, we know we have fields
         * if the value stored is different than the next record.
         */
+
        if (next_is_valid)
                last = cols_next [4] - 1;
        else
                last = m->tables [META_TABLE_FIELD].rows;
                        
-       if (cols [4] != cols_next [4] && cols_next [4] != 0)
+       /*if (cols [4] != cols_next [4] && cols_next [4] != 0)
+               dis_field_list (m, cols [4] - 1, last);*/
+       if (cols[4] && cols[4] <= m->tables [META_TABLE_FIELD].rows)
                dis_field_list (m, cols [4] - 1, last);
+       /*fprintf (output, "cols[4] -> %d   cols_next[4] -> %d   last -> %d  rows -> %d\n", cols[4], cols_next[4], last, m->tables [META_TABLE_FIELD].rows);*/
        fprintf (output, "\n");
 
        if (next_is_valid)
@@ -530,8 +538,11 @@ dis_type (metadata_t *m, cli_image_info_t *ii, int n)
        else
                last = m->tables [META_TABLE_METHOD].rows;
        
-       if (cols [4] != cols_next [5] && cols_next [5] != 0)
-               dis_method_list (m, ii, cols [5] - 1, last);
+       /*if (cols [4] != cols_next [5] && cols_next [5] != 0)
+               dis_method_list (m, ii, cols [5] - 1, last);*/
+       /*fprintf (output, "method(%d): cols[5] -> %d   cols_next[5] -> %d   last -> %d  rows -> %d\n", next_is_valid, cols[5], cols_next[5], last, m->tables [META_TABLE_METHOD].rows);*/
+       if (cols [5] < m->tables [META_TABLE_METHOD].rows)
+               dis_method_list (m, ii, cols [5]-1, last);
 
        fprintf (output, "  }\n}\n\n");
 }
@@ -570,6 +581,7 @@ struct {
        { "--event",       META_TABLE_EVENT,       dump_table_event },
        { "--file",        META_TABLE_FILE,        dump_table_file },
        { "--moduleref",   META_TABLE_MODULEREF,   dump_table_moduleref },
+       { "--method",      META_TABLE_METHOD,      dump_table_method },
        { NULL, -1 }
 };