Merge branch 'master' into msbuilddll2
[mono.git] / mono / mini / dwarfwriter.c
index ae72268f8d85d3870460532186f262c540e4e113..c8acff20d24a44ea16ab5d8b7996f7680e76a118 100644 (file)
@@ -35,7 +35,6 @@ typedef struct {
        char *start_symbol, *end_symbol;
        guint8 *code;
        guint32 code_size;
-       MonoDebugMethodJitInfo *debug_info;
 } MethodLineNumberInfo;
 
 struct _MonoDwarfWriter
@@ -466,9 +465,6 @@ static int subprogram_attr [] = {
 
 static int tramp_subprogram_attr [] = {
        DW_AT_name         , DW_FORM_string,
-#ifndef TARGET_IOS
-       DW_AT_description  , DW_FORM_string,
-#endif
     DW_AT_low_pc       , DW_FORM_addr,
     DW_AT_high_pc      , DW_FORM_addr,
 };
@@ -742,14 +738,15 @@ emit_line_number_info_begin (MonoDwarfWriter *w)
        emit_label (w, ".Ldebug_line_end");
 }
 
-static char *
-escape_path (char *name)
+char *
+mono_dwarf_escape_path (const char *name)
 {
        if (strchr (name, '\\')) {
-               char *s = g_malloc (strlen (name) * 2);
+               char *s;
                int len, i, j;
 
                len = strlen (name);
+               s = g_malloc0 ((len + 1) * 2);
                j = 0;
                for (i = 0; i < len; ++i) {
                        if (name [i] == '\\') {
@@ -761,7 +758,7 @@ escape_path (char *name)
                }
                return s;
        }
-       return name;
+       return g_strdup (name);
 }
 
 static void
@@ -852,7 +849,7 @@ emit_all_line_number_info (MonoDwarfWriter *w)
        for (i = 0; i < w->line_number_dir_index; ++i) {
                char *dir = g_hash_table_lookup (index_to_dir, GUINT_TO_POINTER (i + 1));
 
-               emit_string (w, escape_path (dir));
+               emit_string (w, mono_dwarf_escape_path (dir));
        }
        /* End of Includes */
        emit_byte (w, 0);
@@ -873,7 +870,7 @@ emit_all_line_number_info (MonoDwarfWriter *w)
                if (basename)
                        emit_string (w, basename);
                else
-                       emit_string (w, escape_path (name));
+                       emit_string (w, mono_dwarf_escape_path (name));
                emit_uleb128 (w, dir_index);
                emit_byte (w, 0);
                emit_byte (w, 0);
@@ -887,8 +884,11 @@ emit_all_line_number_info (MonoDwarfWriter *w)
        /* Emit line number table */
        for (l = info_list; l; l = l->next) {
                MethodLineNumberInfo *info = l->data;
+               MonoDebugMethodJitInfo *dmji;
 
-               emit_line_number_info (w, info->method, info->start_symbol, info->end_symbol, info->code, info->code_size, info->debug_info);
+               dmji = mono_debug_find_method (info->method, mono_domain_get ());;
+               emit_line_number_info (w, info->method, info->start_symbol, info->end_symbol, info->code, info->code_size, dmji);
+               mono_debug_free_method_jit_info (dmji);
        }
        g_slist_free (info_list);
 
@@ -916,7 +916,7 @@ emit_debug_info_end (MonoDwarfWriter *w)
 }
 
 void
-mono_dwarf_writer_emit_base_info (MonoDwarfWriter *w, GSList *base_unwind_program)
+mono_dwarf_writer_emit_base_info (MonoDwarfWriter *w, const char *cu_name, GSList *base_unwind_program)
 {
        char *s, *build_info;
        int i;
@@ -985,13 +985,16 @@ mono_dwarf_writer_emit_base_info (MonoDwarfWriter *w, GSList *base_unwind_progra
        emit_string (w, s);
        g_free (build_info);
        g_free (s);
-       emit_string (w, "JITted code");
+       emit_string (w, cu_name);
        emit_string (w, "");
        emit_byte (w, DW_LANG_C);
        emit_pointer_value (w, 0);
        emit_pointer_value (w, 0);
        /* offset into .debug_line section */
-       emit_symbol_diff (w, ".Ldebug_line_start", ".Ldebug_line_section_start", 0);
+       if (w->emit_line)
+               emit_symbol_diff (w, ".Ldebug_line_start", ".Ldebug_line_section_start", 0);
+       else
+               emit_pointer_value (w, 0);
 
        /* Base types */
        for (i = 0; i < G_N_ELEMENTS (basic_types); ++i) {
@@ -1008,14 +1011,6 @@ mono_dwarf_writer_emit_base_info (MonoDwarfWriter *w, GSList *base_unwind_progra
        emit_section_change (w, ".debug_loc", 0);
        emit_label (w, ".Ldebug_loc_start");
 
-       /* debug_line section */
-       /*
-        * We emit some info even if emit_line is FALSE, as the
-        * apple linker seems to require a .debug_line section.
-        */
-       if (!w->collect_line_info)
-               emit_line_number_info_begin (w);
-
        emit_cie (w);
 }
 
@@ -2082,7 +2077,6 @@ mono_dwarf_writer_emit_method (MonoDwarfWriter *w, MonoCompile *cfg, MonoMethod
                        info->end_symbol = g_strdup (end_symbol);
                        info->code = code;
                        info->code_size = code_size;
-                       info->debug_info = debug_info;
                        w->line_info = g_slist_prepend (w->line_info, info);
                } else {
                        emit_line_number_info (w, method, start_symbol, end_symbol, code, code_size, debug_info);