Commit Graph

311 Commits

Author SHA1 Message Date
Alessandro Arzilli
abad6bb97e
proc: use .closureptr for stepping through range-over-func statements (#3763)
* proc: use .closureptr for stepping through range-over-func statements

Uses special variables .closureptr and #yieldN to correctly identify
the parent frame of a range-over-func body closure call.

Updates #3733

* fix
2024-07-11 10:26:38 -07:00
Oleksandr Redko
b791f91c0e
pkg/dwarf/line: use t.Logf instead of fmt.Printf in tests (#3772) 2024-07-11 10:19:09 -07:00
Oleksandr Redko
7a801c440b
*: remove redundant lines at the start/end of block (#3773) 2024-07-11 13:54:55 +02:00
Alessandro Arzilli
608eaa3d7c
proc: support stepping through range-over-func statements with inlining (#3755)
Extends support for stepping through range-over-func statement to
programs compiled with inlining enabled.

Updates #3733
2024-07-01 11:22:59 -07:00
Alessandro Arzilli
ed2960b01c
proc: initial support for expressions with range-over-func (#3750)
Supports viewing local variables and evaluating expressions correctly
when range-over-func is used.
The same limitations that the previous commit on this line had still
apply (no inlining, wrong way to identify the range parent in some
cases).

Updates #3733
2024-06-24 13:04:06 -07:00
Oleksandr Redko
0d0d2e1b16
*: replace fmt.Errorf with errors.New (#3752) 2024-06-20 21:50:18 +02:00
Alessandro Arzilli
4b628b81cb
proc: refactor identifier evaluation for range-over-func support (#3738)
Because of how range-over-func is implemented it is difficult to
determine the set of visible local variables during expression
compilation (i.e. it is difficulto to keep the HasLocal function
correct).
This commit moves that logic from expression compilation to expression
evaluation.

Updates #3733
2024-06-14 14:36:11 -07:00
Alessandro Arzilli
cce54c0992
proc: fix TestRangeOverFuncNext (#3740)
Fix TestRangeOverFuncNext on non-linux operating systems, on arm64 and
when the build mode is PIE.
2024-06-14 14:32:34 -07:00
Alessandro Arzilli
06053a7e4b
proc: fix bug with stack watchpoints going out of scope (#3742)
When stack watchpoints go out of scope simultaneously they can hide (or
duplicate the effect) of other breakpoints (including other watchpoints
going out of scope) that are placed on the same physical memory
location.

This happens because we delete the watchpoint-out-of-scope breakpoint
while we are evaluating hit breakpoints, mangling the breaklets list.

This commit moves breakpoint deletion out of the
watchpoint-out-of-scope condition, delaying it until all hit
breakpoints have been evaluated.

Also fix bug where on amd64 if all four watchpoints are in use the last
one is not checked.

Fixes #3739
2024-06-12 12:37:04 -07:00
Alessandro Arzilli
2ec2e831d6
proc: initial stepping with range-over-func support (#3736)
Initial support for stepping in functions that use the new
range-over-func statement in go1.23.
Does not support:

- inlining
- viewing variables of the enclosing function from a range-over-func
  body closure
- the correct way to find the enclosing function from a range-over-func
  body closure (but it should work most of the time).

Updates #3733
2024-06-04 12:52:30 -07:00
Oleksandr Redko
8347f97c00
*: remove redundant lines at the start/end of block (#3730) 2024-05-20 14:16:22 -07:00
Derek Parker
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
Alessandro Arzilli
fb430eac5e
proc: change 'step' command so that it steps through go statements (#3686)
Change 'step' command so that when stepping into a 'go statement' the
debugger will stop on the newly created goroutine, instead of just
stepping over the go statement.
2024-04-09 15:53:23 +02:00
Alessandro Arzilli
bbcea6b9f4
proc: support reading captured variables of closures (#3682)
Supports showing captured variables for function closures on versions
of Go that export informations about the closure struct (Go >= 1.23)

Fixes #3612
2024-04-07 21:36:50 -07:00
Derek Parker
6f1f549c71
pkg/proc: defend better against missing DWARF (#3695)
The `scope.Locals` function did not have any guard checks against missing DWARF information.
This patch adds a check, which likely will need to be added to other functions as well.
2024-04-05 11:46:39 +02: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
Derek Parker
4a72c523be
pkg/proc: remove usage of gore dependency (#3664) 2024-02-21 12:10:41 +01:00
Alessandro Arzilli
0d35295491
proc: skip TestDebugStripped on development versions of Go (#3642)
The test can never work on development versions of Go.
2024-01-24 09:18:51 -08:00
Alessandro Arzilli
4ed69d0280
proc: fix stacktrace frame after runtime.sigpanic (#3638)
The first frame after sigpanic didn't execute a call so we shouldn't
decrement the PC address to look up its location.

Fixes #3634
2024-01-17 16:31:04 -08:00
Alessandro Arzilli
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
Derek Parker
050a108c3c
*: Update gore dep for 1.22 (#3611) 2023-12-27 18:28:56 +01:00
Alessandro Arzilli
c4a10ecb16
tests: fix tests in go1.22 (#3583)
Go1.22 has changed some line number assignments. The new line number
assignments are still valid however some tests in dap relied on them
being different and broke as a result. This commit fixes those tests
and makes them less brittle.
Also disables TestDebugStripped and TestDebugStripped2 temporarily on
1.22.
2023-11-27 14:59:55 -08:00
Alessandro Arzilli
4ed41e9060
proc: fix TestIssue1101 flake (#3585)
If the target process exits and receives a signal at the same time and
we receive the signal first we should call waitpid again to read the
target's exit status.

This also fixes a nil pointer dereference when trapWaitInternal returns
an error, this fix is probably incomplete but I wasn't able to
reproduce its circumstances after 30000 runs of TestIssue1101 to
properly address it.
2023-11-27 08:58:27 -08:00
Derek Parker
6e8e1cee9b
pkg/proc: use gore to obtain info from stripped binaries (#3577)
This patch switches from using a forked version of one of the libraries
of goretk/gore to using the module directly. This is possible now that
certain functionality has been exposed / fixed within that module making
it usable for Delve.
2023-11-23 09:12:10 +01: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
Derek Parker
0466226b1d
pkg/proc: unskip passing tests and reorganize (#3561) 2023-11-12 12:01:21 +01:00
Derek Parker
d186e14fd9
pkg/proc: improve support unwinding from sigpanic (#3559)
See: https://github.com/golang/go/issues/63862

Fixes #3545
2023-11-10 15:32:20 +01:00
Alessandro Arzilli
438d036fed
TeamCity: reupgrade linux/386 builder to Go 1.21 (#3560)
The bug that prevented updating to linux/386 has been fixed upstream,
update linux/386 to 1.21 in the test matrix and fix some broken bugs.
2023-11-09 17:38:37 -06:00
Oleksandr Redko
13d6cd4e0d
*: Correct spelling mistakes (#3555) 2023-11-06 07:55:44 -06:00
Derek Parker
6c77c35586
pkg/proc: add inline function support for stripped binaries (#3549)
This patch adds support for listing and setting breakpoints on inlined functions within stripped binaries. It uses a forked version of `debug/gosym` copied from golang.org/x/vuln/internal/vulncheck/internal/gosym which adds support for parsing the inline tree of the pclntab section. Parsing this section requires knowing the offset of the "go:func.*" symbol, which is not present in stripped binaries via the ``.symtab` section so instead, we search the `.noptrdata` section which contains `runtime.moduledatap` which contains the value of that missing symbol, which we then can use to find the inline tree for a given function.

Given all this we parse the inline tree for each function we find, and then add that information the the appropriate `Function` contained in `bi.Functions`, using a relatively empty `Function` struct as what would be the abstract origin.
2023-11-03 10:00:49 +01:00
Alessandro Arzilli
2187c75fb5
proc,service/dap,proc/gdbserial: fixes for debugserver --unmask-signals (#3541)
- fix TestRefreshCurThreadSelGAfterContinueOnceError and TestBadAccess
  to work when debugserver has --unmask-signals
- when a fatal signal is received while singlestepping delay its
  delivery until the subsequent continue, otherwise debugserver will get
  stuck completely (fixes TestNilPtrDerefInBreakInstr)
2023-10-30 09:19:23 -07:00
Derek Parker
1e2338d233
proc: allow evaluator to reference previous frames (#3534)
Fixes #3515
2023-10-24 18:57:39 +02:00
Alessandro Arzilli
788df884e6
proc: use DW_AT_trampoline to detect auto-generated code (#3528)
Use the trampoline attribute to detect auto-generated code. This fixes
a bug where stepping into a method of a generic type called through an
interface will take the debugger into an auto-generated wrapper that
does not have a dictionary and using next will step out of the wrapper.

Fixes a bug reported on the #delve channel of the gophers slack server.
2023-10-16 08:57:33 -07:00
Alessandro Arzilli
20350611ce
proc: implement follow exec mode on Windows (#3507) 2023-10-13 16:51:11 +02:00
Oleksandr Redko
899ba72505
all: replace deprecated io/ioutil with io and os (#3509) 2023-09-25 11:41:59 -07:00
Pat Gavlin
224a2805a4
pkg/proc: macho: Enable debugging stripped binaries (#3511)
Load a symbol table from pclntab as when debugging stripped ELF
binaries.
2023-09-25 11:41:34 -07:00
Archana Ravindar
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
Alessandro Arzilli
db7e60aef3
proc: move StepInstruction method to TargetGroup (#3488)
Move StepInstruction method to TargetGroup since it will need access to
the process group on Windows to call WaitForDebugEvent.
2023-09-20 09:17:45 +02:00
Oleksandr Redko
2b9c3d5c04
proc,service: simplify tests with T.Setenv (#3503) 2023-09-19 09:29:47 -07:00
Archana Ravindar
86020cdd7a
pkg/proc: Fix PIE tests on ppc64le port (#3498)
* Fix PIE tests on ppc64le port

* formatted ppc64le_disasm.go as part of fixing PIE tests for ppc64le port
2023-09-14 10:08:29 -07:00
Oleksandr Redko
e404917db7
pkg,service: fix typos in comments, exceptions, tests (#3486) 2023-08-29 14:44:18 +02:00
Alessandro Arzilli
80e6c28ab2
proc: disable "wait-for" tests on freebsd (#3482)
They are flaky in CI, I can not reproduce the problem locally.
2023-08-23 12:57:34 -07:00
Alessandro Arzilli
32b937c953
teamcity: misc changes to CI (#3476)
- add architecture rule for ppc64le so that incompatible agents don't
  pick up the build
- disable PIE tests on linux/ppc64le (the tests claim it doesn't work)
- enable PIE tests on darwin/amd64 now that the entry point calculation
  has been fixed
- remove dependency on wget and curl in the test script for linux to
  reduce test time
- only install git in the linux test script when we need it
- remove staticcheck from linux/ppc64le builds (it takes almost 5
  minutes between installation and execution and makes the test timeout
  sometimes)
- drop windows/arm64/tip build, the windows/arm64 build is broken
  anyway and since there is only one agent it makes CI runs slow
- drop linux/ppc64le/tip build, there is only one agent, it's slow and
  it will always timeout. CI runs in excess of 1h are too long.
2023-08-22 09:24:25 -07:00
Alessandro Arzilli
6a0423a1e9
proc: when stepping set condition on thread ID if there is no curg (#3475)
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
2023-08-21 12:30:56 -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
gocurr
80840dd2bf
all: fix typos (#3434) 2023-07-06 11:16:06 +02: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
Alessandro Arzilli
afef1aec60
proc: skip TestDebugStripped on linux/386/pie (#3427)
PIEs do not have a .data.rel.ro.gopclntab section on linux/386. Disable
the test.
2023-06-20 09:55:30 -07:00