Hi!

As discussed in the PR, GDB is using the second line note as a marker
to find the end of prologue, but is confused if the prologue contains
multiple basic blocks.  This happens e.g. on x86_64 in stdarg function
which aren't known not to need floating point arguments (GDB apparently
has some hackish disassembling recognizer for that), or e.g. newly
with -fsanitize=address use-after-return prologues, which GDB just doesn't
handle.

My understanding from the
http://gcc.gnu.org/ml/gcc-patches/2004-01/msg01589.html
change that introduced this was that forcing the line note on the second
basic block was added just out of paranoia, so this patch attempts
to fix that by not doing that anymore.

Bootstrapped/regtested on x86_64-linux and i686-linux, and Jan Kratochvil
has tested it with GDB testsuite.  Ok for trunk?

2014-02-18  Jakub Jelinek  <ja...@redhat.com>

        PR sanitizer/60142
        * final.c (SEEN_BB): Remove.
        (SEEN_NOTE, SEEN_EMITTED): Renumber.
        (final_scan_insn): Don't force_source_line on second
        NOTE_INSN_BASIC_BLOCK.

--- gcc/final.c.jj      2014-01-03 11:40:35.000000000 +0100
+++ gcc/final.c 2014-02-18 14:50:36.675445581 +0100
@@ -112,9 +112,8 @@ along with GCC; see the file COPYING3.
 #endif
 
 /* Bitflags used by final_scan_insn.  */
-#define SEEN_BB                1
-#define SEEN_NOTE      2
-#define SEEN_EMITTED   4
+#define SEEN_NOTE      1
+#define SEEN_EMITTED   2
 
 /* Last insn processed by final_scan_insn.  */
 static rtx debug_insn;
@@ -2128,9 +2127,7 @@ call_from_call_insn (rtx insn)
 
    SEEN is used to track the end of the prologue, for emitting
    debug information.  We force the emission of a line note after
-   both NOTE_INSN_PROLOGUE_END and NOTE_INSN_FUNCTION_BEG, or
-   at the beginning of the second basic block, whichever comes
-   first.  */
+   both NOTE_INSN_PROLOGUE_END and NOTE_INSN_FUNCTION_BEG.  */
 
 rtx
 final_scan_insn (rtx insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED,
@@ -2189,14 +2186,6 @@ final_scan_insn (rtx insn, FILE *file, i
          if (targetm.asm_out.unwind_emit)
            targetm.asm_out.unwind_emit (asm_out_file, insn);
 
-         if ((*seen & (SEEN_EMITTED | SEEN_BB)) == SEEN_BB)
-           {
-             *seen |= SEEN_EMITTED;
-             force_source_line = true;
-           }
-         else
-           *seen |= SEEN_BB;
-
           discriminator = NOTE_BASIC_BLOCK (insn)->discriminator;
 
          break;

        Jakub

Reply via email to