Commit Graph

1219 Commits

Author SHA1 Message Date
aarzilli
ec8dc3a10d proc,vendor: show global variables in disassembly
updates vendored version of x86asm, adds a symbol lookup function to
pass to the disassembler.

This will show global symbol names in the disassembly like go tool
objdump does.
2018-03-22 10:01:00 -07:00
aarzilli
84ce278352 proc: allow evaluating constants specified with a partial package path
Fixes #1151
2018-03-20 09:46:35 -07:00
aarzilli
918ab760a4 proc/core: Make TestCoreFpTest less flaky
Registers XMM1 and XMM2 get sometimes clobbered between the time we set
them and the panic. There is no guarantee that they won't in the go
spec so we shouldn't expect any register to keep its value. However
since this seems to only affect 1 and 2 let's try to use 9 and 10
instead.
2018-03-20 09:34:05 -07:00
Josh Soref
1d3b41f64e all: Spelling 2018-03-20 11:05:35 +01:00
Giuseppe
2ba27af6e7 Documentation: make install must run in workspace 2018-03-15 17:56:39 -07:00
aarzilli
449b3cedef proc: manual stop requests should clear internal breakpoints
Fixes #1145
2018-03-08 12:02:29 -08:00
aarzilli
cd5203e305 proc: fix reading of empty strings in core files
Every time we read an empty string we accidentally issue a read for 0
bytes at address 0, this is fine for real memory but the core file
reader doesn't like it.

Fixes an issue reported on the mailing list.
2018-03-08 11:58:03 -08:00
aarzilli
bef0d05d16 travis-ci: Update to go 1.10 2018-03-07 14:50:50 -08:00
aarzilli
6c973bf230 proc/native: move halt to os specific struct
The windows backend isn't using the halt field so it can be removed
there.
On linux it can be replaced with a parameter passed to trapWait.
2018-03-06 09:06:19 -08:00
aarzilli
8561db8c2c proc/native: move Thread.running to os struct
Windows and macOS aren't using this field so move it to the os-specific
thread struct and remove it from everything except linux.
2018-03-06 09:06:19 -08:00
aarzilli
f26bb0b875 proc/native: refactor Halt/setCurrentBreakpoint call pair 2018-03-06 09:06:19 -08:00
aarzilli
e47599d09a proc: remove proc.Process.Halt
The proper way to stop a running process is to call RequestManualStop,
which most code already did with the exception of some old test code.
2018-03-06 09:06:19 -08:00
aarzilli
ac1aa98378 proc: remove proc.Process.Kill
the proper way to kill the target process is to pass true to Detach.
Everything except old test code did that already.
2018-03-06 09:06:19 -08:00
aarzilli
f32ce1b21d proc/native: fix race condition between Halt and process death (linux)
If a breakpoint is hit close to process death on a thread that isn't
the group leader the process could die while we are trying to stop it.

This can be easily reproduced by having the goroutine that's executing
main.main (which will almost always run on the thread group leader)
wait for a second goroutine before exiting, then setting a breakpoint
on the second goroutine and stepping through it (see TestIssue1101 in
proc_test.go).

When stepping over the return instruction of main.f the deferred
wg.Done() call will be executed which will cause the main goroutine to
resume and proceed to exit. Both the temporary breakpoint on wg.Done
and the temporary breakpoint on the return address of main.f will be in
close proximity to main.main calling os.Exit() and causing the death of
the thread group leader.

Under these circumstances the call to native.(*Thread).waitFast in
native.(*Thread).halt can hang forever due to a bug similar to
https://sourceware.org/bugzilla/show_bug.cgi?id=12702 (see comment in
native.(*Thread).wait for an explanation).

Replacing waitFast with a normal wait work in most circumstances,
however, besides the performance hit, it looks like in this
circumstances trapWait sometimes receives a spurious SIGTRAP on the
dying group leader which would cause the subsequent call to wait in
halt to accidentally reap the process without noting that it did exit.

Instead this patch removes the call to wait from halt and instead calls
trapWait in a loop in setCurrentBreakpoints until all threads are set
to running=false. This is also a better fix than the workaround to
ESRCH error while setting current breakpoints implemented in 94b50d.

Fixes #1101
2018-03-06 09:06:19 -08:00
aarzilli
fbd152f6a8 Documentation: remove homebrew as an install method
The formula is broken and produces an endless stream of duplicate bug
reports yet nobody steps up to fix it. Using the formula isn't
necessary and hasn't been in almost a year, the maintainers of delve
aren't using it and the original maintainer of the formula vacated.
2018-03-05 10:10:17 -08:00
aarzilli
dc7a4ccb16 proc: support interface type resolution for packages containing a dot
If the last entry of the package path contains a '.' the corresponding
DIEs for its types will replace the '.' character with '%2e'. We must
do the same when resolving the package path of the concrete type of an
interface variable.

