Author: martin
Date: 2008-02-15 06:55:15 -0500 (Fri, 15 Feb 2008)
New Revision: 95735

Modified:
   branches/martin/debugger-terrania/runtime/metadata/ChangeLog
   branches/martin/debugger-terrania/runtime/metadata/debug-mono-symfile.c
   branches/martin/debugger-terrania/runtime/metadata/debug-mono-symfile.h
   branches/martin/debugger-terrania/runtime/metadata/mono-debug.c
   branches/martin/debugger-terrania/runtime/metadata/mono-debug.h
   branches/martin/debugger-terrania/runtime/mini/debug-mini.c
Log:
2008-02-15  Martin Baulig  <[EMAIL PROTECTED]>

        Reflect latest symbol writer changes.  Keep compatibility with
        older symbol file versions.

        * debug-mono-symfile.h
        (MONO_SYMBOL_FILE_COMPATIBILITY_VERSION): New #define; keep
        compatibility with this version.
        (MonoSymbolFileOffsetTable): Added `_num_code_blocks' and
        `_code_block_table_offset'.
        (MonoSymbolFileMethodEntry): Added `num_code_blocks' and
        `code_block_table_offset'.
        (MonoDebugMethodInfo): Likewise.
        (MonoSymbolFileCodeBlockEntry): New typedef.
        (MonoSymbolFile): Added `version'.

        * mono-debug.h
        (__MonoDebugMethodJitInfo): Replaced `num_lexical_blocks' and
        `lexical_blocks' with `num_code_blocks' and `code_blocks'.



Modified: branches/martin/debugger-terrania/runtime/metadata/ChangeLog
===================================================================
--- branches/martin/debugger-terrania/runtime/metadata/ChangeLog        
2008-02-15 11:52:35 UTC (rev 95734)
+++ branches/martin/debugger-terrania/runtime/metadata/ChangeLog        
2008-02-15 11:55:15 UTC (rev 95735)
@@ -1,3 +1,23 @@
+2008-02-15  Martin Baulig  <[EMAIL PROTECTED]>
+
+       Reflect latest symbol writer changes.  Keep compatibility with
+       older symbol file versions.
+
+       * debug-mono-symfile.h
+       (MONO_SYMBOL_FILE_COMPATIBILITY_VERSION): New #define; keep
+       compatibility with this version.
+       (MonoSymbolFileOffsetTable): Added `_num_code_blocks' and
+       `_code_block_table_offset'.
+       (MonoSymbolFileMethodEntry): Added `num_code_blocks' and
+       `code_block_table_offset'.
+       (MonoDebugMethodInfo): Likewise.
+       (MonoSymbolFileCodeBlockEntry): New typedef.
+       (MonoSymbolFile): Added `version'.
+
+       * mono-debug.h
+       (__MonoDebugMethodJitInfo): Replaced `num_lexical_blocks' and
+       `lexical_blocks' with `num_code_blocks' and `code_blocks'.
+
 2008-02-02  Martin Baulig  <[EMAIL PROTECTED]>
 
        * debug-mono-symfile.h

Modified: 
branches/martin/debugger-terrania/runtime/metadata/debug-mono-symfile.c
===================================================================
--- branches/martin/debugger-terrania/runtime/metadata/debug-mono-symfile.c     
2008-02-15 11:52:35 UTC (rev 95734)
+++ branches/martin/debugger-terrania/runtime/metadata/debug-mono-symfile.c     
2008-02-15 11:55:15 UTC (rev 95735)
@@ -77,7 +77,7 @@
 
        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,
@@ -97,6 +97,8 @@
                return FALSE;
        }
 
