We've always said that predefined breakpoints (like the
unrecovered-panic breakpoint) are just like any other breakpoint and
clients can remove them by using the ClearBreakpoint API.
However commit 78471b3a in 2022 made this not true by treating negative
IDs (which is what we assign to predefined breakpoints) specially.
That change was made as part of a series of changes to support
debugging child processes: prior to that change breakpoints were
cleared by address only (which worked fine for predefined breakpoints)
but this was not tenable for multiprocess debugging.
So ClearBreakpoint was changed to clear breakpoints by breakpoint ID
and only use address in a backward compatibility mode when no ID was
specified.
The current implementation of ClearBreakpoint works fine for user
breakpoints in all cases and for predefined breakpoints as long as
there is only one target process (clearing a predefined breakpoint will
be processed in backwards compatibility mode using its address).
However it should be possible to clear predefined breakpoints even when
Delve is attached to multiple processes. For this reason limit the
backwards compatibility mode of ClearBreakpoint to only ID == 0,
sparing negative IDs as valid.
* Add flag to retain trace directory after detach
Fixes https://github.com/go-delve/delve/issues/4079
* Addressing review comments
* To fix test errors coming in issue 4051
* Skip TestIssue4051 for rr backend
* Address remaining review comments
Adds an RPC call to cancel in-progress debuginfod-find downloads. Wires
this call to ^C in the terminal interface and to receiving a Pause
request while already pausing in DAP.
Adds a new terminal command to download the debug info for libraries
for which it hasn't been downloaded already.
Fixes#3906
Save the attached to PID to the configuration when WaitFor is used so
that we later know that we attached and behave identically to when the
normal attach command is used, particularly with respect to killing the
process on exit.
Fixes#4119
Add a GetEvents method that can be used to retrieve debug events, adds
events for downloading debug info through debuginfod and shows those
events in the command line client as well as console messages in DAP.
In the future this events mechanism can be used to unify EBPF
tracepoints with old style tracepoints.
Update #3906
We had a few problems with missing targetMutex acquisitions in
service/debugger, this commit takes care of a few other methods (although I
don't think any of these are problems in practice).
- DwarfRegisterToString is removed, there is no need to call this method
outside of the context of ScopeRegisters/ThreadRegisters which can
directly return the function that DwarfRegisterToString would call
- add lock acquisition to BuildID
- remove Target, TargetGroup, TargetLock and TargetUnlock. Replace them with
a single LockTargetGroup method that acquires the lock and returns the
target group and the unlock function. Callers can still misuse
LockTargetGroup by calling unlock immediately and continuing to use the
target group but this is harder to do accidentally compared to the others.
Replaces the Thread.Location method with a ThreadLocation function. All
backends implemented the Location method exactly the same way, this
change deduplicates it.
Previously breakpoints with hitcount conditions that became
unsatisfiable
would become disabled, this was done as an optimization so that the
continue loop would no longer need to stop on them and evaluate their
conditions.
As a side effect this meant that on restart these breakpoints would
remain disabled, even though their hit condition returned satisfiable.
This commit changes Delve behavior so that breakpoints with
unsatisifiable hitcount conditions are no longer disabled but the
associated physical breakpoints are removed anyway, preserving the
optimization.
Some refactoring is done to the way conditions are represented and the
enable status is managed so that in the future it will be possible to
use hitcount conditions to implement "chained" breakpoints (also known
as dependet breakpoints), i.e. breakpoints that become active only
after a second breakpoint has been hit.
Fixes bug where the incorrect Build ID could be used to try and download the source for a binary. This is because the Build ID was stored on the BinInfo object for a target and not the image itself.
* rebasing on master to implement --followcalls
* in progress changes to enable --followcalls
* rebase to master: modified function to add children to funcs array
* modify main traversal loop
* added tests to check different scenarios
* added tests to check different scenarios
* added tests to check different scenarios
* add test to check for overlapping regular expression
* modified type of strings array as a return only
* changed depth to a simple integer instead of a global map
* avoid calling traverse on recursive calls
* Added tests for various call graphs to test trace followfuncs
* Added tests for various call graphs to test trace followfuncs
* Added tests for various call graphs to test trace followfuncs
* made auxillary changes for build to go through for new option follow-calls
* Add support to print depth of the function calls as well
* Added two sample output files for checking
* Bypass morestack_noctxt in output for verification testing
* Corrected newline error by adding newlines only if the line does not match morestack_noctxt
* Added more tests
* Cleanup
* Updated documentation
* fixed error message in fmt.Errorf
* Fixed result of Errorf not used error
* Addressing review comments to fix depth reporting and other issues
* dont invoke stacktrace if tracefollowcalls is enabled, compute depth from main regex root symbol than main.main
* Addressing a part of review comments
* Added changes to allow deferred functions to be picked up for tracing
* Fix issue to avoid printing stack for a simple trace option
* Moving most tests to integration2_test.go and keeping only one in dlv_test.go
* Moving most tests to integration2_test.go and keeping only one in dlv_test.go
* Adding panic-defer test case
* Moved rest of the tests to integration2_test.go
* addressing review comments: folding Functions and FunctionsDeep, reducing branches by using depth prefix, wrap using %w and other comments
* Optimize traversal and parts of printing trace point function and modify trace output layout
and adjust tests accordingly
* Resolved error occurring due to staticcheck
* Implemented traversal algorithm using breadth first search
* Addressing review comments on the breadth first search implementation and
other comments
* Inline filterRuntimeFuncs and remove duplicate initialization
* Print out message and dump stack on pause
* Fix test
* Move the logic to debugger layer
* Remove unused fields
* Do not use defer to get state
* move channel to connection
* remove lock on isClosed
* Use mutex
* Remove unwanted changes
It seems newer MacOS kernels are sending mach exceptions for watchpoints
which contain the hardware register number as opposed to the address
which triggered the exception. Also, ARM64 seems to have switched to
sending _EXC_I386_SGL as medata[0] for this exception type.
We used to autoremove the trace recorded by rr but as a result of
various refactorings done to implement follow exec mode this broke.
Restore the functionality.
Also remove the _fixtures/testfnpos.go file which is autogenerated
during testing.
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.
If there is no current goroutine when 'next', 'step' or 'stepout' are
used set a condition that the thread ID should stay the same instead.
This makes stepping work for multithreaded C programs or Go programs
that have threads started by cgo code.
Fixes#3262
Adds a waitfor option to 'dlv attach' that waits for a process with a
name starting with a given prefix to appear before attaching to it.
Debugserver on macOS does not support follow-fork mode, but has this
feature instead which is not the same thing but still helps with
multiprocess debugging somewhat.
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
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.
* logflags,proc: flag to log stacktrace execution
Add a log flag to write logs about what the stacktracer does.
* proc: read context from sigtrampgo, fixes TestCgoStacktrace2 on 1.21
Changes stacktrace code to read the signal context from the arguments
of sigtrampgo.
Also changes the automatic fatalthrow breakpoint for go 1.21.
In combination these two changes fix TestCgoStacktrace2 on Go 1.21 on
various platforms.
We used to parse the .gopclntab section but removed support in favor of
simply using DWARF debug information, due to lack of C symbols among
other reasons. This makes it impossible to debug stripped binaries,
which some distrubutions ship by default.
Add back in basic support for .gopclntab which survives if the binary
is stripped, allowing for rudimentary debugging such as basic
program navigation, tracing, etc...
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
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