https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97774
Bug ID: 97774 Summary: Incorrect line info for try/catch Product: gcc Version: 7.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- [ This PR is FTR, it's already fixed. ] Consider this test-case, minimized from gdb.cp/gdb9593.cc ( https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer-vla-tests.patch ): ... $ cat -n test.cc 1 void 2 function1 (void) 3 { 4 throw 20; 5 } 6 7 int 8 main (void) 9 { 10 try 11 { 12 function1 (); 13 } 14 catch (int x) 15 { 16 } 17 18 return 0; 19 } ... We compile using gcc 7.5.0: ... $ g++ -g test.cc -save-temps -dA ... When trying to step over function1 using next, we end up on line 18, and not at the start of line 18 (given the $hex prefix): ... $ gdb a.out -ex start -ex next Reading symbols from a.out... Temporary breakpoint 1 at 0x4007b5: file test.cc, line 12. Starting program: a.out Temporary breakpoint 1, main () at test.cc:12 12 function1 (); 0x00000000004007c1 18 return 0; (gdb) ... This is caused by the following. There's a .loc for line 18 after the call to function1, but then we jump away to label .L9: ... # test.cc:12 .loc 1 12 0 call _Z9function1v .LEHE0: # BLOCK 3 seq:1 # PRED: 2 (FALLTHRU) 6 [100.0%] .L7: # test.cc:18 .loc 1 18 0 movl $0, %eax # SUCC: 7 [100.0%] jmp .L9 # BLOCK 4 seq:2 # PRED: 2 (ABNORMAL,ABNORMAL_CALL,EH) .L8: cmpq $1, %rdx ... Since there's no other loc before the insn at .L8, it's considered to be part of line 18.