Skip to content

Commit

Permalink
Merge branch 'go-delve:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Dufty committed Mar 22, 2023
2 parents 900b843 + 1522382 commit b397040
Show file tree
Hide file tree
Showing 162 changed files with 6,174 additions and 2,432 deletions.
2 changes: 1 addition & 1 deletion .teamcity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</repository>
<repository>
<id>teamcity-server</id>
<url>https://delve.beta.teamcity.com/app/dsl-plugins-repository</url>
<url>https://delve.teamcity.com/app/dsl-plugins-repository</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
Expand Down
15 changes: 9 additions & 6 deletions .teamcity/settings.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,26 @@ To debug in IntelliJ Idea, open the 'Maven Projects' tool window (View
version = "2020.2"

val targets = arrayOf(
"linux/amd64/1.17",
"linux/amd64/1.18",
"linux/amd64/1.19",
"linux/amd64/1.20",
"linux/amd64/tip",

"linux/386/1.19",
"linux/386/1.20",

"linux/arm64/1.19",
"linux/arm64/1.20",
"linux/arm64/tip",

"windows/amd64/1.19",
"windows/amd64/1.20",
"windows/amd64/tip",

"mac/amd64/1.19",
"windows/arm64/1.20",
"windows/arm64/tip",

"mac/amd64/1.20",
"mac/amd64/tip",

"mac/arm64/1.19",
"mac/arm64/1.20",
"mac/arm64/tip"
)

Expand Down
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,37 @@
All notable changes to this project will be documented in this file.
This project adheres to Semantic Versioning.

## [1.20.1] 2022-12-12

### Fixed

- Fix executing programs on macOS with most versions of debugserver installed (#3211, @aarzilli)

## [1.20.0] 2022-12-07

### Added

- Support for Go 1.20 (#3129, #3196, #3180, @cuiweixie, @qmuntal, @aarzilli)
- Support for Windows/arm64 (gated by a build tag) (#3063, #3198, #3200, @qmuntal)
- Compatibility with coredumpctl (#3195, @Foxboron)

### Fixed

- Improve evaluation of type casts (#3146, #3149, #3186, @aarzilli)
- DAP: Added type to response of EvaluateRequest (#3172, @gfszr)
- Cgo stacktraces on linux/arm64 (#3192, @derekparker)
- Debugserver crashes on recent versions of macOS when $DYLD_INSERT_LIBRARIES is set (#3181, @aviramha)
- Stacktraces and stepping on Go 1.19.2 and later on macOS (#3204, @aarzilli)
- Attaching to processes used by a different user on Windows (#3162, @aarzilli)
- Nil pointer dereference when current address is not part of a function (#3157, @aarzilli)

### Changed

- Change behavior of exec command so that it looks for the executable in the current directory (#3167, @derekparker)
- DAP shows full value when evaluating log messages (#3141, @suzmue)
- Wait time is no longer reported for parked goroutines (its value was always incorrect) (#3139, @aarzilli)
- Miscellaneous improvements to documentation and error messages (#3119, #3117, #3154, #3161, #3169, #3188, @aarzilli, @derekparker, @cuishuang, @Frederick888, @dlipovetsky)

## [1.9.1] 2022-08-23

### Added
Expand Down
4 changes: 2 additions & 2 deletions Documentation/api/ClientHowto.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ breakpoints: "next" will continue until the next line of the program,
unexported runtime functions).

All of "next", "step" and "stepout" operate on the selected goroutine. The
selected gorutine is described by the `SelectedGoroutine` field of
selected goroutine is described by the `SelectedGoroutine` field of
`DebuggerState`. Every time `Command` returns the selected goroutine will be
reset to the goroutine that triggered the breakpoint.

Expand Down Expand Up @@ -203,7 +203,7 @@ There are several API entry points to evaluate variables in Delve:
* RPCServer.ListPackageVars returns all global variables in all packages
* PRCServer.ListLocalVars returns all local variables of a stack frame
* RPCServer.ListFunctionArgs returns all function arguments of a stack frame
* RPCServer.Eval evaluets an expression on a given stack frame
* RPCServer.Eval evaluates an expression on a given stack frame

All those API calls take a LoadConfig argument. The LoadConfig specifies how
much of the variable's value should actually be loaded. Because of
Expand Down
6 changes: 3 additions & 3 deletions Documentation/api/dap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Delve exposes a [DAP](https://microsoft.github.io/debug-adapter-protocol/overvie

This interface is served over a streaming TCP socket using `dlv` server in one of the two headless modes:
1. [`dlv dap`](../../usage/dlv_dap.md) - starts a single-use DAP-only server that waits for a client to specify launch/attach configuration for starting the debug session.
2. `dlv --headless <command> <debugee>` - starts a general server, enters a debug session for the specified debuggee and waits for a [JSON-RPC](../json-rpc/README.md) or a [DAP](https://microsoft.github.io/debug-adapter-protocol/overview) remote-attach client to begin interactive debugging. Can be used in multi-client mode with the following options:
2. `dlv --headless <command> <debuggee>` - starts a general server, enters a debug session for the specified debuggee and waits for a [JSON-RPC](../json-rpc/README.md) or a [DAP](https://microsoft.github.io/debug-adapter-protocol/overview) remote-attach client to begin interactive debugging. Can be used in multi-client mode with the following options:
* `--accept-multiclient` - use to support connections from multiple clients
* `--continue` - use to resume debuggee execution as soon as server session starts

Expand Down Expand Up @@ -73,7 +73,7 @@ Not all of the configurations are supported by each of the two available DAP ser

### Single-Client Mode

When used with `dlv dap` or `dlv --headless --accept-multiclient=false` (default), the DAP server will shut itself down at the end of the debug session, when the client sends a [disconnect request](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disconnect). If the debuggee was launched, it will be taken down as well. If the debugee was attached to, `terminateDebuggee` option will be respected.
When used with `dlv dap` or `dlv --headless --accept-multiclient=false` (default), the DAP server will shut itself down at the end of the debug session, when the client sends a [disconnect request](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disconnect). If the debuggee was launched, it will be taken down as well. If the debuggee was attached to, `terminateDebuggee` option will be respected.

When the program terminates, we send a [terminated event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Terminated), which is expected to trigger a [disconnect request](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disconnect) from the client for a session and a server shutdown. The [restart request](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Restart) is not yet supported.

Expand All @@ -83,7 +83,7 @@ Pressing Ctrl-C on the terminal where a headless server is running sends SIGINT

### Multi-Client Mode

When used with `dlv --headless --accept-multiclient=true`, the DAP server will honor the multi-client mode when a client [disconnects](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disconnect)) or client connection fails. The server will remain running and ready for a new client connection, and the debuggee will remain in whatever state it was at the time of disconnect - running or halted. Once [`suspendDebuggee`](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disconnect) option is supported by frontends like VS Code ([vscode/issues/134412](https://github.com/microsoft/vscode/issues/134412)), we will update the server to offer this as a way to specify debuggee state on disconnect.
When used with `dlv --headless --accept-multiclient=true`, the DAP server will honor the multi-client mode when a client [disconnects](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disconnect) or client connection fails. The server will remain running and ready for a new client connection, and the debuggee will remain in whatever state it was at the time of disconnect - running or halted. Once [`suspendDebuggee`](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disconnect) option is supported by frontends like VS Code ([vscode/issues/134412](https://github.com/microsoft/vscode/issues/134412)), we will update the server to offer this as a way to specify debuggee state on disconnect.

The client may request full shutdown of the server and the debuggee with [`terminateDebuggee`](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disconnect) option.

Expand Down
8 changes: 4 additions & 4 deletions Documentation/backend_test_health.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ Tests skipped by each supported backend:
* 1 broken - cgo stacktraces
* darwin/lldb skipped = 1
* 1 upstream issue
* freebsd skipped = 16
* 12 broken
* freebsd skipped = 4
* 4 not implemented
* linux/386/pie skipped = 1
* 1 broken
* linux/arm64 skipped = 1
* 1 broken - cgo stacktraces
* pie skipped = 2
* 2 upstream issue - https://github.com/golang/go/issues/29322
* windows skipped = 5
* 1 broken
* 3 see https://github.com/go-delve/delve/issues/2768
* 1 upstream issue
* windows/arm64 skipped = 2
* 1 broken - cgo stacktraces
* 1 broken - step concurrent
5 changes: 3 additions & 2 deletions Documentation/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ With the -hitcount option a condition on the breakpoint hit count can be set, th

The -per-g-hitcount option works like -hitcount, but use per goroutine hitcount to compare with n.

With the -clear option a condtion on the breakpoint can removed.
With the -clear option a condition on the breakpoint can removed.

The '% n' form means we should stop at the breakpoint when the hitcount is a multiple of n.

Expand Down Expand Up @@ -699,8 +699,9 @@ Set watchpoint.
The memory location is specified with the same expression language used by 'print', for example:

watch v
watch -w *(*int)(0x1400007c018)

will watch the address of variable 'v'.
will watch the address of variable 'v' and writes to an int at addr '0x1400007c018'.

Note that writes that do not change the value of the watched memory address might not be reported.

Expand Down
2 changes: 1 addition & 1 deletion Documentation/cli/expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Because many architectures have SIMD registers that can be used by the applicati

* `REGNAME.intN` returns the register REGNAME as an array of intN elements.
* `REGNAME.uintN` returns the register REGNAME as an array of uintN elements.
* `REGNAME.floatN` returns the register REGNAME as an array fo floatN elements.
* `REGNAME.floatN` returns the register REGNAME as an array of floatN elements.

In all cases N must be a power of 2.

15 changes: 7 additions & 8 deletions Documentation/cli/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ otherwise it optionally accepts a package path.
For example given this project layout:

```
.
├── github.com/me/foo
github.com/me/foo
├── cmd
└── foo
└── main.go
── pkg
└── baz
├── bar.go
└── bar_test.go
   └── foo
   └── main.go
── pkg
└── baz
├── bar.go
└── bar_test.go
```

If you are in the directory `github.com/me/foo/cmd/foo` you can simply run `dlv debug`
Expand Down
2 changes: 1 addition & 1 deletion Documentation/cli/starlark.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def command_echo_expr(a, b, c):
print("a", a, "b", b, "c", c)
```

The first commnad, `echo`, takes its arguments as a single string, while for `echo_expr` it will be possible to pass starlark expression as arguments:
The first command, `echo`, takes its arguments as a single string, while for `echo_expr` it will be possible to pass starlark expression as arguments:

```
(dlv) echo 2+2, 2-1, 2*3
Expand Down
35 changes: 28 additions & 7 deletions Documentation/faq.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
## Frequently Asked Questions

#### I'm getting an error while compiling Delve / unsupported architectures and OSs
<!-- BEGIN TOC -->
* [I'm getting an error while compiling Delve / unsupported architectures and OSs](#unsupportedplatforms)
* [How do I use Delve with Docker?](#docker)
* [How can I use Delve to debug a CLI application?](#ttydebug)
* [How can I use Delve for remote debugging?](#remote)
* [Can not set breakpoints or see source listing in a complicated debugging environment](#substpath)
* [Using Delve to debug the Go runtime](#runtime)
<!-- END TOC -->

### <a name="unsupportedplatforms"></a> I'm getting an error while compiling Delve / unsupported architectures and OSs

The most likely cause of this is that you are running an unsupported Operating System or architecture.
Currently Delve supports (GOOS / GOARCH):
Expand All @@ -18,7 +27,7 @@ There is no planned ETA for support of other architectures or operating systems.

See also: [backend test health](backend_test_health.md).

#### How do I use Delve with Docker?
### <a name="docker"></a> How do I use Delve with Docker?

When running the container you should pass the `--security-opt=seccomp:unconfined` option to Docker. You can start a headless instance of Delve inside the container like this:

Expand All @@ -40,7 +49,7 @@ dlv exec --headless --continue --listen :4040 --accept-multiclient /path/to/exec

Note that the connection to Delve is unauthenticated and will allow arbitrary remote code execution: *do not do this in production*.

#### How can I use Delve to debug a CLI application?
### <a name="ttydebug"></a> How can I use Delve to debug a CLI application?

There are three good ways to go about this

Expand All @@ -54,7 +63,7 @@ the terminal TTY.
`dlv debug` and `dlv exec` commands. For the best experience, you should create your own PTY and
assign it as the TTY. This can be done via [ptyme](https://github.com/derekparker/ptyme).

#### How can I use Delve for remote debugging?
### <a name="remote"></a> How can I use Delve for remote debugging?

It is best not to use remote debugging on a public network. If you have to do this, we recommend using ssh tunnels or a vpn connection.

Expand All @@ -77,7 +86,7 @@ ssh -NL 4040:localhost:4040 [email protected]
dlv connect :4040
```

#### <a name="substpath"></a> Can not set breakpoints or see source listing in a complicated debugging environment
### <a name="substpath"></a> Can not set breakpoints or see source listing in a complicated debugging environment

This problem manifests when one or more of these things happen:

Expand All @@ -103,8 +112,20 @@ Command failed: open /path/to/the/mainfile.go: no such file or directory

This is not a bug. The Go compiler embeds the paths of source files into the executable so that debuggers, including Delve, can use them. Doing any of the things listed above will prevent this feature from working seamlessly.

The substitute-path feature can be used to solve this problem, see `config help substitute-path` or the `substitutePath` option in launch.json.
The substitute-path feature can be used to solve this problem, see `help config` or the `substitutePath` option in launch.json.

The `source` command could also be useful in troubleshooting this problem, it shows the list of file paths that has been embedded by the compiler into the executable.
The `sources` command could also be useful in troubleshooting this problem, it shows the list of file paths that has been embedded by the compiler into the executable.

If you still think this is a bug in Delve and not a configuration problem, open an [issue](https://github.com/go-delve/delve/issues), filling the issue template and including the logs produced by delve with the options `--log --log-output=rpc,dap`.

### <a name="runtime"></a> Using Delve to debug the Go runtime

It's possible to use Delve to debug the Go runtime, however there are some caveats to keep in mind

* The `runtime` package is always compiled with optimizations and inlining, all of the caveats that apply to debugging optimized binaries apply to the runtime package. In particular some variables could be unavailable or have stale values and it could expose some bugs with the compiler assigning line numbers to instructions.

* Next, step and stepout try to follow the current goroutine, if you debug one of the functions in the runtime that modify the curg pointer they will get confused. The 'step-instruction' command should be used instead.

* When executing a stacktrace from g0 Delve will return the top frame and then immediately switch to the goroutine stack. If you want to see the g0 stacktrace use `stack -mode simple`.

* The step command only steps into private runtime functions if it is already inside a runtime function. To step inside a private runtime function inserted into user code by the compiler set a breakpoint and then use `runtime.curg.goid == <current goroutine id>` as condition.
3 changes: 2 additions & 1 deletion Documentation/usage/dlv_replay.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ dlv replay [trace directory] [flags]
### Options

```
-h, --help help for replay
-h, --help help for replay
-p, --onprocess int Pass onprocess pid to rr.
```

### Options inherited from parent commands
Expand Down
2 changes: 1 addition & 1 deletion Documentation/usage/dlv_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ unit tests. By default Delve will debug the tests in the current directory.
Alternatively you can specify a package name, and Delve will debug the tests in
that package instead. Double-dashes `--` can be used to pass arguments to the test program:

dlv test [package] -- -test.v -other-argument
dlv test [package] -- -test.run TestSomething -test.v -other-argument

See also: 'go help testflag'.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![license](http://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/go-delve/delve/master/LICENSE)
[![GoDoc](https://godoc.org/github.com/go-delve/delve?status.svg)](https://godoc.org/github.com/go-delve/delve)
[![Build Status](https://delve.beta.teamcity.com/app/rest/builds/buildType:(id:Delve_AggregatorBuild)/statusIcon.svg)](https://delve.beta.teamcity.com/viewType.html?buildTypeId=Delve_AggregatorBuild&guest=1)
[![Build Status](https://delve.teamcity.com/app/rest/builds/buildType:(id:Delve_AggregatorBuild)/statusIcon.svg)](https://delve.teamcity.com/viewType.html?buildTypeId=Delve_AggregatorBuild&guest=1)

The GitHub issue tracker is for **bugs** only. Please use the [developer mailing list](https://groups.google.com/forum/#!forum/delve-dev) for any feature proposals and discussions.

Expand Down
4 changes: 4 additions & 0 deletions _fixtures/cgostacktest/hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
#elif __i386__
#define BREAKPOINT asm("int3;")
#elif __aarch64__
#ifdef WIN32
#define BREAKPOINT asm("brk 0xF000;")
#else
#define BREAKPOINT asm("brk 0;")
#endif
#endif

void helloworld_pt2(int x) {
BREAKPOINT;
Expand Down
5 changes: 4 additions & 1 deletion _fixtures/fncall.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,15 @@ func main() {

d := &Derived{3, Base{4}}

var ref strings.Builder
fmt.Fprintf(&ref, "blah")

runtime.Breakpoint() // breakpoint here
call1(one, two)
fn2clos(2)
strings.LastIndexByte(stringslice[1], 'w')
d.Method()
d.Base.Method()
x.CallMe()
fmt.Println(one, two, zero, call, call0, call2, callexit, callpanic, callbreak, callstacktrace, stringsJoin, intslice, stringslice, comma, a.VRcvr, a.PRcvr, pa, vable_a, vable_pa, pable_pa, fn2clos, fn2glob, fn2valmeth, fn2ptrmeth, fn2nil, ga, escapeArg, a2, square, intcallpanic, onetwothree, curriedAdd, getAStruct, getAStructPtr, getVRcvrableFromAStruct, getPRcvrableFromAStructPtr, getVRcvrableFromAStructPtr, pa2, noreturncall, str, d, x, x2.CallMe(5), longstrs, regabistacktest, regabistacktest2, issue2698.String(), regabistacktest3, rast3, floatsum)
fmt.Println(one, two, zero, call, call0, call2, callexit, callpanic, callbreak, callstacktrace, stringsJoin, intslice, stringslice, comma, a.VRcvr, a.PRcvr, pa, vable_a, vable_pa, pable_pa, fn2clos, fn2glob, fn2valmeth, fn2ptrmeth, fn2nil, ga, escapeArg, a2, square, intcallpanic, onetwothree, curriedAdd, getAStruct, getAStructPtr, getVRcvrableFromAStruct, getPRcvrableFromAStructPtr, getVRcvrableFromAStructPtr, pa2, noreturncall, str, d, x, x2.CallMe(5), longstrs, regabistacktest, regabistacktest2, issue2698.String(), regabistacktest3, rast3, floatsum, ref)
}
17 changes: 17 additions & 0 deletions _fixtures/issue3194.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

/*
#cgo LDFLAGS: -framework CoreFoundation
#cgo LDFLAGS: -framework CFNetwork
#include <CFNetwork/CFProxySupport.h>
*/
import "C"
import "fmt"

func main() {
f() // break here
}

func f() {
fmt.Println("ok")
}
Loading

0 comments on commit b397040

Please sign in to comment.