Commit Graph

203 Commits

Author SHA1 Message Date
Alessandro Arzilli
2e88b7ead3
tests: fix tests on Go 1.23 (#3697)
* Adjust rtype.go script to handle constants moved to internal/abi from
  runtime
* Remove tests in service/dap/server_test that relied on knowledge of
  the internal layout of channels.
2024-04-11 09:40:57 -07:00
Alessandro Arzilli
f2b3b18ca7
service/dap: support waitfor option for 'dap attach' only (#3656)
Add a waitfor option for 'dap attach' that waits for a process with a
given name to appear before attaching to it.

This recovers PR #3584, originally by @muggle-nil, which was fine
except for a broken test.
2024-02-07 11:03:36 -08:00
Alessandro Arzilli
4b2612a6b3
service/dap: make TestEvaluateCallFunction independent of line numbers (#3644)
_fixtures/fncall.go was made to support TestCallFunction in pkg/proc
and new things must be added to fncall.go to test new features. Having
a test depend on precise line numbers makes the process tedious.
2024-01-24 09:17:56 -08:00
Alessandro Arzilli
1a1e215fac
TeamCity: speed up ppc64le CI (#3622)
The builder is currently spending 15 to 20 minutes installing gcc and
upgrading packages every time we run the tests.
Because of this the build fails sometimes by running out of time.
This change reduces that to 5 minutes by:

* switching from curl to wget (which seems to have fewer dependencies)
* not installing gcc on ppc64le
* skipping tests that depend on gcc or other binutils
2024-01-09 14:13:00 -08:00
Stefan Haller
f8c8b33da3
Show pprof labels in thread names (#3501)
* Add pprofLabelForThreadNames config

The config is a string value that indicates the key of a pprof label whose value
should be shown as a goroutine name in the threads view.
2023-12-04 15:44:10 +01:00
Alessandro Arzilli
f558ca4f32
service/dap: fix close on closed channel panic (#3573)
Fixes close on closed channel panic that happens sporadically on many
of the dap tests (for example 1 ~ 3% of the times on
TestStepInstruction).
2023-12-04 15:40:59 +01:00
Alessandro Arzilli
c4a10ecb16
tests: fix tests in go1.22 (#3583)
Go1.22 has changed some line number assignments. The new line number
assignments are still valid however some tests in dap relied on them
being different and broke as a result. This commit fixes those tests
and makes them less brittle.
Also disables TestDebugStripped and TestDebugStripped2 temporarily on
1.22.
2023-11-27 14:59:55 -08:00
Oleksandr Redko
f1daaeb1b0
pkg,service/dap: use switch instead of ifs (#3576) 2023-11-22 09:07:08 -08:00
Oleksandr Redko
938cb6e9d8
pkg,service: remove unnecessary convertions (#3564) 2023-11-14 16:36:55 +01:00
Alessandro Arzilli
438d036fed
TeamCity: reupgrade linux/386 builder to Go 1.21 (#3560)
The bug that prevented updating to linux/386 has been fixed upstream,
update linux/386 to 1.21 in the test matrix and fix some broken bugs.
2023-11-09 17:38:37 -06:00
Stefan Haller
aec354cd0b
Shorten variable types (#3535)
* Add ShortenType function

Taken from

  https://github.com/aarzilli/gdlv/blob/master/internal/prettyprint/short.go

with kind permission by @aarzilli.

* Shorten type names in variable values

The variables view in VS Code is a lot easier to read if long type names are
shortened in much the same way as we shorten them for functions in the call
stack view.

We only shorten them in the value strings; the Type field of dap.Variable is
kept as is. Since this only appears in a tooltip, it isn't a problem to have the
full type visible there.
2023-11-09 10:15:25 +01:00
Oleksandr Redko
13d6cd4e0d
*: Correct spelling mistakes (#3555) 2023-11-06 07:55:44 -06:00
Alessandro Arzilli
2187c75fb5
proc,service/dap,proc/gdbserial: fixes for debugserver --unmask-signals (#3541)
- fix TestRefreshCurThreadSelGAfterContinueOnceError and TestBadAccess
  to work when debugserver has --unmask-signals
- when a fatal signal is received while singlestepping delay its
  delivery until the subsequent continue, otherwise debugserver will get
  stuck completely (fixes TestNilPtrDerefInBreakInstr)
2023-10-30 09:19:23 -07:00
Suzy Mueller
b041bd8e98
service/dap: add the concrete type to interface type (#3510) 2023-10-03 08:51:46 -07:00
Oleksandr Redko
899ba72505
all: replace deprecated io/ioutil with io and os (#3509) 2023-09-25 11:41:59 -07:00
Hyang-Ah Hana Kim
30b70bc606
service/dap: accept a string list as launch request's buildFlags (#3496)
This change accepts both string type and []string. dap.BuildFlags
is a union of string and []string.

Fixes #2718
For golang/vscode-go#1831, golang/vscode-go#1027
2023-09-19 09:32:15 -07:00
Oleksandr Redko
2b9c3d5c04
proc,service: simplify tests with T.Setenv (#3503) 2023-09-19 09:29:47 -07:00
Stefan Haller
c7097b8e1d
service/dap: strip package paths from symbols in callstack (#3500)
This solves the problem that function names with long package paths are hard to
read when the callstack window is narrow, because all you see is the beginning
of the package path.

For example, instead of

  github.com/some/long/package/path/pkg.(*SomeType).SomeMethod

we now display

  pkg.(*SomeType).SomeMethod
2023-09-16 06:06:28 +02:00
Oleksandr Redko
e404917db7
pkg,service: fix typos in comments, exceptions, tests (#3486) 2023-08-29 14:44:18 +02:00
Oleksandr Redko
0e3cae9dc9
service/dap: fix typos in comments (#3438) 2023-07-11 16:10:41 +02:00
Álex Sáez
71f1220717
*: add ppc64le support (#2963)
* Add vendor/golang.org/x/arch/ppc64

* Add ppc64le support
2023-07-07 09:30:38 -07:00
Suzy Mueller
9f3e146129
service/dap: fix test for debug in progress (#3407)
The regular expression attempted to match for a network address,
but actually does not match any network addresses. The two
documentation includes "192.0.2.1:25" and "[2001:db8::1]:80" as
examples, neither of which match the current regex. This change
updates the regular expression to ensure that there is some text
at the desired position, but not what the text is.
2023-07-07 08:17:39 +02:00
ttoad
53998cbb18
pkg/proc,service/*: Supports sending output to clients when running programs remotely (#3253)
* wip: Support sending output when remote debug

* wip: Support local output and remote output

* wip: fix stderr and stdout assignment error

* wip: optimize code

* wip: Only if outputMode is "remote" is the redirected console output

* wip: Redirected debugMode output(Not tested on windows)

* wip: support remote debugging output redirection of windows

* wip: real-time write back output

* wip: support for windows

* wip: fix windows remote debug not output

* wip: fix truncated output redirection

* wip: delete printfln

* wip: use debugger.Config to pass redirect(macOS)

* wip: use debugger.Config to pass redirect(linux)

* wip: Change redirect to a concrete type

* wip: s.wg.wait before sending "terminated"

* wip: add proc/redirect test(darwin and linux)

* Merge branch 'master' of github.com:tttoad/delve into feat-console

* wip: Fix test failure on windows

* fix: undefined: proc.Redirects

* fix: compile failure

* wip: Remove useless code

* fix: filename error

* fix: os.file not close

* test: add server_test.redirect

* fix: Remove 'eol' from end of file

* fix: gdbserial: File not closed in file mode.
(in reality, gdbserial will never use file mode)

* feat: Remove "only-remote". Fix spelling mistakes.

* fix: spelling mistakes

* refactor: redirect

* fix: stdout and stderr are not set to default values

* fix: Restore code logic for rr.openRedirects()

* fix: Optimization Code

* fix: utiltest

* fix: execpt out

* fix: Resource release for redirects

* fix: build failure

* fix: clean->clear

* fix: build failure

* fix: test failure

* fix: Optimization Code

* style: remove useless code

* refactor: namedpipe

* refactor: namedpipe, launch ...

* fix: freebsd compile failure

* fix: proc_darwin compile failure

* style:  remove useless code

* feat: add d.config.Stdxx check on debug.Restart

* style: formatting and adding comments

* style: formatting and adding comments

* feat: add d.config.Stdxx check on debug.Restart

* style: namedpipe->redirector

* style: namedPipe->redirector

---------

Co-authored-by: 李翔 <qian.fu2@amh-group.com>
2023-07-05 08:39:01 -07:00
Oleksandr Redko
322a138cf2
service/dap: fix typos in comments (#3426) 2023-06-20 14:53:18 +02:00
Suzy Mueller
e549a02f0e
service/dap: update go-dap to latest (#3414)
* service/dap: update go-dap to latest

* update remaining possible nil checks

* move helper functions to the end of the file
2023-06-12 14:29:44 -07:00
Oleksandr Redko
e33806a3f7
service: fix typos in comments, logs, tests, and vars (#3378) 2023-05-23 18:21:36 +02:00
Alessandro Arzilli
13ad7dc1d5
*: misc improvements to config command and substitute-path rules (#3335)
A series of interconnected changes to both the terminal command
'config', DAP command 'dlv config', quality of life improvements to how
substitute-path works, and better documentation.

- Let 'config substitute-path' show the current substitute path rules
- Add a -clear command to 'config substitute-path'
- Support 'config-debug-info-directories'
- rewrite SubstitutePath to be platform independent (see below)
- document path substitution more

Regarding the rewrite of SubstitutePath: the previous version used
runtime.GOOS and filepath.IsAbs to determine which filepath separator to use
and if matching should be case insensitive. This is wrong in all situations
where the client and server run on different OSes, when examining core files
and when cross-compilation is involved.

The new version of SubstitutePath checks the rules and the input path to
determine if Windows is involved in the process, if it looks like it is it
switches to case-insensitive matching. It uses a lax version of
filepath.IsAbs to determine if a path is absolute and tries to avoid having
to select a path separator as much as possible

Fixes #2891, #2890, #2889, #3179, #3332, #3343
2023-05-02 12:23:59 -07:00
Oleksandr Redko
5f588d8927 service/dap,service/debugger: refactor regexp funcs
Use regex.MatchString and regex.MustCompile.
2023-04-28 17:23:35 +02:00
Oleksandr Redko
cc71863594
service: fix typos in comments (#3344) 2023-04-27 13:39:33 -07:00
Alessandro Arzilli
70b80623d1
service/dap: fix failing test on Go 1.21 (#3312) 2023-04-24 12:11:50 -07:00
Alessandro Arzilli
6d88b52509
proc: disable flaky tests on windows/arm64 (#3328)
Disable some tests on windows/arm64 that are flaky.
2023-04-24 12:10:50 -07:00
Oleksandr Redko
c728f90dcf
TeamCity,Documentation: use new TeamCity URL (#3275)
Change delve.beta.teamcity.com to delve.teamcity.com.
2023-02-15 11:11:42 +01:00
Oleksandr Redko
4303ae45a8
service/dap: correct typos in comments (#3264) 2023-02-02 13:46:19 +01:00
Alessandro Arzilli
00df758d57
proc/native: fix FreeBSD backend (#3224)
- use PT_SUSPEND/PT_RESUME to control running threads in
  resume/stop/singleStep
- change manual stop signal from SIGTRAP to SIGSTOP to make manual stop
  handling simpler
- change (*nativeProcess).trapWaitInternal to suspend newly created
  threads when we are stepping a thread
- change (*nativeProcess).trapWaitInternal to handle some unhandled
  stop events
- remove misleading (*nativeProcess).waitFast which does not do
  anything different from the normal wait variant
- rewrite (*nativeProcess).stop to only set breakpoints for threads of
  which we have received SIGTRAP
- rewrite (*nativeThread).singleStep to actually execute a single
  instruction and to properly route signals
2022-12-20 09:54:16 -08:00
Quim Muntal
e5006c105c
Test windows/arm64 pipeline (#3200)
* Test windows/arm64 pipeline

* update build script to support windows/arm64

* skip TestLaunchRequestWithRelativeExecPath is symblink can't be created

* partially fix and skip TestCgoStacktrace

* update backend health docs

* update

* log test output

* skip starbind test on windows arm64

* skip starbind test on windows arm64

* skip rtype test on windows arm64

* skip pie backend tests on windows/arm64

* fix tests

* skip function calls test on windows/arm64

* fix tests

* revert hardware breakpoint test relax

* add pie test clarification

* skip symlink test only on windows

* skip TestStepConcurrentDirect

* readd exp.winarm64

* fix param

* add exp.winarm64 tags

* skip TestGeneratedDoc on winarm64
2022-12-05 15:21:52 -08:00
Alessandro Arzilli
6bda7085c7
proc: allow type casts between compatible types (#3149)
Go allows some type casts when the underlying types are the same.
Conform to that behavior.

Fixes #3130
2022-09-29 10:08:19 -07:00
Suzy Mueller
8a230b7f59
service/dap: show full value when evaluating log messages (#3141)
When evaluating variables in a log message, do not truncate the
string representation.

Updates golang/vscode-go#2447
2022-09-26 10:11:15 -07:00
Suzy Mueller
5170a6e0ff
service/dap: fix indexing bug for maps (#3068)
service/dap: fix indexing bug for maps

There was a bug that cut off the second half of a map, because the
number of variables was not accurately reported to the client.

Fixes golang/vscode-go#2351
2022-07-29 11:58:46 +02:00
Alessandro Arzilli
059406e74f
service/dap: limit disassembly range (#3045)
Due to dyanmically loaded libraries there could be aribitrarily large
gaps in the address space, between functions. Limit the memory size we
are willing to disassemble.

Fixes #3040
2022-07-15 13:29:44 +02:00
Alessandro Arzilli
c412dcdc4f
*: run go1.19 'go fmt' on everything and fix problems (#3031)
Go 1.19 also formats doc comments according to the new godoc syntax.
Some of our comments, especially unexported symbols did not conform to
the godoc syntax and therefore are mangled by 'go fmt'.

This PR runs 'go fmt' from go1.19 on everything and manually fixes the
problems.

See also:
	https://github.com/golang/proposal/blob/master/design/51082-godocfmt.md
2022-06-17 10:08:11 -07:00
polinasok
5bc8460328
dap: add MultiClientCloseServerMock and fix test shutdown leak (#3011)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2022-05-18 10:33:06 -07:00
polinasok
705ab206cd
dap: remote attach must not use terminateDebuggee in single-client launch mode (#2995) 2022-05-18 12:23:47 +02:00
Alessandro Arzilli
2b97231e30
proc,service: pretty print time.Time variables (#2865)
Fixes #999
2022-03-25 13:59:57 -07: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
b3e528e4fb
service/dap: deflake DAP tests (#2872)
1. change ExpectOutputEventProcessExited to accept -1 exit status, this
   is a real problem on linux but we don't know how to fix it and we
   already have a test in proc for it.
2. change TestNoDebug_AcceptNoRequestButDisconnect to be less picky
   about message ordering, all message orderings seem to be fine, there
   is no reason to insist on a particular one, since the DAP server is
   unable to actually produce it deterministically.

Fixes #2860
2022-01-19 10:40:54 -08:00
Suzy Mueller
a2927f6117
service/dap: set min/max addresses for invalid instructions (#2832) 2022-01-06 09:02:19 -08:00
Suzy Mueller
66478f21e3
pkg/proc: set stop reason for step instruction (#2828)
* service/dap: move presentationHint to frame from source

* pkg/proc: set stop reason for step instruction
2022-01-06 09:01:47 -08:00
Hyang-Ah Hana Kim
21bdb466f1
dap: support 'Env' attribute for launch requests (#2846)
* dap: support 'Env' attribute for launch requests

Env is applied in addition to the delve process environment
variables. The env setting is done by calling os.Setenv
as early as possible when a Launch request is received.

Prior discussion is in https://github.com/go-delve/delve/pull/2582

In Visual Studio Code, setting null for an environment variable
in launch.json or tasks.json indicates users want to unset
the environment variable. Support the behavior by accepting
nil value.

* dap: Env field itself can be omitempty

* edit comment
2022-01-06 09:01:09 -08:00
Alessandro Arzilli
4a94b3eff2
Updates for go1.18beta1 (#2831)
* go.mod: update golang.org/x/tools to v0.1.8

Fixes TestGeneratedDoc on go1.18

* TeamCity: bump test matrix

Add 1.18 to test matrix. Remove 1.15 from test matrix and from support range.

* proc,tests: update for regabi on arm64 and 386

Make sure that stacktrace registers always contain the PC register of
the current frame, even though the debug_frame rules might not specify
it on architectures that use a link register.
The PC register is needed to look up loclist entries for variable
evaluation.

* goversion: bump maximum supported Go version to 1.18

* proc: disable asyncpreempt on linux/arm64

Asyncpreempt on linux/arm64 can sometimes restart a sequence of
instructions which will make breakpoint appear to be hit twice in some
cases.
2021-12-22 10:26:21 -08:00
Suzy Mueller
a4ac69e87d
service/dap: support goroutine filters in dap (#2759)
* service/dap: filter goroutines

* adjust defaults

* add tests

* remove label change

* fix typos

* send invalidated areas

* respond to review, and allow to clear goroutineFilters
2021-12-07 09:23:55 -08:00