Commit Graph

41 Commits

Author SHA1 Message Date
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
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
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
Derek Parker
c0ba4681c9 Use boolean zero value instead of setting false 2015-07-28 07:52:29 -05:00
Derek Parker
510133ae5a Return after error parsing version string 2015-07-28 07:51:09 -05:00
aarzilli
0933a681cf proc.(*Thread).GetG: reading TLS memory directly for g address instead of modifying the executable code 2015-07-28 07:33:51 +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
1727df4b1b Fix: Properly attach to running process on OSX 2015-07-15 20:37:43 -05:00
Derek Parker
c96d0a5ab2 Add pid flag to trace subcommand 2015-07-13 19:20:37 -05:00
Derek Parker
40284111d4 Kill process outright if manually forked 2015-07-11 01:43:47 -05:00
Derek Parker
98da14b078 Add comments to proc.Detach 2015-07-10 15:57:32 -05:00
Derek Parker
8107955039 Remove accidental GOMAXPROCS call in proc 2015-07-10 15:52:49 -05:00
Derek Parker
1ce255ffa3 Remove any printing from core proc package
Also, reorganizes some code.

Initially, the `proc` package emitted a lot of output. Now, that should
not be the case. The `proc` package should never print, for any reason.
That should be handled by clients.
2015-07-10 15:48:51 -05:00
Derek Parker
c8e4fcc285 Upper case comment 2015-07-10 15:43:42 -05:00
Derek Parker
b31575b54c Refactor: condense code for looking at current fn 2015-07-10 15:42:09 -05:00
Derek Parker
38e2cfc615 Remove duplicate call to Halt 2015-07-10 15:15:44 -05:00
Derek Parker
99cf3abc18 Inline superfluous function definition 2015-07-10 14:48:45 -05:00
Derek Parker
aa71d787aa Always stop the world after trapWait in resume
We do not need to verify a current breakpoint, nor do a redundant check
on whether we have been asked to manually halt. Assume trapWait has done
its due diligence and stop the world once it returns.
2015-07-09 23:13:20 -05:00
Derek Parker
a00957fcf5 Reuse existing function for BP by ID lookup
Also, kill whitespace to make code appear more as a singular block for
readability.
2015-07-09 15:45:43 -05:00
Derek Parker
386101466a Update comment in next 2015-07-09 15:21:10 -05:00
Derek Parker
8c44181d56 Prefer actual thread location in goroutine struct 2015-07-07 21:21:47 -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
3a96d8eed7 trace command 2015-06-29 21:16:55 +02:00
Derek Parker
c267eda9ba Update docs for ClearBreakpoint 2015-06-29 08:06:48 -05:00
aarzilli
2fcbc4bdef ClearBreakpoint should clear a hardware breakpoint from all threads
additionally fixes a bug when Detach is called on an exiting/exited thread: dbp.CurrentThread could point to a thread that has already been removed from dbp.Threads by trapWait which will lead to a nil pointer dereference caused proc.Process.clearBreakpoint getting nil from dbp.Threads[tid]
2015-06-29 11:35:53 +02: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
9d1711d376 dbp.Running determined by any thread running 2015-06-26 09:58:26 -05:00
Derek Parker
db278d0453 Improve TestHalt reliability on Linux 2015-06-26 07:46:46 -05:00
Derek Parker
b5483aa9cb Set GOMAXPROCS in proc_test
Makes for more deterministic test runs.
2015-06-21 21:11:48 -05:00
Derek Parker
48bb398c4b Properly report process exits 2015-06-21 21:11:47 -05:00
Derek Parker
687dc4172d Introduce JSON-RPC service 2015-06-21 21:11:30 -05:00
Derek Parker
38f97b4023 Update documentation on Process.Breakpoints 2015-06-20 18:07:32 -05:00
Derek Parker
6e538119d2 Refactor: Rename breakpoint methods
s/Break/SetBreakpoint/
s/Clear/ClearBreakpoint/
s/BreakByLocation/SetBreakpointByLocation/
2015-06-20 18:01:06 -05:00
Derek Parker
102d4c89ae s/DebuggedProcess/Process/ 2015-06-20 17:54:52 -05:00
aarzilli
07473f04c5 Implement stack command
Finishes #63 #64
2015-06-20 15:29:33 -05:00
Derek Parker
37235bba7f Store hardware/software breakpoints in same struct 2015-06-17 18:14:56 -05:00
Derek Parker
e4fc5e32c2 Refactor: Use thread-locked goroutine for ptrace ops
Previously either the terminal client or the debugger service would
either lock main goroutine to a thread or provide a locked goroutine to
run _all_ DebuggedProcess functions in. This is unnecessary because only
ptrace functions need to be run from the same thread that originated the
PT_ATTACH request.

Here we use a specific thread-locked goroutine to service any ptrace
request. That goroutine is also responsible for the initial spawning /
attaching of the process, since it must be responsible for the PT_ATTACH
request.
2015-06-13 12:57:42 -05:00
Derek Parker
e5233e7262 Rename: s/ThreadContext/Thread/ 2015-06-12 14:51:23 -05:00
Derek Parker
bfca6114d4 Rename package proctl -> proc 2015-06-12 14:49:23 -05:00