Commit Graph

163 Commits

Author SHA1 Message Date
Derek Parker
689c86355b
pkg/terminal: allow postfix if for breakpoint conds (#3693)
Allows for a user to specify the breakpoint condition directly
when creating the breakpoint. The new syntax looks like the
following:

```
break <name> <locspec> [if <expression>]
```

Also updates docs to include more examples and locspec description
instead of directing users to the online / source documentation.
2024-04-09 15:15:38 +02:00
Derek Parker
d688d4c83b
pkg/terminal: print breakpoint number on stop (#3675) 2024-02-28 15:49:33 +01:00
Derek Parker
29aa2ea8c9
pkg/terminal,pkg/proc: Implement next-instruction (#3671)
The next-instruction (nexti) command behaves like
step-instruction (stepi) however, similar to the
`next` command it will step over function calls.
2024-02-28 09:28:33 +01:00
Alessandro Arzilli
5bd835a801
*: misc fixes for go1.23 (#3663)
- skip staticcheck on go1.23 for now
- fix reading interface values in go1.23
- sync list of waitreasons from go1.23
2024-02-22 11:35:15 -08:00
Alessandro Arzilli
9405996b5d
terminal: add color highlighting to stacktraces (#3649)
Adds configurable highlighting for function names and filenames in stack traces.

Fixes #720
2024-02-07 11:06:30 -08:00
Alessandro Arzilli
88380654fe
proc: fix dynamic library loading with musl loader (#3621)
With the glibc loader the link map entry for the static executable has
an empty name field and address equal to 0x0. This case was already
handled by the check in bininfo.go AddImage for names to be valid
paths.
With the musl loader however the first entry, corresponding to the
static executable, has a valid path with address equal to 0x0, since we
record a real address for the image corresponding to the static
executable this results in having two entries for the executable when
musl is used to link go programs.

Change the code scanning the debug link map so that the first entry is
skipped if it has address equal to zero.

Fixes #3617
2024-01-10 07:33:35 -08:00
Alessandro Arzilli
f8de498d77
terminal: add paging to print, vars, args and locals (#3620)
Add automatic paging to the output of print, vars, args and locals.

Fixes #3615
2024-01-09 14:13:37 -08:00
Derek Parker
6185e673c2
pkg/terminal: support vscode in edit command (#3524) 2023-10-09 17:58:21 +02:00
Oleksandr Redko
899ba72505
all: replace deprecated io/ioutil with io and os (#3509) 2023-09-25 11:41:59 -07:00
Derek Parker
4d30cd461b
pkg/terminal: support more editors with edit command (#3506)
The current implementation assumes a specific command line interface
for opening an editor at a specific location within the source file.
This patch updates for different formats, namely the one used by the
editor 'hx'.
2023-09-20 09:25:48 +02:00
Hyang-Ah Hana Kim
e072a64903
pkg/terminal: add 'packages' command (#3499)
This command lists the packages included in the debugee.
The implementation utilizes "ListPackagesBuildInfo" RPC.

In order to support server-side filtering like `sources` and other
commands, expanded the ListPackagesBuildInfo RPC to take an optional
filter field.
2023-09-18 08:59:58 -07:00
Alessandro Arzilli
0b35fe6d42
proc,service,terminal: add ways to list goroutines waiting on a channel (#3481)
Adds -chan option to the goroutines command to list only the goroutines
running on a specified channel.
Also when printing a variable if it is a channel also print the list of
goroutines that are waiting on it.
2023-08-23 13:02:34 -07:00
Alessandro Arzilli
ca611db449
terminal: restore breakpoints set with line offset on restart (#3425)
Change FindLocation so it can return a substitute location expression
and propagate it to pkg/terminal/command.
When breakpoints are set using the syntax :<lineno> or +<lineno>
produce a substitute location expression that doesn't depend on having
a valid scope and can be used to restore the breakpoint.

Fixes #3423
2023-07-20 12:29:59 +02:00
Alessandro Arzilli
db0bc26949
terminal,service: better printing of suspended breakpoints (#3415)
Show the location expression that will be used to set a suspended
breakpoint in the breakpoints list.

Also change 'target' called without arguments to print a better error
message and 'target follow-exec' without the last argument to print the
state of follow-exec.
2023-07-07 10:33:40 -07:00
Alessandro Arzilli
95dac8f19b
service,terminal: when libraries don't have debug_info print reason (#3419)
Print the reason why libraries don't have debug info in response to the
'libraries' command.
2023-06-15 08:00:59 -07:00
Alessandro Arzilli
c958128f21
terminal: expand ~ in paths passed to 'source' (#3387) 2023-06-06 20:52:19 -07:00
Alessandro Arzilli
9b17415e83
terminal: ask for confirmation when using 'quit -c' with breakpoints (#3398) 2023-06-06 20:46:56 -07:00
Alessandro Arzilli
e95ae9c21b
proc,terminal: read command line of new processes (#3346)
Read the command line of the main target process as well as any other
process Delve attaches to in follow exec mode.
The command line can be viewed using the 'target list' command.

In follow exec mode this command line is used to match the follow exec
regex to decide whether or not to attach to a child process.

On macOS or when using rr the list of arguments is not available for
attached processes since there is no way to use the gdb serial protocol
to read it.

Fixes #2242
2023-05-09 11:40:00 -07:00
罗泽轩
801a9109c7
trace: add timestamp to the output (#3358)
Fix #3356
2023-05-08 10:41:47 -07:00
Alessandro Arzilli
13ad7dc1d5
*: misc improvements to config command and substitute-path rules (#3335)
A series of interconnected changes to both the terminal command
'config', DAP command 'dlv config', quality of life improvements to how
substitute-path works, and better documentation.

- Let 'config substitute-path' show the current substitute path rules
- Add a -clear command to 'config substitute-path'
- Support 'config-debug-info-directories'
- rewrite SubstitutePath to be platform independent (see below)
- document path substitution more

Regarding the rewrite of SubstitutePath: the previous version used
runtime.GOOS and filepath.IsAbs to determine which filepath separator to use
and if matching should be case insensitive. This is wrong in all situations
where the client and server run on different OSes, when examining core files
and when cross-compilation is involved.

The new version of SubstitutePath checks the rules and the input path to
determine if Windows is involved in the process, if it looks like it is it
switches to case-insensitive matching. It uses a lax version of
filepath.IsAbs to determine if a path is absolute and tries to avoid having
to select a path separator as much as possible

Fixes #2891, #2890, #2889, #3179, #3332, #3343
2023-05-02 12:23:59 -07:00
Álex Sáez
bdec83da45 Fix typo 2023-04-25 15:35:06 +02:00
Álex Sáez
5a159c2ef2 Add additional information to how to filter goroutines 2023-04-25 15:35:06 +02:00
Alessandro Arzilli
a61ccea65a
service/debugger,terminal: API and user interface for follow exec mode (#3286)
Updates #2551
2023-04-24 14:37:31 -07:00
Oleksandr Redko
372552bf1f
Documentation: fix typo and grammar issues (#3291) 2023-02-28 14:52:52 +01:00
Felix Geisendörfer
e11e8858ea
Documentation: watch example for arbitrary address (#3268)
Fixes #3266
2023-02-13 06:27:14 -08:00
Derek Parker
3847b7a199
debugger,terminal: Allow setting and clearing breakpoints after process exit (#3246)
This patch allows users to set a breakpoint even when the process has
exited. It will be left in a pending state until the process is
restarted.

Fixes #3242
2023-01-06 18:37:35 +01:00
Derek Parker
8db9be977c
pkg/terminal: use default for Y/n empty response (#3248)
The typical convention with `[Y/n]` type command line questions
is that the capitalized letter represents the default if the user
simply hits "enter" instead of typing an actual response.
This patch fixes our implementation to use the implied default response.
2023-01-06 08:49:15 +01:00
Alessandro Arzilli
6e7e1d8830
proc,terminal: allow setting suspended breakpoints (#3154)
Allows setting suspended breakpoints and try to enable them
automatically after every time a plugin is loaded.

Fixes #1653
Updates #2551
2022-10-04 08:07:05 -07:00
Alessandro Arzilli
ec5fcc07fe
proc,service/debugger: track how breakpoints were originally set (#3148)
Adds field to breakpoint struct to track how a breakpoint was
originally set, moves the logic for disabling and enabling a breakpoint
to proc.
This will allow creating suspended breakpoints that are automatically
enabled when a plugin is loaded. When follow exec mode is implemented
it will also be possible to automatically enable breakpoints (whether
or not they were suspended) on new child processes, as they are
spawned.

It also improves breakpoint restore after a restart, before this after
a restart breakpoints would be re-enabled using their file:line
position, for breakpoints set using a function name or a location
expression this could be the wrong location after a recompile.

Updates #1653
Updates #2551
2022-09-28 11:35:07 -07:00
Alessandro Arzilli
a73eaeffd2
proc,service: change FindLocation to work with multiple targets (#3103)
Changes FindLocation to support multiple targets and adds an AddrPid
member to api.Breakpoint so that clients can set breakpoints by address
when multiple targets are connected (but at them moment this field is
ignored).

Updates #1653
Updates #2551
2022-09-26 10:12:34 -07:00
Alessandro Arzilli
1add32b4d9
terminal: do not use WaitSince as unix time (#3139)
g.waitsince is the output of runtime.nanotime and represents a
monotonic clock which can not be converted directly into unix time. A
better fix would be to convert it to a time.Duration by reading the
current value of runtime.nanotime. This is complicated, however,
because on some systems (for example macOS) the current value of
runtime.nanotime can only be read by making a system call.

Updates #3137
2022-09-20 13:05:57 -07:00
Alessandro Arzilli
b19d67ccf2
terminal: remove leftover GOPATH references (#3117)
Remove leftover references to $GOPATH in documentation, change script
that generates markdown documentation to look for substrings that start
with "Documentation/" instead.
2022-08-30 10:12:19 -07:00
Frederick Zhang
e2ec3eb633
Documentation: reverse step, next and stepout (#3119)
These were implemented in [1].

[1] https://github.com/go-delve/delve/pull/1785
2022-08-24 16:27:07 +02:00
Alessandro Arzilli
cb91509630
terminal: send large output to pager (#3060)
For commands that could produce large amounts of output switch to a
pager command ($DELVE_PAGER, $PAGER or more) after a certain amount of
output is produced.

Fixes #919
2022-08-17 09:02:53 +02:00
Alessandro Arzilli
5b9f65dac2
*: switch to int64 for goroutine IDs (#3110)
Go 1.20 switched to uint64 to represent goroutine IDs, we can't
actually follow suit because we have allowed clients to use -1 to refer
to the currently selected goroutine, however we should at least switch
to int64 and also update the rtype check to accept the 1.20 type.
2022-08-16 09:31:11 -07:00
Derek Parker
be08778975
:* Improve trace subcommand output (#3091)
This patch improves the output of the trace subcommand by
adding better line breaks, adding goroutine info to the
return statement, and removing unnecessary output.
2022-08-04 10:10:54 +02:00
Alessandro Arzilli
d17c5e155a
Documentation: fix documentation of examinemem (#3087)
The 'addr' option was removed during review and doesn't exist.

Fixes #3086
2022-08-01 09:03:48 -07:00
roketyyang
ec1d1efb7f
terminal/command: 'goroutines' command add new flags '-exec command' (#3044)
* terminal/command: 'goroutines' command add new flags '-exec command'

Support run command on every goroutine.

Fixes #3043

* terminal/command: 'goroutines' command add new flags '-exec command'

Support run command on every goroutine.

Fixes #3043

* terminal/command: add -per-g-hitcount option to condition command

Support use per goroutine hitcount as hintcond operand.

Fixes #3050

Co-authored-by: roketyyang <roketyyang@tencent.com>
2022-07-25 10:14:43 -07:00
Alessandro Arzilli
1fe03e728c
terminal: add ability to show disassembly instead of source (#3047)
Adds ability to show current position as disassembly instead of source
listing every time execution stops. Change default to show disassembly
after step-instruction and source listing in every other case.

Fixes #2878
2022-07-14 14:08:47 -07:00
roketyyang
278e4d10c8
terminal/command: add -per-g-hitcount option to condition command (#3055)
Support use per goroutine hitcount as hintcond operand.

Fixes #3050

Co-authored-by: roketyyang <roketyyang@tencent.com>
2022-07-12 10:31:34 +02:00
Adrien Barreau
aac4e19c24
Documentation: Fix example block in cli README (#2974) 2022-04-19 11:35:54 -07:00
Derek Parker
cdf73b5365
Prefer locspec to linespec (#2941)
Often in the CLI documentation we were to inputs as linespec
when in reality we mean locspec which is a
location specifier, not necessarily a
line specifier.
2022-03-23 15:12:40 +01:00
chainhelen
bb88e8b52e
pkg/terminal: add '-clear' option to 'condition' command (#2882)
This change adds the '-clear' to 'condition' which will clear
condtion on the breakpoint.

Co-authored-by: qianhailong <qianhailong@bytedance.com>
2022-02-15 18:41:23 +01:00
Morten Linderud
8c392d2fdf
Implement source listing from debuginfo (#2885)
* service: Implement BuildID

Parse the BuildID of executables and provides it over the RPC
service.

Signed-off-by: Morten Linderud <morten@linderud.pw>

* command: Support debuinfod for file listing

Signed-off-by: Morten Linderud <morten@linderud.pw>

* debuginfod: create debuginfod package for common code

We remove the duplicated code and provide our a new debuginfod package.

Signed-off-by: Morten Linderud <morten@linderud.pw>

* starlark: Workaround for 'build_i_d'

Signed-off-by: Morten Linderud <morten@linderud.pw>

* command: Ensure we only overwrite path when one has been found

Signed-off-by: Morten Linderud <morten@linderud.pw>

* bininfo: Inline parseBuildID

Signed-off-by: Morten Linderud <morten@linderud.pw>
2022-01-30 13:39:30 -08:00
Alessandro Arzilli
5b925d4f5d
terminal: add transcript command (#2814)
Adds a transcript command that appends all command output to a file.
This command is equivalent to gdb's 'set logging'.

As part of this refactor the pkg/terminal commands to always write to a
io.Writer instead of using os.Stdout directly (through
fmt.Printf/fmt.Println).

Fixes #2237
2022-01-27 13:18:25 -08:00
Gareth Rees
c75f7a2658
Documentation: improve wording for "rewind" command (#2870) (#2871) 2022-01-14 09:44:22 -08:00
Tim Hockin
0ecdc6e4a9
pkg/terminal: Support b and t without a linespec (#2863)
This could probably be more user-friendly, in that you can't give a name
to such a breakpoint.  To add support for names, we would need to try
a single arg first as a location, and if that fails try it as a name for
current line.  That seems somewht dubious, so I didn't try.
2022-01-06 08:56:21 -08:00
Alessandro Arzilli
07bcf0cb13
Documentation: document runtime.curg and runtime.frameoff (#2835) 2021-12-22 09:38:39 -08:00
kaddy-tom
15bb95ccc3
terminal/command: fix up OoB in deferred command (#2823)
Prior to this, sending a `deferred` command with no arguments would immediately
crash the debug session.
2021-12-10 10:52:05 +01:00
Suzy Mueller
a4ac69e87d
service/dap: support goroutine filters in dap (#2759)
* service/dap: filter goroutines

* adjust defaults

* add tests

* remove label change

* fix typos

* send invalidated areas

* respond to review, and allow to clear goroutineFilters
2021-12-07 09:23:55 -08:00