Commit Graph

65 Commits

Author SHA1 Message Date
Alessandro Arzilli
d89d115ef9 proc/variables: support NaN/Inf float values (#706)
Unfortunately go/constant does not support NaN and Inf float values so
we need to store this information alongside.

Fixes #705
2017-01-20 14:22:36 -08:00
aarzilli
63b8fa8269 proc: support for ver. 10.12.1 the OS formerly known as Mac OS X
Fixes #645
2016-12-17 11:07:43 +01:00
Alessandro Arzilli
6bff4d1970 proc/variables: extend sign of read negative integers. (#657)
Since we store all signed integers as int64 the sign bit should be
extended, otherwise we read negative integers as their 2-complement
value.
2016-11-02 14:32:48 -07:00
aarzilli
f62bf8d1e3 proc: Names of concrete types of interfaces parsing their runtime._type
Generate names of the concrete types stored inside interface variables
by fully parsing their runtime._type instead of simply using the str
field.

This allows delve to read the contents of an interface variable when
the program imports multiple packages that have the same name. It also
allows delve to correctly interpret some complex anonymous types.

Fixes #455
2016-10-27 09:56:15 +02:00
Alessandro Arzilli
fb8388ab2e proc/variables: missing return statement on error (#643)
Fixes #642
2016-09-25 08:28:22 -07:00
Alessandro Arzilli
e4c7df1469 Fix prologue detection on testvariables2.go's main.main (#625) 2016-09-06 10:27:07 -07:00
Alessandro Arzilli
372869c9e1 proc: Back to using vendored golang.org/x/debug/ (#585)
Patch https://go-review.googlesource.com/23085 has been merged so we
can go back to using golang.org/x/debug/.
2016-07-05 11:58:11 -07:00
Alessandro Arzilli
9bc6ad4f46 Go 1.7 compatibility (#524)
* tests: update to cope with go1.7 SSA compiler

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

We need our own tweaked version

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

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

* proc: Updated loadInterface to work with go1.7

go1.7 changed the internal representation of types, removing the string
field from runtime._type.
Updated loadInterface to use the new str field.
2016-05-29 12:20:09 -07:00
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
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
d735d1824c proc: removed dead code from proc.(*Variable).parseG 2016-03-23 13:45:57 +01:00
Hubert Krauze
37f124817d dlv: Misc refactors 2016-03-17 15:32:30 -07:00
aarzilli
14a92352bc proc: Add filter for non-variable global symbols to PackageVariables 2016-02-27 15:26:24 -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
51e87386da proc: Bug loading maps
Past the maximum recursion depth maps shouldn't be loaded at all,
adding map children and not loading them breaks assumptions in
the prettyprinter.

Fixes #406
2016-02-10 08:27:48 -08:00
aarzilli
06bba9b7a9 proc/variables: crash while reading unintialized variable
Fixes #384
2016-01-31 20:14:17 +01: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
Derek Parker
afe77160b0 proc: refactor parseg
Instead of doing a bunch of manual DWARF / memory parsing we instead can
just dogfood the internal Variable API to retrieve the G struct.
2016-01-24 17:11:17 +01:00
aarzilli
092571591f proc: added fake runtime.curg variable 2016-01-24 08:31:16 +01: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
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
aarzilli
32a0c752eb proc: fix 2 typos 2016-01-10 12:47:54 +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
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
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
aarzilli
8346a6ee08 proc/variables: bugfix: disable cast to maps and channels
It's was implemented unintentionally and the unintentional
implementation doesn't work and causes a crash.
2015-12-15 15:18:52 -08:00
aarzilli
48e13a9045 proc/variables: Support for interface types 2015-12-15 15:18:52 -08:00
aarzilli
2deb7fba20 proc/eval: fix panic slicing or indexing 'nil' 2015-12-15 15:18:52 -08:00
aarzilli
ff3e2344c4 proc/eval: Support type casts between basic types 2015-12-15 15:18:52 -08:00
aarzilli
e45443b3c4 proc/eval: Return an error when slicing a map over its length
Fixes #288
2015-11-07 11:48:40 +01:00
aarzilli
7a36967b5e proc/variables: unsafe.Pointer support 2015-11-06 17:01:38 -08:00
aarzilli
943c12030a proc/variables: map types support
Use m[n:] to skip the first n keys of a map
Map indexing is implemented with a linear scan

Implements #61, #122
2015-11-06 17:01:38 -08:00
aarzilli
988d529e91 proc/variables: Support chan types
Pretty print will print them with the format:
chan <element type> <queued elements>/<queue size>
2015-11-06 17:01:38 -08: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
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
56d57ee97a proc: Format & refactor 2015-10-06 18:24:50 -07:00
Luke Hoban
a8512ba11a proc: Move nil check into toField 2015-10-06 18:24:46 -07:00
Luke Hoban
e6477c01b1 proc/variables: Support for embedded structs
Embedded structs are encoded in DWARF as fields with
package-qualified names.  They define an anonymous field
on the struct with the non-qualified name, as well as
promoted fields for each field of the embedded struct so
long as these are not shadowed by fields of the containing
struct.

Fixes #220.
2015-10-06 18:17:49 -07:00
aarzilli
d30221dac7 proc/variables: chanRecvReturnAddress uses outdated frame info
g.SP refers to the frame the goroutine was in the last time it was
scheduled out. Instead of calling proc.(*Process).stacktrace directly
we should call proc.(*Process).GoroutineStacktrace that substitutes
fresh values retrieved from thread registers when necessary.
This bug leads to occasional problems with `next`.
2015-10-02 13:09:41 +02:00
Luke Hoban
e0519dd540 proc/variables: Support for nested struct members
Fixes #220
2015-09-29 22:50:42 -07:00
Derek Parker
af16cfa90b variables: Misc cleanup / renaming 2015-09-28 22:59:39 -07:00
aarzilli
c9b517067b Implements set command for pointers and numerical values
set <variable name> <value>
2015-09-28 22:45:06 -07:00
Derek Parker
8f2ccbad0a variables: Misc cleanup / renaming 2015-09-28 22:25:40 -07:00
aarzilli
8d920931e1 proc/variables: Split address calculations from value extraction
Refactored variables.go to separate calculation of a variable's address from
reading its value. This change is useful to implement the 'set' command
as well as the evaluation of more complex expressions (in the future).
2015-09-28 11:17:27 +02:00