Commit Graph

2297 Commits

Author SHA1 Message Date
Alessandro Arzilli
038cd99b73
tests: run staticcheck during tests (#2705) 2021-09-24 15:31:54 -07:00
Michael Knyszek
041eedd126
pkg/proc: merge register data before writing to register (#2699)
Right now, if (*compositeMemory).WriteMemory needs to write a value to
a register that's smaller than the full size of the register (say, a
uint32 being passed as an argument), then (*AMD64Registers).SetReg can
later fail a sanity check that ensures the passed DwarfRegister is a
full size register.

Fix this by reading the old value of the register and overwriting just
the relevant parts with the new register. For the purposes of an
argument, it would probably be fine to just pad with zeroes, but merging
with the existing value is what gdb does.

Fixes #2698
2021-09-24 15:27:44 -07:00
Suzy Mueller
4b30ba4228
service/dap: add basic log points (#2634)
Log points are special kinds of breakpoints that do not 'break' but instead log a message and then continue. This change implements basic log points that simply log the provided message, without any interpolation.

In order to resume execution after hitting a breakpoint, I added a new lock resumeMu and tracked the running state within the DAP server. resumeMu must be held in order to issue a debugger request that would start execution. This means it can be used to make sure that another goroutine does not resume execution while you are holding the lock.

Most of the synchronization logic is taken from PR #2530

Updates golang/vscode-go#123
2021-09-24 15:22:32 -07:00
Suzy Mueller
e00670b901
service/debugger: return correct exit status on manual halt (#2674)
* service/dap: add test for nonzero exit status
2021-09-24 15:18:28 -07:00
Alessandro Arzilli
b50052cc17
proc/native: support watchpoints on Windows (#2651) 2021-09-24 15:17:46 -07:00
polinasok
2b306e32a6
service/dap: initial remote attach (handler support only) (#2709) 2021-09-24 13:43:46 +02:00
Hyang-Ah Hana Kim
eef04b9646
dap: delete unused function (#2720)
staticcheck reported a warning (U1000)
2021-09-24 07:17:01 +02:00
Suzy Mueller
c7e2a9b6fb
service/dap: remove unused test helper arg (#2714) 2021-09-22 21:29:05 -07:00
polinasok
b03d468b24
go.mod: update google/go-dap to 0.6.0 (#2710)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-09-22 21:26:40 -07:00
Yang Wei
ff52a37a6a
cmd/dlv: Parse Go+BoringCrypto version (#2712)
This changes allow us to parse Go+BoringCrypto which formatted in <GoVersion>b<BoringCryptoVersion> so that we can surpress `Version of Go is too old for this version of Delve` error.

Fixes #2711
2021-09-22 21:25:31 -07:00
Davide Masserut
9f8b352a98
vendor: update liner dependency (#2700)
This change update liner to the latest release that adds support to
delete the next and the previous word with Alt-d and Alt-BackSpace
plus a small amount of fixes.
2021-09-22 21:15:02 -07:00
polinasok
a3897eafa7
service/dap: client must treat non-build launch/attach errors as visible (#2671)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-09-22 21:12:48 -07:00
Derek Parker
2adb72d053
v1.7.2 (#2708)
Release v1.7.2, update CHANGELOG.
2021-09-22 21:05:04 -07:00
polinasok
cf10647360
service/dap: fix test setup for forcing server stop, add extra test (#2702)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-09-20 08:53:01 -07:00
Suzy Mueller
ab38d71147
service/dap: show decimal and hex values for uint (#2694) 2021-09-16 12:19:01 +02:00
Suzy Mueller
53eed29900
pkg/proc: update check for system goroutine (#2585)
* pkg/proc: update check for system goroutine

The finalizer goroutine can be either a system goroutine or a user goroutine. It is considered a user goroutine only when it calls back to user code. This change attempts to get closer to the implementation in the src/runtime/traceback.go by checking the value of fingRunning.

We could alternatively adopt the approximation done by src/cmd/trace/trace.go which only special cases "runtime.main", and always considers the finalizer to be a system goroutine.
2021-09-13 14:42:21 -07:00
Claus Lensbøl
4bcb8fb144
terminal/make: Add GOARCH and GOOS arguments (#2696)
This change adds '--GOARCH=[arch]' and '--GOOS=[os]' as arguments for
the make script to simplify the process of cross compilling.
2021-09-13 09:11:45 -07:00
Gabriel Vasile
822c1ed2f1
Documentation: remove individual os install instruction links (#2697)
Since the install instructions are more or less the same on all four
operating systems, remove individual install instruction links from
readme.
2021-09-13 10:55:06 +02:00
Suzy Mueller
0979847100
service/dap: do not send a halt request if the debuggee is not running (#2686)
updates go-delve/delve#2685
2021-09-09 08:49:11 -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
Johannes Altmanninger
45f44bc218
Prefer string variant for source-list-line-color config option (#2676)
The string variant is more powerful and can be passed
directly to "echo -e" / "printf" and friends.

Remove the mention of the integer variant from the default config. This
makes the option appear more consistent with other color options.
The user shouldn't care about the historic differences.
2021-09-01 10:03:58 -07:00
polinasok
47d07e095c
service/dap: add test coverage for Stop() (#2678)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-09-01 09:59:51 -07:00
Johannes Altmanninger
f5105c57f7
terminal: config -list to print strings inside interfaces in quotes (#2680)
Commit 3d6bbbe9 made "config -list" print strings in quotes to avoid
the strings being interpreted as terminal escape codes.  This commit
does the same for "source-list-line-color", which is a raw interface.
This fixes "config -list" with a config like

	source-list-line-color: "\x1b[34m"

The "int" variant is already printed correctly, so just use the
default case for that.
2021-09-01 09:59:15 -07:00
Suzy Mueller
88b163d038
service/dap: include selected goroutine in threads request (#2683)
When we set a limit on the number of threads that would be
returned, it was possible that the selected thread was not
included in the list of threads. This could cause issues
because the stopped reason is associated with the selected
goroutine, so users could be missing out on important info.

This change makes sure that the selected goroutine is included
by adding it to the end of the list.
2021-09-01 09:58:42 -07:00
Alessandro Arzilli
7dddcc186e
tests: fix TestIssue419 (#2682)
errChan should not be closed otherwise the function that requests the
manual stop might find it closed.
2021-08-31 10:44:57 -07:00
Hyang-Ah Hana Kim
1433c07957
dap: define LaunchConfig/AttachConfig types (#2571)
Formally define these types and document their meaning.
We will auto-generate the dlv-dap documentation from these Go type doc.

mapToStruct is a helper that sets the given struct's fields with the
info in map[string]interface{} (launch/attach's Arguments). We achieve
this by reencoding map[string]interface{} to json and decoding back to
the target struct. If go-dap left the implementation-specific arguments
as json.RawMessage and let the implementation decode as needed, this
reencoding could've been avoided.

encoding/json itself does not have mean to enforce required fields.
There was a test case that checks substitutePath elements must set
both from/to fields. Path.UnmarshalJSON implements the check.
I am not yet sure about the need for distinction between missing
'from/to' and empty strings yet. (empty value is useful when dealing with
a binary built with trimpath, right?)

A minor behavior change - previously, if noDebug is not a boolean type,
we ignored the attribute silently. Since we use json decoding, any
mismatched types will cause an error and this non-boolean type noDebug
attribute will result in launch failure.
2021-08-26 14:42:58 +02:00
Johannes Altmanninger
7c91fa0d72
pkg/terminal: avoid bright colors in default syntax highlighting (#2675)
These two were hard to read on default xterm or on Konsole's "White on
Black" theme. The non-bright colors still work on dark backgrounds.

See https://github.com/go-delve/delve/pull/2294#discussion_r691076091
2021-08-25 08:51:11 -07:00
Derek Parker
914e1bc80e
pkg/proc: attempt to leverage debuginfod-find (#2670)
If we cannot find debug information locally on the system, try and
invoke debuginfod-find in order to ask the linux distribution we're on
to find the debug information for us.
2021-08-25 13:29:28 +02:00
Alessandro Arzilli
a1a726d315
tests: correctly check for 1.17 + regabi (#2673)
regabi is not supported on FreeBSD, the tests must act accordingly
2021-08-24 08:21:17 -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
Alessandro Arzilli
3d6bbbe92a
terminal: config -list should print strings in quotes (#2605)
Commit 8e91d3b0b added a number of configuration options to control the
colors of sytnax highlighting, unfortunately 'config -list' will print
all of those to stdout without quoting them, resulting in the color of
the last one being applied to all subsequent text.

Change 'config -list' to print strings in quotes so that we don't
accidentally send escape sequences to the terminal.
2021-08-23 11:28:27 -07:00
polinasok
7cdf48605b
service/dap: clarify handling of relative program path (#2653)
* service/dap: add test verifying handling of relative program path

* Add exec test, log build dir and document in --help

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-08-23 11:27:49 -07:00
Alessandro Arzilli
d76181bba5
Documentation: add notes on porting Delve to other architectures (#2666) 2021-08-20 09:32:56 -07:00
Derek Parker
df1108b277
*: v1.7.1 (#2662) 2021-08-18 09:08:57 +02:00
polinasok
a4d416d5f1
service/dap: add test that verifies output path is relative to wd (#2656)
* service/dap: add test that verifies output path is relative to wd

* Use cleanExeName to get the right output name on Win

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-08-17 11:40:31 -07:00
polinasok
694b45c893
service/dap: fix noDebug mode to handle requests while running (#2658)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-08-16 08:51:23 -07:00
Alessandro Arzilli
513751573e
service: fix sameuser check (#2642)
Change the socket search to check both the remote and local fields of the
socket match the socket we want to find.

Sockets are identified by the 4-uple

	local_addr, local_port, remote_addr, remote_port

Two socket can differ by a single one of this four elements.
It is possible for the same local_port to be used by two different sockets,
as long as they are connecting to different remote addresses (or remote
ports).

An example of this bug in action can be seen at:

https://github.com/golang/vscode-go/runs/3141270564?check_suite_focus=true

There the server starts listening on 127.0.0.1:46011 and rejects a valid
client connection by finding the following socket:

60: 0100007F:DD82 0100007F:962D 06 00000000:00000000 03:00000133 00000000     0        0 0 3 0000000000000000

the local address of this socket is 0100007F:DD82 (127.0.0.1:56706), and the
remote address is 0100007F:962D (127.0.0.1:38445).

The reported error is:

	closing connection from different user (127.0.0.1:56706): connections to localhost are only accepted from the same UNIX user for security reasons

note how the local port does match the socket line (56706) but the remote
port is wrong (38445 instead of 46011).

Note also that the state of this socket is 06, or TIME_WAIT, which would be
impossible if this was the right socket, since the right socket would still
be open.

Fixes https://github.com/golang/vscode-go/issues/1555
2021-08-10 11:40:39 +02:00
Suzy Mueller
c426c5b38d
pkg/proc: configure target to not clear stepping breakpoints (#2635)
In order for DAP to support halting the program (either manually or on a breakpoint) performing some action and then resuming execution, there needs to be a way to stop the program without clearing the internal breakpoints. This is necessary for log points and stopping the program to set breakpoints.

The debugging UI makes it seem like a user should be able to set or clear a breakpoint at any time. Adding this ability to complete synchronous requests while the program is running is thus important to create a seamless user experience.

This change just adds a configuration to determine whether the target should clear the stepping breakpoints, and changes the server to use this new mode. Using the new mode means that the DAP server must determine when it expect the next to be canceled and do this manually.
2021-08-09 10:56:20 -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
f3e76238e3
proc: move breakpoint condition evaluation out of backends (#2628)
* proc: move breakpoint condition evaluation out of backends

Moves breakpoint condition evaluation from the point where breakpoints
are set, inside ContinueOnce, to (*Target).Continue.

This accomplishes three things:

1. the breakpoint evaluation method needs not be exported anymore
2. breakpoint condition evaluation can be done with a full scope,
   containing a Target object, something that wasn't possible before
   because ContinueOnce doesn't have access to the Target object.
3. moves breakpoint condition evaluation out of the critical section
   where some of the threads of the target process might be still
   running.

* proc/native: handle process death during stop() on Windows

It is possible that the thread dies while we are inside the stop()
function. This results in an Access is denied error being returned by
SuspendThread being called on threads that no longer exist.

Delay the reporting the error from SuspendThread until the end of
stop() and only report it if the thread still exists at that point.

Fixes flakyness with TestIssue1101 that was exacerbated by moving
breakpoint condition evaluation outside of the backends.
2021-08-09 10:16:24 -07:00
hitzhangjie
4e5bddee9b
cmd/dlv: use simple chan read instead of select-case (#2649) 2021-08-09 10:08:12 -07:00
hitzhangjie
6b83e6baae
vendor: run go mod vendor (#2647) 2021-08-06 08:26:44 +02:00
Alessandro Arzilli
e175d68e97
service/dap: fix race condition in TestContinueOnEntry (#2641)
The Threads request sent immediately after the ConfigurationDone
request can be processed in two possible states:

- while the program is being executed, when it will return Id=1,
  Name=Dummy
- after the program terminates, when it will return Id=-1, Name=Current

additionally the response could be received in any order with the
Terminate event.

Remove the problematic Threads request from the test.
2021-08-05 22:19:27 -07:00
Derek Parker
43d50202f3
pkg/terminal: Allow fuzzy searching tab completions (#2633)
This patch implements fuzzy searching for tab completions in the
terminal client. Under the hood it is using a trie data structure
(https://en.wikipedia.org/wiki/Trie) to perform very fast prefix / fuzzy
searches.
2021-08-05 19:55:27 +02:00
polinasok
985eca462c
service/dap: log execution-halted message when setting breakpoints (#2631)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-08-05 10:16:15 -07:00
Derek Parker
7caa534d76
service/debugger: Remove target lock on GetBufferedTracepoints (#2645)
There is already a lock on the actual buffered tracepoints collection
within proc, and this method call doesn't do anything to mutate Target
otherwise so we shouldn't be opening ourselves up for a race condition
error or any other kind of parallelism problem.

Additionally, with this lock we essentially can never get the data until
the process has exited becuase `continue` will lock the target. This
change allows us to get the buffered tracepoint information immediately
and display it as the program is running.
2021-08-05 13:53:09 +02:00
Alessandro Arzilli
2971fd4c68
service/dap: fix TestNextParked/TestStepInParked (#2643)
The loop searching for a suitable goroutine is not guaranteed to ever
find it, and failing to find one is not an error.

Changes testStepParkedHelper to match the behavior of TestNextParked in
proc_test.go.
Deletes TestStepInParked because it does not test anything meaningful
beyond what's already tested by TestNextParked.
2021-08-04 14:12:58 -07:00
Alessandro Arzilli
4e242098f8
tests: check presence of gcc for cgo tests (#2644)
The install of gcc sometimes fails on our CI, it is not an error if the
tests for cgo can not run because there's no C compiler.
2021-08-04 14:12:15 -07:00
Derek Parker
f95340ae1b
pkg/proc: Fix build errors (#2637)
Fix ebpf build errors on Windows and update bininfo.Location API call.

Fixes #2636
2021-08-04 10:00:32 +02:00