Commit Graph

120 Commits

Author SHA1 Message Date
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
aarzilli
971d7968c0 service/debugger: Bugfix: support pkg names with slashes in linespecs
Fixes #275
2015-10-17 09:31:07 +02:00
Luke Hoban
e18aa9da01 proc/variables: Don't print during testcase 2015-10-06 18:17:49 -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
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
c9b517067b Implements set command for pointers and numerical values
set <variable name> <value>
2015-09-28 22:45:06 -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
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
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
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
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
Michael Gehring
9f3f77ce31 add complex types to TestVariableEvaluation 2015-07-30 17:37:17 +02:00
aarzilli
d0f3459efb bugfix, Issue #163: offset of g struct in TLS picked based on the value of runtime.buildVersion and presence of compile units created by GNU AS, instead of being fixed to -16 2015-07-28 07:33:51 +02:00
Derek Parker
b32afd92ad Add test for kevent patch 2015-07-15 19:57:54 -05:00
Derek Parker
4d1dc5ad0e Inject SIGTRAP for manual stop
Instead of fighting against the normal flow, just signal a SIGTRAP and
let the existing flow handle it, as long as we set the halt flag
correctly the system should halt.
2015-07-07 15:55:22 -05:00
aarzilli
d919114d32 Fix: Linux - call wait4 on thread grp leader is broken
On a thread that's leader of its group,
that is ptraced and that was survived by its children.
2015-06-26 22:10:09 -05:00
Derek Parker
db278d0453 Improve TestHalt reliability on Linux 2015-06-26 07:46:46 -05:00
Derek Parker
687dc4172d Introduce JSON-RPC service 2015-06-21 21:11:30 -05:00
aarzilli
07473f04c5 Implement stack command
Finishes #63 #64
2015-06-20 15:29:33 -05:00
Derek Parker
3fba1f7113 Correctly handle hardware breakpoints across threads
* Set hardware breakpoints on all existing threads
* Set hardware breakpoints on any new thread the spawns

Fixes #111
2015-06-11 22:46:06 -05:00
Derek Parker
39945498a8 Improve 'next': return into deferred func 2015-05-09 12:44:38 -05:00
Derek Parker
867b3ff8a1 Handle defer blocks when next'ing 2015-05-08 17:35:25 -05:00
Derek Parker
da688b8184 Handle runtime.Breakpoint 2015-04-25 14:13:35 -05:00
Derek Parker
58db8322ef Improve chan / goroutine coordination
* Properly find next source line for goroutines blocked in chanrecv
* Refactor breakpoint clearing
* Refactor temp breakpoint setting
2015-04-19 17:15:34 -05:00
Derek Parker
86e1530524 Improve next implementation
* Better tracking of current goroutine
* More efficient, eliminates superfluous step syscalls
* Handles concurrency and thread coordination better
2015-03-31 17:12:45 -05:00
Derek Parker
2d2d70641e (Mostly) working on OS X 2015-02-27 15:03:06 -06:00
epipho
c7fe4e3e88 Added limit to array size (64) and struct member recursion (2) when printing 2015-02-04 13:15:10 -05:00
epipho
1782e13f74 Genericized slice reading 2015-01-20 01:37:52 -05:00
epipho
e2236664dd Genericized array reading 2015-01-20 00:32:08 -05:00
epipho
99b614a028 Adding support for reading function pointers and mapping them to function names 2015-01-19 23:15:40 -05:00
epipho
056df44318 Support for uint and boolean types 2015-01-19 22:18:17 -05:00
epipho
67ad85feec readString can now read strings of any length as well as sliced strings 2015-01-19 19:30:15 -05:00
epipho
7c61e2a1cb EvalSymbol supports evaluating struct members on pointers. Fixed panic
when evaluating a nil pointer.
2015-01-02 10:02:56 -06:00
epipho
2c5527c6c9 Refactor member variable evaluation so it works in all cases 2014-12-31 16:20:26 -05:00
epipho
07940dc59e Added info locals and info args commands 2014-12-30 12:58:44 -05:00
Derek Parker
623ec5e53d Improve array evaluation support
* First of a few commits to allow for evaluating arrays of arbitrary
  types
* Adds support for 32 bit integer arrays
2014-12-28 22:37:18 -06:00
Derek Parker
3b2b17938b Improve support for goroutine context switching
Remove any assumption that a wait syscall on a thread id after a
continue will return. Any time we continue a thread, wait for activity
from any thread, because the scheduler may well have switched contexts
on us due to syscall entrace, channel op, etc...

