Commit Graph

272 Commits

Author SHA1 Message Date
Alessandro Arzilli
9a3c9ebad1
proc/*: add launch option to disable ASLR (#2202)
Fixes #1847
2020-10-21 12:50:52 -07:00
Suzy Mueller
5632cf92be
service/dap: add "panic" and "fatal error" as stopped reasons (#2186)
* service/dap: add "panic" and "fatal error" as stopped reasons

The unrecovered panic and fatal throw breakpoints are not set by the
user. We now check for these special breakpoints and send appropriate
stopped reasons to the client.

* Add getter for StopReason

* Set threadID and stop reason correctly

If there is no selected goroutine, no goroutine ID should be set in
the stopped event.

The stopped reason can be better determined using the process
StopReason.

* Update panic breakpoint on next test to work with Go 1.13 runtime

When running panic.go with Go1.13, the next line that is stepped to
after panic('boom') is the defer function in the runtime package. The
unrecovered panic breakpoint is not hit until after several steps.

The test now steps until the breakpoint is hit, or the program terminates
without hitting the unrecovered panic breakpoint, in which case it fails.

* Skip breakpoint on next test in < Go 1.14
2020-10-07 08:24:40 -07:00
Alessandro Arzilli
310a124dba
service/*: remove threadID argument of (*Debugger).PackageVariables (#2182)
* Travis-CI: add ignorechecksum option to chocolatey command

Looks like a configuration problem on chocolatey's end.

* service/*: remove threadID argument of (*Debugger).PackageVariables

Which thread is used doesn't make any difference to the list of package
variables that is returned and this option was only ever used by an old
v1 API call.
2020-09-24 08:02:29 -07:00
polinasok
4980fff8ce
service/dap: Add support for package globals to scopes/variables requests (#2160)
* Support global variables

* Respond to review comments

* Clarify comment

* Add more details to test error messages

* Remove flaky main..inittask checks

* Rename globals flag to match vscode-go

* Normalize filepath with slash separator

* Improve handling for unknown package

* Tweak error message

* More refactoring, normalization and error details to deal with Win test failures

* Clean up optional launch args processing

* Add CurrentPackage to debugger and use instead of ListPackagesBuildInfo

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2020-09-15 13:14:55 -07:00
aarzilli
6ef7aa8743 service: move some type conversions from service/debugger to rpc pkgs
Move the conversion of some 'proc' types from service/debugger into
service/rpc1 and service/rpc2. The methods of
service/debugger.(*Debugger) are also used by service/dap which
requires these types to be converted differently and converting them
twice is inefficent and doesn't make much sense.

Updates #2161
2020-09-10 16:19:04 +02:00
Alessandro Arzilli
12009e9833
proc/*,service: replace uses of uintptr with uint64 (#2163)
Since proc is supposed to work independently from the target
architecture it shouldn't use architecture-dependent types, like
uintptr. For example when reading a 64bit core file on a 32bit
architecture, uintptr will be 32bit but the addresses proc needs to
represent will be 64bit.
2020-09-09 10:36:15 -07:00
aarzilli
7555d1c063 cmd,proc,terminal,debugger: Support default file descriptor redirects
Adds features to support default file descriptor redirects for the
target process:

1. A new command line flag '--redirect' and '-r' are added to specify
   file redirects for the target process
2. New syntax is added to the 'restart' command to specify file
   redirects.
3. Interactive instances will check if stdin/stdout and stderr are
   terminals and print a helpful error message if they aren't.
2020-09-01 21:50:27 +02:00
Álex Sáez
95e7cafd0c
terminal/command: Add 'reload' command (#1971)
* terminal/command: Add 'reload' command

These changes add the 'reload' command, which allows us to rebuild the project
and start the debugging session again. Currently, if the project's code is
updated while debugging it, Delve shows the new source code, but it's still
running the old one. With 'reload', the whole binary is rebuilt, and the
process starts again.

Fixes #1551

* Remove unnecessary print

Changes to be committed:
      modified:   pkg/terminal/command.go

* Add tests and refactor the code

Changes to be committed:
      modified:   cmd/dlv/cmds/commands.go
      modified:   go.mod
      modified:   pkg/terminal/command.go
      modified:   service/config.go
      modified:   service/debugger/debugger.go
      modified:   service/test/integration2_test.go

* Fix typo in the comment

Changes to be committed:
      modified:   service/debugger/debugger.go

* Fix typo in the name of the variables

The variables are local therefore the capitalization is not needed

Changes to be committed:
      modified:   cmd/dlv/cmds/commands.go

* Call GoTestBuild

Also, remove the := to avoid redeclaration

* Change the Kind in the tests

Change from debugger.ExecutingGeneratedTest to
debugger.ExecutingGeneratedFile for consistency.
We are generating a real binary instead of a test
one so ExecutingGeneratedFile makes more sense here.

Changes to be committed:
      modified:   service/test/integration2_test.go

* Avoid breakpoints based on addresses

Changes to be committed:
      modified:   service/debugger/debugger.go

* Update the rebuild behaviour

There are a few cases where we can't rebuild the binary because we don't
know how it was build.

Changes to be committed:
      modified:   service/debugger/debugger.go

* Fix typos and update documentation

Changes to be committed:
      modified:   Documentation/cli/README.md
      modified:   pkg/terminal/command.go
      modified:   service/config.go
      modified:   service/debugger/debugger.go

* Fix typo

* Remove variables

They were added to the debugger.Config

* Rename variable

Rename Kind to ExecuteKind to make it more accurate

Changes to be committed:
      modified:   cmd/dlv/cmds/commands.go
      modified:   service/debugger/debugger.go
      modified:   service/test/integration2_test.go
2020-06-05 11:03:09 -07:00
Alessandro Arzilli
80b5b95182
proc/*: move Set/Clear Breakpoint methods to Target (#2064) 2020-06-03 11:14:14 -07:00
Alessandro Arzilli
200994bc8f
proc/*: only load floating point registers when needed (#1981)
Changes implementations of proc.Registers interface and the
op.DwarfRegisters struct so that floating point registers can be loaded
only when they are needed.
Removes the floatingPoint parameter from proc.Thread.Registers.
This accomplishes three things:

1. it simplifies the proc.Thread.Registers interface
2. it makes it impossible to accidentally create a broken set of saved
   registers or of op.DwarfRegisters by accidentally calling
   Registers(false)
3. it improves general performance of Delve by avoiding to load
   floating point registers as much as possible

Floating point registers are loaded under two circumstances:

1. When the Slice method is called with floatingPoint == true
2. When the Copy method is called

Benchmark before:

BenchmarkConditionalBreakpoints-4   	       1	4327350142 ns/op

Benchmark after:

BenchmarkConditionalBreakpoints-4   	       1	3852642917 ns/op

Updates #1549
2020-05-13 11:56:50 -07:00
Derek Parker
f96663a243
cmd/dlv: Fix trace output (#2038)
* cmd/dlv,debugger: Improve dlv trace and trace command output

This patch improves the `dlv trace` subcommand output by reducing the
noise that is generated and providing clearer more concise information.

Also adds new tests closing a gap in our testing (we previously never
really tested this subcommand).

This patch also fixes the `dlv trace` REPL command to behave like the
subcommand in certain situations. If the tracepoint is for a function,
we now show function arguements and return values properly.

Also makes the overall output of the trace subcommand clearer.

Fixes #2027
2020-05-13 08:38:10 +02:00
Derek Parker
682ee7ffd0 service/debugger: Rename processMutex to targetMutex
Fixes a long standing dangling TODO item.
2020-04-16 20:14:18 +02:00
Derek Parker
e5d24a96bf *: Consolidate service/debugger config
Embed the debugger config object in the service config object to avoid needless duplication of fields.
2020-04-14 21:02:38 +02:00
Derek Parker
3e60ae202b *: Add --tty flag for debug / exec
This flag allows users on UNIX systems to set the tty for the program
being debugged by Delve. This is useful for debugging command line
applications which need access to their own TTY, and also for
controlling the output of the debugged programs so that IDEs may open a
dedicated terminal to show the output for the process.
2020-04-10 09:53:13 -07:00
Lukas Spieß
eac6ebed03
Use proper spelling of Xcode (#1984) 2020-04-04 13:58:06 +02:00
Derek Parker
aa0b4eb180 *: Better error launching invalid binary format
Fixes #1310
2020-04-02 18:41:16 +02:00
aarzilli
72eeb5ae84 debugger: ClearBreakpoint should clear a logical breakpoint
Clear all physical breakpoints associated with a logical breakpoint in
ClearBreakpoint.

Fixes #1955
2020-04-02 08:53:09 -07:00
Derek Parker
ccd438c65f pkg/proc: Move proc exec funcs to Target methods 2020-03-25 17:45:12 +01:00
Alessandro Arzilli
8bb93e9ae1
proc/gdbserial,debugger: allow clients to stop a recording (#1890)
Allows Delve clients to stop a recording midway by sending a
Command('halt')
request.

This is implemented by changing debugger.New to start recording the
process on a separate goroutine while holding the processMutex locked.
By locking the processMutex we ensure that almost all RPC requests will
block until the recording is done, since we can not respond correctly
to any of them.
API calls that do not require manipulating or examining the target
process, such as "IsMulticlient", "SetApiVersion" and
"GetState(nowait=true)" will work while we are recording the process.

Two other internal changes are made to the API: both GetState and
Restart become asynchronous requests, like Command. Restart because
this way it can be interrupted by a StopRecording request if the
rerecord option is passed.
GetState because clients need a call that will block until the
recording is compelted and can also be interrupted with a
StopRecording.

Clients that are uninterested in allowing the user to stop a recording
can ignore this change, since eventually they will make a request to
Delve that will block until the recording is completed.

Clients that wish to support this feature must:

1. call GetState(nowait=false) after connecting to Delve, before any
   call that would need to manipulate the target process
2. allow the user to send a StopRecording request during the initial
   GetState call
3. allow the user to send a StopRecording request during any subsequent
   Restart(rerecord=true) request (if supported).

Implements #1747
2020-03-24 09:09:28 -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
Alessandro Arzilli
1a9e38aa0c
proc,terminal: Implement reverse step, next and stepout (#1785)
* proc: move defer breakpoint code into a function

Moves the code that sets a breakpoint on the first deferred function,
used by both next and StepOut, to its function.

* proc: implement reverse step/next/stepout

When the direction of execution is reversed (on a recording) Step, Next and
StepOut will behave similarly to their forward version. However there are
some subtle interactions between their behavior, prologue skipping, deferred
calls and normal calls. Specifically:

- when stepping backwards we need to set a breakpoint on the first
  instruction after each CALL instruction, once this breakpoint is reached we
  need to execute a single StepInstruction operation to reverse step into the
  CALL.
- to insure that the prologue is skipped reverse next needs to check if it
  is on the first instruction after the prologue, and if it is behave like
  reverse stepout.
- there is no reason to set breakpoints on deferred calls when reverse
  nexting or reverse stepping out, they will never be hit.
- reverse step out should generally place its breakpoint on the CALL
  instruction that created the current stack frame (which will be the CALL
  instruction immediately preceding the instruction at the return address).
- reverse step out needs to treat panic calls and deferreturn calls
  specially.

* service,terminal: implement reverse step, next, stepout
2020-03-11 15:40:41 -07:00
chainhelen
f3a191cd73
pkg/proc,service: support linux/386 (#1884)
Implement debugging function for 386 on linux with reference to AMD64.
There are a few remaining problems that need to be solved in another time.

1. The stacktrace of cgo are not exactly as expected.
2. Not implement `core` for now.
3. Not implement `call` for now. Can't not find `runtime·debugCallV1` or
   similar function in $GOROOT/src/runtime/asm_386.s.

Update #20
2020-03-10 09:34:40 -07:00
chainhelen
7560c33819
pkg,service: Use PCToFunc instead of PCToLine if it only needs func (#1894) 2020-02-25 21:01:37 -08:00
Alessandro Arzilli
897d5c4288
debugger: CreateBreakpoint should delete existing breakpoints (#1892)
Fixes a bug introduced by the logical breakpoint change, where creating
the same breakpoint twice deletes the breakpoint.
2020-02-25 12:29:20 -08:00
Alessandro Arzilli
d925f6b719
proc,service: allow printing registers for arbitrary frames (#1875)
Adds an optional scope prefix to the `regs` command which allows
printing registers for any stack frame (as long as they were somehow
saved). Issue #1838 is not yet to be closed since we are still not
recovering the registers of a segfaulting frame.

Updates #1838
2020-02-24 10:47:02 -08:00
chainhelen
a5d9dbee79
pkg,service: add cmd examinemem(x) for examining memory. (#1814)
According to #1800 #1584 #1038, `dlv` should enable the user to dive into
memory. User can print binary data in specific memory address range.
But not support for sepecific variable name or structures temporarily.(Because
I have no idea that modify `print` command.)

Close #1584.
2020-02-13 09:29:21 -08:00
Alessandro Arzilli
b9d0ddd82c
proc: only format registers value when it's necessary (#1860)
A significant amount of time is spent generating the string
representation for the proc.Registers object of each thread, since this
field is rarely used (only when the Registers API is called) it should
be generated on demand.

Also by changing the internal representation of proc.Register to be
closer to that of op.DwarfRegister it will help us implement #1838
(when Delve will need to be able to display the registers of an
internal frame, which we currently represent using op.DwarfRegister
objects).

Benchmark before:

BenchmarkConditionalBreakpoints-4   	       1	22292554301 ns/op

Benchmark after:

BenchmarkConditionalBreakpoints-4   	       1	17326345671 ns/op

Reduces conditional breakpoint latency from 2.2ms to 1.7ms.

Updates #1549, #1838
2020-02-12 13:31:48 -08:00
Derek Parker
94a20d57da
pkg/proc: Introduce Target and remove CommonProcess (#1834)
* pkg/proc: Introduce Target

* pkg/proc: Remove Common.fncallEnabled

Realistically we only block it on recorded backends.

* pkg/proc: Move fncallForG to Target

* pkg/proc: Remove CommonProcess

Remove final bit of functionality stored in CommonProcess and move it to
*Target.

* pkg/proc: Add SupportsFunctionCall to Target
2020-01-21 12:41:24 -08:00
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
348432c3b9 debugger: fix off-by-one error in ListDynamicLibraries 2020-01-02 09:30:22 -08:00
aarzilli
035190c292 debugger: fix nil pointer dereference in FunctionReturnLocations
Fixes #1787
2019-12-10 07:55: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
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
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
3d0bd515d8 service/debugger: make Disassemble work without a selected goroutine (#1704)
The Disassemble API call should work when there is no selected
goroutine (for example because the program was just started).

Fixes #1703
2019-10-07 09:32:38 -07:00
Alessandro Arzilli
efd628616b proc: add options to bypass smart stacktraces (#1686)
Add options to start a stacktrace from the values saved in the
runtime.g struct as well as a way to disable the stackSwitch logic and
just get a normal stacktrace.
2019-09-25 10:21:20 -07:00
Derek Parker
9963458d77 pkg/proc: Refactor Disassemble 2019-08-10 14:03:12 +02:00
Alessandro Arzilli
dc3fca3f7b service: add backend to GetVersion response (#1641)
Implements #1640
2019-07-27 16:44:48 -07:00
dpapastamos
c7d1692e92 terminal,service: Add support for rev prefix and step-instruction (#1596)
Support for rev {next,step} is not currently implemented.
2019-07-08 18:01:00 -07:00
Alessandro Arzilli
dd4fd5dc9c proc: allow simultaneous call injection to multiple goroutines (#1591)
* proc: allow simultaneous call injection to multiple goroutines

Changes the call injection code so that we can have multiple call
injections going on at the same time as long as they happen on distinct
goroutines.

* proc: fix EvalExpressionWithCalls for constant expressions

The lack of address of constant expressions would confuse EvalExpressionWithCalls

Fixes #1577
2019-06-30 10:44:30 -07:00
Alessandro Arzilli
7afda8dbe0 proc,service: remove support for locspec '<fnname>:0' (#1588)
The location specified '<fnname>:0' could be used to set a breakpoint
on the entry point of the function (as opposed to locspec '<fnname>'
which sets it after the prologue).
Setting a breakpoint on an entry point is almost never useful, the way
this feature was implemented could cause it to be used accidentally and
there are other ways to accomplish the same task (by setting a
breakpoint on the PC address directly).
2019-06-25 13:50:05 -07:00
Alessandro Arzilli
2d6d016bf1 proc: fix panic when calling Ancestors on a parked goroutine (#1570)
Fixes #1568
2019-06-03 10:41:33 -07:00
Alessandro Arzilli
c30a333f7b proc: allow function calls to appear inside an expression (#1503)
The initial implementation of the 'call' command required the
function call to be the root expression, i.e. something like:

	double(3) + 1

was not allowed, because the root expression was the binary operator
'+', not the function call.

With this change expressions like the one above and others are
allowed.

This is the first step necessary to implement nested function calls
(where the result of a function call is used as argument to another
function call).

This is implemented by replacing proc.CallFunction with
proc.EvalExpressionWithCalls. EvalExpressionWithCalls will run
proc.(*EvalScope).EvalExpression in a different goroutine. This
goroutine, the 'eval' goroutine, will communicate with the main
goroutine of the debugger by means of two channels: continueRequest
and continueCompleted.

The eval goroutine evaluates the expression recursively, when
a function call is encountered it takes care of setting up the
function call on the target program and writes a request to the
continueRequest channel, this causes the 'main' goroutine to restart
the target program by calling proc.Continue.

Whenever Continue encounters a breakpoint that belongs to the
function call injection protocol (runtime.debugCallV1 and associated
functions) it writes to continueCompleted which resumes the 'eval'
goroutine.

The 'eval' goroutine takes care of implementing the function call
injection protocol.

When the expression is fully evaluated the 'eval' goroutine will
write a special message to 'continueRequest' signaling that the
expression evaluation is terminated which will cause Continue to
return to the user.

Updates #119
2019-05-09 08:29:58 -07:00
Alessandro Arzilli
f3b149bda7 proc: support debugging plugins (#1414)
This change splits the BinaryInfo object into a slice of Image objects
containing information about the base executable and each loaded shared
library (note: go plugins are shared libraries).

Delve backens are supposed to call BinaryInfo.AddImage whenever they
detect that a new shared library has been loaded.

Member fields of BinaryInfo that are used to speed up access to dwarf
(Functions, packageVars, consts, etc...) remain part of BinaryInfo and
are updated to reference the correct image object. This simplifies this
change.

This approach has a few shortcomings:

1. Multiple shared libraries can define functions or globals with the
   same name and we have no way to disambiguate between them.

2. We don't have a way to handle library unloading.

Both of those affect C shared libraries much more than they affect go
plugins. Go plugins can't be unloaded at all and a lot of name
collisions are prevented by import paths.

There's only one problem that is concerning: if two plugins both import
the same package they will end up with multiple definition for the same
function.
For example if two plugins use fmt.Printf the final in-memory image
(and therefore our BinaryInfo object) will end up with two copies of
fmt.Printf at different memory addresses. If a user types
  break fmt.Printf
a breakpoint should be created at *both* locations.
Allowing this is a relatively complex change that should be done in a
different PR than this.

For this reason I consider this approach an acceptable and sustainable
stopgap.

Updates #865
2019-05-08 14:06:38 -07:00
Alessandro Arzilli
79e0f543c0 cmd/dlv: add Go version check (#1533)
Before doing anything check that the version of Go is compatible with
the current version of Delve.
This will improve the error message in the case that  another change as
disruptive as Go1.11 dwarf compression, happens.
2019-04-26 10:24:21 -07:00
aarzilli
9826531597 proc,debugger,terminal: read goroutine ancestors
Add options to the stack command to read the goroutine ancestors.
Ancestor tracking was added to Go 1.12 with CL:
https://go-review.googlesource.com/c/go/+/70993/

Implements #1491
2019-03-28 13:55:32 +01:00
Alessandro Arzilli
48f1f51ef9 Miscellaneous logging improvements (#1525)
* *: use loglevel to control what gets logged instead of output redirection

This stops logrus from doing all the formatting just to discard it
immediately afterwards.

* logflags: replace default formatter of logrus

The default formatter of logrus emits logs in two different formats
depending on whether or not the output is going to a terminal. The
output format for non-terminals is indented to be machine readable, but
we mostly read logs ourselves and the excessive quoting makes that
format unreadable.
When outputting to terminals it uses ANSI escape codes unconditionally,
without checking whether the terminal it is connected to actually
supports colors.

This commit replaces the default formatter with a much simpler
formatter that always uses a more readable format, doesn't use colors
and places the key-value pairs at the beginning of the line (which is a
better match for how we use them).

* cmd/dlv: add command line options to redirect logs

Adds two options, --log-to-file and --log-to-fd, to redirect logs to a
file or to a file descriptor.

When one of those two options is specified the "API server listening
at:" message will also be redirected to the specified file/file
descriptor.
This allows clients that want to use the "API server listening at:"
message to do so even if they want to redirect the target's stdout to
another file or device.

Implements #1179, #1523
2019-03-27 14:58:36 -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
Alessandro Arzilli
14aeea2bd9 proc/gdbserial: do not return floating point regs when not requested (#1497)
Fixes #1493
2019-02-26 08:53:45 -08: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
Sergio Lopez
11accd4d71 proc/proc: Extend GoroutinesInfo to allow specifying a range
Instead of unconditionally returning all present goroutines,
GoroutinesInfo now allows specifying a range (start and count). In
addition to the array of goroutines and the error, it now also returns
the next goroutine to be processed, to be used as 'start' argument on
the next call, or 0 if all present goroutines have already been
processed.

This way clients can avoid eating large amounts of RAM while debugging
core dumps and processes with a exceptionally high amount of goroutines.

Fixes #1403
2018-11-19 10:06:38 -08:00
Derek Parker
51c342c6b7 pkg/prog: Improve support for external debug info
Adds a config file option to allow specifying a list of directories to
search in when looking for seperate external debug info files.

Fixes #1353
2018-11-08 10:16:42 -08:00
Derek Parker
3129aa7330 *: Show return values on CLI trace
This patch allows the `trace` CLI subcommand to display return values of
a function. Additionally, it will also display information on where the
function exited, which could also be helpful in determining the path
taken during function execution.

Fixes #388
2018-10-19 20:32:27 +02:00
aarzilli
b59032516e proc,service,terminal: eval expressions in the scope of a deferred call
Add ability to evaluate variables on the scope of a deferred call's
argument frame.
2018-10-16 08:40:07 -07:00
aarzilli
d2904322fa proc: add flag to disable escape checking in function calls
Fix escape checking in function calls  and add a flag to disable it.
2018-10-15 09:31:35 -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
ac74944d53 proc,service,terminal: information about stack trace truncation
Add a flag to Stackframe that indicates where the stack frame is the
bottom-most frame of the stack. This allows clients to know whether the
stack trace terminated normally or if it was truncated because the
maximum depth was reached.
Add a truncation message to the 'stack' command.
2018-08-30 16:52:00 -07:00
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
8588e97b01 service/debugger: better error message for Go 1.11 executables
Output a better error message when users try to debug a Go 1.11
executable but delve was not built with Go 1.11.
2018-07-10 11:21:13 -07:00
aarzilli
c53c43d140 *: Fix log level setting in logrus
Setting the Level field of a logrus logger doesn't actually do anything
since the Level field simply reports the log level of the last log
message emitted on the logger.
The right way to do that is to set logger.Logger.Level.
Also cleans up newline characters from log messages emitted through
logrus and fixes the direction of the arrows in the messages emitted by
rpccommon, which was inconsistent with the arrows of gdbserial.
2018-07-02 09:31:53 -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
454491ce86 service,logflags: log all RPC messages
We occasionally receive bug reports from users of VSCode-go and GoLand.
GoLand has its own way of capturing the packet exchange between itself
and delve but VSCode-go (supposedly) doesn't.
So far this hasn't been a problem since all bug reports were obvious
bugs on the plugin or easy to reproduce without VSCode-go, but it might
be helpful in the future to have a way to log the packet exchange
between dlv and a frontend.

This commit adds a --log-output option to enable logging of all rpc
messages and changes service/rpccommon accordingly.
2018-06-14 09:27:38 -07: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
cc86bde549 proc/native,proc/gdbserial: let target access terminal
Change the linux verison of proc/native and proc/gdbserial (with
debugserver) so that they let the target process use the terminal when
delve is launched in headless mode.

Windows already worked, proc/gdbserial (with rr) already worked.
I couldn't find a way to make proc/gdbserial (with lldb-server) work.

No tests are added because I can't think of a way to test for
foregroundness of a process.

Fixes #65
2018-05-18 09:53:29 -07:00
aarzilli
21be59469a proc: cache entire frame in FrameToScope instead of variablesByTag
Caching the frame in variablesByTag is problematic:

1. accounting for variables that are (partially) stored in registers is
complicated (see issue #1106)
2. for some types (strings, interfaces...) simply creating the Variable
object reads memory, which therefore happens before we can do any
caching.

Instead cache the entire frame when the EvalScope object is created.
The cached range is between the SP value of the current frame and the
CFA of the preceeding frame, if available, or the CFA of the current
frame otherwise.

Fixes #1106
2018-04-23 10:13:21 -07:00
aarzilli
166121d18e gdbserial,debugger: better error message when debugserver not installed
When gdbserial can not find debugserver or lldb-server the error
message is always the same and it complains about lldb-server not being
found.

This is fine on linux (where the backend is unnecessary) but incomplete
on macOS (where the backend is actually used).

Make the error message clearer so that users who do not bother reading
install instructions are not confused.
2018-04-10 13:49:57 -07:00
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
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
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
Florin Patan
480fc02d50 Remove limitation of exit notification only for specific API calls 2018-01-02 11:28:43 -08:00
aarzilli
17bd4b52e8 pkg/terminal: -offsets flag for stack command
Prints the frame and frame pointer offsets for each frame.
2017-11-28 11:00:53 -08:00
aarzilli
5372588c61 proc: support cgo stacktraces
When creating a stack trace we should switch between the goroutine
stack and the system stack (where cgo code is executed) as appropriate
to reconstruct the logical stacktrace.

Goroutines that are currently executing on the system stack will have
the SystemStack flag set, frames of the goroutine stack will have a
negative FrameOffset (like always) and frames of the system stack will
have a positive FrameOffset (which is actually just the CFA value for
the frame).

Updates #935
2017-11-28 11:00:53 -08:00
aarzilli
1ced7c3a60 proc: next should not skip lines with conditional bps
Conditional breakpoints with unmet conditions would cause next and step
to skip the line.

This breakpoint changes the Kind field of proc.Breakpoint from a single
value to a bit field, each breakpoint object can represent
simultaneously a user breakpoint and one internal breakpoint (of which
we have several different kinds).

The breakpoint condition for internal breakpoints is stored in the new
internalCond field of proc.Breakpoint so that it will not conflict with
user specified conditions.

The breakpoint setting code is changed to allow overlapping one
internal breakpoint on a user breakpoint, or a user breakpoint on an
existing internal breakpoint. All other combinations are rejected. The
breakpoint clearing code is changed to clear the UserBreakpoint bit and
only remove the phisical breakpoint if no other bits are set in the
Kind field. ClearInternalBreakpoints does the same thing but clearing
all bits that aren't the UserBreakpoint bit.

Fixes #844
2017-11-20 11:25:35 -08:00
aarzilli
178589a4e7 proc: breakpoints refactoring
Move some duplicate code, related to breakpoints, that was in both
backends into a single place.
This is in preparation to solve issue #844 (conditional breakpoints
make step and next fail) which will make this common breakpoint code
more complicated.
2017-11-20 11:25:35 -08:00
aarzilli
f4e2000fc8 proc: refactor stack.go to use DWARF registers
Instead of only tracking a few cherrypicked registers in stack.go track
all DWARF registers.

This is needed for cgo code and for the locationlists emitted by go in
1.10:
* The debug_frame sections emitted by C compilers can not be used
  without tracking all registers
* the loclists emitted by go1.10 need all registers of a frame to be
  interpreted.
2017-11-17 10:17:24 -08:00
aarzilli
6d40517944 proc: replace all uses of gosymtab/gopclntab with uses of debug_line
gosymtab and gopclntab only contain informations about go code, linked
C code isn't there, we should use debug_line instead to also cover C.

Updates #935
2017-11-03 20:57:04 +01:00
aarzilli
55e44c9dc0 proc/gdbserial: automatically retrieve exe path on attach on macOS
debugserver doesn't support qXfer:exec-file:read, and it doesn't return
the executable path in the response to qProcessInfoPID, however we can
find out the executable path by using jGetLoadedDynamicLibrariesInfos.
2017-09-08 10:27:08 -07:00
Derek Parker
cc63d209c1 pkg/proc: return proper error when debugger has exited
Instead of panicing for sending on a closed channel, detect that the
process has exited and return a proper error message.

This patch also cleans up some spots where the Pid is omitted from the
error.

Fixes #920
2017-07-29 06:31:15 +02:00
aarzilli
283128aeab service/debugger: revert Next/StepOut/Step behavior on exit
When the process exits during we used to return an error, but after
commit 8bbcc89711f4263e7bb2b6d9c00fa96d0294e56f we move the error into
state.Err. Revert this behavior change.
2017-07-26 12:50:09 -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
aarzilli
a7718bd358 proc: tolerate memory read errors during stacktrace
When there's a error reading the stack trace the call stack itself
could be corrupted and we should return the partial stacktrace that we
have.

Fixes #868
2017-07-26 12:50:09 -06:00
Alessandro Arzilli
04c4b019f7 api: add FrameOffset to Stackframe (#864)
Other debuggers can be instructed to decorate the stacktrace with the
value of SP. Our SP equivalent is the frame offset, since we can add it
to the Stackframe structure without incurring into added costs we
should, so that frontends can use it if they want.
2017-06-20 10:39:33 -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
aarzilli
16d8bd647f proc/*: remove Process.Running
Implementing proc.Process.Running in a thread safe way is complicated
and nothing actually uses it besides tests, so we are better off
rewriting the tests without Running and removing it.

In particular:

* The call to d.target.Running() in service/debugger/debugger.go
  (Restart) can never return true because that line executes while
  holding processMutex and all continue operations are also executed
  while holding processMutex.
* The call to dbp.Running() pkg/proc/native/proc.go (Detach) can never
  return true, because it's only called from
  debugger.(*Debugger).detach() which is also always called while
  holding processMutex.

Since some tests are hard to write correctly without Process.Running a
simpler interface, Process.NotifyResumed, is introduced.

Fixes #830
2017-06-13 08:53:54 +02:00
Alessandro Arzilli
a843f7944e proc/gdbserial: mozilla rr support (#804)
Implements #727
2017-05-05 15:17:52 -07:00
Alessandro Arzilli
a731eb661f Minor post-refactoring cleanup (#808)
* proc/native: remove unused utility methods

* proc: turn FindFileLocation, FindFunctionLocation, FirstPCAfterPrologue methods into function
2017-04-28 10:15:39 -07:00
aarzilli
b6fe5aebaf proc: refactoring: merge target into proc
- moved target.Interface into proc as proc.Process
- rename proc.IThread to proc.Thread
- replaced interfaces DisassembleInfo, Continuable and
  EvalScopeConvertible with Process.
- removed superfluous Gdbserver prefix from types in the gdbserial
  backend.
- removed superfluous Core prefix from types in the core backend.
2017-04-21 14:00:04 -07:00
aarzilli
15bac71979 proc: refactoring: split backends to separate packages
- move native backend to pkg/proc/native
- move gdbserver backend to pkg/proc/gdbserial
- move core dumps backend to pkg/proc/core
2017-04-21 14:00:04 -07:00
aarzilli
905d3d9962 debugger: always detach in debugger
GdbserverProcess does its cleanup in Detach we need to always call
that function.
2017-04-18 13:25:11 -07:00
aarzilli
c8d9352522 proc: Implement target.Interface for gdbserver backend 2017-04-18 13:25:11 -07:00
aarzilli
c1879472a1 proc: implement target.Interface for core files 2017-04-18 13:25:11 -07:00
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
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
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
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
Derek Parker
26ad5f1d82 Introduce target interface 2017-02-08 12:16:51 -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
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
Evgeny L
4064d6acc0 Flag to set working directory (#650)
* proc: Add `wd` to Launch

This change adds the `wd` arg which specify working directory of the
program.

Fixes #295

* service/debugger: Add `Wd` field to debugger.Config

This change adds the `Wd` field which specify working directory of the
program launched by debugger.

Fixes #295

* service: Add `Wd` to service.Config

This change adds the `Wd` field which specify working directory of the
program debugger will launch.

Fixes #295

* cmd/dlv: Add `Wd` flag

This change adds `Wd` flag which specify working directory of the
program which launched by debugger.

Fixes #295

* only set the Linux working directory if it is set,
stub out param in darwin and windows

* set working directory for Windows
https://godoc.org/golang.org/x/sys/windows#CreateProcess
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx

* Windows workingDir must be an *uint16

* attempt to chdir on darwin via @yuntan

* proc/exec_darwin.c: fix working directory for darwin

* Add tests to check if working directory works.
* Fix darwin implementation of fork/exec, which paniced if
  child fork returned.

* cmd, service: rename Wd to WorkingDir
2016-11-01 12:58:42 -07: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
aarzilli
9cbe768836 proc: Renamed temp breakpoints to internal breakpoints 2016-09-30 08:35:29 +02:00
aarzilli
7c49d4968d proc: Implement Step using Continue
Instead of repeatedly calling StepInstruction set breakpoints to the
destination of CALL instructions (or on the CALL instructions
themselves for indirect CALLs), then call Continue.
Calls to unexported runtime functions are skipped.
Reduces the number of code paths managing inferior state from 3 to 2
(StepInstruction, Continue).

Fixes #561
2016-09-27 09:37:33 +02:00
aarzilli
51c39ed171 proc: detect when Launching non-executable files
This provides a better error message when the user tries to run dlv
debug on a directory that does not contain a main package, when `dlv
exec` is used with a source file.

Additionally the architecture of the executable is checked as suggested
by @alexbrainman in #443.

Fixes #509
2016-06-30 09:39:18 +02:00
Alessandro Arzilli
c4e01da5ca terminal,service: auto-continue during next and step (#448)
* proc: bugfix: StepInto can not function when temp bps exist

* terminal,service: auto-continue during next and step

Make dlv call continue automatically when a breakpoint is hit on a
different goroutine during a next or step operation.
Added API hooks to implement the other solution to this problem (cancel
the next/step operation if a different breakpoint is hit).

Fixes #387
2016-04-24 16:20:02 -07: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
aarzilli
497b526194 proc: stacktrace refactoring
- made GoroutineStacktrace a method of struct G
- made stacktrace a method of StackIterator
- renamed StackIterator to stackIterator
- factored out logic to obtain a stackIterator from a goroutine that's
used by both (*G).Stacktrace and by (*G).UserCurrent
2016-03-28 09:01:16 -07:00
aarzilli
59beb7b442 debugger: Allow disassembly even if the scope can not be converted
It is sometimes impossible to convert an EvalScope immediately after
starting the program but disassembly can still proceed.
2016-03-28 08:44:18 -07:00
aarzilli
c4797ea445 proc: Breakpoint to catch unrecovered panics
Automatically sets a breakpoint on runtime.startpanic, the function
that gets called by runtime.dopanic when a panic is not recovered.

Implements #317
2016-03-09 14:15:30 +01:00
aarzilli
ecc95cd2ac debugger: bugfix: BreakpointInfo variables evaluated on wrong thread
BreakpointInfo variables were always evaluated on CurrentThread
instead of the thread that triggered the breakpoint.
2016-02-28 13:38:05 +01:00
aarzilli
c8f4cee97d New command 'types'
Lists all the types defined in the debugged program.
2016-02-27 15:39:11 -08:00
Derek Parker
1efc4940cd service/debugger: Fix typo 2016-02-24 17:50:11 -08:00
aarzilli
82ef3cce78 debugger: bugfix: make delve API thread safe
proc.(*Process) methods are not thread safe, multiple clients
connecting simultaneously to a delve server (Issue #383) or a even
a single over-eager client (Issue #408) can easily crash it.
Additionally (Issue #419) calls to client.(*RPCClient).Halt can
crash the server because they can result in calling the function
debug/dwarf.(*Data).Type simultaneously in multiple threads which
will cause it to return incompletely parsed dwarf.Type values.

Fixes #408, #419 (partial)
2016-02-24 17:49:30 -08:00
aarzilli
3be65a4c1f service, terminal: Named breakpoints and breakpoint conditions
Implements #109 and #120
2016-02-16 15:59:37 -08:00
aarzilli
e7a9a3ea9a Disassemble command
Implements #368
2016-02-11 16:59:07 -08:00
Luke Hoban
cf3a07b584 Fix path lookup logic on Windows.
Fixes #370.
2016-02-05 14:45:27 -08:00
aarzilli
3a8730de72 proc: Do not panic when a command is executed on an exited process
Fixes #355
2016-01-30 07:23:21 +01:00
Luke Hoban
d756eba13a [service/debugger] Case-insensitive paths on Windows
Fixes #370.
2016-01-26 18:50:53 -08:00
Derek Parker
1bda586115 proc: step now goes to next line, including funcs
This patch modifies the `step` command to step to the next source line,
stepping into any function encountered along the way.

Fixes #360
2016-01-24 15:48:36 -08:00
aarzilli
d9a31dd598 proc: implement conditional breakpoints
Backend only, no UI

Implements #120 (partial)
2016-01-24 08:32:28 +01:00
Luke Hoban
bddb712a6b Add support for Windows.
Fixes #198.
2016-01-20 19:06:31 -08:00
aarzilli
70cbbdc083 service/locations: hooked expression evaluator to location specifiers
Location specifiers starting with '*' can be followed by any
expression supported by the evaluator.
The expression should evaluate to either an integer (which will be
interpreted as an address) or to a function pointer (which will be
dereferenced to get the function's entry point).
2016-01-17 21:45:28 -08:00
Derek Parker
0188dc2c8b misc: cleanup and documentation 2016-01-10 02:10:51 -08:00
aarzilli
5441135668 proc: Next implemented as conditional breakpoints + Continue
Next sets its temporary breakpoints with the condition that they
must only activate on the current goroutine, and then calls Continue
When Continue encounters a temporary breakpoint it clears all
the breakpoint.

User visible changes: breakpoints that get hit while executing Next
are not ignored.

This commit does not implement full conditional breakpoints
functionality, the only condition that can be set is on the
goroutine id.

Fixes race conditions in Next affecting TestNextConcurrent.
2016-01-09 08:44:32 +01:00
aarzilli
708cf2f290 service,terminal: propagating simultaneous breakpoints 2016-01-09 08:44:25 +01:00
aarzilli
50b5fc92e2 Changed api.Variable to have a machine readable value
The new contents of api.Variable are documented in
proc/variables.go.

Implements #243
2015-10-28 18:28:58 -07:00
Derek Parker
d8dd9c8d0e proc: Properly close channels upon process exit
Prevents a lot of goroutines hanging around, especially when running
tests.
2015-10-09 17:33:16 -07:00
aarzilli
c9b517067b Implements set command for pointers and numerical values
set <variable name> <value>
2015-09-28 22:45:06 -07:00
aarzilli
5ba0435382 Refactor: use FindGoroutine
Use proc.(*Process).FindGoroutine in proc.(*Process).SwitchGoroutine and
debugger.(*Debugger).Stacktrace. That method did not exist when those
were originally written.
2015-09-20 09:03:52 -07:00
aarzilli
da39258bec stack command: -full flag prints local variables and arguments of all the functions on the stack trace 2015-09-18 08:34:21 +02:00
Derek Parker
af9e97b697 service/debugger: Use PC instead of scope in Location.Find 2015-09-05 17:23:59 -05:00
aarzilli
c6ebd80905 Variable evaluation on arbitrary (goroutine, frame) pair. 2015-09-05 12:08:40 -05:00
Derek Parker
e3e13dc672 service/debugger: Do not preserve temp breakpoints on restart 2015-08-17 19:27:29 -05:00
aarzilli
8e8d2660ef Improve commands which take a location spec
Breakpoints, tracepoints, etc.. take a location spec as input. This
patch improves the expressiveness of that API. It allows:

* Breakpoint at line
* Breakpoint at function (handling package / receiver smoothing)
* Breakpoint at address
* Breakpoint at file:line
* Setting breakpoint based off regexp
2015-08-08 14:41:48 -05:00
Derek Parker
d06abe3f2f Debugger.Restart: Preserve breakpoints
Fixes #188
2015-08-02 00:08:48 -05:00
Derek Parker
3cee10d8bc Implement 'trace' subcommand
Allows a user to execute `dlv trace [regexp]` and Delve will execute the
program and output information on functions matching [regexp].
2015-07-12 15:20:12 -05:00
Derek Parker
40284111d4 Kill process outright if manually forked 2015-07-11 01:43:47 -05:00
Derek Parker
2f7612d4af Add command to restart process
Fixes #95
2015-07-03 15:35:22 -05:00
Derek Parker
d2b8d57053 Return exit status with DebuggerState 2015-07-03 15:28:46 -05:00
Derek Parker
dcfa1aea2b Properly return ProcessExitedError upon process death 2015-07-01 21:36:13 -05:00
Derek Parker
6b99c5f519 Cleanup tracepoint commit
* Cleanup comments
* Cleanup naming in certain instances
* Modify stacktrace to return current location
2015-06-30 22:16:52 -05:00
aarzilli
3a96d8eed7 trace command 2015-06-29 21:16:55 +02:00
aarzilli
358fb75fc6 Return helpful error when attaching to a process is impossible 2015-06-27 23:21:26 -05:00