Commit Graph

272 Commits

Author SHA1 Message Date
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
Derek Parker
29ed169848 Return error when invoking Delve with invalid path
Fixes #154
2015-06-26 23:05:15 -05:00
Derek Parker
48bb398c4b Properly report process exits 2015-06-21 21:11:47 -05:00
Derek Parker
6e538119d2 Refactor: Rename breakpoint methods
s/Break/SetBreakpoint/
s/Clear/ClearBreakpoint/
s/BreakByLocation/SetBreakpointByLocation/
2015-06-20 18:01:06 -05:00
Derek Parker
102d4c89ae s/DebuggedProcess/Process/ 2015-06-20 17:54:52 -05:00
Derek Parker
d265fa764f Update Debugger documentation 2015-06-20 17:50:24 -05:00
aarzilli
07473f04c5 Implement stack command
Finishes #63 #64
2015-06-20 15:29:33 -05:00
Giulio Iotti
256c83b17b Implement regs command to print registers values, fixes #62 2015-06-19 14:27:01 -05:00
Derek Parker
37235bba7f Store hardware/software breakpoints in same struct 2015-06-17 18:14:56 -05:00
Derek Parker
e4fc5e32c2 Refactor: Use thread-locked goroutine for ptrace ops
Previously either the terminal client or the debugger service would
either lock main goroutine to a thread or provide a locked goroutine to
run _all_ DebuggedProcess functions in. This is unnecessary because only
ptrace functions need to be run from the same thread that originated the
PT_ATTACH request.

Here we use a specific thread-locked goroutine to service any ptrace
request. That goroutine is also responsible for the initial spawning /
attaching of the process, since it must be responsible for the PT_ATTACH
request.
2015-06-13 12:57:42 -05:00
Derek Parker
e5233e7262 Rename: s/ThreadContext/Thread/ 2015-06-12 14:51:23 -05:00
Derek Parker
bfca6114d4 Rename package proctl -> proc 2015-06-12 14:49:23 -05:00
Derek Parker
a71f218e35 Rename: s/BreakPoint/Breakpoint/ 2015-06-12 14:48:18 -05:00
Derek Parker
98e7089dd3 Move list of hardware breakpoints onto arch struct
Hardware breakpoints are by definition architecture dependant. Move them
off the DebuggedProcess struct and onto the associated arch struct.
2015-06-12 14:30:59 -05:00
Derek Parker
fe19f3f20c Rename: s/EvalSymbol/EvalVariable/ 2015-06-12 14:04:14 -05:00
Derek Parker
c7dc57d44f Detach from process in tests
Prevents leaving around a bunch of zombie processes
2015-05-27 17:38:53 -05:00
Derek Parker
49667f2302 Rename thread.Process -> thread.dbp
Process is an incorrect name for the DebuggedProcess struct that the
thread is "a part" of. Also, no need to export that field.
2015-05-27 12:16:45 -05:00
Derek Parker
819c476aa9 Do not attempt to automatically read locals/args 2015-05-08 16:43:03 -05:00
Derek Parker
794d5b1e19 Revert errors.New change 2015-05-04 17:31:13 -05:00
Derek Parker
1ad66660a1 Prefer errors.New for unformatted errors 2015-05-01 16:27:29 -05:00
Derek Parker
6cadeb41fc Pass kill signal to ptrace_detach 2015-05-01 15:50:29 -05:00
Derek Parker
9040ec1af1 Only detach if not killing process 2015-05-01 15:14:58 -05:00
Dan Mace
2954e03a20 Introduce client/server separation
Refactor to introduce client/server separation, including a typed
client API and a HTTP REST server implementation.

Refactor the terminal to be an API consumer.
2015-04-29 21:05:41 -05:00