Commit Graph

35 Commits

Author SHA1 Message Date
aarzilli
8f1fc63da8 proc,service,terminal: read defer list
Adds -defer flag to the stack command that decorates the stack traces
by associating each stack frame with its deferred calls.

Reworks proc.next to use this feature instead of using proc.DeferPC,
laying the groundwork to implement #1240.
2018-07-24 14:58:56 -07:00
aarzilli
2925c0310a *: function call injection for go 1.11
Implements the function call injection protocol introduced in go 1.11
by https://go-review.googlesource.com/c/go/+/109699.

This is only the basic support, see TODO comments in pkg/proc/fncall.go
for a list of missing features.

Updates #119
2018-07-13 13:37:54 -07:00
aarzilli
9a216211d3 proc,terminal,service: let headless instances run without connected clients
This pull request makes several changes to delve to allow headless
instancess that are started with the --accept-multiclient flag to
keep running even if there is no connected client. Specifically:

1. Makes a headless instance started with --accept-multiclient quit
    after one of the clients sends a Detach request (previously they
    would never ever quit, which was a bug).
2. Changes proc/gdbserial and proc/native so that they mark the
    Process as exited after they detach, even if they did not kill the
    process during detach. This prevents bugs such as #1231 where we
    attempt to manipulate a target process after we detached from it.
3. On non --accept-multiclient instances do not kill the target
    process unless we started it or the client specifically requests
    it (previously if the client did not Detach before closing the
    connection we would kill the target process unconditionally)
4. Add a -c option to the quit command that detaches from the
    headless server after restarting the target.
5. Change terminal so that, when attached to --accept-multiclient,
    pressing ^C will prompt the user to either disconnect from the
    server or pause the target process. Also extend the exit prompt to
    ask if the user wants to keep the headless server running.

Implements #245, #952, #1159, #1231
2018-06-26 10:32:40 -07:00
Derek Parker
a208c89719 *: Use structured logging
Implements structured logging via Logrus. This gives us a logger per
boundry that we care about, allowing for easier parsing of logs if users
have more than one log option enabled. Also, cleans up a lot of
conditionals in the code by simply silencing the logger at creation as
opposed to conditionally logging everywhere.
2018-06-22 09:45:10 +02:00
aarzilli
60c58acb8e proc,service: display return values when stepping out of a function
Displays the return values of the current function when we step out of
it after executing a step, next or stepout command.

Implementation of this feature is tricky: when the function has
returned the return variables are not in scope anymore. Implementing
this feature requires evaluating variables that are out of scope, using
a stack frame that doesn't exist anymore.

We can't calculate the address of these variables when the
next/step/stepout command is initiated either, because between that
point and the time where the stepout breakpoint is actually hit the
goroutine stack could grow and be moved to a different memory address.
2018-06-12 11:35:56 +02:00
aarzilli
119cb93460 tests: cache and delete fixtures built with non-zero flags 2018-04-19 13:28:11 -07:00
Josh Soref
1d3b41f64e all: Spelling 2018-03-20 11:05:35 +01: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
Florin Patan
480fc02d50 Remove limitation of exit notification only for specific API calls 2018-01-02 11:28:43 -08:00
aarzilli
9ee21686e6 proc: report errors when loading executable on attach
Fixes #940
2017-08-30 11:20:20 -07:00
aarzilli
1128c26b87 cmd/dlv: do not pass "linkmode internal" for windows on go1.9 and later
go1.9 no longer needs "linkmode internal" on windows.

