delve
delve copied to clipboard
Make `list` display the next set of lines when the empty command is sent
Note: This is a feature request.
Please answer the following before submitting your issue:
Note: Please include any substantial examples (debug session output, stacktraces, etc) as linked gists.
- What version of Delve are you using (
dlv version
)?
Delve Debugger
Version: 1.4.0
Build: $Id: 67422e6f7148fa1efa0eac1423ab5594b223d93b $
-
What version of Go are you using? (
go version
)?go version go1.14.2 linux/amd64
-
What operating system and processor architecture are you using?
x86_64 GNU/Linux
-
What did you do?
-
list <func>
# output 10 lines of code -
<pressed enter>
# output same 10 lines of code
- What did you expect to see?
Next 10 lines of code, similar to gdb & lldb. Makes displaying source while debugging more convenient.
- What did you see instead?
The same 10 lines of code
Example:
(dlv) list snode.attr
Showing /go/pkg/mod/bazil.org/[email protected]/fs/serve.go:492 (PC: 0x56d9d3)
487: // - hold Server.meta while calling wg.Add, then unlock
488: // - do NOT try to reacquire Server.meta
489: wg sync.WaitGroup
490: }
491:
492: func (sn *serveNode) attr(ctx context.Context, attr *fuse.Attr) error {
493: err := nodeAttr(ctx, sn.node, attr)
494: if attr.Inode == 0 {
495: attr.Inode = sn.inode
496: }
497: return err
(dlv)
Showing /go/pkg/mod/bazil.org/[email protected]/fs/serve.go:492 (PC: 0x56d9d3)
487: // - hold Server.meta while calling wg.Add, then unlock
488: // - do NOT try to reacquire Server.meta
489: wg sync.WaitGroup
490: }
491:
492: func (sn *serveNode) attr(ctx context.Context, attr *fuse.Attr) error {
493: err := nodeAttr(ctx, sn.node, attr)
494: if attr.Inode == 0 {
495: attr.Inode = sn.inode
496: }
497: return err
There's an edit command that can open the source code at the current line. You can even set it up to open the source in a different window easily. I've always thought the behavior of list
in gdb was archaic, designed for physical teletypes from the '70s.
It is archaic, but occasionally you're working in an environment like that. For example, writing a user-space filesystem with bazil.org/fuse on a mac, which doesn't support mac, I'm forced to run all tests & debugging within a docker image.
+1
Also, there should be a way to see the previous lines and to set the number of lines printed when issuing list
.
Not to derail OP's original issue, but I would like to add my +1 to @jginsburgn's suggestion:
set the number of lines printed when issuing list.
It would be useful to be able to print more than the 5 lines either side of the current line, similar to grep
's A, B and C flags.
That can already be done:
(dlv) config source-list-line-count 10
I think it might be more intuitive and user-friendly to have something like list -A 15 -B 12
or list -C 17
. If you know roughly where in the codebase I could get started, I might have time over the next few weekends to take a look.
List takes a location expression as an argument, which can be anything. It's difficult to change it to also take other arguments in an unambiguous way. Also I still think there's little need for this when there's edit
.
Fair enough 👍🏻