X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fdebug-helpers.c;h=5fe0b9a77b528c38b85da04777331fb1bd842261;hb=HEAD;hp=2553361c14db27d1af028b583ffbf1848b13c6a6;hpb=62c49f89ad1cc35593a00d909ea57bb41955288b;p=mono.git diff --git a/mono/metadata/debug-helpers.c b/mono/metadata/debug-helpers.c index 2553361c14d..5fe0b9a77b5 100644 --- a/mono/metadata/debug-helpers.c +++ b/mono/metadata/debug-helpers.c @@ -1,10 +1,11 @@ -/* - * debug-helpers.c: +/** + * \file * * Author: * Mono Project (http://www.mono-project.com) * * Copyright (C) 2005-2008 Novell, Inc. (http://www.novell.com) + * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #include @@ -162,7 +163,10 @@ mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace) break; case MONO_TYPE_ARRAY: mono_type_get_desc (res, &type->data.array->eklass->byval_arg, include_namespace); - g_string_append_printf (res, "[%d]", type->data.array->rank); + g_string_append_c (res, '['); + for (i = 1; i < type->data.array->rank; ++i) + g_string_append_c (res, ','); + g_string_append_c (res, ']'); break; case MONO_TYPE_SZARRAY: mono_type_get_desc (res, &type->data.klass->byval_arg, include_namespace); @@ -219,6 +223,9 @@ mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace) g_string_append_c (res, '&'); } +/** + * mono_type_full_name: + */ char* mono_type_full_name (MonoType *type) { @@ -229,6 +236,9 @@ mono_type_full_name (MonoType *type) return g_string_free (str, FALSE); } +/** + * mono_signature_get_desc: + */ char* mono_signature_get_desc (MonoMethodSignature *sig, gboolean include_namespace) { @@ -276,8 +286,8 @@ mono_signature_full_name (MonoMethodSignature *sig) return result; } -static void -ginst_get_desc (GString *str, MonoGenericInst *ginst) +void +mono_ginst_get_desc (GString *str, MonoGenericInst *ginst) { int i; @@ -298,11 +308,11 @@ mono_context_get_desc (MonoGenericContext *context) g_string_append (str, "<"); if (context->class_inst) - ginst_get_desc (str, context->class_inst); + mono_ginst_get_desc (str, context->class_inst); if (context->method_inst) { if (context->class_inst) g_string_append (str, "; "); - ginst_get_desc (str, context->method_inst); + mono_ginst_get_desc (str, context->method_inst); } g_string_append (str, ">"); @@ -313,19 +323,19 @@ mono_context_get_desc (MonoGenericContext *context) /** * mono_method_desc_new: - * @name: the method name. - * @include_namespace: whether the name includes a namespace or not. + * \param name the method name. + * \param include_namespace whether the name includes a namespace or not. * - * Creates a method description for @name, which conforms to the following + * Creates a method description for \p name, which conforms to the following * specification: * - * [namespace.]classname:methodname[(args...)] + * [namespace.]classname:methodname[(args...)] * * in all the loaded assemblies. * - * Both classname and methodname can contain '*' which matches anything. + * Both classname and methodname can contain * which matches anything. * - * Returns: a parsed representation of the method description. + * \returns a parsed representation of the method description. */ MonoMethodDesc* mono_method_desc_new (const char *name, gboolean include_namespace) @@ -396,6 +406,9 @@ mono_method_desc_new (const char *name, gboolean include_namespace) return result; } +/** + * mono_method_desc_from_method: + */ MonoMethodDesc* mono_method_desc_from_method (MonoMethod *method) { @@ -412,9 +425,8 @@ mono_method_desc_from_method (MonoMethod *method) /** * mono_method_desc_free: - * @desc: method description to be released - * - * Releases the MonoMethodDesc object @desc. + * \param desc method description to be released + * Releases the \c MonoMethodDesc object \p desc. */ void mono_method_desc_free (MonoMethodDesc *desc) @@ -427,14 +439,14 @@ mono_method_desc_free (MonoMethodDesc *desc) } /** - * mono_method_descr_match: - * @desc: MonoMethoDescription - * @method: MonoMethod to test + * mono_method_desc_match: + * \param desc \c MonoMethoDescription + * \param method \c MonoMethod to test * - * Determines whether the specified @method matches the provided @desc description. + * Determines whether the specified \p method matches the provided \p desc description. * * namespace and class are supposed to match already if this function is used. - * Returns: True if the method matches the description, false otherwise. + * \returns TRUE if the method matches the description, FALSE otherwise. */ gboolean mono_method_desc_match (MonoMethodDesc *desc, MonoMethod *method) @@ -443,10 +455,6 @@ mono_method_desc_match (MonoMethodDesc *desc, MonoMethod *method) gboolean name_match; name_match = strcmp (desc->name, method->name) == 0; -#ifndef _EGLIB_MAJOR - if (!name_match && desc->name_glob) - name_match = g_pattern_match_simple (desc->name, method->name); -#endif if (!name_match) return FALSE; if (!desc->args) @@ -506,6 +514,9 @@ match_class (MonoMethodDesc *desc, int pos, MonoClass *klass) return match_class (desc, pos, klass->nested_in); } +/** + * mono_method_desc_full_match: + */ gboolean mono_method_desc_full_match (MonoMethodDesc *desc, MonoMethod *method) { @@ -517,6 +528,9 @@ mono_method_desc_full_match (MonoMethodDesc *desc, MonoMethod *method) return mono_method_desc_match (desc, method); } +/** + * mono_method_desc_search_in_class: + */ MonoMethod* mono_method_desc_search_in_class (MonoMethodDesc *desc, MonoClass *klass) { @@ -529,6 +543,9 @@ mono_method_desc_search_in_class (MonoMethodDesc *desc, MonoClass *klass) return NULL; } +/** + * mono_method_desc_search_in_image: + */ MonoMethod* mono_method_desc_search_in_image (MonoMethodDesc *desc, MonoImage *image) { @@ -754,6 +771,9 @@ default_dh = { NULL /* user data */ }; +/** + * mono_disasm_code_one: + */ char* mono_disasm_code_one (MonoDisHelper *dh, MonoMethod *method, const guchar *ip, const guchar **endp) { @@ -772,6 +792,9 @@ mono_disasm_code_one (MonoDisHelper *dh, MonoMethod *method, const guchar *ip, c return result; } +/** + * mono_disasm_code: + */ char* mono_disasm_code (MonoDisHelper *dh, MonoMethod *method, const guchar *ip, const guchar* end) { @@ -791,9 +814,8 @@ mono_disasm_code (MonoDisHelper *dh, MonoMethod *method, const guchar *ip, const /** * mono_field_full_name: - * @field: field to retrieve information for - * - * Returns: the full name for the field, made up of the namespace, type name and the field name. + * \param field field to retrieve information for + * \returns the full name for the field, made up of the namespace, type name and the field name. */ char * mono_field_full_name (MonoClassField *field) @@ -814,6 +836,14 @@ mono_method_get_name_full (MonoMethod *method, gboolean signature, gboolean ret, char wrapper [64]; char *klass_desc; char *inst_desc = NULL; + MonoError error; + + const char *class_method_separator = ":"; + const char *method_sig_space = " "; + if (format == MONO_TYPE_NAME_FORMAT_REFLECTION) { + class_method_separator = "."; + method_sig_space = ""; + } if (format == MONO_TYPE_NAME_FORMAT_IL) klass_desc = mono_type_full_name (&method->klass->byval_arg); @@ -826,7 +856,7 @@ mono_method_get_name_full (MonoMethod *method, gboolean signature, gboolean ret, g_string_append (str, "<"); else g_string_append (str, "["); - ginst_get_desc (str, ((MonoMethodInflated*)method)->context.method_inst); + mono_ginst_get_desc (str, ((MonoMethodInflated*)method)->context.method_inst); if (format == MONO_TYPE_NAME_FORMAT_IL) g_string_append_c (str, '>'); else @@ -842,7 +872,7 @@ mono_method_get_name_full (MonoMethod *method, gboolean signature, gboolean ret, g_string_append (str, "<"); else g_string_append (str, "["); - ginst_get_desc (str, container->context.method_inst); + mono_ginst_get_desc (str, container->context.method_inst); if (format == MONO_TYPE_NAME_FORMAT_IL) g_string_append_c (str, '>'); else @@ -858,24 +888,35 @@ mono_method_get_name_full (MonoMethod *method, gboolean signature, gboolean ret, strcpy (wrapper, ""); if (signature) { - char *tmpsig = mono_signature_get_desc (mono_method_signature (method), TRUE); + MonoMethodSignature *sig = mono_method_signature_checked (method, &error); + char *tmpsig; + + if (!is_ok (&error)) { + tmpsig = g_strdup_printf (""); + mono_error_cleanup (&error); + } else { + tmpsig = mono_signature_get_desc (sig, TRUE); + } if (method->wrapper_type != MONO_WRAPPER_NONE) sprintf (wrapper, "(wrapper %s) ", wrapper_type_to_str (method->wrapper_type)); else strcpy (wrapper, ""); - if (ret) { - char *ret_str = mono_type_full_name (mono_method_signature (method)->ret); - res = g_strdup_printf ("%s%s %s:%s%s (%s)", wrapper, ret_str, klass_desc, - method->name, inst_desc ? inst_desc : "", tmpsig); + if (ret && sig) { + char *ret_str = mono_type_full_name (sig->ret); + res = g_strdup_printf ("%s%s %s%s%s%s%s(%s)", wrapper, ret_str, klass_desc, + class_method_separator, + method->name, inst_desc ? inst_desc : "", method_sig_space, tmpsig); g_free (ret_str); } else { - res = g_strdup_printf ("%s%s:%s%s (%s)", wrapper, klass_desc, - method->name, inst_desc ? inst_desc : "", tmpsig); + res = g_strdup_printf ("%s%s%s%s%s%s(%s)", wrapper, klass_desc, + class_method_separator, + method->name, inst_desc ? inst_desc : "", method_sig_space, tmpsig); } g_free (tmpsig); } else { - res = g_strdup_printf ("%s%s:%s%s", wrapper, klass_desc, + res = g_strdup_printf ("%s%s%s%s%s", wrapper, klass_desc, + class_method_separator, method->name, inst_desc ? inst_desc : ""); } @@ -885,6 +926,9 @@ mono_method_get_name_full (MonoMethod *method, gboolean signature, gboolean ret, return res; } +/** + * mono_method_full_name: + */ char * mono_method_full_name (MonoMethod *method, gboolean signature) { @@ -897,6 +941,17 @@ mono_method_get_full_name (MonoMethod *method) return mono_method_get_name_full (method, TRUE, TRUE, MONO_TYPE_NAME_FORMAT_IL); } +/** + * mono_method_get_reflection_name: + * + * Returns the name of the method, including signature, using the same formating as reflection. + */ +char * +mono_method_get_reflection_name (MonoMethod *method) +{ + return mono_method_get_name_full (method, TRUE, FALSE, MONO_TYPE_NAME_FORMAT_REFLECTION); +} + static const char* print_name_space (MonoClass *klass) { @@ -915,12 +970,13 @@ print_name_space (MonoClass *klass) /** * mono_object_describe: * - * Prints to stdout a small description of the object @obj. + * Prints to stdout a small description of the object \p obj. * For use in a debugger. */ void mono_object_describe (MonoObject *obj) { + MonoError error; MonoClass* klass; const char* sep; if (!obj) { @@ -929,14 +985,19 @@ mono_object_describe (MonoObject *obj) } klass = mono_object_class (obj); if (klass == mono_defaults.string_class) { - char *utf8 = mono_string_to_utf8 ((MonoString*)obj); - if (strlen (utf8) > 60) { + char *utf8 = mono_string_to_utf8_checked ((MonoString*)obj, &error); + mono_error_cleanup (&error); /* FIXME don't swallow the error */ + if (utf8 && strlen (utf8) > 60) { utf8 [57] = '.'; utf8 [58] = '.'; utf8 [59] = '.'; utf8 [60] = 0; } - g_print ("String at %p, length: %d, '%s'\n", obj, mono_string_length ((MonoString*) obj), utf8); + if (utf8) { + g_print ("String at %p, length: %d, '%s'\n", obj, mono_string_length ((MonoString*) obj), utf8); + } else { + g_print ("String at %p, length: %d, unable to decode UTF16\n", obj, mono_string_length ((MonoString*) obj)); + } g_free (utf8); } else if (klass->rank) { MonoArray *array = (MonoArray*)obj; @@ -1061,7 +1122,7 @@ objval_describe (MonoClass *klass, const char *addr) /** * mono_object_describe_fields: * - * Prints to stdout a small description of each field of the object @obj. + * Prints to stdout a small description of each field of the object \p obj. * For use in a debugger. */ void @@ -1075,7 +1136,7 @@ mono_object_describe_fields (MonoObject *obj) * mono_value_describe_fields: * * Prints to stdout a small description of each field of the value type - * stored at @addr of type @klass. + * stored at \p addr of type \p klass. * For use in a debugger. */ void @@ -1087,7 +1148,7 @@ mono_value_describe_fields (MonoClass* klass, const char* addr) /** * mono_class_describe_statics: * - * Prints to stdout a small description of each static field of the type @klass + * Prints to stdout a small description of each static field of the type \p klass * in the current application domain. * For use in a debugger. */ @@ -1126,7 +1187,7 @@ mono_class_describe_statics (MonoClass* klass) /** * mono_print_method_code - * @MonoMethod: a pointer to the method + * \param method: a pointer to the method * * This method is used from a debugger to print the code of the method. *