Skip to content

Commit 31e9b80

Browse files
committedAug 20, 2012
Escape windows paths in DWARF debug info.
1 parent 398f60a commit 31e9b80

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed
 

Diff for: ‎mono/mini/dwarfwriter.c

+24-2
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,28 @@ emit_line_number_info_begin (MonoDwarfWriter *w)
723723
emit_label (w, ".Ldebug_line_end");
724724
}
725725

726+
static char *
727+
escape_path (char *name)
728+
{
729+
if (strchr (name, '\\')) {
730+
char *s = g_malloc (strlen (name) * 2);
731+
int len, i, j;
732+
733+
len = strlen (name);
734+
j = 0;
735+
for (i = 0; i < len; ++i) {
736+
if (name [i] == '\\') {
737+
s [j ++] = '\\';
738+
s [j ++] = '\\';
739+
} else {
740+
s [j ++] = name [i];
741+
}
742+
}
743+
return s;
744+
}
745+
return name;
746+
}
747+
726748
static void
727749
emit_all_line_number_info (MonoDwarfWriter *w)
728750
{
@@ -810,7 +832,7 @@ emit_all_line_number_info (MonoDwarfWriter *w)
810832
for (i = 0; i < w->line_number_dir_index; ++i) {
811833
char *dir = g_hash_table_lookup (index_to_dir, GUINT_TO_POINTER (i + 1));
812834

813-
emit_string (w, dir);
835+
emit_string (w, escape_path (dir));
814836
}
815837
/* End of Includes */
816838
emit_byte (w, 0);
@@ -831,7 +853,7 @@ emit_all_line_number_info (MonoDwarfWriter *w)
831853
if (basename)
832854
emit_string (w, basename);
833855
else
834-
emit_string (w, name);
856+
emit_string (w, escape_path (name));
835857
emit_uleb128 (w, dir_index);
836858
emit_byte (w, 0);
837859
emit_byte (w, 0);

0 commit comments

Comments
 (0)
Please sign in to comment.