Commit Graph

286 Commits

Author SHA1 Message Date
Alessandro Arzilli
477e46ebbd
pkg/proc: support swiss table map implementation (#3838)
Adds support for the swiss table implementation for Go's maps.
2024-12-04 19:14:47 -08:00
Oleksandr Redko
091e5535ab
all: remove redundant err declarations (#3855) 2024-11-12 08:04:22 -08:00
Oleksandr Redko
b4cfc8f6c7
tests: calling os.Exit in TestMain is not required (#3856) 2024-11-12 08:03:50 -08:00
Alessandro Arzilli
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
Hyang-Ah Hana Kim
ac8b4718bd
all: import go telemetry and enable crash reporting (#3841)
Imported golang.org/x/telemetry@9c0d19e to avoid
go version requirement change.

For #3815
For golang/go#70056
2024-10-29 12:12:42 -07:00
Alessandro Arzilli
2a9af735d0
_scripts: update staticcheck version (#3839)
Update version of staticcheck and reenable for go1.23
2024-10-23 12:40:35 -07:00
Alessandro Arzilli
05dc760877
*: mark riscv64 port as experimental (#3835)
Delete non-working prologue detection code and mark port as experimental.

Updates #3832
2024-10-14 11:04:03 -07:00
Alessandro Arzilli
4a5350fd1f
tests: disable TestGeneratedDoc on 1.24 (tip) (#3820)
The test is currently broken due to a change to the export format.
2024-10-01 11:00:52 -07:00
Nilesh Singh
8b878fb238
cmds/commands: Update 'client-addr' to support Unix domain sockets (#3819)
* cmds/commands: Update 'client-addr' to support Unix domain sockets

This change updates the '--client-addr' flag to accept Unix domain sockets (UDS). Currently, the --listen flag supports UDS, but --client-addr does not. This modification ensures consistency across the APIs and improves support for vscode-go, which uses reverse mode (via client-addr) to connect to DAP.

Fixes #3814

* Undo formatter changes in dlv_test.go

* Update commands.go
2024-09-30 11:20:48 -07:00
Alessandro Arzilli
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
Archana Ravindar
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
Fata Nugraha
15a9f9d353
cmd/dlv: print out message with stack trace when breakpoint is hit but has no waiting client (#3632)
* 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
2024-06-12 12:31:46 -07:00
Alessandro Arzilli
40670aadc2
proc/gdbserial: add environment variables to configure rr invocation (#3726)
Adds two environment variables to configure rr invocations.

Fixes #3670
2024-05-24 11:33:23 -07:00
Archana Ravindar
8c07c984e8
pkg/terminal: Add function name to return tracepoints (#3712) 2024-04-23 14:22:17 -07:00
Ville Skyttä
3f280259ad
cmd/dlv: improve positional argument completion (#3699)
Avoid default filename completions when not applicable.
2024-04-18 08:57:33 -07:00
Ville Skyttä
d7f104bf9c
cmd/dlv: fix panic on connect fail (#3698) 2024-04-11 07:12:42 +02:00
Ville Skyttä
2c946bcbd0
cmd/dlv: add shell (non-)completions to flags taking args (#3696)
Mostly to avoid the default filename completions to flags that don't
operate on filenames. Then again, mark ones that do explicitly as
such, and add more specific completions for a number of other cases,
too.
2024-04-09 11:04:55 -07: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
f32818c9e3
cmd/dlv: fix --continue with unix domain sockets (#3658)
Fixes #3657
2024-02-13 10:14:38 -08:00
Alessandro Arzilli
4f5b74a651
cmd/dlv: support unix domain sockets (#3655)
Add support for listening on a unix domain socket in headless mode and
in the 'connect' command.

Fixes #3654
2024-02-07 11:04:45 -08:00
Alessandro Arzilli
a8ee87e473
*: remove checks for TRAVIS env variable (#3568)
We had a few checks left over for the TRAVIS variable that detected if
we were running under the TravisCI build system.
This variable hasn't been set since 2020.
2023-11-16 10:42:41 -08:00
Oleksandr Redko
13d6cd4e0d
*: Correct spelling mistakes (#3555) 2023-11-06 07:55:44 -06:00
Derek Parker
ff7a9f9f9a
cmd: fix a bunch of linter warnings from GoLand (#3550) 2023-11-03 17:22:02 +01:00
Alessandro Arzilli
90a1571f88
CI: update staticcheck version (#3533)
Update staticcheck version and re-enable TestStaticcheck on Go 1.22.
2023-10-20 10:05:58 -07:00
Oleksandr Redko
899ba72505
all: replace deprecated io/ioutil with io and os (#3509) 2023-09-25 11:41:59 -07:00
Alessandro Arzilli
e0b4bfbed3
Various fixes for go 1.22 (#3455)
* proc: correctly update local variables after continue

At various point during the execution of the call injection protocol
the process is resumed and the call injection goroutine could migrate
to a different thread, we must make sure to update our local variables
correctly after every point where the target program is resumed.

'fncall122debug_clean' on 'f469a0a5'.

* go.mod: update golang.org/x/tools

Go 1.22 broke golang.org/x/tools/packages

* cmd/dlv: disable TestStaticcheck with go1.22

Go 1.22 is not yet supported by staticcheck.
2023-09-19 09:34:34 -07:00
Oleksandr Redko
2b9c3d5c04
proc,service: simplify tests with T.Setenv (#3503) 2023-09-19 09:29:47 -07:00
Oleksandr Redko
e404917db7
pkg,service: fix typos in comments, exceptions, tests (#3486) 2023-08-29 14:44:18 +02:00
Derek Parker
5f01e72bb8
cmd/dlv: handle ctrl-c during tracing (#3477)
Ensure we send a Halt command to stop the process being traced so that
the deferred Detach can run ensuring proper cleanup upon exit.

Fixes #3228
2023-08-23 07:45:44 +02:00
Derek Parker
f0b534ddcc
pkg/proc: add support for more types in ebpf tracing backend (#3474) 2023-08-18 19:56:44 +02:00
Alessandro Arzilli
caf6df0eb9
Documentation,cmd/dlv: clean up command line usage help (#3395)
Due to some very old mistakes too many of Delve's flags are declared as
persistent on cobra's root command. For example the headless flag is a
global flag but does not apply to connect, dap or trace; the backend
flag does not apply to replay, core and dap; etc.

Almost all global flags should have been declared as local flags on
individual subcommands. Unfortunately we can not change this without
breaking backwards compatibility, for example:

   dlv --headless debug

would not parse if headless was a flag of debug instead of a global
flag.

Instead we alter usage function and the markdown generation script to
strategically hide the flags that don't apply.

Fixes #2361
2023-08-09 10:37:55 -07:00
Alessandro Arzilli
dc5d8de320
proc: add waitfor option to attach (#3445)
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.
2023-08-09 10:30:22 -07:00
Álex Sáez
71f1220717
*: add ppc64le support (#2963)
* Add vendor/golang.org/x/arch/ppc64

* Add ppc64le support
2023-07-07 09:30:38 -07:00
ttoad
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
Alessandro Arzilli
d963eb1057
proc: read context from sigtrampgo, fixes TestCgoStacktrace2 on 1.21 (#3401)
* 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.
2023-06-27 09:33:07 -07:00
Derek Parker
1d28ceccdc
pkg/proc: fix ebpf probe tracing backen uprobe handling (#3417)
Uprobes get automatically cleaned and removed when the reference to
the Link object is lost. Hold a reference to any active Uprobe Link
for duration of Delve execution and ensure they are cleaned up
at exit.

Fixes ebpf probes don't work after time.Sleep() #3227
2023-06-15 12:07:32 +02:00
Derek Parker
ccf17a6f42
pkg/proc: enable basic debug functionality for stripped ELF binaries (#3408)
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...
2023-06-14 13:23:46 +02:00
nozzy123nozzy
8b9c3a93f5
cmd/commands: Fix to read debug info file from the correct directory when using trace command with -e option. (#3405) 2023-06-06 16:12:11 -07:00
Alessandro Arzilli
84b757ad57
cmd/dlv,service/dap: use randomized name as default output binary (#3366)
Using a fixed path as the default output binary means that executing
Delve twice in the same directory will cause the second invocation to
overwrite the output binary of the first instance of Delve, making the
restart command not work correctly.

Fixes #3345
2023-05-16 09:36:15 -07:00
Oleksandr Redko
1c9792bce4
cmd/dlv: logger is not closed in connect command (#3367) 2023-05-15 10:22:33 -07:00
罗泽轩
801a9109c7
trace: add timestamp to the output (#3358)
Fix #3356
2023-05-08 10:41:47 -07:00
Joseph Callen
c0b0148525
cmd/dlv: Add flag to replay for rr onprocess pid (#3281)
Add `-p` or `rr-onprocess-pid` to replay
command to pass `-p` or `--onprocess` pid
to `rr`.
2023-03-01 11:28:32 -08:00
Oleksandr Redko
372552bf1f
Documentation: fix typo and grammar issues (#3291) 2023-02-28 14:52:52 +01:00
Alessandro Arzilli
bc5c0d4a9b
_scripts: Update staticcheck (#3270) 2023-02-14 09:36:00 -08:00
Derek Parker
98f6d0b619
cmd/dlv: fix exit status for trace subcommand (#3263)
We currently return an error when the command exits because a process
exited error is always returned. Detect this like we do in other code
paths to return a 0 exit code instead of nonzero which indicates the
command itself failed and can confuse other tools.
2023-02-02 11:11:31 +01:00
Oleksandr Redko
64a9024735
cmd/dlv, pkg/proc: use T.TempDir in tests (#3256) 2023-01-30 15:04:55 -08:00
Derek Parker
a01fe73845
pkg/proc: do not check decl line for FunctionArguments (#3254)
Fixes a bug where we cannot get locals (including arguments and return
values) from a given scope because the line number state machine ends up
in an invalid state because of this parameter being set to false.
2023-01-24 15:56:05 +01:00
Alessandro Arzilli
4aaa184b31
cmd/dlv: match go test behavior when dlv test gets a list of .go files (#3232)
When 'dlv test' is called with a list of files it should match the
behavior of 'go test' and chdir to the directory where the go files are
(if they are all in the same directory).

Fixes #3230
2023-01-04 10:47:27 -08:00
Alessandro Arzilli
709da9a217
Documentation: document how to debug runtime with Delve (#3234)
Add FAQ entry to document how to debug the Go runtime using Delve.
Also add table of contents to FAQ.
2023-01-03 09:23:26 -08:00
Alessandro Arzilli
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