Commit Graph

2493 Commits

Author SHA1 Message Date
Alessandro Arzilli
47989248ed
dwarf/op: use readMemory function (#3391)
dwarf/op gained the ability to execute DW_OP_deref opcodes a while ago
but because we didn't save the readMemory function in the context
structure it never worked.
2023-05-26 10:04:37 -07:00
Andrei Matei
c2bfdfc76b
starbind: Make the time module available to star scripts (#3375)
This patch makes the time library available to Starlark scripts. This
library is one of the very few few that are built into starlark-go (the
others are json, math, proto).
I've played around with Starlark scripting today, and immediately I
wanted to measure how long certain computations take.
2023-05-23 11:23:33 -07:00
Andrei Matei
b79dd04070
documentation: add a note about starlark structs (#3376)
It took me a bit to understand how to pass structs to Starlark built-ins. The
documentation didn't really address it - there was an example, but quite
hidden. This patch adds some words about it.
2023-05-23 11:22:41 -07:00
Frank Ch. Eigler
68f58561bb
debuginfod-find stderr may contain diagnostics; look at stdout only for filename (#3381) 2023-05-23 11:11:51 -07:00
Oleksandr Redko
3b251c9dd3
dwarf,proc: fix typos in comments and error messages (#3379) 2023-05-23 18:22:20 +02:00
Oleksandr Redko
e33806a3f7
service: fix typos in comments, logs, tests, and vars (#3378) 2023-05-23 18:21:36 +02:00
Alessandro Arzilli
faebde12f4
proc: remove addrret field from Stackframe struct (#3373)
This field was part of the original stack tracing algorithm, we haven't
used this in years.
2023-05-17 09:10:19 -07:00
Oleksandr Redko
c5d9baaeb6
pkg/proc,pkg/terminal: close response body in tests (#3372) 2023-05-17 12:01:26 +02: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
Zeke Lu
463b97dd36
pkg/proc: pad variable mem in extractVarInfoFromEntry (#3365)
* pkg/proc: pad variable mem in extractVarInfoFromEntry

On 64 bit system, the byte size of the following struct is 16:
    type myStruct struct {
       a int
       b uint32
    }
But extractVarInfoFromEntry only allocates a mem of 12 bytes for it.
When calling method of this struct with the "call" command, it will
result in this error:
    write out of bounds

This patch extends the mem by adding padding bytes to the end of the
mem.

Fixes #3364.

* move the padding logic into newCompositeMemory
2023-05-15 14:46:33 -07:00
Oleksandr Redko
1c9792bce4
cmd/dlv: logger is not closed in connect command (#3367) 2023-05-15 10:22:33 -07:00
Alessandro Arzilli
674bd63996
proc: fix runtime type handling for Go 1.21 (#3370)
Go 1.21 renamed runtime._type to internal/abi.Type and changed the name
of its fields. Update Delve so that it uses the new names for loading
interfaces and generic type parameters.
2023-05-15 10:21:52 -07:00
Alessandro Arzilli
e95ae9c21b
proc,terminal: read command line of new processes (#3346)
Read the command line of the main target process as well as any other
process Delve attaches to in follow exec mode.
The command line can be viewed using the 'target list' command.

In follow exec mode this command line is used to match the follow exec
regex to decide whether or not to attach to a child process.

On macOS or when using rr the list of arguments is not available for
attached processes since there is no way to use the gdb serial protocol
to read it.

Fixes #2242
2023-05-09 11:40:00 -07:00
罗泽轩
801a9109c7
trace: add timestamp to the output (#3358)
Fix #3356
2023-05-08 10:41:47 -07:00
Oleksandr Redko
a57c60e43a
service/dap: refactor funcs always returning nil error (#3357) 2023-05-08 10:41:14 -07:00
Alessandro Arzilli
5c7049b7b1
dwarf/godwarf: fix alignment calculation for typedef types (#3362)
Alignment calculation for typedef types was wrong due to a missing
Align method.

Fixes #3360
2023-05-08 10:38:53 -07:00
Eng Zer Jun
8711f6217d
refactor: replace Readdir(-1) with os.ReadDir (#3361)
We can simplify the following code
	dir, err := os.Open(dirname)
	if err != nil {
		return err
	}
	defer dir.Close()

	dirs, err := dir.Readdir(-1)

with just `os.ReadDir(dirname)`.

Reference: https://pkg.go.dev/os#ReadDir

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2023-05-08 10:37:30 -07:00
罗泽轩
8c9ce617c9
chore: don't ignore directory cmd/dlv (#3359)
Currently, cmd/dlv is ignored, breaks tools which read the gitignore
file. For example, rg can't search files under cmd/dlv.
2023-05-05 09:59:43 -07:00
Oleksandr Redko
a3b053df86
pkg/proc: add missing response body Close in test (#3355) 2023-05-04 13:59:16 +02:00
Derek Parker
f3bfa7c177
pkg/proc: remove memlock limit for ebpf trace backend (#3353)
Fixes #3283
2023-05-03 09:41:32 +02:00
Alessandro Arzilli
13ad7dc1d5
*: misc improvements to config command and substitute-path rules (#3335)
A series of interconnected changes to both the terminal command
'config', DAP command 'dlv config', quality of life improvements to how
substitute-path works, and better documentation.

- Let 'config substitute-path' show the current substitute path rules
- Add a -clear command to 'config substitute-path'
- Support 'config-debug-info-directories'
- rewrite SubstitutePath to be platform independent (see below)
- document path substitution more

Regarding the rewrite of SubstitutePath: the previous version used
runtime.GOOS and filepath.IsAbs to determine which filepath separator to use
and if matching should be case insensitive. This is wrong in all situations
where the client and server run on different OSes, when examining core files
and when cross-compilation is involved.

The new version of SubstitutePath checks the rules and the input path to
determine if Windows is involved in the process, if it looks like it is it
switches to case-insensitive matching. It uses a lax version of
filepath.IsAbs to determine if a path is absolute and tries to avoid having
to select a path separator as much as possible

Fixes #2891, #2890, #2889, #3179, #3332, #3343
2023-05-02 12:23:59 -07:00
Suzy Mueller
9873e0ef63 service/dap: use reloaded value
The only part of the reloaded value that was used was the
Children. This caused a bug where the Time format string was
reloaded, but it was not being displayed.

Fixes go-delve/delve#3342
2023-04-29 09:55:45 +02:00
Oleksandr Redko
5f588d8927 service/dap,service/debugger: refactor regexp funcs
Use regex.MatchString and regex.MustCompile.
2023-04-28 17:23:35 +02:00
Oleksandr Redko
25f0e7712e proc/test: replace old func testName with T.Name
testName is needed only for Go <= 1.7.
2023-04-28 17:22:41 +02:00
Oleksandr Redko
cc71863594
service: fix typos in comments (#3344) 2023-04-27 13:39:33 -07:00
Álex Sáez
bdec83da45 Fix typo 2023-04-25 15:35:06 +02:00
Álex Sáez
5a159c2ef2 Add additional information to how to filter goroutines 2023-04-25 15:35:06 +02:00
cui fliter
e24a7b1174 fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-04-25 11:19:13 +02:00
Alessandro Arzilli
a61ccea65a
service/debugger,terminal: API and user interface for follow exec mode (#3286)
Updates #2551
2023-04-24 14:37:31 -07:00
Alessandro Arzilli
47481fe0ab
proc/native: support core dumping on FreeBSD (#3305)
Co-authored-by: a <a@kra>
2023-04-24 14:33:38 -07:00
Alessandro Arzilli
83a2555497
debugger: do not panic if defer location can not be found (#3329)
convertDefers should not try to dereference nil if the deferred
location does not belong to a function.
2023-04-24 13:38:19 -07:00
Hengqi Chen
64d5ce26d6
proc: Simplify eBPF backend implementation (#3325)
* Remove standard C headers since we have vmlinux.h already
* Simplify get_goroutine_id() implementation, this reduces a map
  and thus reduces runtime memory comsumption.

While at it, unify all indention using 4 spaces.

Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
2023-04-24 13:37:58 -07:00
Alessandro Arzilli
36980dcbf9
proc: step breakpoints shouldn't hide normal breakpoints (#3287)
When using Step on a function that has a dynamic CALL instruction we
set a Step breakpoint on the call.
When it is hit we determine the destination of the CALL by looking at
registers, set a breakpoint there and continue.
If the Step breakpoint is hit simultaneously with a normal breakpoint
our Step logic will take precedence and the normal breakpoint hit will
be hidden from the user.

Move the Step logic to a breaklet callback so that it does not
interfere with the decision to stop.
2023-04-24 12:12:54 -07:00
Alessandro Arzilli
70b80623d1
service/dap: fix failing test on Go 1.21 (#3312) 2023-04-24 12:11:50 -07:00
Alessandro Arzilli
6d88b52509
proc: disable flaky tests on windows/arm64 (#3328)
Disable some tests on windows/arm64 that are flaky.
2023-04-24 12:10:50 -07:00
Oleksandr Redko
6605d46758 proc: fix match condition in TestGnuDebuglink 2023-04-07 12:34:39 +02:00
Oleksandr Redko
74a69810fc proc: fix test by adding missing assert 2023-04-06 14:15:43 +02:00
Derek Parker
d8ff5d1e43 v1.20.2 2023-04-05 11:25:22 +02:00
Alessandro Arzilli
4c40e8141d
proc: fix TestEvalExpression on Windows (#3313)
On Windows the TZ environment variable does not affect the timezone of
time.Time variables created using time.Unix. Find another way to make
the test pass on our windows/arm64 builder (which is not set to the UTC
timezone).
2023-03-30 08:54:04 -07:00
Vitaliy Filippov
efb119d969
terminal: Fix printing boolean values in Starlark scripts (#3314) 2023-03-29 09:40:58 -07:00
Alessandro Arzilli
be88f980cd
proc: fix escapeCheck infinite recursion if something can not be (#3311)
deref'd

Fix infinite recursion if escapeCheck, at some point during its
recursion, creates an unreadable variable.

The deeper reason for this is that we evaluate function calls in a very
weird order so that we can always have stack space to store
intermediate evaluation results.
The variable 'value' happens to be stored in a register when we try to
make the call and because of our weird evaluation strategy registers
are no longer available to us when we evaluate 'value'.

This is not a complete fix for the issue, the real fix would be to
evaluate everything in its natural order, storing intermediate values
in Delve's memory instead of the target's stack. To do this we need a
mechanism to pin heap allocated objects, which at the moment does not
exist.

Updates #3310
2023-03-27 11:21:01 -07:00
Alessandro Arzilli
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
Alessandro Arzilli
1522382336
proc: fuzzing expression evaluator and variable loader (#3293)
Add code to fuzz the expression evaluator and variable loader, see
comment to FuzzEvalExpression for how to use this.
2023-03-16 12:13:10 -07:00
Alessandro Arzilli
9faf66b7a1
proc: limit maximum time.Time we try to format (#3294)
The loop adding maxAddSeconds to format a time.Time can take multiple
seconds to complete if the time is very far into the future. To avoid
this loop slowing down debugging too much limit it to an arbitrary
maximum.
The chosen maximum is 1000 times the maximum expressible time.Duration,
which is 262 years. This means that we will not format dates beyond
year 262000 AD.
2023-03-16 12:12:20 -07:00
Daniel Frederick Crisman
5b8296782b
Documentation: expand project layout to match usage (#3304)
The tree view of the project layout seemed to show that "github.com",
"cmd", and "pkg" were all in the same directory.  The usage later in the
document (and normal go layout) would have them as subdirectories.

The new tree output was generated with the below:
(cd `mktemp -d`
    mkdir -p github.com/me/foo/{cmd/foo,pkg/baz}
    touch github.com/me/foo/{cmd/foo/main,pkg/baz/bar{_test,}}.go
    tree -n --noreport github.com/me/foo
)
2023-03-16 12:11:06 -07:00
Alessandro Arzilli
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
Oleksandr Redko
7a05a4326f
proc,terminal: remove unused unexported functions (#3299) 2023-03-06 07:58:07 +01: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
Alessandro Arzilli
212c2002bb
proc: do not try to load a non-empty slice if the base address is 0 (#3295) 2023-03-01 11:27:06 -08:00
Oleksandr Redko
372552bf1f
Documentation: fix typo and grammar issues (#3291) 2023-02-28 14:52:52 +01:00