+       symfile->version = version;
+
        symfile->offset_table = (MonoSymbolFileOffsetTable *) ptr;
 
        symfile->method_hash = g_hash_table_new_full (
@@ -267,11 +269,13 @@
        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
@@ -322,6 +326,13 @@
        minfo->num_lexical_blocks = read32(&(me->_num_lexical_blocks));
        minfo->lexical_blocks = (MonoSymbolFileLexicalBlockEntry *)
                (symfile->raw_contents + 
read32(&(me->_lexical_block_table_offset)));
+
+       if (symfile->version > MONO_SYMBOL_FILE_COMPATIBILITY_VERSION) {
+               minfo->num_code_blocks = read32(&(me->_num_code_blocks));
+               minfo->code_blocks = (MonoSymbolFileCodeBlockEntry *)
+                       (symfile->raw_contents + 
read32(&(me->_code_block_table_offset)));
+       }
+
        minfo->entry = me;
 
        g_hash_table_insert (symfile->method_hash, method, minfo);

Modified: 
branches/martin/debugger-terrania/runtime/metadata/debug-mono-symfile.h
===================================================================
--- branches/martin/debugger-terrania/runtime/metadata/debug-mono-symfile.h     
2008-02-15 11:52:35 UTC (rev 95734)
+++ branches/martin/debugger-terrania/runtime/metadata/debug-mono-symfile.h     
2008-02-15 11:55:15 UTC (rev 95735)
@@ -19,6 +19,7 @@
 typedef struct MonoSymbolFileSourceEntry       MonoSymbolFileSourceEntry;
 typedef struct MonoSymbolFileMethodIndexEntry  MonoSymbolFileMethodIndexEntry;
 typedef struct MonoSymbolFileLexicalBlockEntry MonoSymbolFileLexicalBlockEntry;
+typedef struct MonoSymbolFileCodeBlockEntry    MonoSymbolFileCodeBlockEntry;
 
 /* Keep in sync with OffsetTable in 
mcs/class/Mono.CSharp.Debugger/MonoSymbolTable.cs */
 struct MonoSymbolFileOffsetTable {
@@ -49,6 +50,9 @@
        guint32 _lexical_block_table_offset;
        guint32 _namespace_idx;
        guint32 _local_names_ambiguous;
+
+       guint32 _num_code_blocks;
+       guint32 _code_block_table_offset;
 };
 
 struct MonoSymbolFileSourceEntry {
@@ -80,6 +84,8 @@
        guint32 line_number_offset;
        guint32 num_lexical_blocks;
        guint32 lexical_block_table_offset;
+       guint32 num_code_blocks;
+       guint32 code_block_table_offset;
        guint8 data [MONO_ZERO_LEN_ARRAY];
 };
 
@@ -88,6 +94,18 @@
        guint32 _end_offset;
 };
 
+typedef enum {
+       MONO_DEBUG_CODE_BLOCK_TYPE_LEXICAL              = 1,
+       MONO_DEBUG_CODE_BLOCK_TYPE_COMPILER_GENERATED   = 2
+} MonoSymbolFileCodeBlockType;
+
+struct MonoSymbolFileCodeBlockEntry {
+       guint32 _block_type;
+       gint32 _parent_idx;
+       guint32 _start_offset;
+       guint32 _end_offset;
+};
+
 struct MonoSymbolFileLineNumberEntry {
        guint32 _row;
        guint32 _offset;
@@ -101,6 +119,8 @@
        MonoSymbolFileLineNumberEntry *il_offsets;
        guint32 num_lexical_blocks;
        MonoSymbolFileLexicalBlockEntry *lexical_blocks;
+       guint32 num_code_blocks;
+       MonoSymbolFileCodeBlockEntry *code_blocks;
        MonoSymbolFileMethodEntry *entry;
 };
 
@@ -111,20 +131,31 @@
        guint32 native_end_offset;
 };
 
+struct _MonoDebugCodeBlockEntry {
+       guint32 block_type;
+       gint32 parent_block;
+       guint32 il_start_offset;
+       guint32 native_start_offset;
+       guint32 il_end_offset;
+       guint32 native_end_offset;
+};
+
 struct _MonoDebugLineNumberEntry {
-       guint32 il_offset;
+       gint32 il_offset;
        guint32 native_offset;
 };
 
 struct _MonoSymbolFile {
        const guint8 *raw_contents;
        int raw_contents_size;
+       int version;
        gchar *filename;
        GHashTable *method_hash;
        MonoSymbolFileOffsetTable *offset_table;
 };
 
 #define MONO_SYMBOL_FILE_VERSION               40
