Index: gcc/final.c =================================================================== --- gcc/final.c (revision 106485) +++ gcc/final.c (working copy) @@ -129,6 +129,8 @@ static rtx debug_insn; rtx current_output_insn; +int current_start_basic_block = 0; + /* Line number of last NOTE. */ static int last_linenum; @@ -1744,6 +1746,7 @@ else *seen |= SEEN_BB; + current_start_basic_block = 1; break; case NOTE_INSN_EH_REGION_BEG: @@ -2071,8 +2074,21 @@ note in a row. */ if (notice_source_line (insn)) { - (*debug_hooks->source_line) (last_linenum, last_filename); + if (current_start_basic_block) + { + current_start_basic_block = 0; + (*debug_hooks->source_line) (last_linenum, last_filename, LINE_FLAG_BASIC_BLOCK); + } + else + { + (*debug_hooks->source_line) (last_linenum, last_filename, 0); + } } + else if (current_start_basic_block) + { + current_start_basic_block = 0; + (*debug_hooks->source_line) (last_linenum, last_filename, LINE_FLAG_BASIC_BLOCK); + } if (GET_CODE (body) == ASM_INPUT) { @@ -2498,6 +2514,7 @@ current_output_insn = debug_insn = 0; } } + return NEXT_INSN (insn); } Index: gcc/debug.c =================================================================== --- gcc/debug.c (revision 106485) +++ gcc/debug.c (working copy) @@ -33,7 +33,7 @@ debug_nothing_int_int, /* begin_block */ debug_nothing_int_int, /* end_block */ debug_true_tree, /* ignore_block */ - debug_nothing_int_charstar, /* source_line */ + debug_nothing_int_charstar_int, /* source_line */ debug_nothing_int_charstar, /* begin_prologue */ debug_nothing_int_charstar, /* end_prologue */ debug_nothing_int_charstar, /* end_epilogue */ @@ -94,6 +94,13 @@ } void +debug_nothing_int_charstar_int (unsigned int line ATTRIBUTE_UNUSED, + const char *text ATTRIBUTE_UNUSED, + unsigned int flags ATTRIBUTE_UNUSED) +{ +} + +void debug_nothing_int (unsigned int line ATTRIBUTE_UNUSED) { } Index: gcc/debug.h =================================================================== --- gcc/debug.h (revision 106485) +++ gcc/debug.h (working copy) @@ -59,7 +59,7 @@ bool (* ignore_block) (tree); /* Record a source file location at (FILE, LINE). */ - void (* source_line) (unsigned int line, const char *file); + void (* source_line) (unsigned int line, const char *file, unsigned int flags); /* Called at start of prologue code. LINE is the first line in the function. This has been given the same prototype as source_line, @@ -129,12 +129,16 @@ int start_end_main_source_file; }; + +#define LINE_FLAG_BASIC_BLOCK ((unsigned int)1) + extern const struct gcc_debug_hooks *debug_hooks; /* The do-nothing hooks. */ extern void debug_nothing_void (void); extern void debug_nothing_charstar (const char *); extern void debug_nothing_int_charstar (unsigned int, const char *); +extern void debug_nothing_int_charstar_int (unsigned int, const char *, unsigned int flags); extern void debug_nothing_int (unsigned int); extern void debug_nothing_int_int (unsigned int, unsigned int); extern void debug_nothing_tree (tree); Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 106485) +++ gcc/dwarf2out.c (working copy) @@ -69,7 +69,7 @@ #include "input.h" #ifdef DWARF2_DEBUGGING_INFO -static void dwarf2out_source_line (unsigned int, const char *); +static void dwarf2out_source_line (unsigned int, const char *, unsigned int flags); #endif /* DWARF2 Abbreviation Glossary: @@ -2510,7 +2510,7 @@ prologue case, not the eh frame case. */ #ifdef DWARF2_DEBUGGING_INFO if (file) - dwarf2out_source_line (line, file); + dwarf2out_source_line (line, file, 0); #endif } @@ -13534,7 +13534,7 @@ 'line_info_table' for later output of the .debug_line section. */ static void -dwarf2out_source_line (unsigned int line, const char *filename) +dwarf2out_source_line (unsigned int line, const char *filename, unsigned int flags) { if (debug_info_level >= DINFO_LEVEL_NORMAL && line != 0) @@ -13553,7 +13553,14 @@ file_num = maybe_emit_file (file_num); /* Emit the .loc directive understood by GNU as. */ - fprintf (asm_out_file, "\t.loc %d %d 0\n", file_num, line); + if (flags & LINE_FLAG_BASIC_BLOCK) + { + fprintf (asm_out_file, "\t.loc %d %d 0 basic_block\n", file_num, line); + } + else + { + fprintf (asm_out_file, "\t.loc %d %d 0 ;#test\n", file_num, line); + } /* Indicate that line number info exists. */ line_info_table_in_use++;