From ed5ef2e4085ebc1bf6be8f1667365cd328aae0e3 Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Wed, 17 Jun 2009 23:54:40 +0000 Subject: [PATCH] dbxout.c (dbxout_source_line): Add is_stmt parameter. * dbxout.c (dbxout_source_line): Add is_stmt parameter. Change caller. * debug.c (struct gcc_debug_hooks): Change placeholder for source_line hook. (debug_nothing_int_charstar_int): Replaced by... (debug_nothing_int_charstar_int_bool): ...this. * debug.h (struct gcc_debug_hooks): Add is_stmt parameter to source_line prototype. (debug_nothing_int_charstar_int): Replaced by... (debug_nothing_int_charstar_int_bool): ...this. * defaults.h (SUPPORTS_DISCRIMINATOR): New constant. * dwarf2out.c (dwarf2out_source_line): Add is_stmt parameter. Output is_stmt operand when necessary. * final.c (last_is_stmt): New variable. (final_start_function): Initialize last_is_stmt. (final_scan_insn): Pass is_stmt to source_line debug hook. (notice_source_line): Add is_stmt parameter. * sdbout.c (sdbout_source_line): Add is_stmt parameter. * vmsdbgout.c (vmsdbgout_source_line): Add is_stmt parameter. Change callers. * xcoffout.c (xcoffout_source_line): Add is_stmt parameter. * xcoffout.h (xcoffout_source_line): Add is_stmt parameter. From-SVN: r148635 --- gcc/ChangeLog | 25 +++++++++++++++++++++++++ gcc/dbxout.c | 7 ++++--- gcc/debug.c | 9 +++++---- gcc/debug.h | 8 ++++---- gcc/defaults.h | 10 ++++++++++ gcc/dwarf2out.c | 17 +++++++++++------ gcc/final.c | 37 +++++++++++++++++++++++++++---------- gcc/sdbout.c | 5 +++-- gcc/vmsdbgout.c | 10 +++++----- gcc/xcoffout.c | 3 ++- gcc/xcoffout.h | 2 +- 11 files changed, 97 insertions(+), 36 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9bcafa2f7585..5b02ed1de95a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,28 @@ +2009-06-17 Cary Coutant + + * dbxout.c (dbxout_source_line): Add is_stmt parameter. + Change caller. + * debug.c (struct gcc_debug_hooks): Change placeholder for + source_line hook. + (debug_nothing_int_charstar_int): Replaced by... + (debug_nothing_int_charstar_int_bool): ...this. + * debug.h (struct gcc_debug_hooks): Add is_stmt parameter to + source_line prototype. + (debug_nothing_int_charstar_int): Replaced by... + (debug_nothing_int_charstar_int_bool): ...this. + * defaults.h (SUPPORTS_DISCRIMINATOR): New constant. + * dwarf2out.c (dwarf2out_source_line): Add is_stmt parameter. + Output is_stmt operand when necessary. + * final.c (last_is_stmt): New variable. + (final_start_function): Initialize last_is_stmt. + (final_scan_insn): Pass is_stmt to source_line debug hook. + (notice_source_line): Add is_stmt parameter. + * sdbout.c (sdbout_source_line): Add is_stmt parameter. + * vmsdbgout.c (vmsdbgout_source_line): Add is_stmt parameter. + Change callers. + * xcoffout.c (xcoffout_source_line): Add is_stmt parameter. + * xcoffout.h (xcoffout_source_line): Add is_stmt parameter. + 2009-06-17 Ian Lance Taylor * expr.c (struct move_by_pieces_d): Rename from move_by_pieces. diff --git a/gcc/dbxout.c b/gcc/dbxout.c index 17fdf6efed18..ffb2ac2ef7b0 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -333,7 +333,7 @@ static void dbxout_handle_pch (unsigned); /* The debug hooks structure. */ #if defined (DBX_DEBUGGING_INFO) -static void dbxout_source_line (unsigned int, const char *, int); +static void dbxout_source_line (unsigned int, const char *, int, bool); static void dbxout_begin_prologue (unsigned int, const char *); static void dbxout_source_file (const char *); static void dbxout_function_end (tree); @@ -1265,7 +1265,7 @@ dbxout_begin_prologue (unsigned int lineno, const char *filename) /* pre-increment the scope counter */ scope_labelno++; - dbxout_source_line (lineno, filename, 0); + dbxout_source_line (lineno, filename, 0, true); /* Output function begin block at function scope, referenced by dbxout_block, dbxout_source_line and dbxout_function_end. */ emit_pending_bincls_if_required (); @@ -1277,7 +1277,8 @@ dbxout_begin_prologue (unsigned int lineno, const char *filename) static void dbxout_source_line (unsigned int lineno, const char *filename, - int discriminator ATTRIBUTE_UNUSED) + int discriminator ATTRIBUTE_UNUSED, + bool is_stmt ATTRIBUTE_UNUSED) { dbxout_source_file (filename); diff --git a/gcc/debug.c b/gcc/debug.c index c8e80a841c16..df69fd5eb823 100644 --- a/gcc/debug.c +++ b/gcc/debug.c @@ -34,7 +34,7 @@ const struct gcc_debug_hooks do_nothing_debug_hooks = debug_nothing_int_int, /* begin_block */ debug_nothing_int_int, /* end_block */ debug_true_const_tree, /* ignore_block */ - debug_nothing_int_charstar_int, /* source_line */ + debug_nothing_int_charstar_int_bool, /* source_line */ debug_nothing_int_charstar, /* begin_prologue */ debug_nothing_int_charstar, /* end_prologue */ debug_nothing_int_charstar, /* end_epilogue */ @@ -104,9 +104,10 @@ debug_nothing_int_charstar (unsigned int line ATTRIBUTE_UNUSED, } void -debug_nothing_int_charstar_int (unsigned int line ATTRIBUTE_UNUSED, - const char *text ATTRIBUTE_UNUSED, - int discriminator ATTRIBUTE_UNUSED) +debug_nothing_int_charstar_int_bool (unsigned int line ATTRIBUTE_UNUSED, + const char *text ATTRIBUTE_UNUSED, + int discriminator ATTRIBUTE_UNUSED, + bool is_stmt ATTRIBUTE_UNUSED) { } diff --git a/gcc/debug.h b/gcc/debug.h index 8f76aff04a44..de525fec2cd0 100644 --- a/gcc/debug.h +++ b/gcc/debug.h @@ -61,11 +61,10 @@ struct gcc_debug_hooks /* Record a source file location at (FILE, LINE, DISCRIMINATOR). */ void (* source_line) (unsigned int line, const char *file, - int discriminator); + int discriminator, bool is_stmt); /* Called at start of prologue code. LINE is the first line in the - function. This has been given the same prototype as source_line, - so that the source_line hook can be substituted if appropriate. */ + function. */ void (* begin_prologue) (unsigned int line, const char *file); /* Called at end of prologue code. LINE is the first line in the @@ -142,7 +141,8 @@ extern const struct gcc_debug_hooks *debug_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 *, int); +extern void debug_nothing_int_charstar_int_bool (unsigned int, const char *, + int, bool); extern void debug_nothing_int (unsigned int); extern void debug_nothing_int_int (unsigned int, unsigned int); extern void debug_nothing_tree (tree); diff --git a/gcc/defaults.h b/gcc/defaults.h index b41f60366d50..a4b870ef45f5 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -255,6 +255,16 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #endif #endif +/* This determines whether or not we support the discriminator + attribute in the .loc directive. */ +#ifndef SUPPORTS_DISCRIMINATOR +#ifdef HAVE_GAS_DISCRIMINATOR +#define SUPPORTS_DISCRIMINATOR 1 +#else +#define SUPPORTS_DISCRIMINATOR 0 +#endif +#endif + /* This determines whether or not we support link-once semantics. */ #ifndef SUPPORTS_ONE_ONLY #ifdef MAKE_DECL_ONE_ONLY diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 367bda86a7eb..81be71845e49 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -91,7 +91,7 @@ along with GCC; see the file COPYING3. If not see #include "input.h" #ifdef DWARF2_DEBUGGING_INFO -static void dwarf2out_source_line (unsigned int, const char *, int); +static void dwarf2out_source_line (unsigned int, const char *, int, bool); static rtx last_var_location_insn; #endif @@ -3637,7 +3637,7 @@ dwarf2out_begin_prologue (unsigned int line ATTRIBUTE_UNUSED, prologue case, not the eh frame case. */ #ifdef DWARF2_DEBUGGING_INFO if (file) - dwarf2out_source_line (line, file, 0); + dwarf2out_source_line (line, file, 0, true); #endif if (dwarf2out_do_cfi_asm ()) @@ -16283,8 +16283,10 @@ dwarf2out_begin_function (tree fun) static void dwarf2out_source_line (unsigned int line, const char *filename, - int discriminator ATTRIBUTE_UNUSED) + int discriminator, bool is_stmt) { + static bool last_is_stmt = true; + if (debug_info_level >= DINFO_LEVEL_NORMAL && line != 0) { @@ -16301,10 +16303,13 @@ dwarf2out_source_line (unsigned int line, const char *filename, { /* Emit the .loc directive understood by GNU as. */ fprintf (asm_out_file, "\t.loc %d %d 0", file_num, line); -#ifdef HAVE_GAS_DISCRIMINATOR - if (discriminator != 0) + if (is_stmt != last_is_stmt) + { + fprintf (asm_out_file, " is_stmt %d", is_stmt ? 1 : 0); + last_is_stmt = is_stmt; + } + if (SUPPORTS_DISCRIMINATOR && discriminator != 0) fprintf (asm_out_file, " discriminator %d", discriminator); -#endif /* HAVE_GAS_DISCRIMINATOR */ fputc ('\n', asm_out_file); /* Indicate that line number info exists. */ diff --git a/gcc/final.c b/gcc/final.c index b113bc90a39a..3de72811401b 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -213,7 +213,7 @@ static int asm_insn_count (rtx); #endif static void profile_function (FILE *); static void profile_after_prologue (FILE *); -static bool notice_source_line (rtx); +static bool notice_source_line (rtx, bool *); static rtx walk_alter_subreg (rtx *, bool *); static void output_asm_name (void); static void output_alternate_entry_point (FILE *, rtx); @@ -2089,6 +2089,7 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, rtx body = PATTERN (insn); int insn_code_number; const char *templ; + bool is_stmt; #ifdef HAVE_conditional_execution /* Reset this early so it is correct for ASM statements. */ @@ -2190,11 +2191,12 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, } /* Output this line note if it is the first or the last line note in a row. */ - if (notice_source_line (insn)) + if (notice_source_line (insn, &is_stmt)) { (*debug_hooks->source_line) (last_linenum, last_filename, - last_discriminator); + last_discriminator, + is_stmt); } if (GET_CODE (body) == ASM_INPUT) @@ -2698,10 +2700,12 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED, return NEXT_INSN (insn); } -/* Return whether a source line note needs to be emitted before INSN. */ +/* Return whether a source line note needs to be emitted before INSN. + Sets IS_STMT to TRUE if the line should be marked as a possible + breakpoint location. */ static bool -notice_source_line (rtx insn) +notice_source_line (rtx insn, bool *is_stmt) { const char *filename; int linenum; @@ -2717,20 +2721,33 @@ notice_source_line (rtx insn) linenum = insn_line (insn); } - if (filename - && (force_source_line - || filename != last_filename - || last_linenum != linenum - || last_discriminator != discriminator)) + if (filename == NULL) + return false; + + if (force_source_line + || filename != last_filename + || last_linenum != linenum) { force_source_line = false; last_filename = filename; last_linenum = linenum; last_discriminator = discriminator; + *is_stmt = true; high_block_linenum = MAX (last_linenum, high_block_linenum); high_function_linenum = MAX (last_linenum, high_function_linenum); return true; } + + if (SUPPORTS_DISCRIMINATOR && last_discriminator != discriminator) + { + /* If the discriminator changed, but the line number did not, + output the line table entry with is_stmt false so the + debugger does not treat this as a breakpoint location. */ + last_discriminator = discriminator; + *is_stmt = false; + return true; + } + return false; } diff --git a/gcc/sdbout.c b/gcc/sdbout.c index cc8687419ffb..0e1cf18dfb23 100644 --- a/gcc/sdbout.c +++ b/gcc/sdbout.c @@ -117,7 +117,7 @@ static void sdbout_start_source_file (unsigned int, const char *); static void sdbout_end_source_file (unsigned int); static void sdbout_begin_block (unsigned int, unsigned int); static void sdbout_end_block (unsigned int, unsigned int); -static void sdbout_source_line (unsigned int, const char *, int); +static void sdbout_source_line (unsigned int, const char *, int, bool); static void sdbout_end_epilogue (unsigned int, const char *); static void sdbout_global_decl (tree); #ifndef MIPS_DEBUGGING_INFO @@ -1542,7 +1542,8 @@ sdbout_end_block (unsigned int line, unsigned int n ATTRIBUTE_UNUSED) static void sdbout_source_line (unsigned int line, const char *filename ATTRIBUTE_UNUSED, - int discriminator ATTRIBUTE_UNUSED) + int discriminator ATTRIBUTE_UNUSED, + bool is_stmt ATTRIBUTE_UNUSED) { /* COFF relative line numbers must be positive. */ if ((int) line > sdb_begin_function_line) diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c index 41a3420f9ed7..917121a38025 100644 --- a/gcc/vmsdbgout.c +++ b/gcc/vmsdbgout.c @@ -173,7 +173,7 @@ static void vmsdbgout_end_source_file (unsigned int); static void vmsdbgout_begin_block (unsigned int, unsigned int); static void vmsdbgout_end_block (unsigned int, unsigned int); static bool vmsdbgout_ignore_block (const_tree); -static void vmsdbgout_source_line (unsigned int, const char *, int); +static void vmsdbgout_source_line (unsigned int, const char *, int, bool); static void vmsdbgout_begin_prologue (unsigned int, const char *); static void vmsdbgout_end_prologue (unsigned int, const char *); static void vmsdbgout_end_function (unsigned int); @@ -1297,7 +1297,7 @@ vmsdbgout_end_prologue (unsigned int line, const char *file) ASM_OUTPUT_LABEL (asm_out_file, label); /* VMS PCA expects every PC range to correlate to some line and file. */ - vmsdbgout_source_line (line, file, 0); + vmsdbgout_source_line (line, file, 0, true); } } @@ -1331,7 +1331,7 @@ vmsdbgout_end_epilogue (unsigned int line, const char *file) ASM_OUTPUT_LABEL (asm_out_file, label); /* VMS PCA expects every PC range to correlate to some line and file. */ - vmsdbgout_source_line (line, file, 0); + vmsdbgout_source_line (line, file, 0, true); } } @@ -1534,10 +1534,10 @@ lookup_filename (const char *file_name) static void vmsdbgout_source_line (register unsigned line, register const char *filename, - int discriminator) + int discriminator, bool is_stmt) { if (write_symbols == VMS_AND_DWARF2_DEBUG) - (*dwarf2_debug_hooks.source_line) (line, filename, discriminator); + (*dwarf2_debug_hooks.source_line) (line, filename, discriminator, is_stmt); if (debug_info_level >= DINFO_LEVEL_TERSE) { diff --git a/gcc/xcoffout.c b/gcc/xcoffout.c index 3c853544ec4b..0f13486ad1e2 100644 --- a/gcc/xcoffout.c +++ b/gcc/xcoffout.c @@ -322,7 +322,8 @@ xcoffout_source_file (FILE *file, const char *filename, int inline_p) void xcoffout_source_line (unsigned int line, const char *filename, - int discriminator ATTRIBUTE_UNUSED) + int discriminator ATTRIBUTE_UNUSED, + bool is_stmt ATTRIBUTE_UNUSED) { bool inline_p = (strcmp (xcoff_current_function_file, filename) != 0 || (int) line < xcoff_begin_function_line); diff --git a/gcc/xcoffout.h b/gcc/xcoffout.h index caf8b08cc0b4..124c106a8b50 100644 --- a/gcc/xcoffout.h +++ b/gcc/xcoffout.h @@ -182,4 +182,4 @@ extern void xcoffout_end_function (unsigned int); extern void xcoffout_end_block (unsigned, unsigned); extern int xcoff_assign_fundamental_type_number (tree); extern void xcoffout_declare_function (FILE *, tree, const char *); -extern void xcoffout_source_line (unsigned int, const char *, int); +extern void xcoffout_source_line (unsigned int, const char *, int, bool); -- 2.43.5