Commit Graph

11 Commits

Author SHA1 Message Date
Alessandro Arzilli
436a3c2149 proc refactor: split out BinaryInfo implementation (#745)
* proc: refactor BinaryInfo part of proc.Process to own type

The data structures and associated code used by proc.Process
to implement target.BinaryInfo will also be useful to support a
backend for examining core dumps, split this part of proc.Process
to a different type.

* proc: compile support for all executable formats unconditionally

So far we only compiled in support for loading the executable format
supported by the host operating system.
Once support for core files is introduced it is however useful to
support loading in all executable formats, there is no reason why it
shouldn't be possible to examine a linux coredump on windows, or
viceversa.

* proc: bugfix: do not resume threads on detach if killing

* Replace BinaryInfo interface with BinInfo() method returning proc.BinaryInfo
2017-04-06 11:14:01 -07:00
Alessandro Arzilli
7b19fe9e69 proc: add test for attach/detach, fix detach (#773)
Detach did not work for processes we attach to via PID.

Linux: we were only detaching from the main thread, all threads are
detached independently

Windows: we must resume all threads before detaching.

macOS: still broken.

Updates #772
2017-03-28 09:30:27 -07:00
dr2chase
bd48358de3 pkg/proc: tolerate absence of stack barriers in Go 1.9 (#762)
Stack barriers were removed in Go 1.9, and thus code that
expected various stack-barrier-related symbols to exist
does not find them.  Check for their absence and do not
crash when they are missing.  Disable stack-barrier-handling
test for 1.9 and beyond.

Fixes #754.
2017-03-13 10:53:16 -07:00
Alessandro Arzilli
97e3fc261c proc/tests: make TestStacktraceGoroutine more reliable (#764)
One of those goroutines could also conceivably be stopped on line 8.
2017-03-13 10:45:53 -07:00
Alessandro Arzilli
cda7316421 proc/tests: use Detach(true) instead of Kill in tests (#765)
The rest of the code uses Detach to "close" a proc.Process, the tests
should do the same.
Any cleanup that proc.Process needs to do can then be put inside Detach
and the tests will run it.
2017-03-13 10:44:27 -07:00
aarzilli
f2581e608a proc/test: improve TestStepParked
It was possible for TestStepParked to pick a runtime goroutine and
attempt to step it. Nothing guarantees that a goroutine other than the
ones we are using to run the code would actually ever resume before the
end of the program.

This makes the test more discerning in its choice of goroutines.
2017-02-22 20:39:28 +01:00
aarzilli
92faa95bf9 proc/stack: use BP when FDE is not available
On Windows we can sometimes encounter threads stopped in locations for
which we do not have entries in debug_frame.
These cases seem to be due to calls to Windows API in the go runtime,
we can still produce a (partial) stack trace in this circumstance by
following frame pointers (starting with BP).
We still prefer debug_frame entries when available since go functions
do not have frame pointers before go1.8.
2017-02-22 20:39:28 +01:00
aarzilli
1a68f8d351 proc/windows: handle delayed events
Sometimes windows will send us events about breakpoints we have
already removed from the code despite the fact that we go to great
lengths to avoid this already.

Change waitForDebugEvent to check that when we receive a breakpoint
event the corresponding memory actually contains an INT 3
instruction, if it doesn't ignore the event and restart the thread.
2017-02-22 20:39:28 +01:00
Alessandro Arzilli
b9bdf597b0 proc_test: TestStacktraceWithBarriers failing on go1.8 (#735)
Changes to the GC in 1.8 make this test fail because the GC isn't
inserting stack barriers into our test program anymore. This isn't the
same thing as being unable to print stacktraces in presence of stack
barriers so the test shouldn't fail.
2017-02-21 10:38:13 -08:00
Alessandro Arzilli
fc0d40144a proc/variables: fix infinite recursion with pointer loop (#725)
loadValue didn't react correctly to pointer loops going through
slice -> interface{} -> slice or pointer -> interface{} -> pointer.
2017-02-09 16:26:38 -08:00
Derek Parker
53f0d24057 Move top-level packages into pkg 2017-02-08 12:17:19 -08:00