Commit Graph

42 Commits

Author SHA1 Message Date
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
Alessandro Arzilli
2bd1cd3fa7 Documentation,cmd/dlv: tidy up --help output (#1649)
* scripts: use relative path in gen-cli-docs.go

Makes gen-cli-docs.go work outside GOPATH.

* Documentation,cmd/dlv: tidy up --help output

The description of --log-dest, --log-output and --backend is very
verbose and messes up the output of --help, move it to two "additional
help" subcommands.
2019-08-01 16:28:37 -07:00
Derek Parker
f4eaad69d9
*: Add .cirrus.yml for FreeBSD testing (#1639)
* *: Add .cirrus.yml for FreeBSD testing

* *: run go mod tidy

* service/test: prefer 127.0.0.1 over localhost

* dwarf/line: fix TestDebugLinePrologueParser

* vendor: rerun go mod vendor
2019-07-30 08:38:25 -07:00
Brian de Alwis
cb65877297 cmd/dlv: add --continue to continue process on launch/attach (#1585)
* Add --continue to continue process on launch/attach

* Add small test of --continue

* regenerate usage docs

* minor cleanup

* Use similar approach to `trace` and connect and detach using a client instance

* back out previous attempt

* regen usage doc

* fix up continue test

* fix TestContinue to properly test --continue

* back out unnecessary changes

* update faq
2019-07-19 10:59:38 -07:00
Alessandro Arzilli
ed35dce7a3 terminal: adds embedded scripting language (#1466)
If the argument of 'source' ends in '.star' it will be interpreted as a
starlark script.
If the argument of 'source' is '-' an interactive starlark repl will be
started.

For documentation on how the starlark execution environment works see
Documentation/cli/starlark.md.

The starlark API is autogenerated from the JSON-RPC API by
script/gen-starlark-bindings.go.
In general for each JSON-RPC API a single global starlark function is
created.
When one of those functions is called (through a starlark script) the
arguments are converted to go structs using reflection. See
unmarshalStarlarkValue in pkg/terminal/starbind/conv.go.
If there are no type conversion errors the JSON-RPC call is executed.
The return value of the JSON-RPC call is converted back into a starlark
value by interfaceToStarlarkValue (same file):

* primitive types (such as integers, floats or strings) are converted
  by creating the corresponding starlark value.
* compound types (such as structs and slices) are converted by wrapping
  their reflect.Value object into a type that implements the relevant
  starlark interfaces.
* api.Variables are treated specially so that their Value field can be
  of the proper type instead of always being a string.

Implements #1415, #1443
2019-07-02 10:55:27 -07:00
Derek Parker
b9f7dd5008 cmd/dlv: Change name for binary dlv auto compiles
Prevent conflicts by choosing a name that is extremely unlikely to
conflict with any actual package a user may have in their code.

Fixes #580
2019-05-31 20:36:27 +02:00
aarzilli
a357ce0638 tests: fix typecheckrpc.go and convert it to a test
We forgot to run typecheckrpc.go periodically and it didn't work
anymore and there were some minor errors in service/rpc2/client.go.

Rewrite typecheckrpc.go using go/packages, so that it works with go1.11
and go.mod, and fix the issues in client.go
2019-01-07 11:47:49 -08:00
Derek Parker
4c9a72e486 *: Update import name to github.com/go-delve/delve
The repository is being switched from the personal account
github.com/derekparker/delve to the organization account
github.com/go-delve/delve. This patch updates imports and docs, while
preserving things which should not be changed such as my name in the
CHANGELOG and in TODO comments.
2019-01-04 19:43:13 +01:00
aarzilli
d7d4c144c8 cmd/dlv,terminal: fix accept-multiclient behavior
1. Check IsMulticlient and send stop request before doing anything
   else.
2. Allow init file to call 'exit'

Fixes #1430
2018-12-03 09:58:29 -08:00
zavla
a4a5d4b7f6 main_test: Fix "gopath mode" detection in projectRoot() (#1426)
* main_test: Fix "gopath mode" detection in projectRoot()

Fails detect that this is a "gopath mode" when GOPATH contains several paths ex. "d:\\dir\\gopath;f:\\dir\\gopath2"
2018-11-28 19:22:11 +01:00
Derek Parker
d61cd1c0d7 pkg/proc: Refactor process post initialization
This patch is a slight refactor to share more code used for genericprocess initialization. There will always be OS/backend specificinitialization, but as much as can be shared should be to preventduplicating of any logic (setting internal breakpoints, loading bininfo,etc).
2018-11-15 18:16:16 +01:00
Derek Parker
91953dd49c cmd/dlv: Fix tests for use with modules 2018-11-14 09:00:49 +01:00
aarzilli
087431f029 Makefile: replace makefile with a script
We were using our makefile not for the intended purpose of makefiles
but to multiplex a series of small scripts.
We can easily achieve the same result in a more reasonable programming
language and as a bonus we don't need to install a version of make on
windows anymore.
Additionally our test script had become fairly complicated and will
become even more complicated when testing of PIE buildmode is
introduced.
Allows the tests to run on Windows without having to install Mingw
(although we still want it installed so that we can run cgo tests on
Windows).

Fixes building when GOPATH isn't set.

Fixes #759
2018-09-18 12:06:25 -07:00
Derek Parker
a208c89719 *: Use structured logging
Implements structured logging via Logrus. This gives us a logger per
boundry that we care about, allowing for easier parsing of logs if users
have more than one log option enabled. Also, cleans up a lot of
conditionals in the code by simply silencing the logger at creation as
opposed to conditionally logging everywhere.
2018-06-22 09:45:10 +02:00
aarzilli
8ce88095c6 cmd/dlv: Revert 4e177b, use new flag name for debug logging options
Previously to 4e177bb99acc511897f9cdbfc6cbc50d92ae4725 it was possible
to use --log without arguments to enable logging, this commit reenables
that use case.

The new functionality of the --log flag moved to a new flag name
--logx.

Fixes #1188
2018-04-26 09:45:52 -07:00
aarzilli
f27c91ba3c Documentation: automatically check that documentation is up to date
Since we always forget to update the documentation lets check this
automatically.
2018-04-18 10:48:55 -07:00
aarzilli
65d9255040 dlv_test: disable one of the checks of TestOutput on windows
Sometimes delve on Appveyor can't remove the built binary before
exiting and gets an "Access is denied" error when trying.
See: https://ci.appveyor.com/project/derekparker/delve/build/1527
2017-12-18 13:53:35 -08:00
Martin Tournoij
6fe97fa75b Support --output for debug, trace, and test commands (#1028)
* Support --output for debug, trace, and test commands

With the `--output` parameter you can configure the output binary. For
example:

    dlv debug --output /tmp/xxx

Will build the binary to `/tmp/xxx`, instead of always putting it as
`debug` in the current directory.

This ensures that the command always works (even if there is already a
file or directory named `debug`) and doesn't write to the source
directory. Especially for things like Delve/Vim integration this is a
good thing to have, I think.

* Address PR feedback and add a test

- We don't need to use `filepath.IsAbs()` on startup; I added that
  because it previously did `"./" + debugname` everywhere, but I don't
  think that's needed at all, since `pathname` without a leading `./`
  implies the current directory.

- Repurpose the existing `TestIssue398` to also test the `--output`
  flag. Also fix an issue where tests wouldn't work if `GOPATH` has
  multiple entries (e..g `GOPATH=$HOME/go:$HOME/mygocode`).

- Print an error if we can't remove the debug binary on exit instead of
  failing silently. Not strictly related to this PR, but a good change
  to add I think.

* Also warn when delve can't remove the binary in test/trace

I only added that to debug, but good to issue this warning consistently.
2017-11-28 10:51:30 -08:00
Alex Brainman
0cfe539052 proc/native: make sure debugged executable can be deleted on windows (#890)
* proc/native: make sure debugged executable can be deleted on windows

Delve opens debugged executable to read binary info it
contains, but it never closes the file. Windows will not
let you delete file that is opened. So close Process.bi
in Process.postExit, and actually call Process.postExit
from windows Process.Kill.

Also Windows sends some debugging events
(EXIT_PROCESS_DEBUG_EVENT event in particular) after Delve
calls TerminateProcess. The events need to be consumed by
debugger before debugged process will be released by
Windows. So call Process.waitForDebugEvent after
TerminateProcess in Process.Kill.

Fixes #398

* cmd/dlv: make TestIssue398 pass on darwin

* cmd/dlv: add comment for TestIssue398

* proc/native: wait for debuggee to exit before returning from windows Process.Kill

* proc/native: close process handle before returning from windows killProcess

* proc/native: remove not used Process.Process
2017-07-26 12:51:44 -06:00
Alessandro Arzilli
50f6382307 dlv: make headless servers quit automatically when client disconnects (#895) 2017-06-26 11:45:13 -07:00
Hyang-Ah Hana Kim
c67986ed7d cmd/dlv: fix race in test (#805)
% go test -race -v -short

=== RUN   TestBuild
==================
WARNING: DATA RACE
Write at 0x00c4201379a0 by goroutine 9:
  os.(*file).close()
      /usr/local/go/src/os/file_unix.go:143 +0x10a
  os.(*File).Close()
      /usr/local/go/src/os/file_unix.go:132 +0x55
  os/exec.(*Cmd).closeDescriptors()
      /usr/local/go/src/os/exec/exec.go:263 +0x67
  os/exec.(*Cmd).Wait()
      /usr/local/go/src/os/exec/exec.go:448 +0x2b8
  github.com/derekparker/delve/cmd/dlv.TestBuild.func1()
      /home/kbuilder/go/src/github.com/derekparker/delve/cmd/dlv/dlv_test.go:82 +0x8e
  github.com/derekparker/delve/cmd/dlv.TestBuild()
      /home/kbuilder/go/src/github.com/derekparker/delve/cmd/dlv/dlv_test.go:104 +0xb6a
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107

Previous read at 0x00c4201379a0 by goroutine 12:
  os.(*File).Read()
      /usr/local/go/src/os/file.go:98 +0x70
  bufio.(*Scanner).Scan()
      /usr/local/go/src/bufio/scan.go:207 +0x539
  github.com/derekparker/delve/cmd/dlv.TestBuild.func2()
      /home/kbuilder/go/src/github.com/derekparker/delve/cmd/dlv/dlv_test.go:93 +0x38

Change-Id: I09d188dbf964fe4af0b33b6a8fcfe51396176b7e
2017-04-26 12:03:26 -07:00
aarzilli
329bc7e69d dlv_test: fix test on macOS for new Makefile 2017-04-18 13:25:11 -07:00
aarzilli
c8d9352522 proc: Implement target.Interface for gdbserver backend 2017-04-18 13:25:11 -07:00
Hyang-Ah Hana Kim
ab7367ed2b Minor fixes to make some tests build and run (#752)
* cmd/dlv: fall back to go env GOPATH when GOPATH envvar is unset.

Since Go 1.8, GOPATH environment variable has a default value if the
environment variable is unset so not setting GOPATH is perfectly ok.
Depend on `go env` command to query Go related environment variable.

* build: update references to moved packages
2017-03-13 10:59:34 -07:00
aarzilli
1a68f8d351 proc/windows: handle delayed events
Sometimes windows will send us events about breakpoints we have
already removed from the code despite the fact that we go to great
lengths to avoid this already.

Change waitForDebugEvent to check that when we receive a breakpoint
event the corresponding memory actually contains an INT 3
instruction, if it doesn't ignore the event and restart the thread.
2017-02-22 20:39:28 +01:00
Derek Parker
53f0d24057 Move top-level packages into pkg 2017-02-08 12:17:19 -08:00
aarzilli
ee6d2734c9 tests: fix TestBuild on macOS, windows 2016-12-17 10:53:30 +01:00
Alessandro Arzilli
5d78c04e62 dlv: bugfix: Allow quoting in build flags argument (#639)
Allows quoted substrings in build-flags flag. This fixes a build
problem on windows where the default build flags must contain a space.

Fixes #634 and #638
2016-09-25 08:26:59 -07:00