X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fdebug-helpers.c;h=aa62ad230e5cc51e95cabfaa96f6748dcc51e4f4;hb=41c1a773f95c5cc05c8350e8fbeba144341780e2;hp=500ea589342c0a089adf23496f3d81b0b19c7c6a;hpb=20d019fac230a904651f556f1e8bc02e79694a44;p=mono.git diff --git a/mono/metadata/debug-helpers.c b/mono/metadata/debug-helpers.c index 500ea589342..aa62ad230e5 100644 --- a/mono/metadata/debug-helpers.c +++ b/mono/metadata/debug-helpers.c @@ -1,5 +1,5 @@ /* - * console-io.c: ConsoleDriver internal calls + * debug-helpers.c: * * Author: * Mono Project (http://www.mono-project.com) @@ -12,6 +12,7 @@ #include "mono/metadata/opcodes.h" #include "mono/metadata/metadata-internals.h" #include "mono/metadata/class-internals.h" +#include "mono/metadata/object-internals.h" #include "mono/metadata/mono-endian.h" #include "mono/metadata/debug-helpers.h" #include "mono/metadata/tabledefs.h" @@ -86,6 +87,31 @@ append_class_name (GString *res, MonoClass *class, gboolean include_namespace) g_string_append_printf (res, "%s", class->name); } +static MonoClass* +find_system_class (const char *name) +{ + if (!strcmp (name, "void")) + return mono_defaults.void_class; + else if (!strcmp (name, "char")) return mono_defaults.char_class; + else if (!strcmp (name, "bool")) return mono_defaults.boolean_class; + else if (!strcmp (name, "byte")) return mono_defaults.byte_class; + else if (!strcmp (name, "sbyte")) return mono_defaults.sbyte_class; + else if (!strcmp (name, "uint16")) return mono_defaults.uint16_class; + else if (!strcmp (name, "int16")) return mono_defaults.int16_class; + else if (!strcmp (name, "uint")) return mono_defaults.uint32_class; + else if (!strcmp (name, "int")) return mono_defaults.int32_class; + else if (!strcmp (name, "ulong")) return mono_defaults.uint64_class; + else if (!strcmp (name, "long")) return mono_defaults.int64_class; + else if (!strcmp (name, "uintptr")) return mono_defaults.uint_class; + else if (!strcmp (name, "intptr")) return mono_defaults.int_class; + else if (!strcmp (name, "single")) return mono_defaults.single_class; + else if (!strcmp (name, "double")) return mono_defaults.double_class; + else if (!strcmp (name, "string")) return mono_defaults.string_class; + else if (!strcmp (name, "object")) return mono_defaults.object_class; + else + return NULL; +} + void mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace) { @@ -181,6 +207,9 @@ mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace) g_string_append (res, ""); } break; + case MONO_TYPE_TYPEDBYREF: + g_string_append (res, "typedbyref"); + break; default: break; } @@ -203,7 +232,12 @@ mono_signature_get_desc (MonoMethodSignature *sig, gboolean include_namespace) { int i; char *result; - GString *res = g_string_new (""); + GString *res; + + if (!sig) + return g_strdup (""); + + res = g_string_new (""); for (i = 0; i < sig->param_count; ++i) { if (i > 0) @@ -276,6 +310,9 @@ mono_method_desc_new (const char *name, gboolean include_namespace) class_nspace = g_strdup (name); use_args = strchr (class_nspace, '('); if (use_args) { + /* Allow a ' ' between the method name and the signature */ + if (use_args > class_nspace && use_args [-1] == ' ') + use_args [-1] = 0; *use_args++ = 0; end = strchr (use_args, ')'); if (!end) { @@ -289,10 +326,10 @@ mono_method_desc_new (const char *name, gboolean include_namespace) g_free (class_nspace); return NULL; } - *method_name++ = 0; /* allow two :: to separate the method name */ - if (*method_name == ':') - method_name++; + if (method_name != class_nspace && method_name [-1] == ':') + method_name [-1] = 0; + *method_name++ = 0; class_name = strrchr (class_nspace, '.'); if (class_name) { *class_name++ = 0; @@ -431,6 +468,8 @@ match_class (MonoMethodDesc *desc, int pos, MonoClass *klass) gboolean mono_method_desc_full_match (MonoMethodDesc *desc, MonoMethod *method) { + if (!desc->klass) + return FALSE; if (!match_class (desc, strlen (desc->klass), method->klass)) return FALSE; @@ -458,6 +497,13 @@ mono_method_desc_search_in_image (MonoMethodDesc *desc, MonoImage *image) MonoMethod *method; int i; + /* Handle short names for system classes */ + if (!desc->namespace && image == mono_defaults.corlib) { + klass = find_system_class (desc->klass); + if (klass) + return mono_method_desc_search_in_class (desc, klass); + } + if (desc->namespace && desc->klass) { klass = mono_class_from_name (image, desc->namespace, desc->klass); if (!klass) @@ -529,7 +575,7 @@ dis_one (GString *str, MonoDisHelper *dh, MonoMethod *method, const unsigned cha size_t len2; char *blob2 = NULL; - if (!method->klass->image->dynamic) { + if (!image_is_dynamic (method->klass->image) && !method_is_dynamic (method)) { token = read32 (ip); blob = mono_metadata_user_string (method->klass->image, mono_metadata_token_index (token)); @@ -546,7 +592,7 @@ dis_one (GString *str, MonoDisHelper *dh, MonoMethod *method, const unsigned cha #if G_BYTE_ORDER != G_LITTLE_ENDIAN { - guint16 *buf = g_new (guint16, len2); + guint16 *buf = g_new (guint16, len2 + 1); int i; for (i = 0; i < len2; ++i) @@ -640,6 +686,7 @@ dis_one (GString *str, MonoDisHelper *dh, MonoMethod *method, const unsigned cha if (dh->newline) g_string_append (str, dh->newline); + mono_metadata_free_mh (header); return ip; } @@ -799,7 +846,7 @@ mono_object_describe (MonoObject *obj) MonoArray *array = (MonoArray*)obj; sep = print_name_space (klass); g_print ("%s%s", sep, klass->name); - g_print (" at %p, rank: %d, length: %d\n", obj, klass->rank, mono_array_length (array)); + g_print (" at %p, rank: %d, length: %d\n", obj, klass->rank, (int)mono_array_length (array)); } else { sep = print_name_space (klass); g_print ("%s%s", sep, klass->name); @@ -958,7 +1005,7 @@ mono_class_describe_statics (MonoClass* klass) if (!vtable) return; - if (!(addr = vtable->data)) + if (!(addr = mono_vtable_get_static_field_data (vtable))) return; for (p = klass; p != NULL; p = p->parent) { @@ -975,4 +1022,3 @@ mono_class_describe_statics (MonoClass* klass) } } } -