Commit Graph

1695 Commits

Author SHA1 Message Date
aarzilli
a8606afb0b proc,service: return build informations for each package
Adds an API call that returns a list of packages contained in the
program and the files that were used to build them, and also a best
guess at which filesystem directory contained the package when it was
built.

This can be used by IDEs to map file paths if the debugging environment
doesn't match the build environment exactly.
2020-01-09 20:19:02 +01:00
aarzilli
0e0d689246 dwarf/line: make LineToPCIn behave like LineToPC for lines without stmt
When a line has instructions associated but none of them have is_stmt
set LineToPC and LineToPCIn should behave in the same way.

Fixes #1817
2020-01-09 09:41:44 -08:00
chainhelen
c5f9a03d6f pkg/proc: fix one typo.
Change `copy form` into `copy from`.
2020-01-09 09:03:08 -08:00
aarzilli
059c51ea0c proc: fix loclist access for Position Independent Executables 2020-01-02 09:30:55 -08:00
aarzilli
dd2a59a9a4 proc/native: call ElfUpdateSharedObjects after Attach
When attaching to a process in linux ElfUpdateSharedObjects will be
called for the first time during the call to updateThreadList,
unfortunately it won't do anything because the dynamic section of the
base elf executable needs to have been read first and that's done when
we initialize the BinaryInfo object (which happens later during the
call to initialize).
2020-01-02 09:30:22 -08:00
aarzilli
348432c3b9 debugger: fix off-by-one error in ListDynamicLibraries 2020-01-02 09:30:22 -08:00
aarzilli
4a6b53c08c proc: build disassemblers unconditionally
Remove build tags from disassembler code, move architecture specific
functionality inside proc.Arch.
This is necessary because Delve should be able to debug corefiles
cross-platform.
2020-01-02 09:29:01 -08:00
aarzilli
8ed7a840e7 tests: disable function call injection tests on macOS on Travis-CI
Updates #1802
2020-01-02 09:20:12 -08:00
spacewander
a7f598057f Documentation/cli: Add the configuration and command history file
Close #1714.
2020-01-02 09:18:58 -08:00
hengwu0
d2be791466 test: add reason for skipping TestDisassembleGlobalVars on arm64 (#1778) 2019-12-11 10:33:20 -08:00
aarzilli
7de5369508 Revert "travis: exclude builds of Go other than most recent from ARM64 builds"
This reverts commit 35d168ac16527dcb19f8e8761ad7c5de24b56eca.

See: https://github.com/go-delve/delve/pull/1786#issuecomment-562160264
2019-12-10 07:55:57 -08:00
aarzilli
035190c292 debugger: fix nil pointer dereference in FunctionReturnLocations
Fixes #1787
2019-12-10 07:55:12 -08:00
aarzilli
35d168ac16 travis: exclude builds of Go other than most recent from ARM64 builds 2019-12-04 07:03:50 -08:00
Derek Parker
c119e40c6d pkg/terminal: Fix exit status
During a debug session if the process exited and then the user quit the
debug session, the process exit message would display again and Delve
would exit non-zero (specifically with exit code 1) despite nothing
going wrong.

This patch fixes this so that Delve exits with a clean 0 status and the
process exit message is not printed yet again.
2019-12-03 08:39:07 +01:00
aarzilli
7e2660e7de vendor: Fix inconsistent vendoring
The ARM64 left the vendor directory in an inconsistent state, go1.13
doesn't care so we didn't catch it but go1.14 does.
2019-12-02 07:08:07 -08:00
吴衡10223547
23d080abe3 proc_test: fix and remove skip-code of Detach tests on arm64
* fix TestKill test:
It will fail in Open /proc/pid/ sporadicly since there is no any sync between signal sended(tracee handled) and open /proc/%d/, especially in some weak arm64 cpu. Skip /proc check on arm64.
* remove skip-code of Detach tests.
2019-11-27 11:07:31 -08:00
hengwu0
6a9a8c9770 nits fix: Fix code format and english grammar
* move firstPCAfterPrologueDisassembly() and checkPrologue() out of arch independent.
* s/do not/does not/ (for all tests)
2019-11-27 11:07:31 -08:00
hengwu0
da2028dcdf test: fix tests on arm64
* remove skip-code of some arm64 tests, which implemented.
* fix errors in testsuits for arm64
2019-11-27 11:07:31 -08:00
hengwu0
f88899ea97 proc/native: fix SetCurrentBreakpoint on arm64
arm64 use hardware breakpoint, and it will not set PC to the next instruction like amd64. Let adjustPC always fasle in arm64, in case of infinite loop.
2019-11-27 11:07:31 -08:00
hengwu0
b34936f5cc proc: fix arm64 prologue 2019-11-27 11:07:31 -08:00
hengwu0
1c9cfc035b test: skip failed tests on arm64
Skip the failed tests that don't work on arm64.
2019-11-27 11:07:31 -08:00
jim
36574e34fe proc: fix delve hang on arm64 BRK instruction
PtraceSingleStep cannot step over BRK instruction(linux-arm64 feature or kernel bug maybe).
GDB has the same question too, it will hang on forever with c command or execute that instruction indefinitely with s,si command.

SetPC+BreakpointSize to jump over BRK to prevent repeating the instruction indefinitely.

Co-authored-by: tykcd996 <tang.yuke@zte.com.cn>
Co-authored-by: hengwu0 <wu.heng@zte.com.cn>
2019-11-27 11:07:31 -08:00
hengwu0
2a68058b4a delve: support linux-arm64 native debug(#118)
* delve now can be built to arm64-arch and running on linux-arm64 OS.
* arm64 general-purpose registers have completed.
* arm64 disasm has completed.

Co-authored-by: tykcd996 <tang.yuke@zte.com.cn>
Co-authored-by: hengwu0 <wu.heng@zte.com.cn>
2019-11-27 11:07:31 -08:00
hengwu0
be98a8503c proc/native: separate amd64-arch code
As proc/native is arch related, it should move some functions to arch-relate file. And this patch can help us to separate the architecture code, make code tidy. So that the merge of arm64 code later will not cause chaos.(#118)
2019-11-27 11:07:31 -08:00
hengwu0
eb6d01a63e proc/native: always remove breakpoints when detaching (#1771) (#1772)
the tracee may coredumped after detach: trace/breakpoint trap (core dumped).
2019-11-27 11:06:51 -08:00
Alessandro Arzilli
151de14d08 proc: support DW_AT_go_package_name (#1757)
Use the name specified by compile unit attribute DW_AT_go_package_name,
introduced in Go 1.13, to map package names to package paths, instead of
trying to deduce it from names of types.
Also use this mapping for resolving global variables and function
expressions.
2019-11-25 09:10:18 -08:00
Alessandro Arzilli
834591f4b6 proc: make ignorable errors reading debug_info look less scary (#1767)
We used to not do anything say anything at all about them anyway.
2019-11-25 09:06:30 -08:00
Michael Stapelberg
a22dc3ff38 service: verify local connections originate from the same UID (#1764)
This prevents other users on the same machine (e.g. a production server) from
using dlv under the credentials of another user, which poses a security issue.
2019-11-25 09:05:45 -08:00
nd
3c26681075 cmd/dlv: Don't stop headless server on SIGINT on windows (go-delve#1745) (#1746)
This allows to execute and debug signal handlers in inferior.
2019-11-13 09:39:14 -08:00
Derek Parker
c902522a8c pkg/proc,pkg/dwarf: Introduce loclist package
Move the loclist code out of proc and into its own package in
`pkg/dwarf`.
2019-11-13 18:30:21 +01:00
Alessandro Arzilli
5da5eee10d proc/core: enable PIE tests (#1755)
* Makefile: discard stderr of "go list"

In module mode "go" will print messages about downloading modules to
stderr, we shouldn't confuse them for the real command output.

* proc/core: enable PIE tests

PIE tests for core files were never enabled due to a missing flag.Parse
call.
2019-11-12 07:26:20 -08:00
Alessandro Arzilli
4fc8528997 proc/linux: do not route signals to threads while stopping (#1752)
* proc/linux: do not route signals to threads while stopping

While we are trying to stop the process we should not route signals
sent to threads because that will result in threads being resumed.
Also keep better track of which threads are stopped.

This fixes an incompatibility with Go 1.14, which sends a lot of
signals to its threads to implement non-cooperative preemption,
resulting in Delve hanging waiting for an already-stopped thread to
stop.

In principle however this bug has nothing to do with Go 1.14 and could
manifest in any instance of high signal pressure.

* Makefile: discard stderr of "go list"

In module mode "go" will print messages about downloading modules to
stderr, we shouldn't confuse them for the real command output.
2019-11-12 06:58:54 -08:00
Alessandro Arzilli
79143468ea gdbserial: propagate unhandled signals back to a specific thread (#1749)
Instead of just sending unhandled signals back to the process send them
to the specific thread that received them.
This is important because:

1. debugserver does not appear to support the vCont;CXX packet without
specifying a target thread
2. the non-cooperative preemption change in an upcoming version of Go
(1.15?) will require sending signals to a specific thread.

Fixes #1744
2019-11-08 13:02:12 -08:00
Alessandro Arzilli
e8d4ed7ece service,terminal: support logical breakpoints (#1742)
Changes CreateBreakpoint to create a logical breakpoint when multiple
addresses are specified, FindLocation and the api.Location type to
return logical locations and the cli to support logical breakpoints.
2019-11-04 08:43:12 -08:00
Alessandro Arzilli
222deeec36 proc,debugger: implement logical breakpoints (#1717)
Modifies FindFileLocation, FindFunctionLocation and LineToPC as well as
service/debugger to support inlining and introduces the concept of
logical breakpoints.

For inlined functions FindFileLocation, FindFunctionLocation and
LineToPC will now return one PC address for each inlining and one PC
for the concrete implementation of the function (if present).

A proc.Breakpoint will continue to represent a physical breakpoint, at
a single memory location.

Breakpoints returned by service/debugger, however, will represent
logical breakpoints and may be associated with multiple memory
locations and, therefore, multiple proc.Breakpoints.

The necessary logic is introduced in service/debugger so that a change
to a logical breakpoint will be mirrored to all its physical
breakpoints and physical breakpoints are aggregated into a single
logical breakpoint when returned.
2019-11-01 12:41:06 -07:00
Alan Yee
1c5e8abf34 Update install.md
Maintain naming convention
2019-10-30 09:38:21 +01:00
aarzilli
5a947bceff proc: always resolve array types even if they don't appear in the
program

When evaluating type casts always resolve array types.

Instead of resolving them by looking up the string in debug_info
construct a fake array type so that a type cast to an array type always
works as long as the element type exists.

We already did this for byte arrays, this commit extends this to any
array type. The reason is that we return a fake array type (that
doesn't exist in the target program) for the array of a channel type.

Fixes #1736
2019-10-29 09:04:36 +01:00
Alessandro Arzilli
f1a5e654ff proc: fix breakpoint confusion on resume (#1738)
Fixes a case of breakpoint confusion on resume caused by having two
breakpoints one byte apart. This bug can cause the target program to
resume execution a single byte inside an instruction and crash either
with SIGILL or a SIGSEGV, or misbehave (depending on how the truncated
instruction is decoded).

native.(*Thread).StepInstruction should call FindBreakpoint using
adjustPC==false because at that point the PC of the thread should
already have been adjusted (and it has been).
2019-10-28 14:55:32 -07:00
Alessandro Arzilli
1c96680c6b Documentation: add another starlark example script (#1731)
This script re-runs a program until it fails or hits a breakpoint, it
is useful for debugging non-deterministic problems when used in
conjunction with rr.
2019-10-25 09:59:52 -07:00
Alessandro Arzilli
ccf57b9454 terminal: let 'list' work on file:line exprs that don't map to code (#1728)
Make the 'list' command succeed for file:line expressions that don't
map to any instruction.
Adds an argument to the FindLocations API call that makes FindLocations
return if the expression can be parsed, even if it doesn't end up
matching any instruction in debug_line.
2019-10-25 09:59:18 -07:00
Alessandro Arzilli
d064d1fe05 service: add min/max supported ver and target ver to GetVersion resp (#1718)
Fixes #1713
2019-10-22 16:39:22 -07:00
Derek Parker
6c8c4508db all: Bump to v1.3.2
Thanks to everyone who contributed!
2019-10-22 18:13:41 +02:00
Alessandro Arzilli
6b20e880e2 *: add option to re-record recorded targets (#1702)
Adds a '-r' option to the 'restart' command (and to the Restart API)
that re-records the target when using rr.

Also moves the code to delete the trace directory inside the gdbserial
package.
2019-10-21 11:48:04 -07:00
Alessandro Arzilli
1381454362 proc: GetG should check that loc isn't nil before accessing its members (#1712)
Updates #1711
2019-10-21 10:44:25 -07:00
Alessandro Arzilli
6239f956a3 Documentation: add new example to starlark documentation (#1716) 2019-10-21 10:43:44 -07:00
Alessandro Arzilli
45fb477379 proc: better handling of bad DW_TAG_inlined_subroutine without debug_line (#1722)
Avoid crashing with nil pointer dereference, signal error instead.

Fixes #1720
2019-10-21 10:43:03 -07:00
TerrySolar
52c395eb64 fix panic when config value set 0 (#1723) 2019-10-21 10:40:37 -07:00
Alessandro Arzilli
fb3941324b dwarf/line: fix state machine behavior with multi-sequence units (#1681)
A compile unit can produce a debug_line program consisting of multiple
sequences according to the DWARF standard. The standard guarantees that
addresses monotonically increment within a single sequence but
different sequences may not follow this rule.

This commit changes dwarf/line (in particular PCToLine and
AllPCsBetween) to support debug_line sections containing units with
multiple sequences.

TestPCToLine needs to be changed so that it picks valid addresses (i.e.
addresses covered by a sequence) as values for basePC, instead of just
rounding.

Fixes #1694
2019-10-07 09:54:32 -07:00
Alessandro Arzilli
ca6c6301cd proc: refactor dwarf function information loading (#1685)
Splits the code that loads function information from debug_info into
multiple functions.
This makes the changes needed to implement logical breakpoints easier
to make.
2019-10-07 09:38:47 -07:00
Alun Evans
36d688bf14 pkg/terminal: Fix starlark map iteration for maps > 64 entries (#1699)
* Fix starlark map iteration for maps > 64 entries

* Fix TestMapEvaluation
2019-10-07 09:35:58 -07:00