Commit Graph

33 Commits

Author SHA1 Message Date
Alessandro Arzilli
a1a726d315
tests: correctly check for 1.17 + regabi (#2673)
regabi is not supported on FreeBSD, the tests must act accordingly
2021-08-24 08:21:17 -07:00
Alessandro Arzilli
4e242098f8
tests: check presence of gcc for cgo tests (#2644)
The install of gcc sometimes fails on our CI, it is not an error if the
tests for cgo can not run because there's no C compiler.
2021-08-04 14:12:15 -07:00
Than McIntosh
dceffacb89
pkg/proc: fix for file reference handling with DWARF 5 compilation units (#2327)
Add a helper method for collecting line table file references that
does the correct thing for DWARF 5 vs DWARF 4 (in the latter case you
have an implicit 0 entry which is the comp dir, whereas in the former
case you do not). This is to avoid out-of-bounds errors when examining
the file table section of a DWARF 5 compilation unit's line table.

Included is a new linux/amd-only test that includes a precompiled C
object file with a DWARF-5 section that triggers the bug in question.

Fixes #2319
2021-01-29 09:23:52 -08:00
Alessandro Arzilli
f9c8f7f55b
Go 1.15 support (#2011)
* proc: start variable visibility one line after their decl line

In most cases variables shouldn't be visible on their declaration line
because they won't be initialized there.
Function arguments are treated as an exception.

This fix is only applied to programs compiled with Go 1.15 or later as
previous versions of Go did not report the correct declaration line for
variables captured by closures.

Fixes #1134

* proc: silence go vet error

* Makefile: enable PIE tests on windows/Go 1.15

* core: support core files for PIEs on windows

* goversion: add Go 1.15 to supported versions

* proc: fix function call injection for Go 1.15

Go 1.15 changed the call injection protocol so that the runtime will
execute the injected call on a different (new) goroutine.

This commit changes the function call support in delve to:

1. correctly track down the call injection state after the runtime
   switches to a different goroutine.
2. correctly perform the escapeCheck when stack values can come from
   multiple goroutine stacks.

* proc: miscellaneous fixed for call injection under macOS with go 1.15

- create copy of SP in debugCallAXCompleteCall case because the code
  used to assume that regs doesn't change
- fix automatic address calculation for function arguments when an
  argument has a spurious DW_OP_piece at entry
2020-07-28 09:19:51 -07:00
Alessandro Arzilli
bc299a7a30
tests: properly check if cgo is enabled for cgo related tests (#2010) 2020-04-16 10:42:22 -07:00
aarzilli
3c8d4d52b8 *: un-export unnecessarily public symbols 2020-03-31 14:47:29 -07:00
Alessandro Arzilli
e1cfd72795
proc: fix bad cached goroutines after a call injection (#1926)
Inserts a call to ClearAllGCache into stepInstructionOut so that cached
goroutine state is not inconsistent after an injected function call.\

Fixes #1925
2020-03-19 12:27:31 -07:00
Derek Parker
ad75f78c4e
*: Fix go vet complaints (#1935)
* *: Fix go vet struct complaints

* *: Fix struct vet issue on linux

* *: Ignore proc/native in go vet check

We have to do some unsafe pointer manipulation that will never make go
vet happy within the proc/native package. Ignore it for runs of go vet.
2020-03-18 09:25:32 -07:00
aarzilli
8ed7a840e7 tests: disable function call injection tests on macOS on Travis-CI
Updates #1802
2020-01-02 09:20:12 -08:00
Alessandro Arzilli
67b6d4b9c9 travis-ci: fix dwz test problems (#1648)
For some reason the version of dwz in Travis-CI now fails to run on Go
binaries. Ignore the particular error.
2019-07-31 13:09:00 -07:00
Alessandro Arzilli
55eed318fd Go 1.13 support (#1546)
* tests: fix tests for Go 1.13

- Go 1.13 doesn't autogenerate init functions anymore, tests that
  expected that now fail and should be skipped.
- Plugin tests now need -gcflags'all=-N -l' now, we were probably
  getting lucky with -gcflags='-N -l' before.

* proc: allow signed integers as shift counts

Go1.13 allows signed integers to be used as the right hand side of a
shift operator, change eval to match.

* goversion: update maximum supported version

* travis: force Go to use vendor directory

Travis scripts get confused by "go: downloading" lines, the exact
reason is not clear. Testing that the vendor directory is up to date is
a good idea anyway.
2019-06-30 10:34:47 -07:00
Alessandro Arzilli
af1ffc8504 proc,proc/native,proc/gdbserial: initial plugin support (#1413)
Adds initial support for plugins, this is only the code needed to keep
track of loaded plugins on linux (both native and gdbserial backend).

It does not actually implement support for debugging plugins on linux.

Updates #865
2019-03-20 10:32:51 -07:00
Derek Parker
389e96ae95 pkg/proc: Disable default compression on DWZ test
When compression is applied by default running the DWZ tool on the
resulting binary will crash.

The actual default compression code will look and see if compression
makes any difference and if so replace the normal `.debug_*` section
with `.zdebug_*`. This is why it may not have been hit before. On one of
my workstations I build with 1.12rc1 and no compression happens, but on
a Fedora VM I build and the binary results in compressed DWARF sections.

Adding this flag will make this test more consistent overall.
2019-02-21 12:01:05 +01:00
Derek Parker
4c9a72e486 *: Update import name to github.com/go-delve/delve
The repository is being switched from the personal account
github.com/derekparker/delve to the organization account
github.com/go-delve/delve. This patch updates imports and docs, while
preserving things which should not be changed such as my name in the
CHANGELOG and in TODO comments.
2019-01-04 19:43:13 +01:00
Derek Parker
de6682d291 pkg/proc/test: Eval symlinks for test source (#1452)
Some build environments (such as when building RPMs) enjoy symlinking
things. This unfortunately causes our tests to fail as we record the
path of fixtures and use that when looking up file:line information.
However, the debug info in the binary records the original file
location, not the location of the symlink.
2019-01-04 11:03:16 +01:00
aarzilli
74c98bc961 proc: support position independent executables (PIE)
Support for position independent executables (PIE) on the native linux
backend, the gdbserver backend on linux and the core backend.
Also implemented in the windows native backend, but it can't be tested
because go doesn't support PIE on windows yet.
2018-10-11 11:21:27 -07:00
aarzilli
910f90c3c8 proc/native,Makefile: allow compiling on macOS without native backend
On macOS 10.14 Apple changed the command line tools so that system
headers now need to be manually installed.

Instead of adding one extra install step to the install procedure add a
build tag to allow compilation of delve without the native backend on
macOS. By default (i.e. when using `go get`) this is how delve will be
compiled on macOS, the make script is changed to enable compiling the
native backend if the required dependencies have been installed.

Insure that both configuration still build correctly on Travis CI and
change the documentation to describe how to compile the native backend
and that it isn't normally needed.

Fixes #1359
2018-10-02 10:46:09 -07:00
Derek Parker
c3f50742b9 *: Misc refactors, and doc additions
Refactors some code, adds a bunch of docstrings and just generally fixes
a bunch of linter complaints.
2018-09-19 20:59:35 +02:00
aarzilli
b8e80746e5 proc/native: implement Copy/RestoreRegisters on windows 2018-08-30 15:48:10 -07:00
aarzilli
438e51f330 proc: replace SavedRegisters interface with a Copy method
Fncall.go was written with the assumption that the object returned by
proc.Thread.Registers does not change after we call
proc.Thread.SetPC/etc.

This is true for the native backend but not for gdbserial. I had
anticipated this problem and introduced the Save/SavedRegisters
mechanism during the first implementation of fncall.go but that's
insufficient.

Instead:

1. clarify that the object returned by proc.Thread.Registers could
   change when the CPU registers are modified.
2. add a Copy method to Registers that returns a copy of the registers
   that are guaranteed not to change when the CPU registers change.
3. remove the Save/SavedRegisters mechanism.

This solution leaves us the option, in the future, to cache the output
of proc.(Thread).Registers, avoiding a system call every time it's
called.
2018-08-30 15:48:10 -07:00
Derek Parker
f1e66f075f Add function call support for OSX
Implements missing functionality in gdbserial to enable function calls
on OSX.
2018-08-30 15:48:10 -07:00
aarzilli
9335c54014 proc: use (*Variable).setValue in fncall 2018-08-15 10:29:16 -07:00
aarzilli
e19cbcefa9 proc,command: fix optimized function warning in 1.9
A user complained on the mailing list about having continuous
"optimized function warnings" on non-optimized functions when using 1.9.
This commit fixes the problem by disabling optimized function detection
on 1.9 and earlier (where it's impossible) and adds a test so we don't
break it again in the future.
2018-06-20 07:56:32 -07:00
aarzilli
d85cb61cad tests: call RunTestsWithFixtures everywhere we use BuildFixture
If we don't build artifacts aren't removed after the tests run. Also
add a check to prevent this mistake from reoccuring.
2018-06-08 11:39:47 -07:00
Sergio Lopez
ed71248f9b proc/test/support: implement EnableDWZCompression
The EnableDWZCompression flag allows tests to request BuildFixture to
run "dwz" on the Fixture's resulting binary to compress/deduplicate its
DWARF sections.
2018-05-23 13:59:45 -07:00
aarzilli
119cb93460 tests: cache and delete fixtures built with non-zero flags 2018-04-19 13:28:11 -07:00
aarzilli
290e8e7528 proc: support inlining
Go 1.10 added inlined calls to debug_info, this commit adds support
for DW_TAG_inlined_call to delve, both for stack traces (where
inlined calls will appear as normal stack frames) and to correct
the behavior of next, step and stepout.

The calls to Next and Frame of stackIterator continue to work
unchanged and only return real stack frames, after reading each line
appendInlinedCalls is called to unpacked all the inlined calls that
involve the current PC.

The fake stack frames produced by appendInlinedCalls are
distinguished from real stack frames by having the Inlined attribute
set to true. Also their Current and Call locations are treated
differently. The Call location will be changed to represent the
position inside the inlined call, while the Current location will
always reference the real stack frame. This is done because:

* next, step and stepout need to access the debug_info entry of
the real function they are stepping through
* we are already manipulating Call in different ways while Current
is just what we read from the call stack

The strategy remains mostly the same, we disassemble the function
and we set a breakpoint on each instruction corresponding to a
different file:line. The function in question will be the one
corresponding to the first real (i.e. non-inlined) stack frame.

* If the current function contains inlined calls, 'next' will not
set any breakpoints on instructions that belong to inlined calls. We
do not do this for 'step'.

* If we are inside an inlined call that makes other inlined
functions, 'next' will not set any breakpoints that belong to
inlined calls that are children of the current inlined call.

* If the current function is inlined the breakpoint on the return
address won't be set, because inlined frames don't have a return
address.

* The code we use for stepout doesn't work at all if we are inside
an inlined call, instead we call 'next' but instruct it to remove
all PCs belonging to the current inlined call.
2018-03-26 14:30:38 -04:00
aarzilli
5fdcd2c91a cmd, proc/test: disable optimizations on the C compiler
Pass CGO_FLAGS='-O0 -g' to go build to disable optimizations when
calling the C compiler.
2017-11-28 11:00:53 -08:00
aarzilli
40ae277ab2 pkg/prog/test: add flag to run target with -race flag
Adds test command line flag to compile target fixtures using the -race flag.
Multiple tests will fail because of https://github.com/golang/go/issues/22600
but eventually this should work.
2017-11-15 08:51:57 -08:00
aarzilli
9ee21686e6 proc: report errors when loading executable on attach
Fixes #940
2017-08-30 11:20:20 -07:00
aarzilli
189872a7c7 proc/test: show compiler error output 2017-08-01 11:20:25 -06:00
Alessandro Arzilli
a843f7944e proc/gdbserial: mozilla rr support (#804)
Implements #727
2017-05-05 15:17:52 -07:00
Derek Parker
53f0d24057 Move top-level packages into pkg 2017-02-08 12:17:19 -08:00