Commit Graph

114 Commits

Author SHA1 Message Date
Alessandro Arzilli
81781522c3
proc: make sure logical breakpoints map exists (#3115)
The logical breakpoints map was created as a side effect of
createUnrecoveredPanicBreakpoint or createFatalThrowBreakpoint, however
with an executable with incomplete debug info (that must be incomplete
in just the right way) both will fail and the logical breakpoint map
will never be created.

It's unknown how such an executable could be created, one easy way is
to debug a non-go executable.

Fixes #3114
2022-08-22 12:48:34 -07:00
Alessandro Arzilli
ac81269eef
proc: fix prettyprint for register components with large values (#3022)
Fix pretty printing for CPU register components (created with the
XMM0.uintN syntax) while using format strings
Also fixes printing large literal constants with format strings.

Fixes #3020
2022-06-02 10:16:32 -07:00
Fabio Falzoi
79d5db24a5
Automatically disable breakpoints with hitcount conditions that will never be satisfied again (#2833)
* service/debugger: disable breakpoints with hitcond not satisfiable

To avoid slowing down the debugged process unnecessarily, we disable
breakpoints with a hit condition that can no longer be hit again.

* test: add integration tests for hit conditions no more satisfiable

* proc/test: fix typo in breakpoints related tests

* test: use the new API for hitcond integration tests
2022-01-06 09:00:46 -08:00
Alessandro Arzilli
b192d84670
service: use name w/o parameters for breakpoints on generic funcs (#2774)
When printing breakpoints on generic functions use the function name
without parameters instead of using the name of the first instantiation
that appears on the list.
2021-12-13 11:41:28 -08:00
Alessandro Arzilli
617d934d3e
proc/gdbserial: allow rewind to work after process exit with rr (#2815)
* service/debugger: fix bug internal err with Restart on recorded target

If Restart is called after a Continue and Rewind on a recorded target
that has already terminated it will return an internal error.

* proc/gdbserial: allow rewind to work after process exit with rr

It is sometimes useful to set breakpoints and rewind a terminated
process when using rr, for example if interested in the last execution
of some function.
RR will not allow a backward continue after the process exit packet has
been  sent, however rr will also generate a synthetic SIGKILL right
before process exit.
Treat this packet as a process exit and change some things so both
continuing backwards and setting breakpoints can be done, on recorded
targets, after process exit has been reported.
2021-12-13 11:39:20 -08:00
Alessandro Arzilli
c207db792a
proc,locspec: support setting breakpoints by func name on generic funcs (#2745)
* proc,locspec: support setting breakpoints by func name on generic funcs

Changes proc.Function to parse function names correctly when they
contain instantiation lists and locspec to match generic functions.

* vendor: update golang.org/x/tools

The old version of golang.org/x/tools is incompatible with the new
iexport format.
2021-10-30 11:52:26 -07:00
Alessandro Arzilli
1893c9769b
Miscellaneous fixes for Windows native backend (#2736)
* proc/native: always stop after RequestManualStop on Windows

On Windows RequestManualStop will generate an exception on a special
DbgUiRemoteBreakin thread, sometimes this thread will die before we
finish stopping the process. We need to account for that and still stop
even if the thread is gone and no other thread hit a breakpoint.

Fixes flakiness of TestIssue419.

* proc/native: fix watchpoints with new threads on Windows

When a new thread is created we must reapply all watchpoints to it,
like we do on linux.

* tests: be lenient on goroutinestackprog tests on Windows

We can not guarantee that we find all goroutines stopped in a good
place and sometimes the stacktrace fails on Windows.
2021-10-13 08:43:54 -07:00
aarzilli
4e7b689e1a proc: rewrite FindFileLocation to support generics
With generics a single function can have multiple concrete
instantiations, the old version of FindFileLocation supported at most
one concrete instantiation per function and any number of inlined
calls, this supports any number of inlined calls and concrete
functions.
2021-10-02 15:44:30 +02:00
polinasok
5d158820f6
service/rpccommon: halt before detach in Stop (#2677)
* service/rpccommon: halt before detach in Stop

* Addd IsRunning check

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-09-01 10:31:37 -07:00
Alessandro Arzilli
4264bf00f2
proc,terminal,service: support stack watchpoints (#2521)
* terminal,service: add way to see internal breakpoints

Now that Delve has internal breakpoints that survive for long periods
of time it will be useful to have an option to display them.

* proc,terminal,service: support stack watchpoints

Adds support for watchpoints on stack allocated variables.

When a stack variable is watched, in addition to the normal watchpoint
some support breakpoints are created:

- one breakpoint inside runtime.copystack, used to adjust the address
  of the watchpoint when the stack is resized
- one or more breakpoints used to detect when the stack variable goes
  out of scope, those are similar to the breakpoints set by StepOut.

Implements #279
2021-08-09 10:41:25 -07:00
Alessandro Arzilli
658d36cb19
proc: allow multiple overlapping internal breakpoints (#2519)
Changes Breakpoint to allow multiple overlapping internal breakpoints
on the same instruction address.
This is done by changing the Breakpoint structure to contain a list of
"breaklets", each breaklet has a BreakpointKind and a condition
expression, independent of the other.
A breakpoint is considered active if any of its breaklets are active.
A breakpoint is removed when all its breaklets are removed.
We also change the terminology "internal breakpoint" to "stepping
breakpoint":

HasInternalBreakpoints -> HasSteppingBreakpoints
IsInternal -> IsStepping
etc...

The motivation for this change is implementing watchpoints on stack
variables.
Watching a stack variable requires also setting a special breakpoint to
find out when the variable goes out of scope. These breakpoints can not
be UserBreakpoints because only one user breakpoint is allowed on the
same instruction and they can not be internal breakpoints because they
should not be cleared when a next operation is completed (they should
be cleared when the variable watch is cleared).

Updates #279
2021-07-21 08:24:19 -07:00
Alessandro Arzilli
f0a32c8e1b
Go 1.17 support branch (#2451)
* proc: support new Go 1.17 panic/defer mechanism

Go 1.17 will create wrappers for deferred calls that take arguments.
Change defer reading code so that wrappers are automatically unwrapped.

Also the deferred function is called directly by runtime.gopanic, without going through runtime.callN which means that sometimes when a panic happens the stack is either:

0. deferred function call
1. deferred call wrapper
2. runtime.gopanic

or:

0. deferred function call
1. runtime.gopanic

instead of always being:

0. deferred function call
1. runtime.callN
2. runtime.gopanic

the isPanicCall check is changed accordingly.

* test: miscellaneous minor test fixes for Go 1.17

* proc: resolve inlined calls when stepping out of runtime.breakpoint

Calls to runtime.Breakpoint are inlined in Go 1.17 when inlining is
enabled, resolve inlined calls in stepInstructionOut.

* proc: add support for debugCallV2 with regabi

This change adds support for the new debug call protocol which had to
change for the new register ABI introduced in Go 1.17.

Summary of changes:
- Abstracts over the debug call version depending on the Go version
  found in the binary.
- Uses R12 instead of RAX as the debug protocol register when the binary
  is from Go 1.17 or later.
- Creates a variable directly from the DWARF entry for function
  arguments to support passing arguments however the ABI expects.
- Computes a very conservative stack frame size for the call when
  injecting a call into a Go process whose version is >=1.17.

Co-authored-by: Michael Anthony Knyszek <mknyszek@google.com>
Co-authored-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>

* TeamCity: enable tests on go-tip

* goversion: version compatibility bump

* TeamCity: fix go-tip builds on macOS/arm64

Co-authored-by: Michael Anthony Knyszek <mknyszek@google.com>
2021-07-08 08:47:53 -07:00
Alessandro Arzilli
1b0c4310c4
proc: give unique addresses to registerized variables (#2527)
We told clients that further loading of variables can be done by
specifying a type cast using the address of a variable that we
returned.
This does not work for registerized variables (or, in general,
variables that have a complex location expression) because we don't
give them unique addresses and we throw away the compositeMemory object
we made to read them.

This commit changes proc so that:

1. variables with location expression divided in pieces do get a unique
   memory address
2. the compositeMemory object is saved somewhere
3. when an integer is cast back into a pointer type we look through our
   saved compositeMemory objects to see if there is one that covers the
   specified address and use it.

The unique memory addresses we generate have the MSB set to 1, as
specified by the Intel 86x64 manual addresses in this form are reserved
for kernel memory (which we can not read anyway) so we are guaranteed
to never generate a fake memory address that overlaps a real memory
address of the application.

The unfortunate side effect of this is that it will break clients that
do not deserialize the address to a 64bit integer. This practice is
contrary to how we defined our types and contrary to the specification
of the JSON format, as of json.org, however it is also fairly common,
due to javascript itself having only 53bit integers.

We could come up with a new mechanism but then even more old clients
would have to be changed.
2021-07-02 18:37:55 +02:00
Alessandro Arzilli
7c82164264
terminal,service: Add filtering and grouping to goroutines command (#2504)
Adds filtering and grouping to the goroutines command.

The current implementation of the goroutines command is modeled after
the threads command of gdb. It works well for programs that have up to
a couple dozen goroutines but becomes unusable quickly after that.

This commit adds the ability to filter and group goroutines by several
different properties, allowing a better debugging experience on
programs that have hundreds or thousands of goroutines.
2021-07-01 11:25:33 -07:00
Alessandro Arzilli
d9ba60dcfe
test: disable avx512 test when backend is 'rr' (#2547)
The rr backend does not report avx512 registers back to us.
2021-06-28 09:48:51 -07:00
Derek Parker
42ecbd4413
proc,terminal: Ensure correct exit status (#2543)
Ensure that any command executed after the process we are trying to
debug prints a correct and consistent exit status.

Previously the exit code was being lost after the first time we printed
that a process has exited. Additionally, certain commands would print
the PID of the process and other would not. This change makes everything
more correct and consistent.
2021-06-22 13:35:13 +02:00
Alessandro Arzilli
585c711ce5
proc: when converting registers to slices set Base address (#2517)
If the base address isn't set then indexing and slicing will not work.
Large floating point registers already had the base set but small
general purpose registers did not.
2021-06-02 13:46:24 -07:00
Alessandro Arzilli
d552b33822
gdbserial,regnum: support ZMM registers, disable 'g' on debugserver (#2498)
Adds DWARF register number and support for AVX-512 registers.
Changes proc/gdbserial so that the 'g' and 'G' commands are never used
with debugserver since they seem to corrupt the thread state when used
on AVX-512 capable hardware.
Also changes TestClientServer_FpRegisters to be simpler and more
resilient to changes to the Go runtime.

Fixes #2479
2021-05-26 08:21:03 -07:00
Alessandro Arzilli
c5d58f494a
proc: add way to use CPU registers in expressions (#2446)
Changes the expression evaluation code so that register names, when not
shadowed by local or global variables, will evaluate to the current
value of the corresponding CPU register.

This allows a greater flexibility with displaying CPU registers than is
possible with using the ListRegisters API call. Also it allows
debuggers users to view register values even if the frontend they are
using does not implement a register view.
2021-05-04 12:56:17 -07:00
Alessandro Arzilli
e3d438876e
service/rpccommon: fix shutdown related bugs (#2439)
* service/rpcommon: resolve race between Detach and shutdown

Detach will close DisconnectChan causing the server to initiate
shutdown, there is a race between Detach writing its response to the
client and the shutdown terminating the server process.
If Detach loses the race the response to the Detach request is never
sent to the client and the client will report an EOF error instead.

This change delays the start of the shutdown process until after Detach
has written its response.

Fixes an occasional failure of TestContinue.

* service/rpccommon: ignore listener error when shutting down

Ignore the closed listener error when the server is being shut down in
response to a SIGINT signal.

Fixes #1633
2021-04-19 11:12:51 -07:00
Alessandro Arzilli
3c69f7435e
*: Never use pointer to proc.ErrProcessExited (#2431)
We have some places where we use proc.ErrProcessExited and some places
that use &proc.ErrProcessExited, resulting in checks for process exited
errors occasionally failing on some architectures.
Uniform use of ErrProcessExited to the non-pointer version.

Fixes intermittent failure of TestStepOutPreservesGoroutine.
2021-04-13 08:52:29 +02:00
Alessandro Arzilli
781ad72d62
service: fix breakpoint IDs after Restart with disabled breakpoints (#2425)
When restarting we must take care of setting breakpoint IDs correctly
so that enabled breakpoints do not end up having the same ID as a
disabled breakpoint, also we must make sure that breakpoints created
after restart will not get an ID already used by a disabled breakpoint.
2021-04-12 14:59:43 -07:00
Alessandro Arzilli
b120b11cc3
terminal: add optional format argument to print, display (#2398)
Changes print so a format argument can be specified by using '%' as
prefix. For example:

    print %x d

will print variable 'd' in hexadecimal. The interpretarion of the
format argument is the same as that of fmt's package.

Fixes #1038
Fixes #1800
Fixes #2159
2021-03-25 09:45:30 -07:00
Álex Sáez
f5d2e132bc
*: Adds toggle command (#2208)
* Adds toggle command

Also adds two rpc2 tests for testing the new functionality

* Removes Debuggers' ToggleBreakpoint method

rpc2's ToggleBreakpoint now calls AmendBreakpoint
Refactors the ClearBreakpoint to avoid a lock.
2021-03-19 11:02:23 -07:00
Alessandro Arzilli
f0ed4a71e1
Continuous Integration cleanup (#2369)
- remove github workflow for testing macOS/amd64 that is now covered by
  TeamCity
- fix DeepSource glob patterns to actually match what they are intended
  to match (did the interpretation change?)
- disable some cgo tests on darwin/arm64
2021-03-08 09:35:56 -08:00
Alessandro Arzilli
d739cb04e3
test: increase num of frames examined by TestClientServer_FullStacktrace (#2334)
When the runtime is allocating memory the stack trace needed to reach
user code might be greater than 10 frames.
2021-02-22 13:31:06 -08:00
Alessandro Arzilli
fc9e0be8e7
tests: changes to investigate TestClientServer_FullStacktrace errors (#2236)
Changs TestClientServer_FullStacktrace and
Test1ClientServer_FullStacktrace to log more information, also removes
code from TestFrameEvaluation that could mask the error.

Updates #2231
2021-01-26 10:07:06 -08:00
Alessandro Arzilli
6dd686ca49
Go 1.16 support branch (#2214)
* proc: misc test fixes for Go 1.16

* proc: fix cgo stacktraces in Go 1.16 with simplified C -> Go call path

* dwarf/line: make dwarf/line correct when '\\' are used

Our code depends heavily on paths being '/' separated because go always
produced '/' separated file paths. The call to filepath.Join will
normalize the paths, on windows, to always be '\\' separated, which
violated our assumptions.

This didn't use to be a problem because the codepath that calls
filepath.Join was never exercised by executable files produced by Go,
but Go 1.16 started producing debug_line sections that use the
directory table with https://go-review.googlesource.com/c/go/+/263017/.

Fix this to always use path.Join after making sure, on windows, to
always normalize paths to use '/' as a separator. Replace the use of
filepath.IsAbs with an operating system independent version.

* goversion: bump supported Go version
2021-01-05 10:56:30 -08:00
Christian Banse
57f033e4bc
proc/gdbserial: Added support for darwin/arm64 using gdbserver (#2285)
* Added support for reading darwin/arm64 using gdbserver

* Trying to fix test failures

* Addressing review comments
2021-01-04 08:52:04 -08:00
Alessandro Arzilli
d61bf018f0
debugger: check that target is valid when detaching (#2263)
Do not call detach if the target is no longer valid.

Fixes #2259

Co-authored-by: a <a@kra>
2020-12-15 08:13:13 -08:00
aarzilli
db93049813 service,terminal: apply substitute path to trace/break argument
Change FindLocation to apply substitute path rules to location
expressions. Changes terminal to always print paths after applying
substitutions.

Implements #2203
2020-11-17 16:41:35 +01:00
Alessandro Arzilli
0843376018
proc/*: remove proc.Thread.Blocked, refactor memory access (#2206)
On linux we can not read memory if the thread we use to do it is
occupied doing certain system calls. The exact conditions when this
happens have never been clear.

This problem was worked around by using the Blocked method which
recognized the most common circumstances where this would happen.

However this is a hack: Blocked returning true doesn't mean that the
problem will manifest and Blocked returning false doesn't necessarily
mean the problem will not manifest. A side effect of this is issue
#2151 where sometimes we can't read the memory of a thread and find its
associated goroutine.

This commit fixes this problem by always reading memory using a thread
we know to be good for this, specifically the one returned by
ContinueOnce. In particular the changes are as follows:

1. Remove (ProcessInternal).CurrentThread and
(ProcessInternal).SetCurrentThread, the "current thread" becomes a
field of Target, CurrentThread becomes a (*Target) method and
(*Target).SwitchThread basically just sets a field Target.

2. The backends keep track of their own internal idea of what the
current thread is, to use it to read memory, this is the thread they
return from ContinueOnce as trapthread

3. The current thread in the backend and the current thread in Target
only ever get synchronized in two places: when the backend creates a
Target object the currentThread field of Target is initialized with the
backend's current thread and when (*Target).Restart gets called (when a
recording is rewound the currentThread used by Target might not exist
anymore).

4. We remove the MemoryReadWriter interface embedded in Thread and
instead add a Memory method to Process that returns a MemoryReadWriter.
The  backends will return something here that will read memory using
the current thread saved by the backend.

5. The Thread.Blocked method is removed

One possible problem with this change is processes that have threads
with different memory maps. As far as I can determine this could happen
on old versions of linux but this option was removed in linux 2.5.

Fixes #2151
2020-11-09 11:28:40 -08:00
Polina Sokolova
42a4c80678 Remove redundant check in call tests 2020-11-03 11:59:16 +01:00
chainhelen
e07bfd3180
pkg/proc: fix dlv panic when sameGCond is nil. (#2164)
`sameFrameCond` should not be constructed as one `And Express` when
`sameGCond` which is the first child of `BinaryExpr` is nil.

Fixes: #2162
2020-09-08 15:18:49 -07:00
aarzilli
7555d1c063 cmd,proc,terminal,debugger: Support default file descriptor redirects
Adds features to support default file descriptor redirects for the
target process:

1. A new command line flag '--redirect' and '-r' are added to specify
   file redirects for the target process
2. New syntax is added to the 'restart' command to specify file
   redirects.
3. Interactive instances will check if stdin/stdout and stderr are
   terminals and print a helpful error message if they aren't.
2020-09-01 21:50:27 +02:00
Alessandro Arzilli
5a5d5f9e68
proc: fix support for AVX registers (#2139)
Recent changes to the way registers are handled broke reporting of AVX
registers (i.e. YMMx). This change restores the functionality by:

- concatenating the higher half of the YMMx registers to their
  corresponding XMMx lower half (YMMx registers do not have an
  independent DWARF register number)
- modifying the formatSSEReg function to handle them when they are
  present.

Fixes #2033
2020-08-31 10:55:43 -07:00
Alessandro Arzilli
f9c8f7f55b
Go 1.15 support (#2011)
* proc: start variable visibility one line after their decl line

In most cases variables shouldn't be visible on their declaration line
because they won't be initialized there.
Function arguments are treated as an exception.

This fix is only applied to programs compiled with Go 1.15 or later as
previous versions of Go did not report the correct declaration line for
variables captured by closures.

Fixes #1134

* proc: silence go vet error

* Makefile: enable PIE tests on windows/Go 1.15

* core: support core files for PIEs on windows

* goversion: add Go 1.15 to supported versions

* proc: fix function call injection for Go 1.15

Go 1.15 changed the call injection protocol so that the runtime will
execute the injected call on a different (new) goroutine.

This commit changes the function call support in delve to:

1. correctly track down the call injection state after the runtime
   switches to a different goroutine.
2. correctly perform the escapeCheck when stack values can come from
   multiple goroutine stacks.

* proc: miscellaneous fixed for call injection under macOS with go 1.15

- create copy of SP in debugCallAXCompleteCall case because the code
  used to assume that regs doesn't change
- fix automatic address calculation for function arguments when an
  argument has a spurious DW_OP_piece at entry
2020-07-28 09:19:51 -07:00
Álex Sáez
95e7cafd0c
terminal/command: Add 'reload' command (#1971)
* terminal/command: Add 'reload' command

These changes add the 'reload' command, which allows us to rebuild the project
and start the debugging session again. Currently, if the project's code is
updated while debugging it, Delve shows the new source code, but it's still
running the old one. With 'reload', the whole binary is rebuilt, and the
process starts again.

Fixes #1551

* Remove unnecessary print

Changes to be committed:
      modified:   pkg/terminal/command.go

* Add tests and refactor the code

Changes to be committed:
      modified:   cmd/dlv/cmds/commands.go
      modified:   go.mod
      modified:   pkg/terminal/command.go
      modified:   service/config.go
      modified:   service/debugger/debugger.go
      modified:   service/test/integration2_test.go

* Fix typo in the comment

Changes to be committed:
      modified:   service/debugger/debugger.go

* Fix typo in the name of the variables

The variables are local therefore the capitalization is not needed

Changes to be committed:
      modified:   cmd/dlv/cmds/commands.go

* Call GoTestBuild

Also, remove the := to avoid redeclaration

* Change the Kind in the tests

Change from debugger.ExecutingGeneratedTest to
debugger.ExecutingGeneratedFile for consistency.
We are generating a real binary instead of a test
one so ExecutingGeneratedFile makes more sense here.

Changes to be committed:
      modified:   service/test/integration2_test.go

* Avoid breakpoints based on addresses

Changes to be committed:
      modified:   service/debugger/debugger.go

* Update the rebuild behaviour

There are a few cases where we can't rebuild the binary because we don't
know how it was build.

Changes to be committed:
      modified:   service/debugger/debugger.go

* Fix typos and update documentation

Changes to be committed:
      modified:   Documentation/cli/README.md
      modified:   pkg/terminal/command.go
      modified:   service/config.go
      modified:   service/debugger/debugger.go

* Fix typo

* Remove variables

They were added to the debugger.Config

* Rename variable

Rename Kind to ExecuteKind to make it more accurate

Changes to be committed:
      modified:   cmd/dlv/cmds/commands.go
      modified:   service/debugger/debugger.go
      modified:   service/test/integration2_test.go
2020-06-05 11:03:09 -07:00
Derek Parker
e5d24a96bf *: Consolidate service/debugger config
Embed the debugger config object in the service config object to avoid needless duplication of fields.
2020-04-14 21:02:38 +02:00
aarzilli
72eeb5ae84 debugger: ClearBreakpoint should clear a logical breakpoint
Clear all physical breakpoints associated with a logical breakpoint in
ClearBreakpoint.

Fixes #1955
2020-04-02 08:53:09 -07:00
aarzilli
1ee8d5c218 tests: relax TestStacktraceGoroutine with Go 1.14
The test was always flaky because we can't fully control the state of
all goroutines in the target program, Go 1.14's asynchronous preemption
exacerbates the problem.

See for example:
https://travis-ci.com/github/go-delve/delve/jobs/302407282

This commit relaxes the checks made by the test to avoid irrelevante
flakiness.
2020-03-31 10:43:10 -07:00
Alessandro Arzilli
8bb93e9ae1
proc/gdbserial,debugger: allow clients to stop a recording (#1890)
Allows Delve clients to stop a recording midway by sending a
Command('halt')
request.

This is implemented by changing debugger.New to start recording the
process on a separate goroutine while holding the processMutex locked.
By locking the processMutex we ensure that almost all RPC requests will
block until the recording is done, since we can not respond correctly
to any of them.
API calls that do not require manipulating or examining the target
process, such as "IsMulticlient", "SetApiVersion" and
"GetState(nowait=true)" will work while we are recording the process.

Two other internal changes are made to the API: both GetState and
Restart become asynchronous requests, like Command. Restart because
this way it can be interrupted by a StopRecording request if the
rerecord option is passed.
GetState because clients need a call that will block until the
recording is compelted and can also be interrupted with a
StopRecording.

Clients that are uninterested in allowing the user to stop a recording
can ignore this change, since eventually they will make a request to
Delve that will block until the recording is completed.

Clients that wish to support this feature must:

1. call GetState(nowait=false) after connecting to Delve, before any
   call that would need to manipulate the target process
2. allow the user to send a StopRecording request during the initial
   GetState call
3. allow the user to send a StopRecording request during any subsequent
   Restart(rerecord=true) request (if supported).

Implements #1747
2020-03-24 09:09:28 -07:00
Derek Parker
ad75f78c4e
*: Fix go vet complaints (#1935)
* *: Fix go vet struct complaints

* *: Fix struct vet issue on linux

* *: Ignore proc/native in go vet check

We have to do some unsafe pointer manipulation that will never make go
vet happy within the proc/native package. Ignore it for runs of go vet.
2020-03-18 09:25:32 -07:00
chainhelen
f3a191cd73
pkg/proc,service: support linux/386 (#1884)
Implement debugging function for 386 on linux with reference to AMD64.
There are a few remaining problems that need to be solved in another time.

1. The stacktrace of cgo are not exactly as expected.
2. Not implement `core` for now.
3. Not implement `call` for now. Can't not find `runtime·debugCallV1` or
   similar function in $GOROOT/src/runtime/asm_386.s.

Update #20
2020-03-10 09:34:40 -07:00
Alessandro Arzilli
897d5c4288
debugger: CreateBreakpoint should delete existing breakpoints (#1892)
Fixes a bug introduced by the logical breakpoint change, where creating
the same breakpoint twice deletes the breakpoint.
2020-02-25 12:29:20 -08:00
Alessandro Arzilli
d925f6b719
proc,service: allow printing registers for arbitrary frames (#1875)
Adds an optional scope prefix to the `regs` command which allows
printing registers for any stack frame (as long as they were somehow
saved). Issue #1838 is not yet to be closed since we are still not
recovering the registers of a segfaulting frame.

Updates #1838
2020-02-24 10:47:02 -08:00
chainhelen
4f04b81c28
pkg/proc: Judge the validity of addr ranges when disasm. (#1872)
Avoid panic if start addr is greater than end addr when disasm.
2020-02-19 08:46:03 -08:00
hengwu0
3f7571ec30 proc: implement stacktrace of arm64 (#1780)
* proc: separate amd64-arch code

separate amd64 code about stacktrace, so we can add arm64 stacktrace code.

* proc: implemente stacktrace of arm64

* delve now can use stack, frame commands on arm64-arch debug.

Co-authored-by: tykcd996 <tang.yuke@zte.com.cn>
Co-authored-by: hengwu0 <wu.heng@zte.com.cn>

* test: remove skip-code of stacktrace on arm64

* add LR DWARF register and remove skip-code for fixed tests

* proc: fix the Continue command after the hardcoded breakpoint on arm64

Arm64 use hardware breakpoint, and it will not set PC to the next instruction like amd64. We should move PC in both runtime.breakpoints and hardcoded breakpoints(probably cgo).

* proc: implement cgo stacktrace on arm64

* proc: combine amd64_stack.go and arm64_stack.go file

* proc: reorganize the stacktrace code

* move SwitchStack function arch-related
* fix Continue command after manual stop on arm64
* add timeout flag to make.go to enable infinite timeouts

Co-authored-by: aarzilli <alessandro.arzilli@gmail.com>
Co-authored-by: hengwu0 <wu.heng@zte.com.cn>

Co-authored-by: tykcd996 <56993522+tykcd996@users.noreply.github.com>
Co-authored-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
2020-01-21 09:11:20 -08:00
chainhelen
666a618f47 service/test: Fix a wrong judgment about err.
Should judge `state.Err` instead of `err`.
2020-01-14 11:08:46 +01:00
aarzilli
035190c292 debugger: fix nil pointer dereference in FunctionReturnLocations
Fixes #1787
2019-12-10 07:55:12 -08:00