Commit Graph

20 Commits

Author SHA1 Message Date
aarzilli
1ced7c3a60 proc: next should not skip lines with conditional bps
Conditional breakpoints with unmet conditions would cause next and step
to skip the line.

This breakpoint changes the Kind field of proc.Breakpoint from a single
value to a bit field, each breakpoint object can represent
simultaneously a user breakpoint and one internal breakpoint (of which
we have several different kinds).

The breakpoint condition for internal breakpoints is stored in the new
internalCond field of proc.Breakpoint so that it will not conflict with
user specified conditions.

The breakpoint setting code is changed to allow overlapping one
internal breakpoint on a user breakpoint, or a user breakpoint on an
existing internal breakpoint. All other combinations are rejected. The
breakpoint clearing code is changed to clear the UserBreakpoint bit and
only remove the phisical breakpoint if no other bits are set in the
Kind field. ClearInternalBreakpoints does the same thing but clearing
all bits that aren't the UserBreakpoint bit.

Fixes #844
2017-11-20 11:25:35 -08:00
aarzilli
178589a4e7 proc: breakpoints refactoring
Move some duplicate code, related to breakpoints, that was in both
backends into a single place.
This is in preparation to solve issue #844 (conditional breakpoints
make step and next fail) which will make this common breakpoint code
more complicated.
2017-11-20 11:25:35 -08:00
aarzilli
2c0e31160d proc/gdbserial: return error if stopped with a sginal
On macOS we can also stop when we receive a signal,
propagate this reason upwards to the client.

Also clear internal breakpoints after an unrecovered-panic since they
can not be reached anymore.

Fixes #872
2017-09-20 12:39:29 -07:00
aarzilli
9ee21686e6 proc: report errors when loading executable on attach
Fixes #940
2017-08-30 11:20:20 -07:00
Derek Parker
cc63d209c1 pkg/proc: return proper error when debugger has exited
Instead of panicing for sending on a closed channel, detect that the
process has exited and return a proper error message.

This patch also cleans up some spots where the Pid is omitted from the
error.