Fixes #1137
2018-03-05 10:07:11 -08:00
Derek Parker
4da05d62cd pkg/proc: Fix reporting of 'go' statement (#1136)
Fixes a bug where the 'go' statement that created a goroutine was
incorrectly reported.

Fixes #1135
2018-03-05 10:40:42 +01:00
Derek Parker
678576d2ce config: Return handle for created default config (#1130)
Previously the file handle for the newly created default config was
being closed and thrown away as opposed to returned to the caller to
finish setting up config for the rest of the process. This patch changes
to return a handle to the newly created config so setup can happen as
normal. This fixes a bug where Delve can crash on first run when a
config is not present on the system.

Fixes #1129
2018-02-20 20:24:05 +01:00
Derek Parker
279a8a792e all: Bump to v1.0.0 (#1126)
Add new version to CHANGELOG and update internal version.
2018-02-19 21:33:47 +01:00
Alessandro Arzilli
0c40a8f52a dwarf/reader,proc: support DW_AT_abstract_origin (#1111)
debug_info entries can use DW_AT_abstract_origin to inherit the
attributes of another entry, supporting this attribute is necessary to
support DW_TAG_inlined_subroutine.

Go, starting with 1.10, emits DW_TAG_inlined_subroutine entries when
inlining is enabled.
2018-02-13 09:20:45 -08:00
Alessandro Arzilli
be62813261 proc: rename ManualStopRequested to CheckAndClearManualStopRequest (#1119) 2018-02-09 11:42:45 -08:00
Matt Bauer
beb3e76f33 proc: Handle race between fork and task_for_pid (#1117)
* Handle race between fork and task_for_pid

On macOS a call to fork and a subsequent call to task_for_pid will race each other. This is because the macOS kernel assigns a new proc_t structure early but the new task, thread and uthread come much later. The function exec_mach_imgact in the XNU sources contains this logic.

In a system under load or one with delays in fork processing (i.e. various security software), task_for_pid as currently called by Delve often returns the parent task. This can be seen by printing out the task number around line 86. In a normal system we would see three calls:

-> ~/go/bin/dlv --listen=localhost:59115 --headless=true --api-version=2 --backend=native exec ./___main_go -- 
Task: 9731
Task: 9731
Task: 9731
API server listening at: 127.0.0.1:59115

This is the result on a system where the race is lost:

-> ~/go/bin/dlv --listen=localhost:59115 --headless=true --api-version=2 --backend=native exec ./___main_go -- 
Task: 8707
Task: 10499
Task: 10499
could not launch process: could not get thread count

In this latter case, task 8707 is the parent task. The child task of 10499 was desired and hence the error.

This code change checks to make sure the returned task is not that of the parent. If it is, it retries. It's possible other macOS reported Delve issues are the result of this failed race.

* proc: correct formatting
2018-02-07 10:25:34 -08:00
aarzilli
62fe792bfd proc: disable caching for variables with an extended location
Our current frame caching strategy doesn't handle extended locations
expressions correctly, disable it on variables that don't have a simple
address.
2018-01-31 06:39:44 -08:00
aarzilli
03139e8f62 terminal: disable file path case normalization on macOS
Fixes #1088
2018-01-28 01:50:02 -08:00
aarzilli
9bb8b8c9fa gdbserial: fix rr output parsing to support rr 5.1.0 2018-01-27 12:13:04 -08:00
aarzilli
045763ef04 terminal: do not crash when process exits during next
Fixes #1090
2018-01-27 11:23:51 -08:00
aarzilli
74d330a013 proc: Remove unused code 2018-01-26 12:58:21 -08:00
aarzilli
91fdc5202d proc_test: clean some repeated patterns in proc_test 2018-01-26 12:58:21 -08:00
Graham King
0b41a525f6 Documentation: Document passing flags with --. (#1096)
Document how to pass flags to the cli program being debugged.
2018-01-25 11:59:02 -08:00
Lucas Molas
c38d6755f0 Documentation: update usage docs (#1095) 2018-01-25 11:54:00 -08:00
Alessandro Arzilli
550e7d384d core_test: fix TestCoreFpRegisters on go1.9 (#1082)
* core_test: fix TestCoreFpRegisters on go1.9

It was broken by 7bec20e5fca48552b004fc8776dd9e6502a11706

* travis-ci: switch to VM builders for linux
2018-01-24 11:42:35 -08:00
Alessandro Arzilli
bec6a65b15
proc,prettyprint: guard against autodereferenced escaped pointers (#1077)
Much like the bug in issue #1031 and commit
f6f6f0bf13e4c708cb501202b83a6327a0f00e31 pointers can also escape to
the heap and then have a zero address (and no children) when we
autodereference.

1. Mark autodereferenced escaped variables with a 0 address as
   unreadable.
2. Add guards to the pretty printers for unsafe.Pointer and pointers.

Fixes #1075
2018-01-19 15:50:28 +01:00
Alessandro Arzilli
bc77ff4534
proc_test: deflake TestSystemstackOnRuntimeNewstack (#1078)
Depending on how the runtime schedules our goroutines we can get
unlucky and have the first call to runtime.newstack we intercept be for
a different goroutine (usually the garbage collector).
Only check stacktraces that happen on the same goroutine that executed
main.main.
2018-01-19 15:42:23 +01:00
Chad Whitacre
3f3de1a9b5 Add "l" alias for list command (#1080)
Help out those of us habituated to pdb. <:^)

https://docs.python.org/3/library/pdb.html
2018-01-18 16:02:06 -08:00
Yasushi Saito
c5c41f6352 command/terminal: allow restart to change process args (#1060)
* command/terminal: allow restart to change process args

Add -args flag to "restart" command. For example, "restart -args a b c" will
pass args a b c to the new process.

Add "-c" flag to pass the checkpoint name. This is needed to disambiguate the
checkpoint name and arglist.

Reverted unnecessary changes.

* Applied reviewer comments.

Vendored argv.

Change the syntax of restart. When the target is is in recording mode, it always
interprets the args as a checkpoint. Otherwise, it interprets the args as
commandline args. The flag "-args" is still there, to handle the case in which
the user wants to pass an empty args on restart.

* Add restartargs.go.

Change "restart -args" to "restart -noargs" to clarify that this flag is used to
start a process with an empty arg.
2018-01-18 14:16:11 -08:00
Matthew Taylor
3d42ff0ad8 Documentation: renamed gogland to goland and removed beta status 2018-01-12 13:33:07 +01:00
Chad Whitacre
e949a262f1 Documentation: Fix possessive (#1072) 2018-01-07 13:54:21 -08:00
aarzilli
7bec20e5fc proc: avoid scanning system stack if it's not executing cgo
The runtime calls into g0 in many places, not necessarily using
runtime.systemstack or runtime.asmcgocall.
One example of this is the call to runtime.newstack inside
runtime.morestack.

If we stop the process while one goroutine is executing
runtime.newstack we would be unable to fully scan its stack because we
don't know that we have to switch back to the goroutine stack after
runtime.newstack.

Instead of tracking down every possible way that the runtime switches
to g0 we switch to the goroutine stack immediately after the top of the
stack, unless cgo is being executed on the systemstack.

Fixes #1066
2018-01-05 10:29:31 -08:00
aarzilli
1acc1547eb service/test: disable TestClientServerConsistentExit for rr backend
The rr backend doesn't report the exit status (the argument of the W
packet seems to always be 0).

Fixes #1067
2018-01-05 10:25:42 -08:00
Zaytsev Dmitriy
d74cfea204 Documentation: fix link to Getting Started 2018-01-04 11:17:36 -08:00
Derek Parker
01f5b3c8d0 Documentation: Improve link layout, add getting started doc (#1064)
Improve the link ordering for the main README and add a
"Getting Started" doc with basic usage information for new users.
2018-01-04 04:50:44 -08:00
aarzilli
6269244a98 proc: check error accessing g.m.curg in GetG
I saw a test failure related to this in Travis-CI, if it happens again
I would like to know what's causing it.
2018-01-03 10:03:05 -08:00
Florin Patan
480fc02d50 Remove limitation of exit notification only for specific API calls 2018-01-02 11:28:43 -08:00
aarzilli
00e473157a proc/gdbserial: remove dead threads from thread list
Fixes #1052
2018-01-02 09:32:21 -08:00
Victor Titov
690e3fff3f Documentation: add -u flag to go get 2018-01-02 05:07:12 -08:00
aarzilli
1758f8523a pkg/terminal: print DWARF location expression with whatis
Adds a configuration option (show-location-expr) that when activated
will cause the whatis command to also print the DWARF location
expression for a variable.
2017-12-20 16:34:47 -08:00
Koichi Shiraishi
926a6107ff Makefile: use go env GOPATH for install path
As of Go 1.8, allows empty GOPATH environment variable.
2017-12-20 16:34:11 -08:00
aarzilli
65d9255040 dlv_test: disable one of the checks of TestOutput on windows
Sometimes delve on Appveyor can't remove the built binary before
exiting and gets an "Access is denied" error when trying.
See: https://ci.appveyor.com/project/derekparker/delve/build/1527
2017-12-18 13:53:35 -08:00
aarzilli
0fc4ed805b dwarf/line: fix output for the last line of a compile unit
The last entry of the debug_line table is supposed to be valid for
every PC address greater than its address.
2017-12-18 10:34:31 -08:00
aarzilli
3f2335f289 debugger/locations: locspec "+0" should always evaluate to the current PC
So far we have evaluated the locspec "+0" the same way we evaluate all
"+n" locspecs, this means that we turn the current PC into a file:line
pair, then we turn back the file:line into a PC address.

Normally this is harmless, however all autogenerated code returns the
source position "<autogenerated>:1" which resolves back to the very
first autogenerated instruction in the code.

This messes up the behaviour of the "disassemble" command which uses
the locspec "+0" to figure out what code to disassemble if no arguments
are passed.

We should make +0 always resolve to the current PC (of the given scope)
so that clients can use +0 as a default locspec.
2017-12-18 10:30:53 -08:00