2008-03-24 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / metadata / debug-mono-symfile.c
index 8e33d9fa6d740e827fcac29eb5eb7bffeb07f77c..000f9b8ef1635a712530cc7e319bf571c817be96 100644 (file)
@@ -4,7 +4,9 @@
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
+#endif
 #include <sys/stat.h>
 #include <mono/metadata/metadata.h>
 #include <mono/metadata/tabledefs.h>
@@ -21,7 +23,9 @@
 #include <mono/metadata/class-internals.h>
 
 #include <fcntl.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 
 #define RANGE_TABLE_CHUNK_SIZE         256
 #define CLASS_TABLE_CHUNK_SIZE         256
@@ -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 (
@@ -263,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
@@ -315,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);