Commit Graph

2297 Commits

Author SHA1 Message Date
Alessandro Arzilli
97a7455192
_scripts: fix CI on go1.19/linux/386 (#3100)
Go 1.19 is broken on linux/386 with some C compilers, this is a
workaround for our build script. See:

https://github.com/golang/go/issues/52919

Also fix TestBuild if the first message reported by delve is not the
message that indicates the server is listening.
2022-08-15 09:40:25 -07:00
Ruijie Chen
20df19e33b
service/dap: Add support for empty string in substitutePath (#3088)
This changes adds the support to replace relative paths sources with "" as rapresenting current directory.
For example:
Rule like '{from: "", to: "/my/project"}' will map path "src/my/code.go" into "/my/project/src/my/code.go"
Rule like '{from: "/my/project", to: ""}' will map path "/my/project/src/my/code.go" into "src/my/code.go"

Fixes #3082
2022-08-14 16:01:39 +02:00
Alessandro Arzilli
f82d225bdb
proc: fuse evalToplevelTypeCast and evalTypeCast (#3057)
We allowed integer and pointer type casts everywhere but type casts to
string, []byte and []rune only at toplevel.
Fuse evalToplevelTypeCast and evalTypeCast and allow both kinds
everywhere. There are multiple other ways to create variables than
don't reference user memory anyway (which wasn't the case back when
evalToplevelTypeCast was implemented).

Fixes #1423
2022-08-11 13:13:55 +02:00
Derek Parker
db9770fe9d
_scripts: fix command to download Go version (#3099)
We should exclude rc/beta versions as we already run tests
against tip, we don't explicitly test RC versions.
2022-08-09 20:06:42 +02:00
Alessandro Arzilli
65cfd25787
service/debugger: refactor state/collectBreakpointInfo for TargetGroup (#3064)
Change service/debugger.(*Debugger).state and collectBreakpointInfo
methods so that they work with TargetGroup.

Updates #2551

when running custom builds
abstraction
on '5660f9a4'.
2022-08-09 10:03:45 -07:00
Alessandro Arzilli
3de29a88f8
proc: do not panic reading bad G struct (#3098)
Fixes #3095
2022-08-09 10:02:55 -07:00
Alessandro Arzilli
65d5eb7380
TeamCity,goversion: bump test matrix (#3092)
Add Go 1.19 to test matrix, drop 1.16.
2022-08-05 12:04:26 -07:00
Derek Parker
b83ea0c2fa
pkg/dwarf/line: Fix parsing file table for DWARFv5 (#3090)
As we parse this informatin in the loop we must take care to assemble
things correctly. In this situation when we encounter a file name,
the dir index is -1, then subsequently we get the correct dir index
for that file and can put them together. Previously we were adding the
file and then the directory location to the file list instead of
correctly concatenating them, resulting in an incorrect file list making
indexing into the list return incorrect results later on.
2022-08-05 19:16:38 +02:00
Derek Parker
be08778975
:* Improve trace subcommand output (#3091)
This patch improves the output of the trace subcommand by
adding better line breaks, adding goroutine info to the
return statement, and removing unnecessary output.
2022-08-04 10:10:54 +02:00
Alessandro Arzilli
d17c5e155a
Documentation: fix documentation of examinemem (#3087)
The 'addr' option was removed during review and doesn't exist.

Fixes #3086
2022-08-01 09:03:48 -07:00
Quim Muntal
ae55d84279
fix StepInstruction on 1 byte instruction with a software breackpoint (#3084) 2022-08-01 09:03:19 -07:00
Derek Parker
5c5fca4849
pkg/proc/internal/ebpf: Fix handling of entry / return (#3081)
This patch removes the old error-prone way of tracking
whether the tracepoint is for a function entry or
return. Instead of trying to guess, let the data structure
simply tell us directly.
2022-07-29 12:00:32 +02:00
Suzy Mueller
5170a6e0ff
service/dap: fix indexing bug for maps (#3068)
service/dap: fix indexing bug for maps

There was a bug that cut off the second half of a map, because the
number of variables was not accurately reported to the client.

Fixes golang/vscode-go#2351
2022-07-29 11:58:46 +02:00
Derek Parker
36b35aad00
pkg/proc/internal/ebpf: Fix size of ebpf type for fn_addr (#3080)
Must have been an issue overlooked in the initial implementation but
we should be using a 64-bit wide type to store the function address.
2022-07-28 11:30:08 +02:00
Quim Muntal
6ad3169719
proc/native: refactor windows framework (#3079) 2022-07-27 18:36:34 +02:00
roketyyang
ec1d1efb7f
terminal/command: 'goroutines' command add new flags '-exec command' (#3044)
* terminal/command: 'goroutines' command add new flags '-exec command'

Support run command on every goroutine.

Fixes #3043

* terminal/command: 'goroutines' command add new flags '-exec command'

Support run command on every goroutine.

Fixes #3043

* terminal/command: add -per-g-hitcount option to condition command

Support use per goroutine hitcount as hintcond operand.

Fixes #3050

Co-authored-by: roketyyang <roketyyang@tencent.com>
2022-07-25 10:14:43 -07:00
Alessandro Arzilli
2900418e78
proc: support gnu_debuglink section (#3073)
Load separate debug info using gnu_debuglink.

Fixes #2150
2022-07-25 10:01:41 -07:00
André Eriksson
e72d9b3372
pkg/locspec: support exact match in SubstitutePath (#3075)
In order to support substituting a single file within
a larger package, and not substituting a directory wholesale,
this commit introduces the ability for SubstitutePath
to replace individual file paths if there is an exact match.

This behavior is backwards-compatible with the previous
configuration.

Fixes #3074
2022-07-25 09:57:31 -07:00
Alessandro Arzilli
5452c30fac
proc/internal/ebpf: drop dependency on cgo (#3072)
The ebpf implementations uses cgo, but only to access some C struct
definitions. Instead of using cgo simply duplicate the defintion of
those two structs in Go and add a test to check that the duplicate
definitions remain synchronized.

Fixes #2827
2022-07-22 19:39:18 +02:00
Alessandro Arzilli
6ef5284505
cmd/dlv,proc: misc improvements to trace subcommand (#3069)
1. return an error when SetUProbe fails, while creating ebpf tracepoints
2. if no tracepoint can be set for 'dlv trace' exit early
3. never leave the traced program running
4. fix typo in description of --ebpf flag

Fixes #3006
2022-07-22 08:57:57 -07:00
Alessandro Arzilli
5660f9a415
dwarf/op,proc: output register name when printing location exprs (#3052)
Output the architecture specific register name when printing location
expression after DW_OP_regN and DW_OP_bregN operators.
2022-07-15 14:56:00 +02:00
Alessandro Arzilli
059406e74f
service/dap: limit disassembly range (#3045)
Due to dyanmically loaded libraries there could be aribitrarily large
gaps in the address space, between functions. Limit the memory size we
are willing to disassemble.

Fixes #3040
2022-07-15 13:29:44 +02:00
Alessandro Arzilli
6f34add5db
proc,service/debugger: introduce TargetGroup abstraction (#3030)
Introduces a new TargetGroup abstraction that can be used to manage
multiple related targets.
No actual management of child processes is implemented here, this is
just a refactoring to make it possible to do that in the future.

Updates #2551
2022-07-14 14:14:45 -07:00
Alessandro Arzilli
1fe03e728c
terminal: add ability to show disassembly instead of source (#3047)
Adds ability to show current position as disassembly instead of source
listing every time execution stops. Change default to show disassembly
after step-instruction and source listing in every other case.

Fixes #2878
2022-07-14 14:08:47 -07:00
roketyyang
278e4d10c8
terminal/command: add -per-g-hitcount option to condition command (#3055)
Support use per goroutine hitcount as hintcond operand.

Fixes #3050

Co-authored-by: roketyyang <roketyyang@tencent.com>
2022-07-12 10:31:34 +02:00
Alessandro Arzilli
6aa54c5c9f
_scripts: un-pin mingw version (#3046)
The version of mingw was pinned to 10.2.0 because mingw 11 started
using DWARFv5, which wasn't supported by Go 1.17. We are now testing
only 1.18 and 1.19 and both support DWARFv5 correctly.
2022-07-11 14:48:51 -07:00
Alessandro Arzilli
3fb2d49829
*: Bump version to 1.9.0 (#3054)
Update CHANGELOG and add Go1.19 to supported versions.
Thank you @4a6f656c, @pippolo84 and @polinasok.
2022-07-06 19:18:27 +02:00
Alessandro Arzilli
0764cc3aa0
vendor: update version of go/packages to 0.1.11 (#3053)
The current version we use now crashes with go1.19:

https://github.com/golang/go/issues/45584
2022-07-05 10:04:48 -07:00
Alessandro Arzilli
ff3370e676
proc: fix arm64SwitchStack for go1.19 (#3038)
In commit eee6f9f82 Go changed the order that crosscall2 uses to save
its registers, update arm64SwitchStack to use the new order when the
binary was compiled by go 1.19.

Fixes #2993
2022-06-24 06:49:43 -07:00
Alessandro Arzilli
2d09ea65bc
dwarf/frame: discard indirect flag reading personality func in eh_frame (#3032)
We don't do anything with the personality function so there is no point
in complaining that we don't fully support the pointer encoding flags
used to describe it.

This matches the current level of support of pointer encodings in gdb
(they are discarded when reading the personality function and not
supported for FDEs because gcc doesn't generate them).

Fixes #3015
2022-06-24 06:49:18 -07:00
Alessandro Arzilli
76ecc53293
proc/native: fix Ctrl-C handling on non-headless instances on windows (#3039)
In non-headless instances Ctrl-C should pause the process, not
terminate it. To make this work on Windows we have to pass the
syscall.CREATE_NEW_PROCESS_GROUP flag to os.StartProcess.
2022-06-24 06:48:42 -07:00
Alessandro Arzilli
db3e5ef2cd
proc: map access with string literal key should always succeed (#3036)
When doing a map lookup with a string literal we should load as much of
the keys to at least match the length of the string literal, so that
the lookup doesn't fail with the "string too long" error.

Fixes #3034
2022-06-24 06:48:16 -07:00
zhsj
a501814a99
testcase: remove accidental debug binary (#3035) 2022-06-19 17:28:26 +02:00
Alessandro Arzilli
c412dcdc4f
*: run go1.19 'go fmt' on everything and fix problems (#3031)
Go 1.19 also formats doc comments according to the new godoc syntax.
Some of our comments, especially unexported symbols did not conform to
the godoc syntax and therefore are mangled by 'go fmt'.

This PR runs 'go fmt' from go1.19 on everything and manually fixes the
problems.

See also:
	https://github.com/golang/proposal/blob/master/design/51082-godocfmt.md
2022-06-17 10:08:11 -07:00
Alessandro Arzilli
2827145f1e
proc/gdbserver: ignore spurious stop packet from debugserver (#3021)
When we send an interrupt request to debugserver we, sometimes, get one
extra spurious stop packet back.
This stop packet gets interpreted as a response to a qThreadStopInfo request
we make causing the protocol to become desynchronized for a while, until
eventually some kind of error appears.

Here's an example of this problem, distilled from issue #3013:

     1 <- $vCont;c#a8
     2 <- interrupt
     3 -> $T05thread:12efb47;threads:12efb47,12efb8d,12efb8e,12efb8f,12efb90,12efb91;thread-pcs:10abe83,7ff81b20e2be,7ff81b20e3ea,...
     4 <- $qThreadStopInfo12efb8e#28
     5 -> $T05thread:12efb47;threads:12efb47,12efb8d,12efb8e,12efb8f,12efb90,12efb91;thread-pcs:10abe83,7ff81b20e2be,7ff81b20e3ea,...
     6 <- $qThreadStopInfo12efb8f#29
     7 -> $T00thread:12efb8e;threads:12efb47,12efb8d,12efb8e,12efb8f,12efb90,12efb91;thread-pcs:10abe83,7ff81b20e2be,7ff81b20e3ea,...
     8 <- $qThreadStopInfo12efb90#f4
     9 -> $T00thread:12efb8f;threads:12efb47,12efb8d,12efb8e,12efb8f,12efb90,12efb91;thread-pcs:10abe83,7ff81b20e2be,7ff81b20e3ea,...
    10 <- $qThreadStopInfo12efb91#f5
    11 -> $T00thread:12efb90;threads:12efb47,12efb8d,12efb8e,12efb8f,12efb90,12efb91;thread-pcs:10abe83,7ff81b20e2be,7ff81b20e3ea,...
    12 <- $qThreadStopInfo12efb47#f6
    13 -> $T00thread:12efb91;threads:12efb47,12efb8d,12efb8e,12efb8f,12efb90,12efb91;thread-pcs:10abe83,7ff81b20e2be,7ff81b20e3ea,...
    14 <- $qThreadStopInfo12efb8d#27
    15 -> $T05thread:12efb47;threads:12efb47,12efb8d,12efb8e,12efb8f,12efb90,12efb91;thread-pcs:10abe83,7ff81b20e2be,7ff81b20e3ea,...
    16 <- $p0;thread:12efb8e;#f5
    17 -> $T00thread:12efb8d;threads:12efb47,12efb8d,12efb8e,12efb8f,12efb90,12efb91;thread-pcs:10abe83,7ff81b20e2be,7ff81b20e3ea,...

response (3) is interpreted as the response to the vCont request at (1). We
then make a qThreadStopInfo request (4) and receive a stop packet in
response (5). Packet (5) is interpreted as the response to (4) but it
actually isn't, note how the thread ID is different, packet (5) is actually
a spurious stop packet sent by debug server. From response (5) onward the
protocol is desynchronized, none of the response we process are actually the
response to the preceding request.
This eventually causes a failure at packet (17) which debugserver sent as
the response to request (14) but we interpret as the response to (16).

Fixes #3013
2022-06-08 10:56:50 -07:00
Alessandro Arzilli
ac8720eb6e
service/test,proc: move variable evaluation test to pkg/proc (#3024)
Moves variable evaluation tests to pkg/proc which is where most of the
code they test exists, this also allows the removal of a bunch of
duplicate support code.
2022-06-08 08:59:42 -07:00
Alessandro Arzilli
ac81269eef
proc: fix prettyprint for register components with large values (#3022)
Fix pretty printing for CPU register components (created with the
XMM0.uintN syntax) while using format strings
Also fixes printing large literal constants with format strings.

Fixes #3020
2022-06-02 10:16:32 -07:00
Hyang-Ah Hana Kim
d05e88cca2
go.mod: use pseudo verion for github.com/go-delve/liner (#3026)
Fixes #3025
2022-06-02 17:56:28 +02:00
Joel Sing
9c5777e762
pkg/proc: fix and improve freebsd register handling (#3019)
* pkg/proc: convert freebsd ptrace code to cgo

There is little point in having cgo call a custom C function, when the same
can be done directly from cgo (with less code and effort). Split the amd64
specific code into ptrace_freebsd_amd64.go. Also avoid mixing C.ptrace()
with syscall.SYS_PTRACE.

This will make further changes easier - no functional change intended.

* pkg/proc: check return values of ptrace calls on freebsd

The return values of the PT_GETNUMLWPS and PT_GETLWPLIST ptrace calls were
previously unchecked. While these should not fail, panic instead of using
-1 with slice allocation/handling.

* pkg/proc: return *amd64util.AMD64Xstate from freebsd ptraceGetRegset

Return a pointer to a struct, rather than a struct - this simplifies the
code in both the caller and the ptraceGetRegset function, while also avoiding
struct copying.

* pkg/proc: fix floating point register setting on freebsd

The original code could never work - PT_SETREGS on freebsd does not
take an iovec, nor does it set FP registers. Furthermore, the xsave
bytes were not stored in the amd64util.AMD64Xstate struct.

Updates #3001

* pkg/proc: re-enable function call injection on freebsd

Floating point registers can now be set and restored correctly.

This is a partial revert of 51090f003bace1f8cc37b8480ffdb6f6cc91fa5a.

Fixes #3001

* pkg/proc: deduplicate register setting code on freebsd
2022-05-31 16:04:36 -07:00
Alessandro Arzilli
5b88e45ca9
proc/native: fix Windows build (#3023)
Commit b53fcbe broke the build on Windows, we didn't notice because 2d9a9d broke the test script.
2022-05-31 16:03:57 -07:00
Alessandro Arzilli
78471b3a5a
proc,service: represent logical breakpoints explicitly (#2946)
Adds a LogicalBreakpoint type to represent logical breakpoints
explicitly. Until now logical breakpoints were constructed implicitly
by grouping physical breakpoints together by their LogicalID.

Having logical breakpoints represented explicitly allows for a simpler
implementation of disabled breakpoints, as well as allowing a simple
implementation of delayed breakpoints (#1653, #2551) and in general of
breakpoints spanning multiple processes if we implement debugging
process trees (#2551).

Updates #1653
Updates #2551
2022-05-25 13:58:26 -07:00
polinasok
5bc8460328
dap: add MultiClientCloseServerMock and fix test shutdown leak (#3011)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2022-05-18 10:33:06 -07:00
Fabio Falzoi
928e34d50f
pkg/terminal: Add auto-complete for local variables (#3004)
* pkg/terminal: fix typo in loadConfig comment

* pkg/terminal: add auto-complete for local variables

Fixes #2944

* pkg/terminal: use an empty config to load local vars

* pkg/terminal: cache loaded local vars until next command

* pkg/terminal: lazy loading of local vars trie
2022-05-18 09:18:28 -07:00
Alessandro Arzilli
c31040ba9e
proc: fix fatal throw breakpoint on go1.19 (#3009)
Also set breakpoint on runtime.fatal, which didn't exist before go1.19.

Updates #2993
2022-05-18 09:16:26 -07:00
polinasok
705ab206cd
dap: remote attach must not use terminateDebuggee in single-client launch mode (#2995) 2022-05-18 12:23:47 +02:00
Alessandro Arzilli
32bdd19f8f
proc/gdbserver: fix function call injection on rr (#3007)
Issue https://github.com/rr-debugger/rr/issues/3208 was fixed so finish
fixing call injection on rr and remove the test exception.
2022-05-17 09:19:34 -07:00
Alessandro Arzilli
b53fcbe43a
proc: fix RFLAGS corruption after call injection on amd64 (#3002)
debugCallV2 for amd64 has a bug where it corrupts the flags registers
every time it is called, this commit works around that problem by
restoring flags one extra time to its original value after stepping out
of debugCallV2.

Fixes #2985
2022-05-05 08:41:40 -07:00
Alessandro Arzilli
51090f003b
proc: fixes concerning call injection on freebsd and rr (#3000)
* Upgrade FreeBSD version

* proc: fixes concerning call injection on freebsd and rr

On FreeBSD it seems we have problems restoring and setting floating
point registers, since at least restoring is necessary for call
injection to function properly fully disable call injection on FreeBSD.

On rr the same problem exists, however due to the fact that we are
acting on a recording and ending a diversion will restore register
values anyway simply disable the floatsum test.

See also: https://github.com/rr-debugger/rr/issues/3208

Updates #3001
2022-05-05 08:39:54 -07:00
Alessandro Arzilli
10332d6700
Documentation: document substitute-path more (#2998)
Add FAQ entry about substitute-path since it comes up often and link it
in the issue template.
2022-05-04 11:01:56 -07:00
Alessandro Arzilli
55e37e2fc8
proc/core: return true for calls to Recorded (#2979)
The recent refactoring that introduced ContinueOnceContext broke this old behavior.

Fixes #2978
2022-05-04 10:56:41 -07:00