Commit Graph

1034 Commits

Author SHA1 Message Date
aarzilli
3dacc25d2e proc: refactor Continue to work on any Process implementation 2017-04-18 13:25:11 -07:00
aarzilli
510b7db2a7 proc: introduce IThread interface to abstract threads 2017-04-18 13:25:11 -07:00
aarzilli
97cd3a0afe proc: replaced (*Breakpoint).Clear with (*Thread).ClearBreakpoint 2017-04-18 13:25:11 -07:00
Heschi Kreinick
423bcaa83a pkg/proc: add initial data structures for core support
Core files contain a variety of memory mappings either to files or
anonymous regions stored in the core file. These regions can overlap, so
figuring out what exactly to read can be tricky. This commit contains
a data structure, SplicedMemory, which accumulates mappings and reads
from the correct sources.
2017-04-18 13:25:11 -07:00
Michael Robinson
e7fa14d21d Improve sentence in README.md. (#792) 2017-04-18 10:17:32 -07:00
Hyang-Ah Hana Kim
5bd46f34be vendor: update vendored packages (#791)
* pkg/proc: use golang.org/x/arch/x86/x86asm

instead of rsc.io/x86/x86asm

* pkg/dwarf: migrate to github.com/pkg/profile

from github.com/davecheney/profile

* scripts: keep script go files from being considered for the build

scripts/gen-*.go files are scripts for generating documentation
files and don't follow the typical Go package layout. Expected
usage is like

   go run scripts/gen-cli-docs.go

* vendor: update vendored packages

There were many changes in delve, and go tool chains since last
vendored package update. I just rerun godpes from scratch.

$ rm vendor/*
$ rm Godeps/Godeps.json
$ go list ./... | grep -v /vendor/ | grep -v /scripts/ | go get -u -t
$ go get -u github.com/mattn/go-colorable
$ go get -u github.com/mattn/go-isatty
$ go list ./... | grep -v /vendor/ | grep -v /scripts/ | godeps save
2017-04-17 14:13:00 -07:00
Alessandro Arzilli
b5a06f7aa8 proc refactoring: make stack, disassemble and eval independent of proc.Process (#786)
* proc: Refactor stackIterator to use memoryReadWriter and BinaryInfo

* proc: refactor EvalScope to use memoryReadWriter and BinaryInfo

* proc: refactor Disassemble to use memoryReadWriter and BinaryInfo
2017-04-13 16:19:57 -07:00
Derek Parker
f605716160 Bump to version v0.12.2 (#788) 2017-04-13 19:28:24 +02:00
Derek Parker
01a1b35620 cmd/dlv: Use Printf over Println
Fixes #783
2017-04-06 15:32:44 -07:00
Alessandro Arzilli
436a3c2149 proc refactor: split out BinaryInfo implementation (#745)
* proc: refactor BinaryInfo part of proc.Process to own type

The data structures and associated code used by proc.Process
to implement target.BinaryInfo will also be useful to support a
backend for examining core dumps, split this part of proc.Process
to a different type.

* proc: compile support for all executable formats unconditionally

So far we only compiled in support for loading the executable format
supported by the host operating system.
Once support for core files is introduced it is however useful to
support loading in all executable formats, there is no reason why it
shouldn't be possible to examine a linux coredump on windows, or
viceversa.

* proc: bugfix: do not resume threads on detach if killing

* Replace BinaryInfo interface with BinInfo() method returning proc.BinaryInfo
2017-04-06 11:14:01 -07:00
Alessandro Arzilli
7b19fe9e69 proc: add test for attach/detach, fix detach (#773)
Detach did not work for processes we attach to via PID.

Linux: we were only detaching from the main thread, all threads are
detached independently

Windows: we must resume all threads before detaching.

macOS: still broken.

Updates #772
2017-03-28 09:30:27 -07:00
Alessandro Arzilli
ecc2eb6da6 documentation: add gdlv to list of alternative UIs (#774) 2017-03-24 16:10:01 -07:00
Justin Clift
43aa55dee3 Add an entry for Gogland (#775) 2017-03-24 16:07:50 -07:00
Zhou Tao
28a0e5bd63 terminal: trim space in interactive console (#770)
When running interactive command in gdb, it will remove beginning space,
so do the same for dlv, which will be more convient for user
2017-03-21 14:41:02 -07:00
Hyang-Ah Hana Kim
ab7367ed2b Minor fixes to make some tests build and run (#752)
* cmd/dlv: fall back to go env GOPATH when GOPATH envvar is unset.

Since Go 1.8, GOPATH environment variable has a default value if the
environment variable is unset so not setting GOPATH is perfectly ok.
Depend on `go env` command to query Go related environment variable.

* build: update references to moved packages
2017-03-13 10:59:34 -07:00
Justin Clift
a8d11f02a8 Bash script to generate & install signing certificate for delve (#760) 2017-03-13 10:59:10 -07:00
Alessandro Arzilli
b7f9e3c73e proc: bugfix: wrong register used for CH (#763)
We only use Registers.Get besides for evaluating the argument of a CALL
instruction so this doesn't matter in practice, but it's still wrong.
2017-03-13 10:54:41 -07:00
dr2chase
bd48358de3 pkg/proc: tolerate absence of stack barriers in Go 1.9 (#762)
Stack barriers were removed in Go 1.9, and thus code that
expected various stack-barrier-related symbols to exist
does not find them.  Check for their absence and do not
crash when they are missing.  Disable stack-barrier-handling
test for 1.9 and beyond.

Fixes #754.
2017-03-13 10:53:16 -07:00
Alessandro Arzilli
97e3fc261c proc/tests: make TestStacktraceGoroutine more reliable (#764)
One of those goroutines could also conceivably be stopped on line 8.
2017-03-13 10:45:53 -07:00
Alessandro Arzilli
cda7316421 proc/tests: use Detach(true) instead of Kill in tests (#765)
The rest of the code uses Detach to "close" a proc.Process, the tests
should do the same.
Any cleanup that proc.Process needs to do can then be put inside Detach
and the tests will run it.
2017-03-13 10:44:27 -07:00
Derek Parker
bb07fc36b9 Add Go 1.8 to Travis test matrix (#747)
Dropping test coverage for Go 1.6.

Closes #741
2017-02-28 12:27:44 +01:00
aarzilli
1a4b5a05b2 terminal/command_test: improved TestIssue387
The test in question tries to 'next' over a call to wg.Done, this is
not guaranteed to succeed, if the goroutine gets suspended after
wg.Done has notified the waiting group but before returning to
main.dostuff the program could quit before the goroutine is resumed.
2017-02-22 20:39:28 +01:00
aarzilli
f2581e608a proc/test: improve TestStepParked
It was possible for TestStepParked to pick a runtime goroutine and
attempt to step it. Nothing guarantees that a goroutine other than the
ones we are using to run the code would actually ever resume before the
end of the program.

This makes the test more discerning in its choice of goroutines.
2017-02-22 20:39:28 +01:00
aarzilli
92faa95bf9 proc/stack: use BP when FDE is not available
On Windows we can sometimes encounter threads stopped in locations for
which we do not have entries in debug_frame.
These cases seem to be due to calls to Windows API in the go runtime,
we can still produce a (partial) stack trace in this circumstance by
following frame pointers (starting with BP).
We still prefer debug_frame entries when available since go functions
do not have frame pointers before go1.8.
2017-02-22 20:39:28 +01:00
aarzilli
1a68f8d351 proc/windows: handle delayed events
Sometimes windows will send us events about breakpoints we have
already removed from the code despite the fact that we go to great
lengths to avoid this already.

Change waitForDebugEvent to check that when we receive a breakpoint
event the corresponding memory actually contains an INT 3
instruction, if it doesn't ignore the event and restart the thread.
2017-02-22 20:39:28 +01:00
Alessandro Arzilli
b9bdf597b0 proc_test: TestStacktraceWithBarriers failing on go1.8 (#735)
Changes to the GC in 1.8 make this test fail because the GC isn't
inserting stack barriers into our test program anymore. This isn't the
same thing as being unable to print stacktraces in presence of stack
barriers so the test shouldn't fail.
2017-02-21 10:38:13 -08:00
Alessandro Arzilli
dd3cc63d8f proc: use original PC for Call position (#736)
The PC we have is relative to the first instruction after the CALL
instruction currently being executed.

Anyone watching a disassembly will understand what's happening if we
report the return PC, but reporting the first PC of the current line is
useless and confusing.
2017-02-16 11:20:12 -08:00
Jason Biegel
cd2a875459 Add flag support documentation (#740) 2017-02-16 11:05:48 -08:00
Derek Parker
f97bceaf48 Fix benchmark in DWARF line parser test (#737) 2017-02-13 22:24:54 +01:00
Alessandro Arzilli
74eadea71a proc: fix proc.Launch, Makefile on macOS (#734)
Fixes #732
2017-02-13 12:25:22 -08:00
Alessandro Arzilli
fc0d40144a proc/variables: fix infinite recursion with pointer loop (#725)
loadValue didn't react correctly to pointer loops going through
slice -> interface{} -> slice or pointer -> interface{} -> pointer.
2017-02-09 16:26:38 -08:00
Alessandro Arzilli
ce01a67d8b proc: fix proc.Launch on windows (#730)
Fixes #729
2017-02-09 08:44:12 -08:00
Koichi Shiraishi
997f038c47 proc: fix build on macOS (#728)
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
2017-02-09 09:13:12 +01:00
Derek Parker
53f0d24057 Move top-level packages into pkg 2017-02-08 12:17:19 -08:00
Derek Parker
26ad5f1d82 Introduce target interface 2017-02-08 12:16:51 -08:00
Alessandro Arzilli
3658d1e17c proc/variables: mark malformed maps as unreadable instead of panicking (#703)
Under currently undetermined circumstances we encounter a map type that
has a malformed buckets, oldbuckets or overflow field.
Check the type of buckets, oldbuckets and overflow before using them.

Fixes #685
2017-02-08 08:18:13 -08:00
Alessandro Arzilli
e77595ce31 Improve stacktraces (#721)
* service/rpccommon: fixed typo

* proc: test parseG while target is in runtime.deferreturn

runtime.deferreturn will change the value of curg._defer.fn in such a
way that if the target is stopped at just the right instruction it
may crash an incorrect implementation of parseG

* proc/stack: handle stack barriers correctly

Correctly handle stack barriers insterted during garbage collection.
2017-02-08 14:14:57 +01:00
Alessandro Arzilli
8c96e275d0 proc: Make sure CurrentLoc of G returned by GetG is up to date (#723)
We are already doing this in GoroutinesInfo we should be doing it for
GetG. The main consequence of not doing this is that the CurrentLoc of
DebuggerState.SelectedGoroutine is out of date compared to the location
of the thread running it.
2017-02-07 13:44:36 -08:00
Alessandro Arzilli
098457e59e Trace optimizations (#695)
* proc: Added trace benchmark

Results:

BenchmarkTrace-4   	    5000	  36195899 ns/op

* proc/linux: faster single step implementation.

BenchmarkTrace-4   	    5000	   2093271 ns/op

* proc: Cache function debug_info entries to speed up variable lookup.

BenchmarkTrace-4   	    5000	   1864846 ns/op

* proc/variables: Optimize FunctionArguments by prefetching frame

BenchmarkTrace-4   	    5000	   1815795 ns/op

* proc/variables: optimized parseG

BenchmarkTrace-4   	   10000	    712767 ns/op
2017-02-07 13:08:11 -08:00
Alessandro Arzilli
8724b3fce7 Go 1.8 compatibility (part 2) (#667)
* dwarf/line: bugfix: not all values of the state machine can be used

According to DWARF Version 3 Section 6.2 "Line Number Information" not
all the values transversed by the line numbers state machine are valid
instructions, only the ones after a "special opcode", after the
standard opcode DW_LNS_copy and the extended opcode
DW_LINE_end_sequence.

DWARF3 describes this by specifying that only the opcodes listed above
"append a row to the matrix".

Additionally the implementation of DW_LNS_const_add_pc was wrong.

Fixes #664

* dwarf/line: fixed test failing with go1.8

* service/test: fix prologue detection tests

The conditions about which function prologue is emitted by the compiler
changed in go1.8, changed the test program so that callme2 will still
have a prologue under go1.8.

* service/test: fix step test

compilation units are linked in a different order under go1.8 so the
code of 'fmt' is no longer located after 'main' in the executable,
changed the tests so that they don't rely on this assumption anymore.

* proc: change runtime.Breakpoint support for go1.8

Before 1.8 it was sufficient to step twice to exit a
runtime.Breakpoint(), but go 1.8 added frame pointer tracking to small
functions making runtime.Breakpoint longer.
This changes runtime.Breakpoint handling in Continue to single step as
many times as are needed to exit runtime.Breakpoint.

* proc/test: fix TestIssue561 for go1.8
2017-02-07 13:07:18 -08:00
Alessandro Arzilli
025ae26140 Added jodosha/vim-godebug to Documentation/EditorIntegration.md (#722) 2017-02-07 13:05:10 -08:00
Alessandro Arzilli
d89d115ef9 proc/variables: support NaN/Inf float values (#706)
Unfortunately go/constant does not support NaN and Inf float values so
we need to store this information alongside.

Fixes #705
2017-01-20 14:22:36 -08:00
Derek Parker
449b276fe1 Bump to version 0.12.1 2017-01-11 11:37:04 -08:00
Derek Parker
2fb8129fa0 version: Fix version output format 2017-01-11 11:34:54 -08:00
Derek Parker
da39bcd0d7 Bump to version 0.12.0 2017-01-11 11:27:23 -08:00
Alessandro Arzilli
1afcc6c189 Fix for #614 and #683 (#687)
* service: Prevent panics from crashing delve and killing the target

Catch all unrecovered proc and debugger panics in the service layer and
report them as errors, allow users to cleanly detach from the target
and quit.

Fixes #614

* proc: Next/Step should not panic if line info can not be found.

Fixes #683
2017-01-09 15:21:54 -08:00
Alessandro Arzilli
4dd627f669 service/debugger: bugfix: error values can not be marshalled (#697) 2017-01-09 15:19:42 -08:00
Alessandro Arzilli
fd1df948fa proc: Improved prologue detection for big stackframes (#690)
Improved prologue detection for big stackframes and added references to
the function of the compiler that inserts the prologue.
2017-01-05 11:39:34 -08:00
Alessandro Arzilli
464d6c2783 terminal: fixed typo. (#694)
* terminal: fixed typo.

* debugger: bugfix: when restaring use new process to FindFileLocation
2017-01-05 11:13:07 -08:00
Alessandro Arzilli
f4aaffbbf3 Two bugfixes regarding stale executable files, and executables changing between restarts (#689)
* service/debugger: Restore breakpoints using file:line on restart

Restoring by address can cause the breakpoint to be inserted in the
middle of an instruction if the executable file has changed.

* terminal: Warn of stale executable when printing source
2016-12-22 10:53:34 -06:00