Commit Graph

157 Commits

Author SHA1 Message Date
Oleksandr Redko
3ae22627df
*: replace old golang.org links with new go.dev (#3774) 2024-07-12 12:12:44 -07:00
Derek Parker
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
Jayant
a4196f35a9
refactor: move loadModuleData from runtimeTypeToDIE and expose the apis (#3741) 2024-06-25 08:03:28 -07:00
Oleksandr Redko
a8293a36f5
all: fix typos in docs, comments and package name (#3757) 2024-06-25 15:16:58 +02:00
Alessandro Arzilli
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
Oleksandr Redko
8347f97c00
*: remove redundant lines at the start/end of block (#3730) 2024-05-20 14:16:22 -07:00
Derek Parker
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
Alessandro Arzilli
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
Alessandro Arzilli
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
Derek Parker
4a72c523be
pkg/proc: remove usage of gore dependency (#3664) 2024-02-21 12:10:41 +01:00
Derek Parker
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
Derek Parker
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
Alessandro Arzilli
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
Oleksandr Redko
938cb6e9d8
pkg,service: remove unnecessary convertions (#3564) 2023-11-14 16:36:55 +01:00
Oleksandr Redko
13d6cd4e0d
*: Correct spelling mistakes (#3555) 2023-11-06 07:55:44 -06:00
Derek Parker
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
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
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
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
gocurr
8023fa956e
all: use "len == 0" rather than "len <= 0" when checking empty slice/string (#3439) 2023-07-13 11:30:32 -07:00
Álex Sáez
71f1220717
*: add ppc64le support (#2963)
* Add vendor/golang.org/x/arch/ppc64

* Add ppc64le support
2023-07-07 09:30:38 -07:00
gocurr
80840dd2bf
all: fix typos (#3434) 2023-07-06 11:16:06 +02:00
Derek Parker
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
Alessandro Arzilli
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
Derek Parker
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
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
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
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
Gregor Noczinski
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
Oleksandr Redko
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
Oleksandr Redko
58fc3931e8
proc/dwarf: Move util functions to dwarf package (#3252) 2023-01-16 09:20:20 -08:00
Hyang-Ah Hana Kim
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
Oleksandr Redko
a6e3d14455
proc: Fix typos in the comments (#3231) 2022-12-28 12:41:13 +01:00
Alessandro Arzilli
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
Alessandro Arzilli
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
Quim Muntal
f439987f14
G struct offset is a pointer to an offset since go1.20 (#3196) 2022-11-16 09:44:27 -08:00
Daniel Lipovetsky
c7fa713c34
bininfo: Log when the file listed in .gnu_debuglink is not found (#3188) 2022-11-10 09:41:42 -08:00
Alessandro Arzilli
6e7e1d8830
proc,terminal: allow setting suspended breakpoints (#3154)
Allows setting suspended breakpoints and try to enable them
automatically after every time a plugin is loaded.

Fixes #1653
Updates #2551
2022-10-04 08:07:05 -07:00
Alessandro Arzilli
02d46b059e
proc: remove old method to resolve the type of an interface to a DIE (#3150)
Before 1.11 we used to read a bunch of runtime structures to determine
the runtime type of an interface variable. This had significant
dependencies on private structs of the Go runtime and the code is
broken for versions of Go after 1.17.
Remove all this code, since it is no longer used and doesn't work with
newer versions of Go anyway.
2022-09-29 10:06:15 -07:00
Alessandro Arzilli
1effee3576
proc: fix openSeparateDebugInfo backwards compatibility path (#3145)
Fix openSeparateDebugInfo backwards compatibility path to actually be
backwards compatible.
2022-09-26 10:09:06 -07:00
Alessandro Arzilli
b0ac6db339
proc: fix cast to empty interface type (#3146)
Fix cast to empty interface type. This is a workaround for a
discrepancy between how type names are serialized by the compiler vs
how type expressions are formatted by go/printer.
2022-09-26 10:08:01 -07:00
Quim Muntal
4455d6a9ef
Add support for windows/arm64 (#3063)
* Add support for windows/arm64

* split sentinel files and add winarm64 experiment

* update loadBinaryInfoPE to support PIE binaries

* skip TestDump on windows/arm64

* run windows/arm64 compilation on windows/amd64

* add entry point check for pie binaries

* delete unusded code

* document windows/arm64 breakpoint

* implement changing windows/arm64 fp registers

* update crosscall offset names

* fix G load when using CGO

* fix testvariablescgo

* remove DerefGStructOffset

* derefrence gstructoffset in GStructOffset() if necessary
2022-09-21 13:39:44 -07:00
Alessandro Arzilli
0c09fc9bdd
proc: use stdlib to compute CRC for gnu_debuglink section (#3105)
The standard library package has a the CRC algorithm used for
gnu_debuglink, use that instead of our own implementation.
2022-08-16 11:08:53 +02: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
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
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
cui fliter
9a9c1a9f33
*: fix some typos
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-03-23 16:10:00 +01:00
Alessandro Arzilli
a646d06544
proc: downgrade loadBuildID errors to warnings (#2893)
Most binaries do not have build-ids and it's fine, there's no reason to
report it as an error.
2022-02-08 10:54:05 -08:00
Alessandro Arzilli
1f0b39eab5
proc: fix crash trying to open separate debug info (#2901)
If debugInfoDirectories is set, the executable does not have debug info
and build-id is not set we should not crash.
2022-02-08 10:53:45 -08:00