public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/97774] New: Incorrect line info for try/catch
@ 2020-11-10  9:34 vries at gcc dot gnu.org
  2020-11-10  9:42 ` [Bug debug/97774] " vries at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: vries at gcc dot gnu.org @ 2020-11-10  9:34 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug debug/97774] Incorrect line info for try/catch
  2020-11-10  9:34 [Bug debug/97774] New: Incorrect line info for try/catch vries at gcc dot gnu.org
@ 2020-11-10  9:42 ` vries at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: vries at gcc dot gnu.org @ 2020-11-10  9:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97774

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.0
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Starting gcc 10.1, we have instead:
...
        jmp     .L8
# BLOCK 4 seq:2
# PRED: 2 (ABNORMAL,ABNORMAL_CALL,EH)
.L7:
        # test.cc:14:3
        .loc 1 14 3
        cmpq    $1, %rdx
...
and:
...
$ gdb a.out -ex start -ex n
Reading symbols from a.out...
Temporary breakpoint 1 at 0x4007b4: file test.cc, line 12.
Starting program: a.out 

Temporary breakpoint 1, main () at test.cc:12
12            function1 ();
14        catch (int x)
...

This is due to:
...
commit 4500f7510368cdb24b8afcc66e86e09cafe49199
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Fri Jul 5 08:39:13 2019 +0000

    except.c (emit_to_new_bb_before): Make sure to put a location on SEQ.

            * except.c (emit_to_new_bb_before): Make sure to put a location on
SEQ.
            * tree-eh.c (replace_goto_queue_1) <GIMPLE_GOTO>: Propagate
location.
            (emit_eh_dispatch): Delete.
            (lower_catch): Emit the eh_dispatch manually and set the location
of
            the first catch statement onto it.
            (lower_eh_filter): Emit the eh_dispatch manually and set location.
            (lower_eh_dispatch): Propagate location.
            * tree-outof-ssa.c (set_location_for_edge): Handle EH edges
specially.
            (eliminate_build): Likewise.

    From-SVN: r273132
...

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-10  9:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10  9:34 [Bug debug/97774] New: Incorrect line info for try/catch vries at gcc dot gnu.org
2020-11-10  9:42 ` [Bug debug/97774] " vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).