163 Commits

Author SHA1 Message Date
cb52d0cc1b CI: add windows arm64 workflow (#4175)
* CI: add windows arm64 workflow

* add win-arm64 capslock

* add capslock build tag

* add servive test build tag

* skip proc_test.go

* unskip more tests

* skip TestHardcodedBreakpointCounts as flaky

* add gotip

* add version log to ps1

* switch logic to use stable json endpoint for getting latest go

* add continue-on-error for gotip
2025-10-08 17:44:12 -04:00
fd4fc92c74 service,proc: fix tests to enable parallel runs (#4135)
* *: randomize testnextnethttp.go listen port

* service/test: prefer t.Setenv

* *: cleanup port pid files

* service: fix final parallelization bugs

* address review feedback

* pkg/proc: fix test on windows

* fix finding port file on TestIssue462
2025-09-29 11:13:03 -04:00
7a32a3a337 proc: produce materialized breakpoint event for follow-exec mode (#4161)
When a previously suspended breakpoint is un-suspended we should
generate a BreakpointMaterialized event, we already did this when
breakpoints were materialized by opening plugins but we forgot to do it
when targets are added by follow-exec mode.
2025-09-25 16:50:28 -04:00
d44aa4b65a tests: add missing test cleanup (#4163)
- Changes BuildFixture so that fixtures are not built multiple times
- Add some missing calls to AddPathToRemove
2025-09-25 16:42:18 -04:00
8da93b0620 proc,service,terminal: allow cancelling of debuginfod downloads (#4123)
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
2025-09-10 11:49:58 -04:00
b1fcbdbb25 debugger: check that breakpoint exists in ClearBreakpoint (#4141)
ClearBreakpoint should check that the breakpoint exists before trying
to manipulate it.

Fixes #4137
2025-09-10 11:24:06 -04:00
61573cffb3 *: modernize codebase with newer syntax / helpers (#4110)
Changes came from running
https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize
on the codebase.
2025-08-29 15:50:08 +02:00
95e13db069 service/test: reduce TestGoroutinesGrouping runtime (#4111)
The test was spinning up more goroutines than necessary and was sleeping
longer than necessary, casuing the test to run for a really long time
and often timeout. Reduce both goroutine count and sleep time. Test
still passes, as the test is based on goroutine groups not total count
of goroutines.
2025-08-29 11:21:25 +02:00
946e4885b6 pkg,service: simplify tests with slices.Contains (#4040) 2025-06-25 13:40:34 -07:00
9234dbe6d5 service/test: assert error on CreateBreakpoint in TestNextInstruction (#3979) 2025-04-09 12:43:45 -07:00
55486fbab4 service/test: skip substitutepath test when modules disabled (#3955)
See: https://issues.redhat.com/browse/RHEL-83958
2025-03-20 09:14:20 +01:00
67ef10f207 service/test: fix compile error in tests (#3949)
Due to a merge conflict the tests in service/test are not compiling.
2025-03-14 10:36:12 -07:00
f6e0c3e59b service/debugger: fix FindLocation with child processes (#3937)
FindLocation should only return a "location not found" error if none of
the attached target processes can find the location.

Fixes #3933
2025-03-13 11:03:45 -07:00
486574cb65 *: fix various test problems with go1.25 (#3946)
- disable dwz test if it fails because of dwarf5
- fix TestExamineMemoryCmd, which made unwarranted assumptions about memory
2025-03-13 10:57:11 -07:00
967a826bbf service/test: handle wider registers in test (#3929)
When this test is run on machines with support for AVX-512, the length of xmm0Var.Children will be greater, causing an out of bounds error when iterating through the `expected` slice.
2025-03-05 12:21:34 +01:00
d2f748f1bd *: add support for linux/loong64 to native backend (#3892)
* delve: support linux-loong64 native debug

LoongArch is a new RISC ISA, which is independently designed by Loongson Technology.

LoongArch includes a reduced 32-bit version (LA32R), a standard 32-bit version (LA32S)
and a 64-bit version (LA64), and loong64 is the 64-bit version of LoongArch.

LoongArch documentation: https://github.com/loongson/LoongArch-Documentation.git

* *: mark loong64 port as experimental

---------

Co-authored-by: Huang Qiqi <huangqiqi@loongson.cn>
2025-01-17 09:41:37 -08:00
37422e6022 service/test: disable TestGuessSubstitutePath on TeamCity/linux/tip (#3890)
It does not work because of how TeamCity creates the build directory.
2025-01-03 10:40:56 -08:00
84c99e508c tests: removing of dlvbin is not needed (#3875) 2024-12-09 08:51:13 -08:00
d97b471292 pkg/proc,service/debugger: do not disable unsatisfiable breakpoints (#3868)
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.
2024-12-04 19:07:56 -08:00
b4cfc8f6c7 tests: calling os.Exit in TestMain is not required (#3856) 2024-11-12 08:03:50 -08:00
822014b8e8 service,terminal,cmd/dlv: automatically guessing substitute-path config (#3781)
Add command, API calls and launch.json option to automatically guess
substitute-path configuration.
2024-10-31 10:19:08 -07:00
979e487ac7 service/debugger: evaluate breakpoint vars on g-less threads (#3759)
Use a thread scope to evaluate breakpoint variables if the current
thread does not have an associated goroutine.

Fixes #3758
2024-07-01 11:23:39 -07:00
89123a0000 pkg/terminal,service/debugger: Support to add a new suboption --follow-calls to trace subcommand (#3594)
* 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
2024-06-12 12:35:48 -07:00
8347f97c00 *: remove redundant lines at the start/end of block (#3730) 2024-05-20 14:16:22 -07:00
bba7547156 pkg/proc: fix watchpoints on macos (#3703)
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.
2024-04-29 14:06:32 +02:00
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
ef20fbbf12 proc/gdbserver: clean up rr directory on detach (#3570)
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.
2024-01-24 09:21:20 -08:00
1a1e215fac TeamCity: speed up ppc64le CI (#3622)
The builder is currently spending 15 to 20 minutes installing gcc and
upgrading packages every time we run the tests.
Because of this the build fails sometimes by running out of time.
This change reduces that to 5 minutes by:

* switching from curl to wget (which seems to have fewer dependencies)
* not installing gcc on ppc64le
* skipping tests that depend on gcc or other binutils
2024-01-09 14:13:00 -08:00
938cb6e9d8 pkg,service: remove unnecessary convertions (#3564) 2023-11-14 16:36:55 +01:00
9986a9845f service/test: disable TestClientServer_chanGoroutines with rr backend (#3492)
It doesn't work with rr because it uses runtime.Breakpoint to stop.
2023-10-13 10:55:24 -07:00
899ba72505 all: replace deprecated io/ioutil with io and os (#3509) 2023-09-25 11:41:59 -07:00
ebc3e61367 pky/proc: enable function call injection in Delve for linux/ppc64le (#3449)
* enable func call injection on delve for ppc64le

* Function call injection on Delve/ppc64le, modified DWARF encoding and decoding for floating point registers to make floatsum test work

* Function call injection on Delve/ppc64le cleanup

* skip PIE tests for function call injection on other packages

* Address review comments

* accounted for additional skipped PIE tests for function call injection

* Code cleanup and undoing revert of previous commit

* Enable function call injection only on 1.22 and above and some cleanup

* additional cleanup, go fmt run

* Debug function call tests fail on ppc64le/PIE mode adjusted the backup_test_health.md file accordingly
2023-09-21 10:39:57 -07:00
2b9c3d5c04 proc,service: simplify tests with T.Setenv (#3503) 2023-09-19 09:29:47 -07:00
e404917db7 pkg,service: fix typos in comments, exceptions, tests (#3486) 2023-08-29 14:44:18 +02:00
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
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
8023fa956e all: use "len == 0" rather than "len <= 0" when checking empty slice/string (#3439) 2023-07-13 11:30:32 -07:00
71f1220717 *: add ppc64le support (#2963)
* Add vendor/golang.org/x/arch/ppc64

* Add ppc64le support
2023-07-07 09:30:38 -07:00
53998cbb18 pkg/proc,service/*: Supports sending output to clients when running programs remotely (#3253)
* wip: Support sending output when remote debug

* wip: Support local output and remote output

* wip: fix stderr and stdout assignment error

* wip: optimize code

* wip: Only if outputMode is "remote" is the redirected console output

* wip: Redirected debugMode output(Not tested on windows)

* wip: support remote debugging output redirection of windows

* wip: real-time write back output

* wip: support for windows

* wip: fix windows remote debug not output

* wip: fix truncated output redirection

* wip: delete printfln

* wip: use debugger.Config to pass redirect(macOS)

* wip: use debugger.Config to pass redirect(linux)

* wip: Change redirect to a concrete type

* wip: s.wg.wait before sending "terminated"

* wip: add proc/redirect test(darwin and linux)

* Merge branch 'master' of github.com:tttoad/delve into feat-console

* wip: Fix test failure on windows

* fix: undefined: proc.Redirects

* fix: compile failure

* wip: Remove useless code

* fix: filename error

* fix: os.file not close

* test: add server_test.redirect

* fix: Remove 'eol' from end of file

* fix: gdbserial: File not closed in file mode.
(in reality, gdbserial will never use file mode)

* feat: Remove "only-remote". Fix spelling mistakes.

* fix: spelling mistakes

* refactor: redirect

* fix: stdout and stderr are not set to default values

* fix: Restore code logic for rr.openRedirects()

* fix: Optimization Code

* fix: utiltest

* fix: execpt out

* fix: Resource release for redirects

* fix: build failure

* fix: clean->clear

* fix: build failure

* fix: test failure

* fix: Optimization Code

* style: remove useless code

* refactor: namedpipe

* refactor: namedpipe, launch ...

* fix: freebsd compile failure

* fix: proc_darwin compile failure

* style:  remove useless code

* feat: add d.config.Stdxx check on debug.Restart

* style: formatting and adding comments

* style: formatting and adding comments

* feat: add d.config.Stdxx check on debug.Restart

* style: namedpipe->redirector

* style: namedPipe->redirector

---------

Co-authored-by: 李翔 <qian.fu2@amh-group.com>
2023-07-05 08:39:01 -07:00
e33806a3f7 service: fix typos in comments, logs, tests, and vars (#3378) 2023-05-23 18:21:36 +02:00
cc71863594 service: fix typos in comments (#3344) 2023-04-27 13:39:33 -07:00
3507ff977a proc: support multiple functions with the same name (#3297)
The compiler produces ABI compatibility wrappers for some functions.
We have changed the support for breakpoints to allow a single logical
breakpoint to correspond to multiple physical breakpoints, take
advantage of that to set breakpoints on both the ABI wrapper and the
real function.

Fixes #3296
2023-03-22 11:38:09 -07:00
a9d699b581 proc: fix automatic breakpoints visibility (#3300)
Unrecovered-panic and fatal-throw were no longer part of the breakpoint
list because starting in 37e44bf they were created before the logical
breakpoints map was switched to the logical breakpoints map of the
target group.
2023-03-14 14:23:25 -07:00
7c835342d3 *: remove some code for Go 1.12 or earlier (#3271)
Delve no longer compiles on Go1.12 and earlier, we don't test it on
these versions and they are 4 years old and unsupported. Remove some
code related to Go 1.12 and earlier, mostly from tests.
2023-02-14 09:38:15 -08:00
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
00df758d57 proc/native: fix FreeBSD backend (#3224)
- use PT_SUSPEND/PT_RESUME to control running threads in
  resume/stop/singleStep
- change manual stop signal from SIGTRAP to SIGSTOP to make manual stop
  handling simpler
- change (*nativeProcess).trapWaitInternal to suspend newly created
  threads when we are stepping a thread
- change (*nativeProcess).trapWaitInternal to handle some unhandled
  stop events
- remove misleading (*nativeProcess).waitFast which does not do
  anything different from the normal wait variant
- rewrite (*nativeProcess).stop to only set breakpoints for threads of
  which we have received SIGTRAP
- rewrite (*nativeThread).singleStep to actually execute a single
  instruction and to properly route signals
2022-12-20 09:54:16 -08:00
2c10bb3e25 service/debugger: allow setting a breakpoint with a specific ID (#3185)
Before 4c5b111a it was possible for a client to create a breakpoint
with a specific logical ID, restore this ability for backwards
compatibility.
2022-11-08 10:33:25 -08:00
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
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
81781522c3 proc: make sure logical breakpoints map exists (#3115)
The logical breakpoints map was created as a side effect of
createUnrecoveredPanicBreakpoint or createFatalThrowBreakpoint, however
with an executable with incomplete debug info (that must be incomplete
in just the right way) both will fail and the logical breakpoint map
will never be created.

It's unknown how such an executable could be created, one easy way is
to debug a non-go executable.

Fixes #3114
2022-08-22 12:48:34 -07:00