+#define MONO_SYMBOL_FILE_COMPATIBILITY_VERSION 39
 #define MONO_SYMBOL_FILE_MAGIC                 0x45e82623fd7fa614ULL
 
 G_BEGIN_DECLS

Modified: branches/martin/debugger-terrania/runtime/metadata/mono-debug.c
===================================================================
--- branches/martin/debugger-terrania/runtime/metadata/mono-debug.c     
2008-02-15 11:52:35 UTC (rev 95734)
+++ branches/martin/debugger-terrania/runtime/metadata/mono-debug.c     
2008-02-15 11:55:15 UTC (rev 95735)
@@ -546,6 +546,40 @@
        *rptr = ptr;
 }
 
+static guint32
+find_start_address (MonoDebugMethodJitInfo *jit, guint32 il_offset)
+{
+       int i;
+
+       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 jit->num_line_numbers ? jit->line_numbers [0].native_offset : 0;
+}
+
+static guint32
+find_end_address (MonoDebugMethodJitInfo *jit, guint32 il_offset)
+{
+       int i;
+
+       for (i = 0; i < jit->num_line_numbers; i++) {
+               MonoDebugLineNumberEntry lne = jit->line_numbers [i];
+
+               if (lne.il_offset < 0)
+                       continue;
+               if (lne.il_offset >= il_offset)
+                       return lne.native_offset;
+       }
+
+       return jit->num_line_numbers ? jit->line_numbers [jit->num_line_numbers 
- 1].native_offset : 0;
+}
+
 MonoDebugMethodAddress *
 mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, 
MonoDomain *domain)
 {
@@ -557,8 +591,8 @@
        MonoDebugHandle *handle;
        guint8 buffer [BUFSIZ];
        guint8 *ptr, *oldptr;
+       int num_lexical, num_code_blocks;
        guint32 i, size, total_size, max_size;
-       gint32 last_il_offset = 0, last_native_offset = 0;
        gboolean is_wrapper = FALSE;
 
        mono_debugger_lock ();
@@ -576,9 +610,11 @@
                is_wrapper = TRUE;
        }
 
-       jit->num_lexical_blocks = minfo ? minfo->num_lexical_blocks : 0;
+       num_lexical = minfo ? minfo->num_lexical_blocks : 0;
+       num_code_blocks = minfo ? minfo->num_code_blocks : 0;
+       jit->num_code_blocks = num_lexical + num_code_blocks;
 
-       max_size = 24 + 8 * jit->num_line_numbers + 16 * 
jit->num_lexical_blocks +
+       max_size = 24 + 8 * jit->num_line_numbers + 20 * jit->num_code_blocks +
                (20 + sizeof (gpointer)) * (1 + jit->num_params + 
jit->num_locals);
 
        if (max_size > BUFSIZ)
@@ -593,41 +629,48 @@
        for (i = 0; i < jit->num_line_numbers; i++) {
                MonoDebugLineNumberEntry *lne = &jit->line_numbers [i];
 
-               write_sleb128 (lne->il_offset - last_il_offset, ptr, &ptr);
-               write_sleb128 (lne->native_offset - last_native_offset, ptr, 
&ptr);
-
-               last_il_offset = lne->il_offset;
-               last_native_offset = lne->native_offset;
+               write_sleb128 (lne->il_offset, ptr, &ptr);
+               write_sleb128 (lne->native_offset, ptr, &ptr);
        }
 
