Commit Graph

126 Commits

Author SHA1 Message Date
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
Suzy Mueller
922c4cebd4
service/dap: add config expressions to evaluate requests (#2750)
We want to provide more flexibility for users to make changes to their configurations while the debug session is running. This could be accomplished by creating a custom request, but that were require a new UI as well, and every client of dlv dap to provide its own UI for this. By using the evaluate context, users can use the already existing debug console to change their configurations.

This change includes a refactor of the terminal code in order to share the code with the dap package.

This change provides a very similar to UI as the terminal package, but there are different configuration options that are DAP specific. We plan to use this same mechanism to expose a few other commands including "sources" to help users debug an ineffective substitutePath configuration.
2021-10-29 19:35:13 -07:00
Alessandro Arzilli
348c722981
proc/gdbserver: support watchpoints (#2659)
Adds watchpoint support to gdbserver backend for rr debugger and
debugserver on macOS/amd64 and macOS/arm64.

Also changes stack watchpoints to support reverse execution.
2021-10-04 14:45:05 -07:00
Alessandro Arzilli
29eae8f617
*: clean up staticcheck problems (#2723)
Fix problems that can be fixed, ignore the ones that don't make sense
2021-09-28 12:07:42 -07:00
Alessandro Arzilli
4264bf00f2
proc,terminal,service: support stack watchpoints (#2521)
* terminal,service: add way to see internal breakpoints

Now that Delve has internal breakpoints that survive for long periods
of time it will be useful to have an option to display them.

* proc,terminal,service: support stack watchpoints

Adds support for watchpoints on stack allocated variables.

When a stack variable is watched, in addition to the normal watchpoint
some support breakpoints are created:

- one breakpoint inside runtime.copystack, used to adjust the address
  of the watchpoint when the stack is resized
- one or more breakpoints used to detect when the stack variable goes
  out of scope, those are similar to the breakpoints set by StepOut.

Implements #279
2021-08-09 10:41:25 -07:00
Derek Parker
43d50202f3
pkg/terminal: Allow fuzzy searching tab completions (#2633)
This patch implements fuzzy searching for tab completions in the
terminal client. Under the hood it is using a trie data structure
(https://en.wikipedia.org/wiki/Trie) to perform very fast prefix / fuzzy
searches.
2021-08-05 19:55:27 +02:00
Derek Parker
cb73ef8f83
pkg/terminal: Ignore existing breakpoints for continue until (#2624)
Ignore existing breakpoints when using the continue command to continue
to a specific location such as `continue main.main`. The point of this
command is to continue to a specific location, so if there is already a
breakpoint set there there should be no error returned, just continue
until we hit the breakpoint already set in that location.
2021-07-28 13:13:32 +02:00
Derek Parker
56731bd88a
Documentation: Improve help output for examinemem (#2623)
Before this change when you typed `help` at the Delve prompt you would
only see the following:

```
examinemem (alias: x)  Examine memory:
```

Now with this patch the output is more descriptive:

```
examinemem (alias: x)  Examine raw memory at the given address.
```
2021-07-28 13:12:51 +02:00
Alessandro Arzilli
2ecc025311
terminal: add prompt when breakpoint is hit during next/step/stepout (#2548)
* terminal: add prompt when breakpoint is hit during next/step/stepout

Adds a prompt asking the user what to do when a breakpoint is hit on a
different goroutine while next/step/stepout is being executed.
Gives the user the opportunity to cancel next/step/stepout, continue
once skipping the breakpoint or automatically skipping all other
concurrent breakpoints until next/step/stepout is finished.

Fixes #2317
2021-07-26 08:57:09 -07:00
Alessandro Arzilli
8989073548
terminal: improve 'on' command (#2556)
* terminal: improve 'on' command

Adds the ability to edit the list of commands executed after stopping
on a breakpoint, as well as converting a breakpoint into a tracepoint
and vice versa.

Prior to this it was possible to add commands to a breakpoint but
removing commands or changing a breakpoint into a tracepoint, or vice
versa, could only be done by removing and recreating the breakpoint.
2021-07-22 10:16:42 -07:00
Alessandro Arzilli
7c82164264
terminal,service: Add filtering and grouping to goroutines command (#2504)
Adds filtering and grouping to the goroutines command.

The current implementation of the goroutines command is modeled after
the threads command of gdb. It works well for programs that have up to
a couple dozen goroutines but becomes unusable quickly after that.

This commit adds the ability to filter and group goroutines by several
different properties, allowing a better debugging experience on
programs that have hundreds or thousands of goroutines.
2021-07-01 11:25:33 -07:00
Derek Parker
42ecbd4413
proc,terminal: Ensure correct exit status (#2543)
Ensure that any command executed after the process we are trying to
debug prints a correct and consistent exit status.

Previously the exit code was being lost after the first time we printed
that a process has exited. Additionally, certain commands would print
the PID of the process and other would not. This change makes everything
more correct and consistent.
2021-06-22 13:35:13 +02:00
Alessandro Arzilli
29825d41a6
terminal,api: move PrintStack function (#2537)
Commit 30cdedae6910f5e9af6739845bacfd5b8778e745 introduced a dependency
from service/dap to pkg/terminal to call a stack printing function,
it's weird to have code that implements the DAP protocol depend on the
code for the JSON-RPC client.
Move PrintStack to a different package that can be called by both.
2021-06-16 13:05:17 -07:00
Suzy Mueller
aa377789b0
service/dap: deemphasize internal runtime stack frames (#2522)
Apply a presentation hint to the internal runtime stack frames, so that these can be deemphasized in the UI. This should allow
users to more easily inspect their own code, and will keep the option to view those frames if they choose to.
2021-06-10 10:59:24 -07:00
Alessandro Arzilli
d72b03b846
terminal: support setting hitcount conditions on breakpoints (#2518)
Adds a -hitcount argument to condition that sets a hitcount condition
on breakpoints.
2021-06-02 13:47:32 -07:00
Alessandro Arzilli
4f11320e4c
terminal,service: add API and commands for watchpoints (#2488)
Adds API calls and terminal commands to set watchpoints.
2021-05-20 10:04:02 -07:00
Suzy Mueller
30cdedae69
service/dap: implement exception info (#2444)
* service/dap: implement exception info

* remove adding additional thread

* Fix tests

* add exceptionInfo tests

* update comments

* map paths to client paths

* remove launch.json

* remove change to ConvertEvalScope

* correct name of supportsExceptionInfoRequest

* Add TODO for deleting output event

* Print Stack header to buffer

* Try to move resolving exception info to onExceptionInfoRequest

* save the error and return if it is the current thread

* rename thread to g

* findgoroutine returns goroutine

* clean up findgoroutine

* log errors

* remove output event

* fix grammar
2021-05-17 09:25:41 -07:00
Alessandro Arzilli
c5d58f494a
proc: add way to use CPU registers in expressions (#2446)
Changes the expression evaluation code so that register names, when not
shadowed by local or global variables, will evaluate to the current
value of the corresponding CPU register.

This allows a greater flexibility with displaying CPU registers than is
possible with using the ListRegisters API call. Also it allows
debuggers users to view register values even if the frontend they are
using does not implement a register view.
2021-05-04 12:56:17 -07:00
Felix Geisendörfer
7bf5482b32
examinememory: evaluate addr as expression (#2385)
* examinememory: evaluate addr as expression

This makes it easy to read memory locations at an offset of a known
address, e.g.:

x 0xc000046800 + 32

* use feedback from @aarzilli

- expression mode is now enabled via -x flag
- support "-x var", "-x &var" in addition to "-x <addr expr>"
- some refactoring

* add test cases

* deal with double spaces

* update docs

* add new failing test

* fix docs

* simplify implementation, update test & docs

* Fix docs
2021-04-26 10:36:24 -07:00
Alessandro Arzilli
b120b11cc3
terminal: add optional format argument to print, display (#2398)
Changes print so a format argument can be specified by using '%' as
prefix. For example:

    print %x d

will print variable 'd' in hexadecimal. The interpretarion of the
format argument is the same as that of fmt's package.

Fixes #1038
Fixes #1800
Fixes #2159
2021-03-25 09:45:30 -07:00
Álex Sáez
f5d2e132bc
*: Adds toggle command (#2208)
* Adds toggle command

Also adds two rpc2 tests for testing the new functionality

* Removes Debuggers' ToggleBreakpoint method

rpc2's ToggleBreakpoint now calls AmendBreakpoint
Refactors the ClearBreakpoint to avoid a lock.
2021-03-19 11:02:23 -07:00
Bryan Heden
6c6331c150
Documentation: fix spelling error (#2337)
* fix spelling error

* Revert "fix spelling error"

This reverts commit 08058c9efbcee5d86ef429be5bd66f8307fb02d8.

* update doc source and doc/fix spelling error
2021-03-12 08:49:15 -08:00
Ilia Choly
d1834df3c5
terminal: Add [linespec] argument to 'continue' command (#2376)
This change allows specifying an optional linespec after the 'continue'
command which sets a temporary breakpoint.

Fixes #2373
2021-03-11 22:27:29 +01:00
Ilia Choly
375f442949
terminal/command: Check for missing argument to 'dump' command (#2377) 2021-03-09 11:06:07 -08:00
Alessandro Arzilli
2c1a822632
terminal,service,proc/*: adds dump command (gcore equivalent) (#2173)
* proc/core: off-by-one error reading ELF core files

core.(*splicedMemory).ReadMemory checked the entry interval
erroneously when dealing with contiguous entries.

* terminal,service,proc/*: adds dump command (gcore equivalent)

Adds the `dump` command that creates a core file from the target process.

Backends will need to implement a new, optional, method `MemoryMap` that
returns a list of mapped memory regions.
Additionally the method `DumpProcessNotes` can be implemented to write out
to the core file notes describing the target process and its threads. If
DumpProcessNotes is not implemented `proc.Dump` will write a description of
the process and its threads in a OS/arch-independent format (that only Delve
understands).

Currently only linux/amd64 implements `DumpProcessNotes`.

Core files are only written in ELF, there is no minidump or macho-o writers.

# Conflicts:
#	pkg/proc/proc_test.go
2021-01-29 13:39:33 -08:00
Alessandro Arzilli
8e91d3b0bf
terminal: Go syntax highlighting for listings (#2294)
Fixes #1273
2021-01-28 07:08:14 -08:00
Alessandro Arzilli
6d1c00e56d
terminal,service: print WaitReason, WaitSince for goroutines (#2270)
Fixes #637
2021-01-05 10:59:17 -08:00
Alessandro Arzilli
75f00b963c
terminal: add way to cancel goroutines command with ctrl-C (#2278)
The goroutines command can take a long time to complete if there are
many goroutines, add the possibility to terminate it early by pressing
ctrl-C.
2021-01-04 08:54:39 -08:00
aarzilli
db93049813 service,terminal: apply substitute path to trace/break argument
Change FindLocation to apply substitute path rules to location
expressions. Changes terminal to always print paths after applying
substitutions.

Implements #2203
2020-11-17 16:41:35 +01:00
hitzhangjie
37d1e0100a
terminal: add -size argument to examinemem command
Adds a -size argument to examinemem that specifies how to group bytes on output.
2020-09-11 08:21:11 +02:00
Alessandro Arzilli
12009e9833
proc/*,service: replace uses of uintptr with uint64 (#2163)
Since proc is supposed to work independently from the target
architecture it shouldn't use architecture-dependent types, like
uintptr. For example when reading a 64bit core file on a 32bit
architecture, uintptr will be 32bit but the addresses proc needs to
represent will be 64bit.
2020-09-09 10:36:15 -07:00
aarzilli
7555d1c063 cmd,proc,terminal,debugger: Support default file descriptor redirects
Adds features to support default file descriptor redirects for the
target process:

1. A new command line flag '--redirect' and '-r' are added to specify
   file redirects for the target process
2. New syntax is added to the 'restart' command to specify file
   redirects.
3. Interactive instances will check if stdin/stdout and stderr are
   terminals and print a helpful error message if they aren't.
2020-09-01 21:50:27 +02:00
Alessandro Arzilli
01909d0f0b
terminal: print breakpoint info for tracepoints (#2121)
Print breakpoint info (requested print variables, stacktrace) when a
tracepoint is hit.

Fixes #2116
2020-08-05 09:38:53 -07:00
Waleed Gadelkareem
b14182324d
Update cosiner/argv to v0.1.0 (#2088) 2020-06-24 10:00:37 -07:00
Álex Sáez
95e7cafd0c
terminal/command: Add 'reload' command (#1971)
* terminal/command: Add 'reload' command

These changes add the 'reload' command, which allows us to rebuild the project
and start the debugging session again. Currently, if the project's code is
updated while debugging it, Delve shows the new source code, but it's still
running the old one. With 'reload', the whole binary is rebuilt, and the
process starts again.

Fixes #1551

* Remove unnecessary print

Changes to be committed:
      modified:   pkg/terminal/command.go

* Add tests and refactor the code

Changes to be committed:
      modified:   cmd/dlv/cmds/commands.go
      modified:   go.mod
      modified:   pkg/terminal/command.go
      modified:   service/config.go
      modified:   service/debugger/debugger.go
      modified:   service/test/integration2_test.go

* Fix typo in the comment

Changes to be committed:
      modified:   service/debugger/debugger.go

* Fix typo in the name of the variables

The variables are local therefore the capitalization is not needed

Changes to be committed:
      modified:   cmd/dlv/cmds/commands.go

* Call GoTestBuild

Also, remove the := to avoid redeclaration

* Change the Kind in the tests

Change from debugger.ExecutingGeneratedTest to
debugger.ExecutingGeneratedFile for consistency.
We are generating a real binary instead of a test
one so ExecutingGeneratedFile makes more sense here.

Changes to be committed:
      modified:   service/test/integration2_test.go

* Avoid breakpoints based on addresses

Changes to be committed:
      modified:   service/debugger/debugger.go

* Update the rebuild behaviour

There are a few cases where we can't rebuild the binary because we don't
know how it was build.

Changes to be committed:
      modified:   service/debugger/debugger.go

* Fix typos and update documentation

Changes to be committed:
      modified:   Documentation/cli/README.md
      modified:   pkg/terminal/command.go
      modified:   service/config.go
      modified:   service/debugger/debugger.go

* Fix typo

* Remove variables

They were added to the debugger.Config

* Rename variable

Rename Kind to ExecuteKind to make it more accurate

Changes to be committed:
      modified:   cmd/dlv/cmds/commands.go
      modified:   service/debugger/debugger.go
      modified:   service/test/integration2_test.go
2020-06-05 11:03:09 -07:00
Alessandro Arzilli
fecf14bd19
terminal: fix nil pointer dereference when printing tracepoints (#2071)
This issue causes a failure of TestTracePid that was observed in CI:

https://travis-ci.com/github/go-delve/delve/jobs/343053383

I'm not sure what causes it in this particular instance but there are
several ways in which a thread stopped at a breakpoint might have a
BreakpointInfo == nil field (see variable withBreakpointInfo in
debugger.Debugger.Command).
2020-06-03 10:54:07 -07:00
Derek Parker
f96663a243
cmd/dlv: Fix trace output (#2038)
* cmd/dlv,debugger: Improve dlv trace and trace command output

This patch improves the `dlv trace` subcommand output by reducing the
noise that is generated and providing clearer more concise information.

Also adds new tests closing a gap in our testing (we previously never
really tested this subcommand).

This patch also fixes the `dlv trace` REPL command to behave like the
subcommand in certain situations. If the tracepoint is for a function,
we now show function arguements and return values properly.

Also makes the overall output of the trace subcommand clearer.

Fixes #2027
2020-05-13 08:38:10 +02:00
Anders Kaare
71a460fc0f
config: add option for printfile() line count (#2043)
The option is "source-list-line-count". It defaults to 5, which was previously
hardcoded in printfile(), but now you can change it dynamically, for instance:

 $ config source-list-line-count 20
 $ list
2020-05-11 09:50:25 -07:00