There are several more things to be done here including:

* Potential tracking of goroutine id as we jump around to thread
  contexts.
* Potential of selectively choosing threads to operate on based on the
  internal M data structures, ensuring that our M has an active G.

This commit partially fixes #23 and #24, however there are still some
random hangs that happen and need to be ironed out.
2014-11-24 17:57:52 -06:00
Derek Parker
dcf9f04d45 Improve variable evaluation scope
Properly scope variable evaluation to the function the traced process is
currently stopped in.
2014-11-10 21:26:13 -06:00
Derek Parker
6b2ee09163 Improve overall thread coordination 2014-11-07 23:45:54 -06:00
Derek Parker
f1ceba0909 Support 32 bit floats 2014-10-26 12:44:26 -05:00
Derek Parker
a3700a4407 Improve support for int variable evaluation 2014-10-25 11:07:12 -05:00
Derek Parker
4c95bf7302 (Mostly) working multithreaded tracing implementation
Areas that need improving:

* Code cleanup
* Promote breakpoints back out of thread context
* Fix potential bug in "Next" implementation, when thread contexts
  switch
2014-10-25 08:59:22 -05:00
Derek Parker
099efeeb9d Allow evaluation of function params 2014-10-17 14:14:55 -05:00
Derek Parker
58c1f54578 Improve Next implementation
Fix bug involving detecting whether or not we have stepped into another
function when we plan on return from the function we are currently in.
2014-10-13 19:04:38 -05:00
Derek Parker
dc8c9cc2a4 Optimize Next implementation
Once the program detects that we have stepped into another function,
we simply calculate the return address and then set a breakpoint and
continue to that location, avoiding numerous syscalls.
2014-10-13 08:24:59 -05:00
Derek Parker
6a71009954 Fix Next impl
Needs some refactoring and some optimization, but fixes several bugs.
2014-10-09 14:19:10 -05:00
Derek Parker
9b6077b100 Update live test prog 2014-10-07 17:02:04 -05:00
Derek Parker
f8a65c41c5 Improve next impl -- needs refactoring 2014-10-04 00:52:40 -05:00
Derek Parker
ea087ba1b1 Modify fixture prog 2014-09-19 19:58:16 -05:00
Derek Parker
8ee9525f47 Ensure temp breakpoints are cleared after next 2014-09-18 22:28:21 -05:00
Derek Parker
2fa307f7c7 Remove test binaries 2014-09-12 14:56:27 -05:00
Derek Parker
93db6249a0 Launch prog from cli, also exit cleanly 2014-08-23 08:20:56 -05:00
Derek Parker
44dba87c5d Add some delay to livetestprog 2014-08-15 21:04:21 -05:00
Derek Parker
21025b2fc6 Implement basic array evaling 2014-08-04 15:21:35 -05:00
Derek Parker
31f7278526 Don't include debug artifacts 2014-08-04 13:52:03 -05:00
Derek Parker
2b83a1f3ca Implement reading of float64 value 2014-08-04 13:20:20 -05:00
Derek Parker
3993cfe148 Implement basic int value expressions 2014-08-01 16:34:49 -05:00
Derek Parker
319f6d2e20 Remove dwarf hack because Go fixed bug 2014-08-01 16:34:27 -05:00
Derek Parker
eeb5757097 Update binary prog for newer Go version 2014-07-11 16:17:51 -05:00
Derek Parker
3566fd5237 Improve next implementation
Improvements:
* `next`ing through a loop works correctly (when not already within a loop)
* `next`ing out of a function works correctly

Needs work:
* `next`ing in a loop can be improved when starting within a loop
2014-07-10 18:07:39 -05:00
Derek Parker
a788e03c7b Implement initial next implementation
This current implementation does not cover the following:

* Setting correct breakpoint when exiting loop
* Setting correct breakpoint when returning from function
    * All facilities are available for this, it just is not taken into
      account in the current `next` implementation.
2014-07-07 08:26:36 -05:00
Derek Parker
38bfdaf47c Implement initial support for stack unwinding.
Implement basic api for figuring out, given a current PC value, where
the function will return. Currently the API provides only a way to
determine the offset from SP (the Canonical Frame Address). It is left
up to the caller to grab the actual address from the traced program.
2014-06-25 14:14:29 -05:00
Derek Parker
8fb5e164b3 Update test progs for go13 2014-06-09 13:28:06 -05:00
Derek Parker
d36297687a Underscore fixtures dir to ignore during test run 2014-06-09 10:55:18 -05:00