Commit Graph

88 Commits

Author SHA1 Message Date
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
39bc379dd2 proc: Fix step when on breakpoint
Fixes #361
2016-01-26 16:45:26 -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
54f1c9b3d4 proc: replace debug/dwarf with golang.org/x/debug/dwarf
Typedefs that resolve to slices are not recorded in DWARF as typedefs
but instead as structs in a way that there is no way to know they
are really slices using debug/dwarf.
Using golang.org/x/debug/dwarf instead this problem is solved and
as a bonus some types are printed with a nicer names: (struct string
→ string, struct []int → []int, etc)

 Fixes #356 and #293
2016-01-24 15:41:41 -08:00
aarzilli
91743d9472 go fmt 2016-01-24 17:30:23 +01:00
aarzilli
d9a31dd598 proc: implement conditional breakpoints
Backend only, no UI

Implements #120 (partial)
2016-01-24 08:32:28 +01:00
aarzilli
092571591f proc: added fake runtime.curg variable 2016-01-24 08:31:16 +01:00
Luke Hoban
bddb712a6b Add support for Windows.
Fixes #198.
2016-01-20 19:06:31 -08:00
Derek Parker
98ae684096 proc: Single step only "current" thread
Instead of the `step` command single stepping every thread, instead only
step the "current" thread. This fixes a few issues surrounding single
stepping, and simplifies the logic. The original concerns around only
stepping a single thread (with regard to coordination) are invalid and
generally non-issues.
2016-01-20 12:22:39 -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
aarzilli
453bd0217f proc: bugfix: clearing temp breakpoints
Temp breakpoints should be cleared even if a non-temp breakpoint is
triggered on the same goroutine that the temp breakpoints are set on.

Fixes #305
2016-01-16 09:13:15 +01:00
Derek Parker
0188dc2c8b misc: cleanup and documentation 2016-01-10 02:10:51 -08:00
aarzilli
ab2b9ad1c6 proc: refactoring of Continue 2016-01-09 08:44:41 +01:00
aarzilli
5354e462e8 proc: bugfix: race condition between termination and Continue (linux)
resume loops in continueOnce moved to a OS specific resume function,
this makes the problem easier to deal with and seems to be more
appropriate to a windows port given what transpired from discussion
of Pull Request #276
2016-01-09 08:44:37 +01:00
aarzilli
2f9f20188a proc: bugfix: proc.Launch race (OS X) 2016-01-09 08:44:35 +01: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
78c79927d6 proc: bugfix: [OS X] desync of mach message queue in Continue 2016-01-09 08:44:30 +01:00
aarzilli
a9e2696f46 proc: bugfix: proc.(*Process).Continue skips breakpoints
Breakpoints are skipped either because:
1. when multiple breakpoints are hit simultaneously only one is
processed
2. a thread hits a breakpoint while another thread is being
singlestepped over the breakpoint.

Additionally fixed a race condition between Continue and tracee
termination.
2016-01-09 08:28:36 +01:00
aarzilli
17b39b789d Revert "proc: Fix parsing of 'BuildVersion' on Go tip"
This reverts commit ad5097a8dc716e61992d5c7dd6213e58cb0a88b5.
runtime/internal/sys.BuildVersion was not used in any official
release.
2015-12-23 10:53:49 +01:00
aarzilli
38716dcc26 proc/variables: bugfix: ifaces with types in user defined packages
The concrete type of an interface only contains the abbreviated
package name, we must construct a map from package names to package
paths to be able to resolve the concrete type of an interface.
2015-12-15 15:18:52 -08:00
Derek Parker
ad5097a8dc proc: Fix parsing of 'BuildVersion' on Go tip
Fixes #301
2015-12-15 08:42:13 +01:00
aarzilli
d65e832524 proc/variable: changed Value's type to constant.Value 2015-10-28 18:28:58 -07: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
Konstantin Shaposhnikov
b0a6dacc1c proc: handle rename of runtime.allg to runtime.allgs
Use runtime.allgs instead of runtime.allg that has been removed in
5a68eb9f25
2015-10-28 20:17:37 +08:00
Derek Parker
28e0a322bf proc: Improve 'next' functionality
Instead of trying to be clever and make an 'educated guess' as to where
the flow of control may go next, simple do the more naive, yet correct,
approach of setting a breakpoint everywhere we can in the function and
seeing where we end up. On top of this we were already setting a
breakpoint at the return address and deferred functions, so that remains
the same.

This removes a lot of gnarly, hard to maintain code and takes all the
guesswork out of this command.

Fixes #281
2015-10-22 10:14:24 -07:00
Derek Parker
d4d4021a41 proc: Update help for new goroutines flags & minor cleanup 2015-10-18 15:02:14 -07:00
aarzilli
cb529eafab terminal,proc: Improved goroutine printing
Three locations are returned for goroutines: its current location,
its current location excluding unexported runtime functions and
the location of its go instruction.
The command 'goroutines' takes a new parameter to select which
location to print (defaulting to current location w/o runtime)
2015-10-18 14:40:52 -07:00
Derek Parker
7847e94cfa proc: Small refactor 2015-10-18 10:24:38 -07:00
Derek Parker
2e71cf2465 proc: refactor: move Process.comm to Process.os.comm
Only used under Linux, no need to have it available on Process itself.
2015-10-09 17:33:16 -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
Florin Patan
197c165699 proc/breakpoint Add breakpoint statistics
This adds support for breakpoints statistics

