169 Commits

Author SHA1 Message Date
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
656c4f13df pkg/proc: improve stripped binary support with PIE (#3421)
Take into account static base for PIE binaries.
2023-06-16 09:38:19 +02:00
14d9c1881d proc: only print warning when gopclntab can not be read for first image (#3420)
Only print the warning that gopclntab can not be read for the first
image (i.e. the executable file), also change the returned when neither
DWARF nor gopclntab are found to preserve the DWARF error.
2023-06-15 08:28:35 -07:00
ccf17a6f42 pkg/proc: enable basic debug functionality for stripped ELF binaries (#3408)
We used to parse the .gopclntab section but removed support in favor of
simply using DWARF debug information, due to lack of C symbols among
other reasons. This makes it impossible to debug stripped binaries,
which some distrubutions ship by default.

Add back in basic support for .gopclntab which survives if the binary
is stripped, allowing for rudimentary debugging such as basic
program navigation, tracing, etc...
2023-06-14 13:23:46 +02:00
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
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
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
260229b979 terminal/logflags: Added SetLoggerFactory(LoggerFactory) (#3257)
* terminal/logflags: Added `SetLoggerFactory(LoggerFactory)`

This change will enable people who want to embed Delve into their applications to adjust the logging better to their needs.

* terminal/logflags: Added `SetLoggerFactory(LoggerFactory)`

Added changes from code review.

* terminal/logflags: Added `SetLoggerFactory(LoggerFactory)`

Reworked requested changes.

* terminal/logflags: Added `SetLoggerFactory(LoggerFactory)`

Reworked requested changes.
2023-02-14 09:46:35 -08:00
f6e6eadd22 pkg/proc,service/test: refactor to strings.ReplaceAll (#3269)
Use strings.ReplaceAll instead of strings.Replace with -1 as the last argument.
2023-02-14 09:36:24 -08:00
58fc3931e8 proc/dwarf: Move util functions to dwarf package (#3252) 2023-01-16 09:20:20 -08:00
bbc22707d0 pkg/proc: apply simplifycompositelit analysis fixes (#3236)
https://pkg.go.dev/golang.org/x/tools/internal/lsp/analysis/simplifycompositelit
2023-01-03 08:13:28 -08:00
a6e3d14455 proc: Fix typos in the comments (#3231) 2022-12-28 12:41:13 +01:00
5ca60a81e8 proc: extend macOS workaround to amd64 (#3204)
Go change 064f34f (which exists in Go 1.19.2 and following) removed the
pagezero_size option from linker calls (because it is deprecated). This
expanded the problem that exists on darwin/arm64 as well as PIE builds
on darwin/amd64 to all darwin/amd64 builds.

This problem is described on: https://github.com/golang/go/issues/25841.

This commit extends the darwin/arm64 workaround to darwin/amd64.

Fixes #3194
2022-12-05 09:46:24 -08:00
b9a8bd7f41 *: early fixes for go1.20 (#3180)
- updated go/packages to support new export format
- rewrite testinline.go fixture because the compiler got too smart with
  constant folding
- temporarily disable staticcheck on go1.20 because it doesn't support
  the new export format.
- workaround for go.dev/cl/429601
2022-12-05 09:02:22 -08:00
f439987f14 G struct offset is a pointer to an offset since go1.20 (#3196) 2022-11-16 09:44:27 -08:00
c7fa713c34 bininfo: Log when the file listed in .gnu_debuglink is not found (#3188) 2022-11-10 09:41:42 -08:00