Commit Graph

214 Commits

Author SHA1 Message Date
aarzilli
2c58d0c242 bugfix: proc/types: loadPackageMap and github.com packages
Makes loadPackageMap actually work with github.com/... packages
2016-01-08 09:58:25 -08:00
aarzilli
7e0d3fc244 workaround: proc/eval: go sometimes inserts &v instead of v 2016-01-04 16:20:23 +01:00
aarzilli
1aa83e30e0 proc/variables: bugfix: nil pointer with interfaces to functions
Fixes #325
2015-12-26 14:49:46 -08: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
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
Derek Parker
ab77435223 docs: update comment docs for GetG 2015-12-16 17:16:59 -08:00
Derek Parker
67ef867762 proc: prefer %q over escaped quoute 2015-12-15 15:18:52 -08: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
141fc4ed21 proc/eval: support for simple builtin functions
supported: len, cap, imag, real, complex
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
Derek Parker
ad5097a8dc proc: Fix parsing of 'BuildVersion' on Go tip
Fixes #301
2015-12-15 08:42:13 +01: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
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
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
Jonathan Boulle
49d8b18c10 proc, terminal: fix package docstrings 2015-10-27 19:38:57 -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
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
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
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
Derek Parker
6ae8633b08 proc: Comment fixes / misc formatting 2015-10-04 12:08:17 -07:00
Derek Parker
f2ae6a27cd proc: fix: Call wg.Done in loadProcessInformation on OSX 2015-10-04 12:08:17 -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
eb2bc2a7ee terminal: Implements init file and source command
The 'source' command reads the file specified as argument and executes
it as a list of delve commands.
Additionally a flag '--init' can be passed to delve specifying a file
containing a list of commands to execute on startup.

Issue #96
2015-10-04 10:32:38 -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
aarzilli
bba999b985 proc: bugfix: intermittent failures of TestRestart_afterExit
During process termination we seem to receive notifications of new
threads that die before we can add them, ignore them
2015-09-27 07:56:47 +02: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
a6391c1f76 proc/variables: Large strings & uninitialized memory fixes
Be more tolerant of unitialized memory, limit length of strings like we
do for array/slices.

Workaround for Issue #189
2015-09-20 08:59:06 -07:00
Derek Parker
784505813d proc/stack: Add punctuation to comment 2015-09-19 23:19:03 -05: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
0cba1fe0ba proc/variables: Use sched.pc instead of gopc for G location
gopc is the instruction of the `go` command that spawned this goroutine.
What we really want (unless we can get the PC from the thread) is the
value of sched.pc which is the value of the PC at the time it was
parked.
2015-09-16 20:59:30 -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
Paul Smith
7206267772 Visually align registers & show 16 bytes for each
This change right-aligns the register names in the output of the "regs" command,
and pads out the display of the hex value of each register to 16 bytes. This
makes scanning registers for set values a bit easier.
2015-09-02 00:00:48 -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
8be76428c8 Remove superfluous var declarations 2015-08-27 16:48:34 -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
38e0051308 thread.Halt: Remove duplication between OS implementations
Bring similar code up to top level, and keep OS dependant code in OS
dependant files. DRY up code a bit.
2015-08-20 10:06:33 -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
12bd0472d2 Only make new process a group leader, not session
We're not dealing with a debugged process having its own controlling
terminal at this point, so no need to make the new process a session
leader. Simply making the process a group leader will suffice for our
purposes at the moment.
2015-08-13 18:18:42 -05:00
aarzilli
77d46a51fb Fix: Support for x.y versions 2015-08-12 09:30:47 -05:00
Derek Parker
a336c92a8b Fix: Improve handling of soft signals on darwin
Fixes a bug on OSX where, if the debugged process spawned a child, when
that process received a SIGCHLD it would cause Delve to hang.

Fixes #197
2015-08-11 19:20:25 -05:00
Derek Parker
d9d3118aa0 Fix: Parse rc version strings 2015-08-11 08:37:27 -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
Derek Parker
f43007c55e Fix: Handle inability to find return addr
Fixes a code path where stacktrace returns < 2 locations and
thread.ReturnAddress would panic. Now returns an error.
2015-08-10 10:45:33 -05:00
aarzilli
8de1a307ee Fix: track recurseLevel in readArray/readSlice
This fix helps avoid infinite recursion.
2015-08-09 20:37:47 -05:00
aarzilli
fe054b2f0f EvalVariable should also evaluate package variables 2015-08-09 20:37:47 -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
869884b9ab Bind to less used port in test 2015-08-08 14:30:23 -05:00
Derek Parker
af55ef3522 Process.Kill: Do not kill if process already exited 2015-08-04 08:32:43 -05:00
Derek Parker
ee3d7e8d55 proc/proc_linux.go: Misc code cleanup 2015-08-01 23:31:50 -05:00
Derek Parker
8034b7c038 Process.Kill: Use PID in wait 2015-08-01 23:18:20 -05:00
Derek Parker
6bac0ae0b2 Remove superfluous comment and misc cleanup 2015-08-01 23:14:06 -05:00
Derek Parker
fd407f8579 Fix Linux compilation error 2015-08-01 23:06:34 -05:00
Derek Parker
286f8ed22e Return result directly from single_step 2015-08-01 21:46:42 -05:00
Derek Parker
93dcd40cee Refactor read/write memory code 2015-08-01 21:43:03 -05:00
Derek Parker
5e5f5aff30 Cleanup comment in setBreakpoint 2015-08-01 21:19:14 -05:00
Derek Parker
1f473241c7 Refactor setBreakpoint code 2015-08-01 21:16:58 -05:00
Derek Parker
e2d92a1104 Extract constant for breakpoint line in test 2015-07-30 12:11:10 -05:00
Michael Gehring
2d79acd2fe more variable test fixes 2015-07-30 18:00:23 +02:00
Michael Gehring
9f3f77ce31 add complex types to TestVariableEvaluation 2015-07-30 17:37:17 +02:00
Michael Gehring
720a592348 Make info locals understand/print complex types
Fixes #192
2015-07-30 17:07:08 +02:00
Derek Parker
a506bb7d8e Finish support for Go1.5beta2 2015-07-28 18:56:55 -05:00
Derek Parker
bcbda1dba3 Rename version.After to version.AfterOrEqual 2015-07-28 15:42:56 -05:00
aarzilli
311da7c314 bugfix: version string parsing support for beta versions and tolerance for devel versions
fixes issue #179
2015-07-28 15:15:45 -05:00
Derek Parker
77604eff81 Improve code documentation 2015-07-28 13:37:55 -05:00
Derek Parker
15b7c6e562 Send kill signal to process group on Linux 2015-07-28 13:31:54 -05:00
Derek Parker
544c4ccc3d Add more documentation around darwin fork_exec 2015-07-28 12:23:36 -05:00
Derek Parker
a6fc8d11a7 Create new session/process grp for forked process 2015-07-28 12:20:07 -05:00
aarzilli
a0115e3a15 bugfix: Issue #170 (partial) set function breakpoints on the first instruction
the entry point of a function is the beginning of the prologue, which can be run multiple times for each invocation of a function if the stack needs to be expanded or the scheduler needs to be run.
2015-07-28 08:16:20 -05:00
aarzilli
a353735715 Breakpoints are hit multiple times or skipped sometimes (tests) 2015-07-28 08:13:46 -05:00
Derek Parker
051ea39f2c Remove superfluous Kill method call in test
The process will already be killed via withTestProcess
2015-07-28 07:54:26 -05:00