Fixes #247
2015-10-09 16:01:06 -07:00
Konstantin Shaposhnikov
cc9ab6d687 proc: avoid dup chan recv breakpoints
I encountered the error message described in the issue while debugging
InfluxDB. I can confirm that after this fix the error disapeared.

Fixes #258
2015-10-06 18:02:29 -07:00
Derek Parker
c731a83424 proc: Refactor ptrace calls on Darwin 2015-10-06 10:45:36 -07:00
aarzilli
e509c3ce36 proc: bugfix: status does not work with programs containing spaces
/proc/pid/stat needs more complex parsing

Fixes #239
2015-10-04 12:01:09 -07:00
aarzilli
93ad209f24 proc: bugfix: Detach(true) does not kill tracee
Instead of using PTRACE_DETACH to inject SIGINT into the tracee use
sys.Kill directly: PTRACE_DETACH is allowed to ignore its signal
argument if the tracee isn't in signal-delivery-stop status.
2015-09-27 07:56:35 +02:00
Derek Parker
466960d95a proc: Remove hardware assisted breakpoints
Only use software breakpoints for now. The reasoning is because it
complicates the code without justification, and is only supported on
Linux. Eventually, once watchpoints are properly implemented we will
revive some of this code. Also, if it is ever necessary to actually set
a hw breakpoint we can revive that code as well.

All future versions of this code will include support for OSX before
being merged back in.
2015-09-26 13:58:54 -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
Ilia Choly
6527f15e4d proc: Exclude dead goroutines from results.
Some of the goroutines stored in runtime.allg are in the dead state and
should not be displayed. The state is determined by the 'g.atomicstatus'
member.
2015-09-17 12:17:26 -07:00
Ilia Choly
c185b7d004 proc/proc: Cache 'GoroutineInfo' result during halt
The GoroutineInfo method can be slow if there are many goroutines. This
patch caches the results during a halt so they are not needlessly
recomputed.

Fixes #234
2015-09-17 12:10:35 -07:00
Derek Parker
c0a0e0bdc1 proc/proc: Fix OSX hangs in highly parallel programs
`next` would hang in highly parallel programs, causing test flickers and
unexpected behavior. This patch fixes it by examining all stopped
threads whenever Delve gets a notification, instead of just the thread
that caused the stop.
2015-09-05 18:29:33 -05:00
aarzilli
c6ebd80905 Variable evaluation on arbitrary (goroutine, frame) pair. 2015-09-05 12:08:40 -05:00
omie
d5e00a583d dwarf/line: Support for parsing multiple file tables
Support multiple file / directory tables for multiple compilation units.

- added a type DebugLines that can hold number of DebugLineInfo
- added a supporting attribute to DebugLineInfo called 'Lookup' which is to be
used to quickly lookup if file exists in FileNames slice
- added supporting methods to lookup and return corresponding DebugLineInfo
- changed the debug_line parsing behavior to read all the available tables and
push them to DebugLines

- since Process.lineInfo is now a slice, it was breaking AllPCsBetween as well
- updated that function's definition to accept a new filename parameter to be
able to extract related DebugLineInfo
- updated calls to AllPCsBetween

- fixed tests that were broken due to attribute type change in Process
- updated _fixtures/cgotest program to include stdio.h, so that it updates
.debug_line header
- added a test to check 'next' in a cgo binary
- OSX - 1.4 does not support cgo, handle that in new testcase
2015-08-29 14:51:27 -05:00
Derek Parker
a0cffab881 Collect errors from defer in proc.next 2015-08-28 08:27:08 -05:00
Derek Parker
8c1853d193 proc/proc: Let thread set its own state 2015-08-21 22:46:17 -05:00
Derek Parker
eb0b4e9392 proc.Next: Further improve handling of highly parallel programs
This patch forces Delve to be more mindful of how it handles many
threads and the goroutine context switching that occurs in such cases.
2015-08-21 22:33:42 -05:00
Derek Parker
b9846c7684 command (next): Improvements for parallel programs
This patch aims to improve how Delve tracks the current goroutine,
especially in very highly parallel programs. The main spirit of this
patch is to ensure that even in situations where the goroutine we care
about is not executing (common for len(g) > len(m)) we still end up back
on that goroutine as a result of executing the 'next' command.

We accomplish this by tracking our original goroutine id, and any time a
breakpoint is hit or a threads stops, we examine the stopped threads and
see if any are executing the goroutine we care about. If not, we set
'next' breakpoint for them again and continue them. This is done so that
one of those threads can eventually pick up the goroutine we care about
and begin executing it again.
2015-08-20 09:32:59 -05:00
Derek Parker
288e2036f6 proc/proc: Refactor next function 2015-08-18 14:48:41 -05:00
Derek Parker
ed9b7769fd Remove unused 'singleStepping' state on Process
We don't care, at the process level, whether or not we're single
stepping. That state is really only relevant at the thread level.
2015-08-11 08:20:44 -05:00