Fixes #920
2017-07-29 06:31:15 +02:00
Alex Brainman
0cfe539052 proc/native: make sure debugged executable can be deleted on windows (#890)
* proc/native: make sure debugged executable can be deleted on windows

Delve opens debugged executable to read binary info it
contains, but it never closes the file. Windows will not
let you delete file that is opened. So close Process.bi
in Process.postExit, and actually call Process.postExit
from windows Process.Kill.

Also Windows sends some debugging events
(EXIT_PROCESS_DEBUG_EVENT event in particular) after Delve
calls TerminateProcess. The events need to be consumed by
debugger before debugged process will be released by
Windows. So call Process.waitForDebugEvent after
TerminateProcess in Process.Kill.

Fixes #398

* cmd/dlv: make TestIssue398 pass on darwin

* cmd/dlv: add comment for TestIssue398

* proc/native: wait for debuggee to exit before returning from windows Process.Kill

* proc/native: close process handle before returning from windows killProcess

* proc/native: remove not used Process.Process
2017-07-26 12:51:44 -06:00
aarzilli
4121fb1f96 proc/native,proc/gdbserial: set selectedGoroutine after StepInstruction
When stepping through runtime sometimes the current goroutine will
change. It is impossible to handle this in Next, Step and StepOut but
StepInstruction can reset the current goroutine correctly.
2017-07-26 12:50:09 -06:00
aarzilli
5c2673a632 proc/native, proc/gdbserial: StepInstruction without goroutine
proc.Process.StepInstruction should work even if there is no goroutine
selected.
2017-07-26 12:50:09 -06:00
Alessandro Arzilli
07e53f7cbb proc: fix interaction of RequestManualStop and conditional breakpoints (#876)
* proc: fix interaction of RequestManualStop and conditional breakpoints

A conditional breakpoint that is hit but has the condition evaluate to
false can block a RequestManualStop from working. If the conditional
breakpoint is set on an instruction that is executed very frequently by
multiple goroutines (or many conditional breakpoints are set) it could
prevent all calls to RequestManualStop from working.

This commit fixes the problem by changing proc.Continue to exit
unconditionally after a RequestManualStop is called.

* proc/gdbserial: fix ContinueOnce getting stuck on macOS

Fixes #902
2017-07-07 16:29:37 -07:00
Alessandro Arzilli
a19bca2298 proc/native/windows: inline PtraceDetach delete ptrace_windows.go (#903)
Windows doesn't actually have ptrace.

Fixes #778
2017-06-29 11:13:32 -07:00
heschik
7d2834a963 proc: read G struct offset from runtime.tlsg if possible (#883)
When a Go program is externally linked, the external linker is
responsible for picking the TLS offset. It records its decision in the
runtime.tlsg symbol. Read the offset from that rather than guessing -16.

This implementation causes a regression: 1.4 and earlier will no longer
work.
2017-06-21 15:40:42 -07:00
aarzilli
16d8bd647f proc/*: remove Process.Running
Implementing proc.Process.Running in a thread safe way is complicated
and nothing actually uses it besides tests, so we are better off
rewriting the tests without Running and removing it.

In particular:

* The call to d.target.Running() in service/debugger/debugger.go
  (Restart) can never return true because that line executes while
  holding processMutex and all continue operations are also executed
  while holding processMutex.
* The call to dbp.Running() pkg/proc/native/proc.go (Detach) can never
  return true, because it's only called from
  debugger.(*Debugger).detach() which is also always called while
  holding processMutex.

Since some tests are hard to write correctly without Process.Running a
simpler interface, Process.NotifyResumed, is introduced.

Fixes #830
2017-06-13 08:53:54 +02:00
aarzilli
98142c695b proc/native: race between RequestManualStop and trapWait
RequestManualStop will run concurrently with trapWait, since one writes
dbp.halt and the other reads it dbp.halt should be protected by a
mutex.

Updates #830
2017-06-13 08:53:54 +02:00
Florin Pățan
640dedb479 Return breakpoints when they already exist (#870)
See https://youtrack.jetbrains.com/issue/GO-3931#comment=27-2224179
for more details
2017-06-12 14:55:53 -07:00
Alessandro Arzilli
862145f874 proc: print runtime.curg._panic.arg on unrecovered-panic breakpoint (#833)
You usually want to know the reason for the panic when a panic happens,
it can be printed manually this is a small quality of life improvement.
2017-05-09 10:32:16 -07:00
Alessandro Arzilli
a843f7944e proc/gdbserial: mozilla rr support (#804)
Implements #727
2017-05-05 15:17:52 -07:00
Alessandro Arzilli
1f1535802e proc/native: Detach should use Kill with child processes we want killed (#822)
While implementing the gdbserial backend everything was changed to call
Detach to "close" a process so that gdbserial could do its clean up in
a single place. However the native implementation of Detach does not
actually kill processes we launched.

Fixes #821
2017-05-05 10:04:32 -07:00
Alessandro Arzilli
a731eb661f Minor post-refactoring cleanup (#808)
* proc/native: remove unused utility methods

* proc: turn FindFileLocation, FindFunctionLocation, FirstPCAfterPrologue methods into function
2017-04-28 10:15:39 -07:00
aarzilli
b6fe5aebaf proc: refactoring: merge target into proc
- moved target.Interface into proc as proc.Process
- rename proc.IThread to proc.Thread
- replaced interfaces DisassembleInfo, Continuable and
  EvalScopeConvertible with Process.
- removed superfluous Gdbserver prefix from types in the gdbserial
  backend.
- removed superfluous Core prefix from types in the core backend.
2017-04-21 14:00:04 -07:00
aarzilli
15bac71979 proc: refactoring: split backends to separate packages
- move native backend to pkg/proc/native
- move gdbserver backend to pkg/proc/gdbserial
- move core dumps backend to pkg/proc/core
2017-04-21 14:00:04 -07:00