Fixes #755
Fixes #477
Fixes #631
2017-08-01 11:20:25 -06:00
Alessandro Arzilli
04adb46ccb tests: remove rr trace directory after running tests (#934)
Can't get the trace directory from the server after we disconnect from
it.
2017-08-01 11:14:11 -06:00
Alessandro Arzilli
e0ac447a75 debugger/locations: if locspec isn't found try interpreting it as expr (#858)
If the user tries to list the contents of a function pointer but
forgets the '*' operator the location lookup will fail and result in a
unhelpful "location not found" error.

Instead if the location lookup fails we should try interpreting the
locspec as if it was preceded by '*'.
2017-07-26 12:52:51 -06:00
aarzilli
e9e0830054 debugger: do not fail continue when breakpoint var can't be evaluated
If one of the expressions that are automatically evaluated when a
breakpoint is hit can't be evaluated breakpoint information collection
should continue and the error should be returned for that specific
expression instead of the whole command.
2017-07-26 12:50:09 -06:00
Florin Pățan
32a005de2b Fix various issues detected by megacheck (#880)
* Fix various issues detected by megacheck

I've ran honnef.co/go/tools/cmd/megacheck and fixed a few of the
things that came up there.

* Cleanup using Gogland
2017-06-29 11:15:59 -07:00
aarzilli
cbf3e1c676 debugger: collect breakpoint information on next/step/stepout
A next/step/stepout command could hit a normal breakpoint, decorated
with a list of variables to evaluate, if that happens the variable
should be evaluated just as if the breakpoint was hit by a continue.
2017-06-13 10:22:47 +02:00
Alessandro Arzilli
a843f7944e proc/gdbserial: mozilla rr support (#804)
Implements #727
2017-05-05 15:17:52 -07:00
Nathan Bruer
43f26fb4d6 pkg/proc: Fixed delve's version extraction to allow propsals (#798)
Go recently introduced proposal tags to their version tags, we
are simply allowing delve to handle it appropriately.

See:
0954fdd51e
2017-04-21 17:45:20 -07:00
Hana Kim
92dad944d7 service/test: change test package name to service_test
According to https://golang.org/cmd/go/#hdr-Test_packages
service_test is more appropriate becuase this directory contains
no non-test code and the intention is to compile these *_test.go
files as a separate package and link/run with the main test package.
2017-04-19 10:09:36 -07:00
aarzilli
c8d9352522 proc: Implement target.Interface for gdbserver backend 2017-04-18 13:25:11 -07: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
Derek Parker
53f0d24057 Move top-level packages into pkg 2017-02-08 12:17:19 -08: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
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
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
aarzilli
8f0646e426 proc: load more registers
Adds ability to load x87, SSE and AVX registers.

Fixes #666
2016-12-19 21:29:45 +01:00
aarzilli
0f4b5150c3 proc, terminal: stepout command
Command to step out of the currently executing function.

Implements #358
2016-10-23 17:09:26 +02:00
Alessandro Arzilli
6e882c50fa debugger/locations: prioritize exact matches of function names (#651)
If the location specification matches the name of a function exactly
return that function as a match event if the expression matches other
functions as well.

Without this some functions, like math/rand.Intn are unmatchable.
2016-10-21 22:04:03 -07:00
aarzilli
80336e57e0 Replaced net/rpc with custom version
This version preserves the order of requests, allows the
client to switch between API versions and introduces a
way to send notifications to the client (see TODO item at:
proc/proc_linux.go:325).

Fixes #523, #571
2016-07-02 12:16:06 +02:00
aarzilli
323c0450d1 tests: fixed version check for go1.7 to include beta versions 2016-06-22 12:38:40 +02:00
Alessandro Arzilli
9bc6ad4f46 Go 1.7 compatibility (#524)
* tests: update to cope with go1.7 SSA compiler

* de-vendored golang.org/x/debug/dwarf

We need our own tweaked version

* dwarf/debug/dwarf: always use the entry's name attribute

Using the name attribute leads to better type names as well as fixes
inconsistencies between 1.5, 1.6 and 1.7.

* proc: Updated loadInterface to work with go1.7

go1.7 changed the internal representation of types, removing the string
field from runtime._type.
Updated loadInterface to use the new str field.
2016-05-29 12:20:09 -07:00
aarzilli
a1ac17f16c service/test: Added test for issue #528
This issue is fixed by go 1.7, the test will only run on newer versions
of the compiler.
2016-05-18 09:07:19 +02:00
Alessandro Arzilli
473b66387c proc: Improvements to Variable printing (#444)
* service/api: Removed unused fields of service/api.Function

* proc/eval: Set return variable name to input expression

* all: fine-grained control of loadValue for better variable printing

Makes proc.(*Variable).loadValue loading parameters configurable
through one extra argument of type LoadConfig.
This interface is also exposed through the API so clients can control
how much of a variable delve should read.
2016-04-24 10:15:39 -07:00
Alessandro Arzilli
af4798e2a9 service,terminal: APIv2 plus method to select API version (#460)
New API version with better backwards compatibility plus mechanism to
select the API version that a headless instance should use.

Adds service/test/cmd/typecheckrpc.go to type check the RPC interface.
2016-04-18 12:20:20 -07:00