X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fdis%2Fdump.c;h=ba2354d5fef582a649cad118d0d94c6fd252f265;hb=e698ebe6355598c0a4a52338dd5cacfce2a2d9d7;hp=a3ed4480ff08f9fb6d9812ff2ee77404664ef0b0;hpb=e605fc95a3cee96c2058054c7d75c814390fe3e0;p=mono.git diff --git a/mono/dis/dump.c b/mono/dis/dump.c index a3ed4480ff0..ba2354d5fef 100644 --- a/mono/dis/dump.c +++ b/mono/dis/dump.c @@ -15,14 +15,20 @@ #include "util.h" #include "dump.h" #include "get.h" +#include "declsec.h" #include "mono/metadata/loader.h" #include "mono/metadata/class.h" +#include "mono/metadata/class-internals.h" #include "mono/utils/mono-compiler.h" +#ifndef HAVE_ISINF + #ifdef HAVE_IEEEFP_H extern int isinf (double); #endif +#endif + void dump_table_assembly (MonoImage *m) { @@ -136,6 +142,7 @@ dump_table_assemblyref (MonoImage *m) cols [MONO_ASSEMBLYREF_BUILD_NUMBER], cols [MONO_ASSEMBLYREF_REV_NUMBER], mono_metadata_string_heap (m, cols [MONO_ASSEMBLYREF_NAME])); + fprintf (output, "\tFlags=0x%08x\n", cols [MONO_ASSEMBLYREF_FLAGS]); ptr = mono_metadata_blob_heap (m, cols [MONO_ASSEMBLYREF_PUBLIC_KEY]); len = mono_metadata_decode_value (ptr, &ptr); if (len > 0){ @@ -275,7 +282,7 @@ dump_table_memberref (MonoImage *m) if (*blob == 0x6) { /* it's a field */ sig = get_field_signature (m, cols [MONO_MEMBERREF_SIGNATURE], NULL); } else { - sig = get_methodref_signature (m, cols [MONO_MEMBERREF_SIGNATURE], NULL, NULL); + sig = get_methodref_signature (m, cols [MONO_MEMBERREF_SIGNATURE], NULL); } fprintf (output, "%d: %s[%d] %s\n\tResolved: %s\n\tSignature: %s\n\t\n", i + 1, @@ -387,7 +394,7 @@ dump_table_property (MonoImage *m) g_warning("incorrect signature in propert blob: 0x%x", *ptr); ptr++; pcount = mono_metadata_decode_value (ptr, &ptr); - ptr = get_type (m, ptr, &type, NULL); + ptr = get_type (m, ptr, &type, FALSE, NULL); fprintf (output, "%d: %s %s (", i + 1, type, mono_metadata_string_heap (m, cols [MONO_PROPERTY_NAME])); g_free (type); @@ -532,7 +539,7 @@ dump_table_module (MonoImage *m) { MonoTableInfo *t = &m->tables [MONO_TABLE_MODULE]; int i; - fprintf (output, "ModuleRef Table (1..%d)\n", t->rows); + fprintf (output, "Module Table (1..%d)\n", t->rows); for (i = 0; i < t->rows; i++){ guint32 cols [MONO_MODULE_SIZE]; @@ -554,6 +561,9 @@ dump_table_method (MonoImage *m) MonoTableInfo *td = &m->tables [MONO_TABLE_TYPEDEF]; int i, current_type; guint32 first_m, last_m; + /* Generic container for Type & method */ + MonoGenericContainer *type_container = NULL, *method_container = NULL; + fprintf (output, "Method Table (1..%d)\n", t->rows); current_type = 1; @@ -575,12 +585,19 @@ dump_table_method (MonoImage *m) mono_metadata_string_heap (m, mono_metadata_decode_row_col (td, current_type - 2, MONO_TYPEDEF_NAMESPACE)), mono_metadata_string_heap (m, mono_metadata_decode_row_col (td, current_type - 2, MONO_TYPEDEF_NAME))); first_m = last_m; + type_container = mono_metadata_load_generic_params (m, MONO_TOKEN_TYPE_DEF | (current_type - 1), NULL); + if (type_container) + mono_metadata_load_generic_param_constraints (m, MONO_TOKEN_TYPE_DEF | (current_type - 1), type_container); } - mono_metadata_decode_row (t, i - 1, cols, MONO_METHOD_SIZE); + + method_container = mono_metadata_load_generic_params (m, MONO_TOKEN_METHOD_DEF | i, type_container); + if (method_container) + mono_metadata_load_generic_param_constraints (m, MONO_TOKEN_METHOD_DEF | i, method_container); + mono_metadata_decode_table_row (m, MONO_TABLE_METHOD, i - 1, cols, MONO_METHOD_SIZE); sigblob = mono_metadata_blob_heap (m, cols [MONO_METHOD_SIGNATURE]); mono_metadata_decode_blob_size (sigblob, &sigblob); - method = mono_metadata_parse_method_signature (m, i, sigblob, &sigblob); - sig = dis_stringify_method_signature (m, method, i, NULL, FALSE); + method = mono_metadata_parse_method_signature_full (m, method_container ? method_container : type_container, i, sigblob, &sigblob); + sig = dis_stringify_method_signature (m, method, i, method_container ? method_container : type_container, FALSE); fprintf (output, "%d: %s (param: %d)\n", i, sig, cols [MONO_METHOD_PARAMLIST]); g_free (sig); mono_metadata_free_method_signature (method); @@ -752,6 +769,9 @@ has_cattr_get_table (MonoImage *m, guint32 val) case MONO_CUSTOM_ATTR_MANIFEST: table = "Manifest"; break; + case MONO_CUSTOM_ATTR_GENERICPAR: + table = "GenericParam"; + break; default: table = "Unknown"; break; @@ -980,6 +1000,18 @@ dump_table_exported (MonoImage *m) } +static void +dump_blob (MonoImage *m, const char* blob) +{ + int j, bsize; + + bsize = mono_metadata_decode_blob_size (blob, &blob); + + for (j = 0; j < bsize; j++) { + fprintf (output, "%02x ", blob [j] & 0xff); + } +} + void dump_table_field_marshal (MonoImage *m) { @@ -998,6 +1030,9 @@ dump_table_field_marshal (MonoImage *m) is_field = (cols [MONO_FIELD_MARSHAL_PARENT] & MONO_HAS_FIELD_MARSHAL_MASK) == MONO_HAS_FIELD_MARSHAL_FIELDSREF; idx = cols [MONO_FIELD_MARSHAL_PARENT] >> MONO_HAS_FIELD_MARSHAL_BITS; fprintf (output, "%d: (0x%04x) %s %d: %s\n", i, cols [MONO_FIELD_MARSHAL_PARENT], is_field? "Field" : "Param", idx, native); + fprintf (output, "\tblob encoding: "); + dump_blob (m, blob); + fprintf (output, "\n"); g_free (native); } @@ -1069,8 +1104,16 @@ dump_table_declsec (MonoImage *m) fprintf (output, "%d: %s on %s %d%s", i, action, parent [idx & MONO_HAS_DECL_SECURITY_MASK], idx >> MONO_HAS_DECL_SECURITY_BITS, len? ":\n\t":"\n"); if (!len) continue; - for (idx = 0; idx < len; ++idx) - fprintf (output, "%c", blob [idx]); + if (blob [0] == MONO_DECLSEC_FORMAT_20) { + /* 2.0 declarative security format */ + char *declsec = dump_declsec_entry20 (m, blob, "\t"); + fprintf (output, "%s", declsec); + g_free (declsec); + } else { + /* 1.0 declarative security format - Unicode XML */ + for (idx = 0; idx < len; ++idx) + fprintf (output, "%c", blob [idx]); + } fprintf (output, "\n"); } } @@ -1166,6 +1209,38 @@ dump_stream_blob (MonoImage *m) fprintf (output, "\n"); } +void +dump_stream_strings (MonoImage *m) +{ + guint32 i; + + fprintf (output, "Strings heap contents\n"); + + for (i = 0; i < m->heap_strings.size; ) { + const char *str = mono_metadata_string_heap (m, i); + fprintf (output, "%02x: \"%s\"\n", i, str); + i += strlen (str) + 1; + } +} + +void +dump_stream_us (MonoImage *m) +{ + guint32 i; + + fprintf (output, "User Strings heap contents\n"); + + for (i = 0; i < m->heap_us.size; ) { + const char *us_ptr = mono_metadata_user_string (m, i); + int len = mono_metadata_decode_blob_size (us_ptr, (const char**)&us_ptr); + + char *str = get_encoded_user_string_or_bytearray ((const guchar*)us_ptr, len); + fprintf (output, "%02x: %s\n", i, str); + g_free (str); + i += len + 1; + } +} + void dump_table_standalonesig (MonoImage *m) { @@ -1187,8 +1262,54 @@ dump_table_standalonesig (MonoImage *m) 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, "%02x ", locals_ptr [j] & 0xff); } fprintf (output, "\n"); } } + +static void +dump_table_ptr (MonoImage *m, int table, const char *name) +{ + MonoTableInfo *t = &m->tables [table]; + guint32 cols [1]; + int i; + + fprintf (output, "%s (1..%d)\n", name, t->rows); + + for (i = 1; i <= t->rows; i++) { + mono_metadata_decode_row (t, i - 1, cols, 1); + + fprintf (output, "%d: %d\n", i, cols [0]); + } +} + +void +dump_table_methodptr (MonoImage *m) +{ + dump_table_ptr (m, MONO_TABLE_METHOD_POINTER, "Method Ptr"); +} + +void +dump_table_fieldptr (MonoImage *m) +{ + dump_table_ptr (m, MONO_TABLE_FIELD_POINTER, "Field Ptr"); +} + +void +dump_table_paramptr (MonoImage *m) +{ + dump_table_ptr (m, MONO_TABLE_PARAM_POINTER, "Param Ptr"); +} + +void +dump_table_eventptr (MonoImage *m) +{ + dump_table_ptr (m, MONO_TABLE_EVENT_POINTER, "Event Ptr"); +} + +void +dump_table_propertyptr (MonoImage *m) +{ + dump_table_ptr (m, MONO_TABLE_PROPERTY_POINTER, "Property Ptr"); +}