public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug cli/25911] New: Show column when stepping through line
@ 2020-05-03 10:32 vries at gcc dot gnu.org
  2020-05-04 14:27 ` [Bug cli/25911] " vries at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-05-03 10:32 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25911

            Bug ID: 25911
           Summary: Show column when stepping through line
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: cli
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

I.

Consider the following test-case:
...
$ cat -n stmts-on-line.c 
     1  int
     2  main (void)
     3  {
     4    int a = 4;
     5
     6    a = 5; a = 6; a = 7;
     7
     8    return 0;
     9  }
...

II.

Compiled with gcc 7.5.0 and debug info:
...
$ gcc -g stmts-on-line.c 
...

We can step through the instructions on line 6 using stepi:
...
$ gdb a.out
Reading symbols from a.out...
(gdb) start
Temporary breakpoint 1 at 0x40049b: file stmts-on-line.c, line 4.
Starting program: a.out 

Temporary breakpoint 1, main () at stmts-on-line.c:4
4         int a = 4;
(gdb) s
6         a = 5; a = 6; a = 7;
(gdb) si
0x00000000004004a9      6         a = 5; a = 6; a = 7;
(gdb) si
0x00000000004004b0      6         a = 5; a = 6; a = 7;
(gdb) si
8         return 0;
...
and can see progress through the line number and instruction addresses.

That works as follows.  The instructions are at addresses:
...
  40049b:       c7 45 fc 04 00 00 00    movl   $0x4,-0x4(%rbp)
  4004a2:       c7 45 fc 05 00 00 00    movl   $0x5,-0x4(%rbp)
  4004a9:       c7 45 fc 06 00 00 00    movl   $0x6,-0x4(%rbp)
  4004b0:       c7 45 fc 07 00 00 00    movl   $0x7,-0x4(%rbp)
  4004b7:       b8 00 00 00 00          mov    $0x0,%eax
...
and the line number info table looks like:
...
  [0x00000125]  Special opcode 62: advance Address by 4 to 0x40049b and Line by
1 to 4
  [0x00000126]  Special opcode 105: advance Address by 7 to 0x4004a2 and Line
by 2 to 6
  [0x00000127]  Advance PC by constant 17 to 0x4004b3
  [0x00000128]  Special opcode 63: advance Address by 4 to 0x4004b7 and Line by
2 to 8
...

So, put in DWARF standard terms, there are "recommended breakpoint locations"
at 0x40049b, 0x4004a2 and 0x4004b7.  When we're stopped at such a location, the
line without address is shown.

When we're stopped at an instruction which is not such a location, the line
with address is shown (4004a9, 4004b0).

III.

Now consider the same test-case, compiled with gcc 10.0.1 and debug info:
...
$ gcc-10 -g stmts-on-line.c 
...

Now when stepping through the instructions on line 6 using stepi:
...
$ gdb a.out
Reading symbols from a.out...
(gdb) start
Temporary breakpoint 1 at 0x400496: file stmts-on-line.c, line 4.
Starting program: /data/gdb_versions/devel/a.out 

Temporary breakpoint 1, main () at stmts-on-line.c:4
4         int a = 4;
(gdb) s
6         a = 5; a = 6; a = 7;
(gdb) si
6         a = 5; a = 6; a = 7;
(gdb) si
6         a = 5; a = 6; a = 7;
(gdb) si
8         return 0;
...
we don't see progress, we seem to be stuck at line 6.

In this case, the instructions are at addresses:
...
  400496:       c7 45 fc 04 00 00 00    movl   $0x4,-0x4(%rbp)
  40049d:       c7 45 fc 05 00 00 00    movl   $0x5,-0x4(%rbp)
  4004a4:       c7 45 fc 06 00 00 00    movl   $0x6,-0x4(%rbp)
  4004ab:       c7 45 fc 07 00 00 00    movl   $0x7,-0x4(%rbp)
  4004b2:       b8 00 00 00 00          mov    $0x0,%eax
...
and the line number info table looks like:
...
  [0x00000129]  Special opcode 62: advance Address by 4 to 0x400496 and Line by
1 to 4
  [0x0000012a]  Set column to 5
  [0x0000012c]  Special opcode 105: advance Address by 7 to 0x40049d and Line
by 2 to 6
  [0x0000012d]  Set column to 12
  [0x0000012f]  Special opcode 103: advance Address by 7 to 0x4004a4 and Line
by 0 to 6
  [0x00000130]  Set column to 19
  [0x00000132]  Special opcode 103: advance Address by 7 to 0x4004ab and Line
by 0 to 6
  [0x00000133]  Set column to 10
  [0x00000135]  Special opcode 105: advance Address by 7 to 0x4004b2 and Line
by ...

Now all the instructions are also breakpoint locations, which explains why we
don't see addresses.

IV.

It would be good if gdb can somehow show progress here, perhaps through
something like:
...
(gdb) s
6         a = 5; a = 6; a = 7;
(gdb) si
6         a = 5; a = 6; a = 7;
                 ^
(gdb) si
6         a = 5; a = 6; a = 7;
                        ^
(gdb) si
8         return 0;
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug cli/25911] Show column when stepping through line
  2020-05-03 10:32 [Bug cli/25911] New: Show column when stepping through line vries at gcc dot gnu.org
@ 2020-05-04 14:27 ` vries at gcc dot gnu.org
  2020-05-04 16:26 ` vries at gcc dot gnu.org
  2022-03-01 23:58 ` tromey at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-05-04 14:27 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25911

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Alternatively, as suggested in PR22531 comment 1, we could try to combine
entries in the line number table with the same line.

That way, progress would be shown by showing the addresses, as before with
gcc-7.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug cli/25911] Show column when stepping through line
  2020-05-03 10:32 [Bug cli/25911] New: Show column when stepping through line vries at gcc dot gnu.org
  2020-05-04 14:27 ` [Bug cli/25911] " vries at gcc dot gnu.org
@ 2020-05-04 16:26 ` vries at gcc dot gnu.org
  2022-03-01 23:58 ` tromey at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-05-04 16:26 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25911

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
Hmm, lldb uses an underline to indicate the column.  That's nice, because it
can be done in the same line.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug cli/25911] Show column when stepping through line
  2020-05-03 10:32 [Bug cli/25911] New: Show column when stepping through line vries at gcc dot gnu.org
  2020-05-04 14:27 ` [Bug cli/25911] " vries at gcc dot gnu.org
  2020-05-04 16:26 ` vries at gcc dot gnu.org
@ 2022-03-01 23:58 ` tromey at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: tromey at sourceware dot org @ 2022-03-01 23:58 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25911

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
We could display it somehow in the TUI as well.

Column stepping is also useful if we ever want to implement
the Debug Adapter Protocol.  It allows for column stepping.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2022-03-01 23:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-03 10:32 [Bug cli/25911] New: Show column when stepping through line vries at gcc dot gnu.org
2020-05-04 14:27 ` [Bug cli/25911] " vries at gcc dot gnu.org
2020-05-04 16:26 ` vries at gcc dot gnu.org
2022-03-01 23:58 ` tromey at sourceware dot 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).