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
lachlanwillis committed Oct 17, 2022
2 parents eb19018 + beaa046 commit 900b843
Show file tree
Hide file tree
Showing 395 changed files with 28,139 additions and 9,004 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ env:
GOFLAGS: -mod=vendor

freebsd_instance:
image: freebsd-11-3-stable-amd64-v20200402
image_family: freebsd-12-3

test_task:
install_script: pkg install -y go gcc git
Expand Down
12 changes: 6 additions & 6 deletions .teamcity/settings.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ To debug in IntelliJ Idea, open the 'Maven Projects' tool window (View
version = "2020.2"

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

"linux/386/1.18",
"linux/386/1.19",

"linux/arm64/1.18",
"linux/arm64/1.19",
"linux/arm64/tip",

"windows/amd64/1.18",
"windows/amd64/1.19",
"windows/amd64/tip",

"mac/amd64/1.18",
"mac/amd64/1.19",
"mac/amd64/tip",

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

Expand Down
53 changes: 52 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,60 @@

# Changelog

All notable changes to this project will be documented in this file.
This project adheres to Semantic Versioning.

## [1.9.1] 2022-08-23

### Added

- Add support for empty string in substitutePath (@RuijieC-dev)
- Support gnu_debuglink section (@aarzilli)
- Support exact matches in SubstitutePath (@eandre)
- Add ability to show disassembly instead of source code (@aazilli)
- Add -per-g-hitcount to breakpoint conditions (@yangxikun)

### Fixed

- Ensure breakpoint map exists (@aarzilli)
- Use standard library to compute CRC for gnu_debuglink section (@aarzilli)
- Fix command to download Go version in CI (@derekparker)
- Do not panic reading bad G struct (@aarzilli)
- Fix parsing DWARFv5 file table (@derekparker)
- Improve trace subcommand output (@derekparker)
- Fix documentation for examinemem (@aaarzilli)
- Fix step instruction on 1 byte instruction with software breakpoint (@qmuntal)
- Fix handling of function entry / return in ebpf tracing backend (@derekparker)
- Fix size of ebpf type for fn_addr (@derekparker)

### Changed

- Send large terminal output to pager (@aarzilli)
- Refactor windows backend framework (@qmuntal)
- Complete the dropping of CGO dependency for ebpf backend (@aarzilli)
- Limit disassembly range in DAP backend (@aarzilli)

## [1.9.0] 2022-07-06

### Added

- Support for Go 1.19 (#3038, #3031, #3009, @aarzilli)
- Autocomplete for local variables (#3004, @pippolo84)
- Support for function call injection on arm64 (#2996, @aarzilli)

### Fixed

- Ctrl-C handling on Windows (#3039, @aarzilli)
- Expressions accessing maps with string literals (#3036, @aarzilli)
- Occasional crash caused by race between manual stop and normal stop on macOS (#3021, @aarzilli)
- Pretty-print of register components (#3022, @aarzilli)
- Misc function call injection bugs (#3007, #3002, #3000, @aarzilli)

### Changed
- Improved FreeBSD port (#3019, #2972, #2981, #2982, @4a6f656c)
- Misc test fixes (#3011, #2995, #2979, @polinasok, @aarzilli)
- Misc documentation changes (#2998, #2991, @aarzilli, @polinasok)
- Better autogenerated function skip (#2975, @aarzilli)

## [1.8.3] 2022-04-25
### Added
- Pretty-print time.Time variables (@aarzilli)
Expand Down
1 change: 1 addition & 0 deletions Documentation/EditorIntegration.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ The following editor plugins for delve are available:
The following alternative UIs for delve are available:

* [Gdlv](https://github.com/aarzilli/gdlv)
* [Debugger](https://github.com/emad-elsaid/debugger)
30 changes: 28 additions & 2 deletions Documentation/api/dap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,34 @@ See [dap.Server.handleRequest](https://github.com/go-delve/delve/search?q=handle
## Launch and Attach Configurations

In addition to the general [DAP spec](https://microsoft.github.io/debug-adapter-protocol/specification), the server supports the following implementation-specific configuration options for starting the debug session:
* [LaunchRequestArguments](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Launch) - see [LaunchConfig godoc](https://pkg.go.dev/github.com/go-delve/delve/service/dap#LaunchConfig)
* [AttachRequestArguments](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Attach) - see [AttachConfig godoc](https://pkg.go.dev/github.com/go-delve/delve/service/dap#AttachConfig)

<table border=1>
<tr><th>request<th>mode<th>required<th colspan=9>optional<th></tr>
<tr><td rowspan=5>launch<br><a href="https://pkg.go.dev/github.com/go-delve/delve/service/dap#LaunchConfig">godoc</a>
<td>debug<td>program <td>dlvCwd<td>env<td>backend<td>args<td>cwd<td>buildFlags<td>output<td>noDebug
<td rowspan=7>
substitutePath<br>
stopOnEntry<br>
stackTraceDepth<br>
showGlobalVariables<br>
showRegisters<br>
hideSystemGoroutines<br>
goroutineFilters
</tr>
<tr>
<td>test<td>program <td>dlvCwd<td>env<td>backend<td>args<td>cwd<td>buildFlags<td>output<td>noDebug</tr>
<tr>
<td>exec<td>program <td>dlvCwd<td>env<td>backend<td>args<td>cwd<td> <td> <td>noDebug</tr>
<tr>
<td>core<td>program<br>corefilePath<td>dlvCwd<td>env<td> <td> <td> <td> <td> <td> </tr>
<tr>
<td>replay<td>traceDirPath <td>dlvCwd<td>env<td> <td> <td> <td> <td> <td> </tr>
<tr><td rowspan=2>attach<br><a href="https://pkg.go.dev/github.com/go-delve/delve/service/dap#AttachConfig">godoc</a>
<td>local<td>processId <td> <td> <td>backend<td> <td> <td> <td> <td> </tr>
<tr>
<td>remote<td> <td> <td> <td> <td> <td> <td> <td> <td> </tr>
</table>


Not all of the configurations are supported by each of the two available DAP servers:

Expand Down
23 changes: 16 additions & 7 deletions Documentation/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,12 @@ Set breakpoint condition.

condition <breakpoint name or id> <boolean expression>.
condition -hitcount <breakpoint name or id> <operator> <argument>.
condition -per-g-hitcount <breakpoint name or id> <operator> <argument>.
condition -clear <breakpoint name or id>.

Specifies that the breakpoint, tracepoint or watchpoint should break only if the boolean expression is true.

See Documentation/cli/expr.md for a description of supported expressions.
See [Documentation/cli/expr.md](//github.com/go-delve/delve/tree/master/Documentation/cli/expr.md) for a description of supported expressions.

With the -hitcount option a condition on the breakpoint hit count can be set, the following operators are supported

Expand All @@ -196,6 +197,8 @@ With the -hitcount option a condition on the breakpoint hit count can be set, th
condition -hitcount bp != n
condition -hitcount bp % n

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.

The '% n' form means we should stop at the breakpoint when the hitcount is a multiple of n.
Expand Down Expand Up @@ -315,7 +318,7 @@ Examine memory:
examinemem [-fmt <format>] [-count|-len <count>] [-size <size>] <address>
examinemem [-fmt <format>] [-count|-len <count>] [-size <size>] -x <expression>

Format represents the data format and the value is one of this list (default hex): bin(binary), oct(octal), dec(decimal), hex(hexadecimal), addr(address).
Format represents the data format and the value is one of this list (default hex): bin(binary), oct(octal), dec(decimal), hex(hexadecimal).
Length is the number of bytes (default 1) and must be less than or equal to 1000.
Address is the memory location of the target to examine. Please note '-len' is deprecated by '-count and -size'.
Expression can be an integer expression or pointer value of the memory location to examine.
Expand Down Expand Up @@ -372,7 +375,7 @@ Aliases: gr
## goroutines
List program goroutines.

goroutines [-u|-r|-g|-s] [-t [depth]] [-l] [-with loc expr] [-without loc expr] [-group argument]
goroutines [-u|-r|-g|-s] [-t [depth]] [-l] [-with loc expr] [-without loc expr] [-group argument] [-exec command]

Print out info for every goroutine. The flag controls what information is shown along with each goroutine:

Expand Down Expand Up @@ -428,6 +431,12 @@ Groups goroutines by the given location, running status or user classification,

Groups goroutines by the value of the label with the specified key.

EXEC

goroutines -exec <command>

Runs the command on every goroutine.


Aliases: grs

Expand Down Expand Up @@ -502,7 +511,7 @@ Evaluate an expression.

[goroutine <n>] [frame <m>] print [%format] <expression>

See Documentation/cli/expr.md for a description of supported expressions.
See [Documentation/cli/expr.md](//github.com/go-delve/delve/tree/master/Documentation/cli/expr.md) for a description of supported expressions.

The optional format argument is a format specifier, like the ones used by the fmt package. For example "print %x v" will print v as an hexadecimal number.

Expand All @@ -517,7 +526,7 @@ Print contents of CPU registers.

regs [-a]

Argument -a shows more registers. Individual registers can also be displayed by 'print' and 'display'. See Documentation/cli/expr.md.
Argument -a shows more registers. Individual registers can also be displayed by 'print' and 'display'. See [Documentation/cli/expr.md.](//github.com/go-delve/delve/tree/master/Documentation/cli/expr.md.)


## restart
Expand Down Expand Up @@ -547,7 +556,7 @@ Aliases: r

## rev
Reverses the execution of the target program for the command specified.
Currently, only the rev step-instruction command is supported.
Currently, rev next, step, step-instruction and stepout commands are supported.


## rewind
Expand All @@ -560,7 +569,7 @@ Changes the value of a variable.

[goroutine <n>] [frame <m>] set <variable> = <value>

See Documentation/cli/expr.md for a description of supported expressions. Only numerical variables and pointers can be changed.
See [Documentation/cli/expr.md](//github.com/go-delve/delve/tree/master/Documentation/cli/expr.md) for a description of supported expressions. Only numerical variables and pointers can be changed.


## source
Expand Down
2 changes: 1 addition & 1 deletion Documentation/cli/starlark.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ checkpoint(Where) | Equivalent to API call [Checkpoint](https://godoc.org/github
clear_breakpoint(Id, Name) | Equivalent to API call [ClearBreakpoint](https://godoc.org/github.com/go-delve/delve/service/rpc2#RPCServer.ClearBreakpoint)
clear_checkpoint(ID) | Equivalent to API call [ClearCheckpoint](https://godoc.org/github.com/go-delve/delve/service/rpc2#RPCServer.ClearCheckpoint)
raw_command(Name, ThreadID, GoroutineID, ReturnInfoLoadConfig, Expr, UnsafeCall) | Equivalent to API call [Command](https://godoc.org/github.com/go-delve/delve/service/rpc2#RPCServer.Command)
create_breakpoint(Breakpoint) | Equivalent to API call [CreateBreakpoint](https://godoc.org/github.com/go-delve/delve/service/rpc2#RPCServer.CreateBreakpoint)
create_breakpoint(Breakpoint, LocExpr, SubstitutePathRules, Suspended) | Equivalent to API call [CreateBreakpoint](https://godoc.org/github.com/go-delve/delve/service/rpc2#RPCServer.CreateBreakpoint)
create_ebpf_tracepoint(FunctionName) | Equivalent to API call [CreateEBPFTracepoint](https://godoc.org/github.com/go-delve/delve/service/rpc2#RPCServer.CreateEBPFTracepoint)
create_watchpoint(Scope, Expr, Type) | Equivalent to API call [CreateWatchpoint](https://godoc.org/github.com/go-delve/delve/service/rpc2#RPCServer.CreateWatchpoint)
detach(Kill) | Equivalent to API call [Detach](https://godoc.org/github.com/go-delve/delve/service/rpc2#RPCServer.Detach)
Expand Down
32 changes: 32 additions & 0 deletions Documentation/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,35 @@ 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

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

* Can not see source code when the program stops at a breakpoint
* Setting a breakpoint using full path, or through an IDE, does not work

While doing one of the following things:

* **The program is built and run inside a container** and Delve (or an IDE) is remotely connecting to it
* Generally, every time the build environment (VM, container, computer...) differs from the environment where Delve's front-end (dlv or a IDE) runs
* Using `-trimpath` or `-gcflags=-trimpath`
* Using a build system other than `go build` (eg. bazel)
* Using symlinks in your source tree

If you are affected by this problem then the `list main.main` command (in the command line interface) will have this result:

```
(dlv) list main.main
Showing /path/to/the/mainfile.go:42 (PC: 0x47dfca)
Command failed: open /path/to/the/mainfile.go: no such file or directory
(dlv)
```

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 `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.

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`.
10 changes: 10 additions & 0 deletions Documentation/installation/osx/install.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
## Homebrew

You can install Delve via HomeBrew with the following command:

```shell
$ brew install delve
```

## Other installation methods

See [general install instructions](../README.md).
9 changes: 9 additions & 0 deletions Documentation/usage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ The [available commands](dlv.md) can be grouped into the following categories:
* [dlv version](dlv_version.md)

The above list may be incomplete. Refer to the auto-generated [complete usage document](dlv.md) to further explore all available commands.

## Environment variables

Delve also reads the following environment variables:

* `$DELVE_EDITOR` is used by the `edit` command (if it isn't set the `$EDITOR` variable is used instead)
* `$DELVE_PAGER` is used by commands that emit large output (if it isn't set the `$PAGER` variable is used instead, if neither is set `more` is used)
* `$TERM` is used to decide whether or not ANSI escape codes should be used for colorized output
* `$DELVE_DEBUGSERVER_PATH` is used to locate the debugserver executable on macOS
2 changes: 1 addition & 1 deletion Documentation/usage/dlv_trace.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dlv trace [package] regexp [flags]
-h, --help help for trace
--output string Output path for the binary. (default "debug")
-p, --pid int Pid to attach to.
-s, --stack int Show stack trace with given depth. (Ignored with -ebpf)
-s, --stack int Show stack trace with given depth. (Ignored with --ebpf)
-t, --test Trace a test binary.
```

Expand Down
5 changes: 5 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Please answer the following before submitting your issue:
Note: Please include any substantial examples (debug session output,
stacktraces, etc) as linked gists.

If this is about source listing not showing up (or breakpoints not being
accepted) while running in a container please read our
[FAQ](https://github.com/go-delve/delve/blob/master/Documentation/faq.md#substpath)
first.

1. What version of Delve are you using (`dlv version`)?
2. What version of Go are you using? (`go version`)?
3. What operating system and processor architecture are you using?
Expand Down
19 changes: 19 additions & 0 deletions _fixtures/badflags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import (
"fmt"
"os"
)

func g() {
}

func main() {
g()
a := os.Args[1] == "1"
if a {
fmt.Printf("true branch %v\n", a)
} else {
fmt.Printf("false branch %v\n", a)
}
}
5 changes: 5 additions & 0 deletions _fixtures/break/break_amd64.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "textflag.h"

TEXT ·asmBrk(SB),0,$0-0
BYTE $0xcc
RET
7 changes: 7 additions & 0 deletions _fixtures/break/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

func asmBrk()

func main() {
asmBrk()
}
14 changes: 14 additions & 0 deletions _fixtures/cgodisass.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

/*
int a(int v) {
return 0xff + v;
}
*/
import "C"
import "fmt"

func main() {
fmt.Println("aaa")
print(C.a(11))
}
25 changes: 25 additions & 0 deletions _fixtures/condperghitcount.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"sync"
"time"
)

func main() {
var wg sync.WaitGroup
wg.Add(2)
for i := 0; i < 2; i++ {
go func() {
j := 0
for {
j++
if j > 10 {
break
}
}
wg.Done()
}()
time.Sleep(time.Second)
}
wg.Wait()
}
Loading

0 comments on commit 900b843

Please sign in to comment.