X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fdebug-mono-symfile.c;h=000f9b8ef1635a712530cc7e319bf571c817be96;hb=9feeb108c2672b1edd3c8cfe5e3717e735e6f96e;hp=6d703a57168f698a19bdb0e5905a209b27d18764;hpb=da4f9e9b2afb23791029d0bb09d78b868aabd870;p=mono.git diff --git a/mono/metadata/debug-mono-symfile.c b/mono/metadata/debug-mono-symfile.c index 6d703a57168..000f9b8ef16 100644 --- a/mono/metadata/debug-mono-symfile.c +++ b/mono/metadata/debug-mono-symfile.c @@ -4,7 +4,9 @@ #include #include #include +#ifdef HAVE_SYS_PARAM_H #include +#endif #include #include #include @@ -21,7 +23,9 @@ #include #include +#ifdef HAVE_UNISTD_H #include +#endif #define RANGE_TABLE_CHUNK_SIZE 256 #define CLASS_TABLE_CHUNK_SIZE 256 @@ -59,7 +63,7 @@ load_symfile (MonoDebugHandle *handle, MonoSymbolFile *symfile, gboolean in_the_ guint64 magic; long version; - ptr = start = symfile->raw_contents; + ptr = start = (const char*)symfile->raw_contents; if (!ptr) return FALSE; @@ -73,7 +77,7 @@ load_symfile (MonoDebugHandle *handle, MonoSymbolFile *symfile, gboolean in_the_ version = read32(ptr); ptr += sizeof(guint32); - if (version != MONO_SYMBOL_FILE_VERSION) { + if ((version != MONO_SYMBOL_FILE_VERSION) && (version != MONO_SYMBOL_FILE_COMPATIBILITY_VERSION)) { if (!in_the_debugger) g_warning ("Symbol file %s has incorrect version " "(expected %d, got %ld)", symfile->filename, @@ -93,6 +97,8 @@ load_symfile (MonoDebugHandle *handle, MonoSymbolFile *symfile, gboolean in_the_ return FALSE; } + symfile->version = version; + symfile->offset_table = (MonoSymbolFileOffsetTable *) ptr; symfile->method_hash = g_hash_table_new_full ( @@ -113,9 +119,10 @@ mono_debug_open_mono_symbols (MonoDebugHandle *handle, const guint8 *raw_content symfile = g_new0 (MonoSymbolFile, 1); if (raw_contents != NULL) { + unsigned char *p; symfile->raw_contents_size = size; - symfile->raw_contents = g_malloc (size); - memcpy(symfile->raw_contents, raw_contents, size); + symfile->raw_contents = p = g_malloc (size); + memcpy (p, raw_contents, size); symfile->filename = g_strdup_printf ("LoadedFromMemory"); } else { symfile->filename = g_strdup_printf ("%s.mdb", mono_image_get_filename (handle->image)); @@ -211,7 +218,7 @@ mono_debug_symfile_lookup_location (MonoDebugMethodInfo *minfo, guint32 offset) MonoSymbolFileLineNumberEntry *lne; MonoSymbolFile *symfile; gchar *source_file = NULL; - const char *ptr; + const unsigned char *ptr; int count, i; if ((symfile = minfo->handle->symfile) == NULL) @@ -224,7 +231,7 @@ mono_debug_symfile_lookup_location (MonoDebugMethodInfo *minfo, guint32 offset) (read32(&(minfo->entry->_source_index)) - 1) * sizeof (MonoSymbolFileSourceEntry); MonoSymbolFileSourceEntry *se = (MonoSymbolFileSourceEntry *) (symfile->raw_contents + offset); - source_file = read_string (symfile->raw_contents + read32(&(se->_name_offset))); + source_file = read_string ((const char*)symfile->raw_contents + read32(&(se->_name_offset))); } ptr = symfile->raw_contents + read32(&(minfo->entry->_line_number_table_offset)); @@ -262,11 +269,13 @@ _mono_debug_address_from_il_offset (MonoDebugMethodJitInfo *jit, guint32 il_offs for (i = jit->num_line_numbers - 1; i >= 0; i--) { MonoDebugLineNumberEntry lne = jit->line_numbers [i]; + if (lne.il_offset < 0) + continue; if (lne.il_offset <= il_offset) return lne.native_offset; } - return -1; + return 0; } static int @@ -314,9 +323,7 @@ mono_debug_symfile_lookup_method (MonoDebugHandle *handle, MonoMethod *method) minfo->num_il_offsets = read32(&(me->_num_line_numbers)); minfo->il_offsets = (MonoSymbolFileLineNumberEntry *) (symfile->raw_contents + read32(&(me->_line_number_table_offset))); - minfo->num_lexical_blocks = read32(&(me->_num_lexical_blocks)); - minfo->lexical_blocks = (MonoSymbolFileLexicalBlockEntry *) - (symfile->raw_contents + read32(&(me->_lexical_block_table_offset))); + minfo->entry = me; g_hash_table_insert (symfile->method_hash, method, minfo);