184 Commits

Author SHA1 Message Date
7b33c542f4 pkg/proc: split off rangeParent from function extras (#4173)
The rangeParent calculation was changed 0b74953f0 to address slowness
(due to repeated calculations) when calling PackageVariables. That
changed caused to program to use a lot of memory due to having to
calculate the range bodies of every function. This change reverts
0b74953f0 and splits off rangeBodies calculation from the extras method
of Function, so that it isn't called from PackageVariables.

Fixes #4146
2025-10-06 14:28:11 -04:00
949bd82138 pkg/proc: fix nil pointer dereference when calling extra on a nil func (#4174)
Fixes #4172
2025-10-06 14:24:55 -04:00
8da93b0620 proc,service,terminal: allow cancelling of debuginfod downloads (#4123)
Adds an RPC call to cancel in-progress debuginfod-find downloads. Wires
this call to ^C in the terminal interface and to receiving a Pause
request while already pausing in DAP.
Adds a new terminal command to download the debug info for libraries
for which it hasn't been downloaded already.

Fixes #3906
2025-09-10 11:49:58 -04:00
8e2d698c54 go.mod: upgrade simplelru to v2 (#4143)
Fixes #4142
2025-09-10 11:23:10 -04:00
f3f3d57c63 *: update trie to v3.2.0 (#4131) 2025-09-03 10:10:52 +02:00
0b74953f0c pkg/proc: optimize range body lookup cost by trie searching and use moduledata cache to reduce LoadModuleData cost (#4113)
Fixes #4112
2025-09-01 12:51:22 -04:00
61573cffb3 *: modernize codebase with newer syntax / helpers (#4110)
Changes came from running
https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize
on the codebase.
2025-08-29 15:50:08 +02:00
17acdb87a7 proc,service,terminal: add events call use it for dld notifications (#3980)
Add a GetEvents method that can be used to retrieve debug events, adds
events for downloading debug info through debuginfod and shows those
events in the command line client as well as console messages in DAP.

In the future this events mechanism can be used to unify EBPF
tracepoints with old style tracepoints.

Update #3906
2025-08-04 08:12:48 -07:00
091ff50645 proc: handle moving of direct interface flag in Go 1.26 (#4032)
This flag in internal/abi.Type is moving from the Kind_ field to
the TFlag field. See https://go-review.googlesource.com/c/go/+/681936

A few of the other Kind fields dlv doesn't use (and don't exist
in Go anymore), so this code can be simplified somewhat.
2025-06-17 16:04:52 -07:00
4dc820ee3c proc: relax DWARFv5 check (#3961)
When using cgo some of the compilation units are produced by the C
compiler and could be in DWARFv5 even if most of the executable is
DWARFv4. In those cases debugging will still work fine outside of C
areas of the executable, it's probably better to proceed.
2025-04-02 09:36:02 -07:00
ae252b0522 proc: fix bug telemetry counter increment (#3967)
The stack counter for bugs is accidentally incremented too early.
2025-04-02 09:23:30 -07:00
18ce5d6baa proc: add support for struct literals (#3935)
* service/test: fix compile error in tests

Due to a merge conflict the tests in service/test are not compiling.

* proc: add support for struct literals

Adds support for evaluating struct literals, and allocating them into
the target's memory.

Updates #1465
2025-03-18 10:11:05 -07:00
b329489c6c goversion: add check for DWARFv5 compatibility (#3943)
Due to #3861 which was fixed in:

https://go-review.googlesource.com/c/go/+/656675
https://go-review.googlesource.com/c/go/+/655976

debugging DWARFv5 executables only works if Delve itself is built with
1.25 or later. Add this check to the version compatibility checks.

Fixes #3861
2025-03-13 10:59:21 -07:00
0b821e4516 telemetry: add stack counter for internal errors (#3930)
Add stack counter for the various places where we catch internal
errors.
2025-03-05 08:25:00 -08:00
e6e7aeb667 dwarf,proc: various fixes to support DWARFv5 (#3893)
Miscellaneous fixes to our DWARFv5 implementation, several contributed by @thanm.
2025-03-03 08:42:44 -08:00
62cd2d423c proc: some refactorings for supporting struct literals (#3909)
* deduplicates exprToString, defined in multiple packages, and moves it
  to astutil
* moves resolveTypedef into pkg/dwarf/godwarf, this is currently only
  used by pkg/proc but we will need to call it from pkg/proc/evalop
* creates a new FakePointerType function in pkg/dwarf/godwarf, this is
  also a function that is only used by pkg/proc but pkg/proc/evalop will
  also need.

Updates #1465
2025-02-07 07:36:23 -08:00
6a362a2b2a proc: better error message for breakpoints on stripped binaries (#3914)
Produce a better error when trying to set a breakpoint, by line, on
stripped binaries.

Fixes #3913
2025-02-07 07:35:46 -08:00
d2f748f1bd *: add support for linux/loong64 to native backend (#3892)
* delve: support linux-loong64 native debug

LoongArch is a new RISC ISA, which is independently designed by Loongson Technology.

LoongArch includes a reduced 32-bit version (LA32R), a standard 32-bit version (LA32S)
and a 64-bit version (LA64), and loong64 is the 64-bit version of LoongArch.

LoongArch documentation: https://github.com/loongson/LoongArch-Documentation.git

* *: mark loong64 port as experimental

---------

Co-authored-by: Huang Qiqi <huangqiqi@loongson.cn>
2025-01-17 09:41:37 -08:00
75c20c328c pkg: refactor sort.Sort to slices.SortFunc (#3880) 2025-01-03 10:44:28 -08:00
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
1a9bd03d7a goversion: parse version for development builds (#3837)
Once upon a time Go version strings for development builds did not
reference the major/minor version they belonged to, therefore the best
we could do was to always assume that a development build belonged to
the most recently released version of Go.

This commit changes pkg/goversion so that the new style of development
version string is fully parsed.
2024-10-21 09:15:02 -07:00
75c41f2b64 delve: add linux-riscv64 support (#3785) 2024-10-11 12:34:25 -07:00
025d47c6e9 proc: adds pointer pinning to call injection (#3787)
This commit adds a new mode to call injection. If the runtime.debugPinner
function is available in the target executable it obtains a pinner by
calling it and then uses it to pin the pointers in the results of call
injection.

This allows the code for call injection to be refactored to execute the
calls in the normal order, since it doesn't need to be concerned with having
space on the target's memory to store intermediate values.

Updates #3310
2024-10-04 10:44:57 -07:00
a3d7712752 *: replace uses of uniq with slices.Compact (#3821) 2024-10-01 10:16:49 -07:00
059f149433 proc: cache module data (#3800)
Cache module data so that we don't reload it every time we look up a
variable with a generic type.
2024-09-18 14:17:07 -07:00
582305a813 proc: for optimized functions allow .closureptr to not exist (#3808)
* proc: flag variables correctly when range-over-func stmts are used

Argument variables of a range-over-func body closure should be returned
flagged as normal local variables, not as function arguments.

Updates #3806

* proc: for optimized functions allow .closureptr to not exist

For optimized functions .closureptr is sometimes omitted from DWARF,
allow it to be 0 and try to recover the range-over-func stack by best
effort.

Fixes #3806
2024-09-18 14:16:34 -07:00
162959baee proc: workaround for macOS section name truncation (#3799)
Go 1.23 and earlier does not take into account that Mach-O section
names are limited to 16 characters, which causes DWARF sections with
long names to be truncated and become unreadable.

Fixes #3797
2024-09-03 10:39:27 -07:00
3ae22627df *: replace old golang.org links with new go.dev (#3774) 2024-07-12 12:12:44 -07:00
b9f50fe9b0 pkg/proc,service/debugger: fix debuginfod-find source (#3762)
Fixes bug where the incorrect Build ID could be used to try and download the source for a binary. This is because the Build ID was stored on the BinInfo object for a target and not the image itself.
2024-06-28 09:15:37 +02:00
a4196f35a9 refactor: move loadModuleData from runtimeTypeToDIE and expose the apis (#3741) 2024-06-25 08:03:28 -07:00
a8293a36f5 all: fix typos in docs, comments and package name (#3757) 2024-06-25 15:16:58 +02:00
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
8347f97c00 *: remove redundant lines at the start/end of block (#3730) 2024-05-20 14:16:22 -07:00
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
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
40b58f9643 proc: catch panics when reading debug info for stripped executables (#3678)
Adds a recover to the functions reading debug info from the go runtime
data structures for stripped executables.

This function is best-effort and can sometimes fail in weird ways,
instead of crashing recover any panic and turn them into errors.

Fixes #3650
2024-03-04 09:17:12 -08:00
4a72c523be pkg/proc: remove usage of gore dependency (#3664) 2024-02-21 12:10:41 +01:00
dda8f693e6 *: Use forked goretk/gore module (#3597)
This allows us to update this dependency on our schedule which is important because the module relies on manually updating the known list of Go versions to function correctly. Forking allows us to keep this up to date ourselves and possibly create a new system to prevent having to perform this manual step in the future.
2023-12-12 10:13:32 +01:00
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
a5b03f0623 proc: simplify and generalize runtime.mallocgc workaround (#3571)
Instead of having a different version for each architecture have a
single version that uses an architecture specific list of registers.
Also generalize it so that, if we want, we can extend the workaround to
other runtime functions we might want to call (for example the channel
send/receive functions).
2023-11-20 10:43:15 -08:00
938cb6e9d8 pkg,service: remove unnecessary convertions (#3564) 2023-11-14 16:36:55 +01:00
13d6cd4e0d *: Correct spelling mistakes (#3555) 2023-11-06 07:55:44 -06:00
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
899ba72505 all: replace deprecated io/ioutil with io and os (#3509) 2023-09-25 11:41:59 -07:00
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
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
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
8023fa956e all: use "len == 0" rather than "len <= 0" when checking empty slice/string (#3439) 2023-07-13 11:30:32 -07:00
71f1220717 *: add ppc64le support (#2963)
* Add vendor/golang.org/x/arch/ppc64

* Add ppc64le support
2023-07-07 09:30:38 -07:00
80840dd2bf all: fix typos (#3434) 2023-07-06 11:16:06 +02:00