-       jit->lexical_blocks = g_new0 (MonoDebugLexicalBlockEntry, 
jit->num_lexical_blocks);
-       for (i = 0; i < jit->num_lexical_blocks; i ++) {
-               MonoDebugLexicalBlockEntry *jit_lbe = &jit->lexical_blocks [i];
+       jit->code_blocks = g_new0 (MonoDebugCodeBlockEntry, 
jit->num_code_blocks);
+       for (i = 0; i < num_lexical; i++) {
+               MonoDebugCodeBlockEntry *jit_cbe = &jit->code_blocks [i];
                MonoSymbolFileLexicalBlockEntry *minfo_lbe = 
&minfo->lexical_blocks [i];
-               jit_lbe->il_start_offset = read32 (&(minfo_lbe->_start_offset));
-               jit_lbe->native_start_offset = 
_mono_debug_address_from_il_offset (jit, jit_lbe->il_start_offset);
+               jit_cbe->block_type = MONO_DEBUG_CODE_BLOCK_TYPE_LEXICAL;
+               jit_cbe->parent_block = -1;
+               jit_cbe->il_start_offset = read32 (&(minfo_lbe->_start_offset));
+               jit_cbe->il_end_offset = read32 (&(minfo_lbe->_end_offset));
 
-               jit_lbe->il_end_offset = read32 (&(minfo_lbe->_end_offset));
-               jit_lbe->native_end_offset = _mono_debug_address_from_il_offset 
(jit, jit_lbe->il_end_offset);
+               jit_cbe->native_start_offset = find_start_address (jit, 
jit_cbe->il_start_offset);
+               jit_cbe->native_end_offset = find_end_address (jit, 
jit_cbe->il_end_offset);
        }
 
-       last_il_offset = 0;
-       last_native_offset = 0;
-       write_leb128 (jit->num_lexical_blocks, ptr, &ptr);
-       for (i = 0; i < jit->num_lexical_blocks; i++) {
-               MonoDebugLexicalBlockEntry *lbe = &jit->lexical_blocks [i];
+       for (i = 0; i < num_code_blocks; i ++) {
+               MonoDebugCodeBlockEntry *jit_cbe = &jit->code_blocks 
[num_lexical + i];
+               MonoSymbolFileCodeBlockEntry *minfo_cbe = &minfo->code_blocks 
[i];
 
-               write_sleb128 (lbe->il_start_offset - last_il_offset, ptr, 
&ptr);
-               write_sleb128 (lbe->native_start_offset - last_native_offset, 
ptr, &ptr);
+               jit_cbe->block_type = read32 (&(minfo_cbe->_block_type));
+               jit_cbe->parent_block = read32 (&(minfo_cbe->_parent_idx));
+               jit_cbe->il_start_offset = read32 (&(minfo_cbe->_start_offset));
+               jit_cbe->il_end_offset = read32 (&(minfo_cbe->_end_offset));
 
-               last_il_offset = lbe->il_start_offset;
-               last_native_offset = lbe->native_start_offset;
+               jit_cbe->native_start_offset = find_start_address (jit, 
jit_cbe->il_start_offset);
+               jit_cbe->native_end_offset = find_end_address (jit, 
jit_cbe->il_end_offset);
+       }
 
-               write_sleb128 (lbe->il_end_offset - last_il_offset, ptr, &ptr);
-               write_sleb128 (lbe->native_end_offset - last_native_offset, 
ptr, &ptr);
+       write_leb128 (jit->num_code_blocks, ptr, &ptr);
+       for (i = 0; i < jit->num_code_blocks; i++) {
+               MonoDebugCodeBlockEntry *cbe = &jit->code_blocks [i];
 
-               last_il_offset = lbe->il_end_offset;
-               last_native_offset = lbe->native_end_offset;
+               write_sleb128 (cbe->block_type, ptr, &ptr);
+               write_leb128 (cbe->parent_block, ptr, &ptr);
+
+               write_sleb128 (cbe->il_start_offset, ptr, &ptr);
+               write_sleb128 (cbe->native_start_offset, ptr, &ptr);
+
+               write_sleb128 (cbe->il_end_offset, ptr, &ptr);
+               write_sleb128 (cbe->native_end_offset, ptr, &ptr);
        }
 
        *ptr++ = jit->this_var ? 1 : 0;
@@ -805,22 +848,25 @@
 
        il_offset = 0;
        native_offset = 0;
-       jit->num_lexical_blocks = read_leb128 (ptr, &ptr);
-       jit->lexical_blocks = g_new0 (MonoDebugLexicalBlockEntry, 
jit->num_lexical_blocks);
-       for (i = 0; i < jit->num_lexical_blocks; i ++) {
-               MonoDebugLexicalBlockEntry *lbe = &jit->lexical_blocks [i];
+       jit->num_code_blocks = read_leb128 (ptr, &ptr);
+       jit->code_blocks = g_new0 (MonoDebugCodeBlockEntry, 
jit->num_code_blocks);
+       for (i = 0; i < jit->num_code_blocks; i ++) {
+               MonoDebugCodeBlockEntry *cbe = &jit->code_blocks [i];
 
+               cbe->block_type = read_sleb128 (ptr, &ptr);
+               cbe->parent_block = read_leb128 (ptr, &ptr);
+
                il_offset += read_sleb128 (ptr, &ptr);
                native_offset += read_sleb128 (ptr, &ptr);
 
-               lbe->il_start_offset = il_offset;
-               lbe->native_start_offset = native_offset;
+               cbe->il_start_offset = il_offset;
+               cbe->native_start_offset = native_offset;
 
                il_offset += read_sleb128 (ptr, &ptr);
                native_offset += read_sleb128 (ptr, &ptr);
 
-               lbe->il_end_offset = il_offset;
-               lbe->native_end_offset = native_offset;
+               cbe->il_end_offset = il_offset;
+               cbe->native_end_offset = native_offset;
        }
 
        if (*ptr++) {

Modified: branches/martin/debugger-terrania/runtime/metadata/mono-debug.h
===================================================================
--- branches/martin/debugger-terrania/runtime/metadata/mono-debug.h     
2008-02-15 11:52:35 UTC (rev 95734)
+++ branches/martin/debugger-terrania/runtime/metadata/mono-debug.h     
2008-02-15 11:55:15 UTC (rev 95735)
@@ -18,7 +18,7 @@
 typedef struct _MonoDebugHandle                        MonoDebugHandle;
 
 typedef struct _MonoDebugLineNumberEntry       MonoDebugLineNumberEntry;
-typedef struct _MonoDebugLexicalBlockEntry     MonoDebugLexicalBlockEntry;
+typedef struct _MonoDebugCodeBlockEntry                MonoDebugCodeBlockEntry;
 
 typedef struct _MonoDebugVarInfo               MonoDebugVarInfo;
 typedef struct _MonoDebugMethodJitInfo         MonoDebugMethodJitInfo;
@@ -81,8 +81,8 @@
        const guint8 *wrapper_addr;
        guint32 num_line_numbers;
        MonoDebugLineNumberEntry *line_numbers;
-       guint32 num_lexical_blocks;
-       MonoDebugLexicalBlockEntry *lexical_blocks;
+       guint32 num_code_blocks;
+       MonoDebugCodeBlockEntry *code_blocks;
        guint32 num_params;
        MonoDebugVarInfo *this_var;
        MonoDebugVarInfo *params;

Modified: branches/martin/debugger-terrania/runtime/mini/debug-mini.c
===================================================================
--- branches/martin/debugger-terrania/runtime/mini/debug-mini.c 2008-02-15 
11:52:35 UTC (rev 95734)
+++ branches/martin/debugger-terrania/runtime/mini/debug-mini.c 2008-02-15 
11:55:15 UTC (rev 95735)
@@ -83,7 +83,7 @@
 mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit)
 {
        g_free (jit->line_numbers);
-       g_free (jit->lexical_blocks);
+       g_free (jit->code_blocks);
        g_free (jit->this_var);
        g_free (jit->params);
        g_free (jit->locals);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to