Commit Graph

86 Commits

Author SHA1 Message Date
Alessandro Arzilli
f6e8fb37a4 proc: changed windows backend to deal with simultaneous breakpoints (#598)
* proc: changed windows backend to deal with simultaneous breakpoints

* bugfix: forgot to add windowsPrologue3 to the prologues list in e4c7df1

* Tolerate errors returned by Stacktrace in TestStacktraceGoroutine.

* bugfix: proc: propagate debug events we don't cause back to the target process

Fixes: #594

* proc: fixed TestStepConcurrentPtr

Implementation of nextInProgress was wrong.
2016-10-21 21:51:34 -07: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
8d58262020 proc: bugfix: Next and normal calls to deferred function
When a deferred function is called directly Next and StepOut should not
step into it.

Fixes #582
2016-09-27 09:37:26 +02:00
Alessandro Arzilli
e4c7df1469 Fix prologue detection on testvariables2.go's main.main (#625) 2016-09-06 10:27:07 -07:00
dr2chase
218c2b953b proc: Fix stepping into runtime.duff* (#575)
Detect calls that do not target a function's entrypoint
(i.e, calls to runtime.duffzero and runtime.duffcopy) and
instead step into them directly.  StepInto sets a breakpoint
past the called function's prologue and expects that continue
will hit that breakpoint, but because the call is into the
interior of the function (well past the prologue) this fails.

Fixes #573
2016-07-21 13:10:35 -07:00
Alessandro Arzilli
16f16cf86d proc: bugfix: cleaning up spurious process exited errors (#599)
Fixes flakiness of TestCmdLineArgs.
2016-07-20 15:36:31 -07:00
aarzilli
da910cc3bd proc: disabled TestUnsupportedArch on go1.7
See: https://github.com/golang/go/issues/16180
2016-07-03 09:02:21 +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
aarzilli
6faa78ff7c proc, terminal: step on parked goroutines
Previously Step would step through the goroutine associated with
CurrentThread if SelectedGoroutine was parked
2016-06-24 21:22:30 +02:00
aarzilli
d17c7c3a61 proc, terminal: next on parked goroutines
Previously Next would step through the goroutine associated with
CurrentThread if SelectedGoroutine was parked

Also fixes a bug with proc.(*Process).StepInto where StepInto could
switch to a different goroutine.
2016-06-24 21:22:30 +02:00
aarzilli
323c0450d1 tests: fixed version check for go1.7 to include beta versions 2016-06-22 12:38:40 +02:00
David Benque
ede880134c Add support for Appengine; parsing Appengine Go custom version (#566) 2016-06-07 11:07:37 -07:00
Alessandro Arzilli
5933a0f48f proc: bugfix: unsigned integer overflow in proc.(*memCache).contains (#555)
Fixes #554
2016-05-29 12:11:00 -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
Matias Lahti
60946a759c proc: Fix command-line arguments on Windows (#501)
* proc: add tests for command-line arguments

adds tests to make sure command-line arguments are passed to Launch() properly

* proc_windows: pass command-line arguments to CreateProcess()

build command-line arguments according to how the standard library does it and pass the command line along to the actual syscall on Windows.

see discussion in #479

* proc: better testing of cmd-line arguments

* proc_windows: fix a possible error-case with passing just 1 argument

previously, the command line pointer passed to sys.CreateProcess was empty, if we had 0 parameters (len(cmd) == 1, as cmd[0] is the executable, so no cmdlineGo would be created, while with any argument it would as len(cmd) > 1). This might cause problems down the road, so make sure we include the command line every time, even if it seems to work without.

* proc: improve testing of command-line arguments

test that arguments with spaces are passed on correctly and DRY failure/success condition checking in the args test
2016-04-21 14:20:38 -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
43756cd864 proc: bugfix: Truncate stacktrace when FDE of a frame can not be found
Instead of returning an error when FDE of a frame can not be found,
just truncate the stack trace.

Fixes #462
2016-03-28 09:01:16 -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
c66c6408a5 proc: Caching type offsets
Caches the mapping of type names to offset in debug_info to speed up
variable evaluation.

BEFORE:
	BenchmarkArray-4         	     100	  13'238'441 ns/op	   0.62 MB/s
	BenchmarkArrayPointer-4  	     200	  10'044'093 ns/op	   0.87 MB/s
	BenchmarkMap-4           	    1000	   1'332'530 ns/op	   0.77 MB/s
	BenchmarkGoroutinesInfo-4	      10	 114'677'462 ns/op
	BenchmarkLocalVariables-4	    2000	   1'223'975 ns/op
AFTER:
	BenchmarkArray-4         	     200	   9'925'686 ns/op	   0.83 MB/s
	BenchmarkArrayPointer-4  	     100	  11'143'930 ns/op	   0.78 MB/s
	BenchmarkMap-4           	    2000	   1'302'520 ns/op	   0.79 MB/s
	BenchmarkGoroutinesInfo-4	      30	  35'079'549 ns/op
	BenchmarkLocalVariables-4	    1000	   1'137'299 ns/op

Note in particular the speedup of BenchmarkGoroutinesInfo, since
proc.(*Variable).parseG is a function we call a lot.
2016-03-05 13:04:11 +01:00
aarzilli
49a0a121e0 tests: Add test for #149, fixed TestNextGeneral on tip
The go compiler changed and break statements no longer get compiled to
nothing when -N is passed:

https://go-review.googlesource.com/#/c/19848/
https://go-review.googlesource.com/#/c/19854/
2016-02-28 16:44:22 -08:00
aarzilli
14a92352bc proc: Add filter for non-variable global symbols to PackageVariables 2016-02-27 15:26:24 -08:00
aarzilli
58913527db proc: Crash when stepping past the end of the program
Fixes #414
2016-02-27 15:15:51 -08:00
aarzilli
6242c4388e _fixtures: Removed testvariables2 and testvariables4
Moved the code in testvariables2 and testvariables4 into
testvariables3, renamed testvariables3 into testvariables2
2016-02-18 12:16:31 -08:00
aarzilli
852f0c95b3 proc: Step should skip function prologue
Step disassembles the current instruction, if it is a CALL sets a
temp breakpoint inside the called function, after the prologue and
calls Continue.

Fixes #332
2016-02-18 09:15:37 -08:00
aarzilli
4116d66c8d proc: Replaced FunctionEntryToFirstLine with disassembly alternative
- Unlike FunctionEntryToFirstLine can skip the prologue on functions
that are defined on a single line, either because they weren't
formatted or because they were autogenerated
- Can skip the prologue on most functions when setting a breakpoint
with the filename:line syntax

Fixes #396
2016-02-18 09:11:34 -08:00
aarzilli
b370e20cd5 proc: bugs setting next breakpoints
1. A running goroutine is by definition not parked waiting for a
chan recv
2. The FDE end address is intended to be exclusive, the code
interpreted as inclusive and sometimes ended up setting a breakpoint
on a function other than the current one.
2016-02-11 08:28:07 +01:00
aarzilli
06bba9b7a9 proc/variables: crash while reading unintialized variable
Fixes #384
2016-01-31 20:14:17 +01: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
d9a31dd598 proc: implement conditional breakpoints
Backend only, no UI

Implements #120 (partial)
2016-01-24 08:32:28 +01:00
Luke Hoban
14f26ffda8 Reenable TestNextNetHTTP on Windows 2016-01-23 21:26:08 -08:00
Luke Hoban
bddb712a6b Add support for Windows.
Fixes #198.
2016-01-20 19:06:31 -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
aarzilli
b839eda2a9 proc/variables: prefetch of target process memory
Prefetch the entire memory of structs and arrays and cache it instead
of issuing readMemory calls only when we get down to primitive types.
This reduces the number of system calls to ptrace that variables makes.

Improves performance in general, greatly improving it in some
particular cases (involving large structs).

Benchmarks without prefetching:
	BenchmarkArray-4         	      10	 132189944 ns/op	   0.06 MB/s
	BenchmarkArrayPointer-4  	       5	 202538503 ns/op	   0.04 MB/s
	BenchmarkMap-4           	     500	   3804336 ns/op	   0.27 MB/s
	BenchmarkGoroutinesInfo-4	      10	 126397104 ns/op
	BenchmarkLocalVariables-4	     500	   2494846 ns/op

Benchmarks with prefetching:
	BenchmarkArray-4         	     200	  10719087 ns/op	   0.76 MB/s
	BenchmarkArrayPointer-4  	     100	  11931326 ns/op	   0.73 MB/s
	BenchmarkMap-4           	    1000	   1466479 ns/op	   0.70 MB/s
	BenchmarkGoroutinesInfo-4	      10	 103407004 ns/op
	BenchmarkLocalVariables-4	    1000	   1530395 ns/op

Improvement factors:
	BenchmarkArray				12.33x
	BenchmarkArrayPointer		16.97x
	BenchmarkMap					 2.59x
	BenchmarkGoroutinesInfo		 1.22x
	BenchmarkLocalVariables		 1.63x
2016-01-10 13:49:03 +01:00
Derek Parker
0188dc2c8b misc: cleanup and documentation 2016-01-10 02:10:51 -08:00
aarzilli
6d50aba71d proc/variables: bugfix: infinite loading loop through maps
Fixes #341
2016-01-10 10:04:14 +01:00
aarzilli
17d8aa2bd1 proc: bugfix: wrong final count in TestBreakpointCounts (linux)
Sometimes after PtraceSingleStep the thread does not advance of a
single instruction but is, instead, blocked immediately by a SIGSTOP
Made singleStep repeat the process until a SIGTRAP is observed.

Unsure where the SIGSTOP comes from.
2016-01-09 08:44:38 +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
b21686e6c4 proc: Continue does not work with breakpoints set on NOP (OSX)
Fixes #262
2016-01-09 08:44:28 +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
1aa83e30e0 proc/variables: bugfix: nil pointer with interfaces to functions
Fixes #325
2015-12-26 14:49:46 -08:00
aarzilli
1a4250fb51 proc/variables: bugfix: hang on ptr loop including interfaces
recurseLevel value should not be reset when evaluating the contents
of an interface variable

Fixes #316
2015-12-19 14:57:48 +01:00
aarzilli
c25b9b369a proc/proc_test: Fixed TestStacktraceGoroutine
TestStacktraceGoroutine would occasionally fail due to race
conditions in the test itself
2015-11-06 19:49:36 +01:00
aarzilli
43b64ec39e proc: Implements expression interpreter
Supported operators:

- All (binary and unary) operators between basic types except <-,
++ and -- (includes & to take the address of an expression)
- Comparison operators between supported compound types
- Typecast of integer constants into pointer types
- struct members
- indexing of arrays, slices and strings
- slicing of arrays, slices and strings
- pointer dereferencing
- true, false and nil constants

Implements #116, #117 and #251
2015-11-04 12:28:48 +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
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
Florin Patan
197c165699 proc/breakpoint Add breakpoint statistics
This adds support for breakpoints statistics

Fixes #247
2015-10-09 16:01:06 -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