Commit Graph

77 Commits

Author SHA1 Message Date
Alessandro Arzilli
70b8a78d04
cmd/dlv: disable TestTraceMultipleGoroutines on FreeBSD (#3144)
This test seems to fail frequently on FreeBSD.
2022-09-29 10:08:46 -07:00
Alessandro Arzilli
4372ce0d27
proc,_scripts/rtype.go: add rtype annotations for g.atomicstatus (#3143)
Adds some rtype annotations for g.atomicstatus and update
_scripts/rtype.go to handle types outside of the runtime package.
2022-09-26 10:10:51 -07:00
Alessandro Arzilli
97a7455192
_scripts: fix CI on go1.19/linux/386 (#3100)
Go 1.19 is broken on linux/386 with some C compilers, this is a
workaround for our build script. See:

https://github.com/golang/go/issues/52919

Also fix TestBuild if the first message reported by delve is not the
message that indicates the server is listening.
2022-08-15 09:40:25 -07:00
Derek Parker
be08778975
:* Improve trace subcommand output (#3091)
This patch improves the output of the trace subcommand by
adding better line breaks, adding goroutine info to the
return statement, and removing unnecessary output.
2022-08-04 10:10:54 +02:00
Derek Parker
5c5fca4849
pkg/proc/internal/ebpf: Fix handling of entry / return (#3081)
This patch removes the old error-prone way of tracking
whether the tracepoint is for a function entry or
return. Instead of trying to guess, let the data structure
simply tell us directly.
2022-07-29 12:00:32 +02:00
Alessandro Arzilli
5452c30fac
proc/internal/ebpf: drop dependency on cgo (#3072)
The ebpf implementations uses cgo, but only to access some C struct
definitions. Instead of using cgo simply duplicate the defintion of
those two structs in Go and add a test to check that the duplicate
definitions remain synchronized.

Fixes #2827
2022-07-22 19:39:18 +02:00
polinasok
705ab206cd
dap: remote attach must not use terminateDebuggee in single-client launch mode (#2995) 2022-05-18 12:23:47 +02:00
polinasok
0b71eeca40
proc/gdbserial: shut down debuggee when failing to debug (#2953)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2022-04-01 10:31:23 -07:00
polinasok
6c368b78a9
debugger: clarify no debug info errors (#2954)
* debugger: clarify no debug info errors

* Fix typo

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2022-04-01 10:31:03 -07:00
polinasok
65e03d673d
dlv_test: fix TestChildProcessExitWhenNoDebugInfo to actually test strip binary (#2949)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2022-03-29 11:01:04 -07:00
cui fliter
9a9c1a9f33
*: fix some typos
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-03-23 16:10:00 +01:00
polinasok
b5f60db954
service/dap: support terminateDebuggee option for attach only (#2940)
* service/dap: support terminateDebuggee option for attach only

* Update dlv_test

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2022-03-22 07:19:56 -07:00
Alessandro Arzilli
5b925d4f5d
terminal: add transcript command (#2814)
Adds a transcript command that appends all command output to a file.
This command is equivalent to gdb's 'set logging'.

As part of this refactor the pkg/terminal commands to always write to a
io.Writer instead of using os.Stdout directly (through
fmt.Printf/fmt.Println).

Fixes #2237
2022-01-27 13:18:25 -08:00
Derek Parker
a88c9bde4a
pkg/proc: add build scripts & docker image for ebpf (#2847)
Adds a few build scripts and a container image for reproducible builds
of the ebpf programs.
2021-12-30 09:04:59 +01:00
polinasok
2f13672765
service/dap: fix compile error from merge conflict (#2818)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-12-08 11:37:35 +01:00
polinasok
d0898e4de1
service/dap: misc remote attach improvements (#2778)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-12-07 09:23:26 -08:00
polinasok
9013a121d8
server/dap: stop running command if conn closed - fixes nil dereference bug (#2781)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-11-09 09:24:26 +01: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
polinasok
b31565d8aa
service/dap: support JSON-RPC and DAP on the same port from "dlv debug/exec/test/attach" (#2755)
* Support JSON-RPC and DAP on the same port

* Fix test

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-10-25 12:39:28 -07:00
Derek Parker
689e08260b
eBPF tracing backend return value parsing (#2704)
Add return value parsing for eBPF tracing backend.
2021-10-25 12:37:36 -07:00
Hyang-Ah Hana Kim
98a0bcf772
cmd/dlv: add --client-addr flag to run dap with a predefined client (#2568)
This adds a new `--client-addr=host:port` flag to `dlv dap`.
If it is supplied, the dap process will dial into the tcp port where
a DAP client is waiting, and work with only the DAP client.
The DAP client is supposed to start the normal DAP message
exchange starting with the 'initialize' request after the dlv dap
process dials in and the connection is set up. 

VS Code Go extension plans to use this mode for

* reliably detecting `dlv dap` readiness. Currently it depends on
watching the log stream. After this PR, it can listen on a network port.
* running `dlv dap` from any terminal (part of RunInTerminal workflow
implementation).
2021-10-13 11:43:47 -07:00
Alessandro Arzilli
29eae8f617
*: clean up staticcheck problems (#2723)
Fix problems that can be fixed, ignore the ones that don't make sense
2021-09-28 12:07:42 -07:00
Alessandro Arzilli
038cd99b73
tests: run staticcheck during tests (#2705) 2021-09-24 15:31:54 -07: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
Derek Parker
1b2f7f0051
pkg/proc: Parse Goroutine ID in eBPF tracer (#2654)
This patch enables the eBPF tracer backend to parse the ID of the
Goroutine which hit the uprobe. This implementation is specific to AMD64
and will have to be generalized further in order to be used on other
architectures.
2021-08-24 14:53:27 +02:00
Alessandro Arzilli
c379296cc8
_scripts: auto check that pkg/proc and runtime are synchronized (#2557)
Adds a script that check automatically that the the assumptions that
pkg/proc makes about runtime are met by the actual runtime, using a
combination of parsing and magic comments.

Also emits a file describing all the struct fields, constants and
variables of the runtime that we use in pkg/proc.
2021-08-23 11:32:02 -07:00
Hyang-Ah Hana Kim
26e7f67cc4
cmd/dlv: dlv version --verbose (#2615)
* cmd/dlv: dlv version --verbose

That prints out runtime/debug.BuildInfo read from the dlv binary.
Users can retrieve the same info using `go version -m <path_to_dlv>`
but I think it is convenient to have.

If dlv was built from cloned delve repo:

```
$ ./dlv version -v
Delve Debugger
Version: 1.7.0
Build: $Id: e353a65161e6ed74952b96bbb62ebfc56090832b $
Build Details: go1.16.5
 mod    github.com/go-delve/delve       (devel)
 dep    github.com/cosiner/argv v0.1.0  h1:BVDiEL32lwHukgJKP87btEPenzrrHUjajs/8yzaqcXg=
...
```

If dlv was built with `go install github.com/go-delve/delve@latest`
with go1.16+, or
`GO111MODULE=on go get github.com/go-delve/delve@latest`
from a clean main module:

```
$ ./dlv version -v
Delve Debugger
Version: 1.7.0
Build: $Id: e353a65161e6ed74952b96bbb62ebfc56090832b $
Build Details: go1.16.5
 mod    github.com/go-delve/delve       v1.7.0
 dep    github.com/cosiner/argv v0.1.0  h1:BVDiEL32lwHukgJKP87btEPenzrrHUjajs/8yzaqcXg=
...
```

* remove an accidentally added bogus test
2021-07-27 09:38:48 -07:00
Suzy Mueller
890cde3d4c
service/dap: send terminated event when disconnecting (#2587)
* service/dap: send terminated event when disconnecting

If the program terminates while disconnecting, either because it
was killed or otherwise, send a terminated event.
2021-07-14 14:32:46 -07: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
polinasok
658d5ece2b
Skip 'access denied' failures in tests (#2386)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-03-15 09:34:26 -07:00
polinasok
54d0d56b9e
Add binary removal delay on Windows to avoid access denied (#2351)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-02-21 11:17:14 -08:00
Alessandro Arzilli
0593a1cebc
cmd/dlv/tests: fix TestGeneratedDoc on Windows (#2314)
Change TestGeneratedDoc to ignore differences in line terminators.
2021-01-20 09:40:03 -08:00
Alessandro Arzilli
6d1c00e56d
terminal,service: print WaitReason, WaitSince for goroutines (#2270)
Fixes #637
2021-01-05 10:59:17 -08:00
aarzilli
6ab6929b9a proc/gdbserial: fix redirect bugs with debugserver
1. Forward stdin/stdout/stderr to the target process when in foreground
   mode instead of always forwarding the current tty (issue #1964)
2. When redirecting a file descriptor make sure to also specify
   something for all three otherwise debugserver will misbehave (either
   exit on launch or run but giving the target process a closed file
   descriptor).

Fixes #1964
2020-11-17 16:00:22 +01:00
chainhelen
0bbf9e4eaf
*: Closer close and use assertNoError for testcase (#2204) 2020-10-19 14:44:04 -07:00
Alessandro Arzilli
84328ed870
proc/tests: keep track of tests skipped due to backend problems (#2178)
* proc/tests: keep track of tests skipped due to backend problems

Mark tests skipped due to backend problems and add a script to keep
track of them.

* Travis-CI: add ignorechecksum option to chocolatey command

Looks like a configuration problem on chocolatey's end.
2020-09-24 08:10:20 -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
1ef8c40ccf
cmd/dlv: subcommand 'dlv test' should switch to package directory (#2128)
Match 'go test' behaviour and switch to package directory, unless one
is specified with the '--wd' option.

Fixes #2125
2020-08-31 10:51:10 -07:00
chainhelen
04a0891913
cmd/dlv: do not ignore regex when tracing pid (#2069)
The trace command line subcommand ignored the regexp argument
when the traced process was specified using the '-p' option.

Fixes #2023
2020-06-02 12:07:03 -07:00
chainhelen
e28e3d30d2
[WIP] pkg/proc: avoid target process leaks. (#2018)
* pkg/proc: avoid target process leaks.

Target process should exit when dlv launch failed.

Fix #2017.
2020-05-14 14:23:16 +02:00
Derek Parker
f96663a243
cmd/dlv: Fix trace output (#2038)
* cmd/dlv,debugger: Improve dlv trace and trace command output

This patch improves the `dlv trace` subcommand output by reducing the
noise that is generated and providing clearer more concise information.

Also adds new tests closing a gap in our testing (we previously never
really tested this subcommand).

This patch also fixes the `dlv trace` REPL command to behave like the
subcommand in certain situations. If the tracepoint is for a function,
we now show function arguements and return values properly.

Also makes the overall output of the trace subcommand clearer.

Fixes #2027
2020-05-13 08:38:10 +02:00
Alessandro Arzilli
0f83fa66f5
cmd/dlv: make core command limitations more prominent (#2031)
Fixes #2026
2020-05-04 10:00:33 -07:00
Derek Parker
85c34e47ee *: mv scripts _scripts
Instead of selectively excluding this directory, hide it from the go
tooling by applying the "_" prefix.
2020-03-28 20:28:51 +01:00
Derek Parker
f05ce09473 *: Fix use of deprecated functionality 2020-03-20 09:05:14 +01:00
Derek Parker
15509d4dc9
*: Remove appveyor, use travis windows support (#1919)
* *: Remove appveyor, use travis windows support

* cmd/dlv: Update TestOutput for Travis on Windows

* cmd/dlv: Skip TestGeneratedDoc in Travis on Windows

* Reduce number of jobs in matrix

We only really want to test the full arch/go matrix on Linux.
For every other os/arch/go combination, only run Go tip and the latest
supported version.
2020-03-13 14:14:32 +01:00
Alessandro Arzilli
1a9e38aa0c
proc,terminal: Implement reverse step, next and stepout (#1785)
* proc: move defer breakpoint code into a function

Moves the code that sets a breakpoint on the first deferred function,
used by both next and StepOut, to its function.

* proc: implement reverse step/next/stepout

When the direction of execution is reversed (on a recording) Step, Next and
StepOut will behave similarly to their forward version. However there are
some subtle interactions between their behavior, prologue skipping, deferred
calls and normal calls. Specifically:

- when stepping backwards we need to set a breakpoint on the first
  instruction after each CALL instruction, once this breakpoint is reached we
  need to execute a single StepInstruction operation to reverse step into the
  CALL.
- to insure that the prologue is skipped reverse next needs to check if it
  is on the first instruction after the prologue, and if it is behave like
  reverse stepout.
- there is no reason to set breakpoints on deferred calls when reverse
  nexting or reverse stepping out, they will never be hit.
- reverse step out should generally place its breakpoint on the CALL
  instruction that created the current stack frame (which will be the CALL
  instruction immediately preceding the instruction at the return address).
- reverse step out needs to treat panic calls and deferreturn calls
  specially.

* service,terminal: implement reverse step, next, stepout
2020-03-11 15:40:41 -07:00
polinasok
0f9b05b9f5
dlv_test: add a basic test for dap command (#1899) 2020-02-28 09:48:59 -08:00
Alessandro Arzilli
0741d3e57f
*: Go 1.14 support branch (#1727)
* tests: misc test fixes for go1.14

- math.go is now ambiguous due to changes to the go runtime so specify
  that we mean our own math.go in _fixtures
- go list -m requires vendor-mode to be disabled so pass '-mod=' to it
  in case user has GOFLAGS=-mod=vendor
- update version of go/packages, required to work with go 1.14 (and
  executed go mod vendor)
- Increased goroutine migration in one development version of Go 1.14
  revealed a problem with TestCheckpoints in command_test.go and
  rr_test.go. The tests were always wrong because Restart(checkpoint)
  doesn't change the current thread but we can't assume that when the
  checkpoint was taken the current goroutine was running on the same
  thread.

* goversion: update maximum supported version

* Makefile: disable testing lldb-server backend on linux with Go 1.14

There seems to be some incompatibility with lldb-server version 6.0.0
on linux and Go 1.14.

* proc/gdbserial: better handling of signals

- if multiple signals are received simultaneously propagate all of them to the
  target threads instead of only one.
- debugserver will drop an interrupt request if a target thread simultaneously
  receives a signal, handle this situation.

* dwarf/line: normalize backslashes for windows executables

Starting with Go 1.14 the compiler sometimes emits backslashes as well
as forward slashes in debug_line, normalize everything to / for
conformity with the behavior of previous versions.

* proc/native: partial support for Windows async preempt mechanism

See https://github.com/golang/go/issues/36494 for a description of why
full support for 1.14 under windows is problematic.

* proc/native: disable Go 1.14 async preemption on Windows

See https://github.com/golang/go/issues/36494
2020-02-10 17:31:54 -08:00
Alessandro Arzilli
6b20e880e2 *: add option to re-record recorded targets (#1702)
Adds a '-r' option to the 'restart' command (and to the Restart API)
that re-records the target when using rr.

Also moves the code to delete the trace directory inside the gdbserial
package.
2019-10-21 11:48:04 -07:00
Alessandro Arzilli
e1e2a1fabb tests: fix TestGeneratedDoc (#1709)
It was failing silently.
2019-10-07 09:20:49 -07:00