Bug 21044 - Text or color mark on current line in code listing
Summary: Text or color mark on current line in code listing
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: cli (show other bugs)
Version: 7.12.1
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-12 09:02 UTC by Yifei Zheng
Modified: 2022-02-24 15:03 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2022-02-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yifei Zheng 2017-01-12 09:02:45 UTC
Would you please add a textual mark or colorize the current line in `list` command?

For example:

102        printf(...)
103 ->     int a = 1; // arrow?
104        return 0;
105    }

Thanks.
Comment 1 Pedro Alves 2017-01-12 11:27:15 UTC
In the TUI (try "tui enable"), we already highlight the current line.

For "list", I agree that'd be really nice.  (I've wanted it for a long while.)

lldb does that, and puts the arrow before the line numbers, which I think is more visible:

   102        printf(...)
-> 103        int a = 1; // arrow?
   104        return 0;
   105    }

This shouldn't be hard to implement if someone wants to take a stab at it.

Note we already print the current instruction in the output of the "disassemble" command:

   0x00000000004009d3 <+12>:    mov    %rsi,-0x30(%rbp)
=> 0x00000000004009d7 <+16>:    mov    $0x400c62,%edi
   0x00000000004009dc <+21>:    callq  0x400760 <objc_get_class@plt>
   0x00000000004009e1 <+26>:    mov    %rax,%rbx

In the TUI, you'll notice that we also indicate which lines have
breakpoints, with "b+".  That's something that I've wanted for "list" and "disassemble" too.
Comment 2 Yifei Zheng 2017-01-15 05:38:40 UTC
(In reply to Pedro Alves from comment #1)
> In the TUI (try "tui enable"), we already highlight the current line.
> 
> For "list", I agree that'd be really nice.  (I've wanted it for a long
> while.)
> 
> lldb does that, and puts the arrow before the line numbers, which I think is
> more visible:
> 
>    102        printf(...)
> -> 103        int a = 1; // arrow?
>    104        return 0;
>    105    }
> 
> This shouldn't be hard to implement if someone wants to take a stab at it.
> 
> Note we already print the current instruction in the output of the
> "disassemble" command:
> 
>    0x00000000004009d3 <+12>:    mov    %rsi,-0x30(%rbp)
> => 0x00000000004009d7 <+16>:    mov    $0x400c62,%edi
>    0x00000000004009dc <+21>:    callq  0x400760 <objc_get_class@plt>
>    0x00000000004009e1 <+26>:    mov    %rax,%rbx
> 
> In the TUI, you'll notice that we also indicate which lines have
> breakpoints, with "b+".  That's something that I've wanted for "list" and
> "disassemble" too.

Really fast reply... Thanks for your tips.

I've never used "tui" before. I tried it just now and discovered it's quite similar to "layout" command (or are they the same?)

And I totally agree with your idea putting arrow before line count.

Anyway thanks for viewing the bug.
Comment 3 Ciro Santilli 2017-08-02 07:32:11 UTC
I really want this, especially with a full line color highlight like TUI.

TUI breaks when you have large stdout, and with vim bindings.

I'm currently using GDB dashboard just for this feature basically: https://github.com/cyrus-and/gdb-dashboard

The problem is that requires Python scripting, which is not available on some targets.

If the highlight were possible natively, I would just put a list on hook-stop, and everything would be perfect.

Another advantage over TUI is that the shell history keeps the debug path if you want to scroll up.

Then just use the "edit" command as well to make things even better.