Commit Graph

2731 Commits

Author SHA1 Message Date
Suzy Mueller
b041bd8e98
service/dap: add the concrete type to interface type (#3510) 2023-10-03 08:51:46 -07:00
Oleksandr Redko
255afbfdb7
all: remove obsolete build tags "// +build" (#3513) 2023-10-03 08:50:11 -07:00
Derek Parker
2dba916a78
V1.21.1 (#3518)
Thank you to everyone who contributed to this release:

@alexsaezm, @pgavlin, @archanaravindar, @aarzilli, @hyangah, @thechampagne, @javierhonduco, @andreimatei, @gocurr, @alexandear, @stefanhaller.
2023-10-03 09:05:40 +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
XXIV
bb59e23f2e
fix memory leak (#3512) 2023-09-25 11:40:57 -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
Derek Parker
4d30cd461b
pkg/terminal: support more editors with edit command (#3506)
The current implementation assumes a specific command line interface
for opening an editor at a specific location within the source file.
This patch updates for different formats, namely the one used by the
editor 'hx'.
2023-09-20 09:25:48 +02: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
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
Hyang-Ah Hana Kim
30b70bc606
service/dap: accept a string list as launch request's buildFlags (#3496)
This change accepts both string type and []string. dap.BuildFlags
is a union of string and []string.

Fixes #2718
For golang/vscode-go#1831, golang/vscode-go#1027
2023-09-19 09:32:15 -07:00
Oleksandr Redko
ffd1c396c2
_scripts: remove unnecessary os.ExpandEnv (#3504) 2023-09-19 09:30:18 -07:00
Oleksandr Redko
2b9c3d5c04
proc,service: simplify tests with T.Setenv (#3503) 2023-09-19 09:29:47 -07:00
Hyang-Ah Hana Kim
e072a64903
pkg/terminal: add 'packages' command (#3499)
This command lists the packages included in the debugee.
The implementation utilizes "ListPackagesBuildInfo" RPC.

In order to support server-side filtering like `sources` and other
commands, expanded the ListPackagesBuildInfo RPC to take an optional
filter field.
2023-09-18 08:59:58 -07:00
Eng Zer Jun
382bb0fde6
pkg/proc/internal/ebpf: remove redundant nil check (#3502)
From the Go specification:

  "1. For a nil slice, the number of iterations is 0." [1]

Therefore, an additional nil check for before the loop is unnecessary.

[1]: https://go.dev/ref/spec#For_range

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2023-09-18 08:01:52 -07:00
Stefan Haller
c7097b8e1d
service/dap: strip package paths from symbols in callstack (#3500)
This solves the problem that function names with long package paths are hard to
read when the callstack window is narrow, because all you see is the beginning
of the package path.

For example, instead of

  github.com/some/long/package/path/pkg.(*SomeType).SomeMethod

we now display

  pkg.(*SomeType).SomeMethod
2023-09-16 06:06:28 +02: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
Alessandro Arzilli
f469a0a57a
go.mod: update version of github.com/cilium/ebpf (#3491)
Fixes #3490
2023-08-30 10:22:08 -07:00
Alessandro Arzilli
7fb9ddae4d
api,dap: fix hexadecimal printing of vars with symbolic const values (#3487)
Fix hexadecimal printing of variables that can be represented using
symbolic const values in DAP as well as the command line interface.

Fixes #3485
2023-08-29 09:24:10 -07:00
Oleksandr Redko
e404917db7
pkg,service: fix typos in comments, exceptions, tests (#3486) 2023-08-29 14:44:18 +02:00
Alessandro Arzilli
7f094c81e9
proc: refactorings to implement follow-exec mode on Windows (#3441)
Miscellaneous non-functional changes to prepare for adding support for
follow-exec mode on Windows:

- removed (*nativeProcess).wait function from Windows backend (unused).
- move close of ptraceDoneChan from release to handlePtraceFuncs, this
  makes postExit callable by a function executed by execPtraceFunc.
- change addTarget to detach before creating the target object if we
  don't actually want to attach to the child process, also moved the
  detach call to (*processGroup).add instead of having one in addTarget
  and one in the code that calls (*processGroup).add.
- changed Detach to be a method of TargetGroup/ProcessGroup, the
  Windows backend will need access to the process group to call
  WaitForDebugEvent.
- moved resume method to processGroup. First all threads stopped at a
  breakpoint need to be stepped, then all other threads can be resumed.
  This is true also for linux even though it didn't cause the current
  tests to fail.
2023-08-28 12:46:19 -07:00
Alessandro Arzilli
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
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
Javier Honduvilla Coto
908876d6aa
DWARF CFI: use a stack for restore/remember opcodes (#3480)
Implementing the `DW_CFA_remember_state` and `DW_CFA_restore_state`
according to the DWARF specification requires us to create a stack that
can store an arbitrary number of elements, that is, there could be
multiple "pushes" before "popping" them.

From the 5th revision of the spec [0]:

> 6.4.2.4 Row State Instructions
> DW_CFA_remember_state
> 	The DW_CFA_remember_state instruction takes no operands. The required
>	action is to push the set of rules for every register onto an implicit stack.
>	DW_CFA_restore_state
> DW_CFA_restore_state
>	The DW_CFA_restore_state instruction takes no operands. The required action
>	is to pop the set of rules off the implicit stack and place them in the
>	current row.

- [0]: https://dwarfstd.org/doc/DWARF5.pdf

Signed-off-by: Francisco Javier Honduvilla Coto <javierhonduco@gmail.com>
2023-08-23 12:56:58 -07:00
Alessandro Arzilli
789f8b4054
proc: remove unused functions (#3479) 2023-08-23 09:49:54 -07: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
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
Derek Parker
f0b534ddcc
pkg/proc: add support for more types in ebpf tracing backend (#3474) 2023-08-18 19:56:44 +02:00
Oleksandr Redko
8aa0050158
pkg,service: make receiver names consistent (#3473) 2023-08-17 14:24:43 -07:00
Alessandro Arzilli
53688a102f
goversion: parse new version format and simplify version representation (#3470)
Add parsing for the new version format with toolchain (X.Y.Z-something)
and simplify internal representation of versions so that revision, beta
version and rc version are all represented on a single field with rc
and beta versions being negative numbers (this limits rc versions to a
maximum of 1000 which will not be a problem in practice).
2023-08-16 09:55:02 -07:00
Ccheers
b07ef66fe4
Update target.go (#3471)
fix(proc): fix nil pointer panic
2023-08-16 15:17:03 +02:00
Derek Parker
1ec7320b1c
*: remove deepsource.toml (#3468)
We don't use deepsource anymore so this is just leftover configuration.
2023-08-15 07:01:30 +02:00
Alessandro Arzilli
e56490e78f
gobuild: pass user specified -C argument first (#3456)
The -C argument must come first on the command line of 'go build' if
the flags specified by the user via  build-flags start with -C pass it
first.

Replaces #3380
2023-08-14 15:37:57 -07:00
Alessandro Arzilli
4ce596b9dd
locspec: fix SubstitutePath when converting a Windows path to Linux (#3453)
Normalize separators when converting a Windows path into a Linux path.

Fixes #3447
2023-08-14 15:34:29 -07:00
Alessandro Arzilli
281f3920dd
proc: fix stacktraces on freebsd/amd64/go1.20 (#3458)
TestStacktraceGoroutine failed intermittently on freebsd/amd64/go1.20.

This happens because of two windows, in the scheduler (right after
parking a goroutine and just before resuming a parked goroutine) where
a thread is associated with a goroutine but running in the system stack
and there is no systemstack_switch frame to connect the two stacks.
2023-08-14 15:32:15 -07:00
Alessandro Arzilli
ec07c27fc7
proc: fix PIE support on macOS (#3467)
Go1.22 switched to emitting PIE by default and also changed some
details of the PIE implementation. This breaks delve entirely on macOS.

Fix how relocations are handled on macOS.
2023-08-14 15:31:05 -07:00
Alessandro Arzilli
894ba63400
teamcity: hold back linux/386 builds to 1.20 (#3465)
Programs built with `-gcflags='all=-N -l'` do not work on
linux/386/1.21 due to https://github.com/golang/go/issues/61975
2023-08-14 11:07:57 -07:00
gocurr
17d1f4c829
service/dap: use == to test io.EOF (#3464)
The documentation of io.EOF: Read must return EOF itself, not an error
wrapping EOF, because callers will test for EOF using ==.

This is a trivial change; people may think it's normal use of "errors.Is",
even it's OK, it could be replaced with "errors.Is(err, io.EOF)" in idiomatic way.
2023-08-12 09:41:30 +02:00
Alessandro Arzilli
891a1f080d
goversion,teamcity: update test matrix and fix build scripts (#3463)
Update test matrix to remove 1.18 and add 1.21, fix build scripts to
deal with the new format returned by:
	https://golang.org/VERSION?m=text
which now has an extra second line with the time.
2023-08-11 08:52:35 -07:00
Derek Parker
e49c81cc5d
*: Fix ppc64le test runs (#3460)
We must pass the build tag through during the 'vet' check, and
additionally there was some extra commands at the end of test_linux.sh
that were not necessary.
2023-08-11 08:51:28 -07: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
Alessandro Arzilli
2b785f293b
logflags: simplify Logger interface (#3274)
Remove methods we never used or used only very sparingly (Print) and we
probably shouldn't be using at all (Fatal).
2023-08-07 13:55:45 -07:00
Andrei Matei
ae67a45a1c
starbind: fix Starlark slice unmarshaling (#3454)
The unmarshaling code for slices wasn't actually setting the
destination. This patch fixes it.
2023-08-07 12:11:05 -07:00
gocurr
b5c9edccff
pkg/terminal: use reflect.Value.IsValid to check a zero Value (#3450)
I searched the source code of Go, and found no usages of
"== (reflect.Value{})" and "!= (reflect.Value{})". I think
it's more idiomatic to use "IsValid" to check a zero Value.
2023-08-01 08:35:59 -07:00
Alessandro Arzilli
7db57df266
proc: replace use of runtime.GOARCH with Arch.Name (#3442) 2023-07-26 08:33:31 -07:00
Alessandro Arzilli
34104fb65d
proc,ebpf: mark as unreadable args with unsupported types with ebpf (#3444)
Only a few types can be read with ebpf, mark everything else as
unreadable so that there are no downstream crashes.

Fixes #3443
2023-07-25 16:27:37 -07:00
Alessandro Arzilli
a53f1bf45d
service/api: in multiline mode print address of pointers (#3448)
When printing a pointer variable first print the address that it points
to before printing its dereferenced value.

Fixes #3446
2023-07-25 16:27:00 -07:00
Alessandro Arzilli
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