Debugging line numbers for delayed branches

Daniel Jacobowitz drow@false.org
Thu Oct 18 15:39:00 GMT 2007


I have been working on GDB support for optimized code.  This turns up
all sorts of interesting quirks in GCC's debug output when optimizing.

reorg.c:emit_delay_sequence does this:

      /* SPARC assembler, for instance, emit warning when debug info is output
         into the delay slot.  */
      if (INSN_LOCATOR (tem) && !INSN_LOCATOR (seq_insn))
        INSN_LOCATOR (seq_insn) = INSN_LOCATOR (tem);
      INSN_LOCATOR (tem) = 0;

There's all sorts of things we could do, at least on platforms which
permit local labels in delay slots, to generate useful debug
information for this case.  But GDB wouldn't handle it anyway, so for
now I've stuck with not emitting it.  But the above is still strange,
because TEM is each instruction in a delay slot, not the branch
itself.  If both the branch and the delay slot had locators, we go
from:

(jump_insn 7 6 15 2 foo.c:5 (set (pc)
	...)

...

(insn 41 40 18 3 foo.c:8 (set (reg/f:SI 3 $3 [198])
        (unspec:SI [
            ...
            ] 24)) 202 {load_gotsi} (nil))

To:

(insn 61 6 15 foo.c:8 (sequence [
            (jump_insn 7 6 41 foo.c:5 (set (pc)
	    	    ...)
            (insn 41 7 15 (set (reg/f:SI 3 $3 [198])
                    (unspec:SI [
		    	       ...
                        ] 24)) 202 {load_gotsi} (nil))
        ]) -1 (nil))

When final emits these, it emits the sequence first and then each
instruction in the sequence.  The final file looks like:

        .loc 1 8 0
        .loc 1 5 0
        bne     $3,$0,$L7
        lw      $3,%got(baz)($28)

The double .loc is not useful.  The branch still shows up on the right
line, so there are no immediate consequences; but the empty line from
the delay slot confused GDB.  The branch came from an inlined function
and stepping through line 5 (containing an inlined call) terminated
too early.

So let's prefer the branch's line number for the SEQUENCE if it has one.
Tested on mips-linux (C, C++, GDB); no change in test results and the
first .loc above vanishes.  OK to commit?

-- 
Daniel Jacobowitz
CodeSourcery

2007-10-18  Daniel Jacobowitz  <dan@codesourcery.com>

	* reorg.c (emit_delay_sequence): Move insn locator from the
	first insn to the sequence.

Index: reorg.c
===================================================================
--- reorg.c	(revision 129380)
+++ reorg.c	(working copy)
@@ -512,6 +512,9 @@ emit_delay_sequence (rtx insn, rtx list,
   INSN_DELETED_P (delay_insn) = 0;
   PREV_INSN (delay_insn) = PREV_INSN (seq_insn);
 
+  INSN_LOCATOR (seq_insn) = INSN_LOCATOR (delay_insn);
+  INSN_LOCATOR (delay_insn) = 0;
+
   for (li = list; li; li = XEXP (li, 1), i++)
     {
       rtx tem = XEXP (li, 0);



More information about the Gcc-patches mailing list