Commit Graph

90 Commits

Author SHA1 Message Date
Luis Gabriel Gomez
69615b3604
service/dap: Support for replay and core modes (#2367)
This PR aims to add support for rr replay and core actions from the DAP layer. This basically encloses the following:
New launch modes: replay and core

The following modes are added:

    replay: Replays an rr trace, allowing backwards flows (reverse continue and stepback). Requires a traceDirPath property on launch.json pointing to a valid rr trace directory.
    Equivalent to dlv replay <tracedir> command.
    core: Replays a core dump file, showing its callstack and the file matching the callsite. Requires a coreFilePath property on launch.json pointing to a valid coredump file.
    Equivalent to dlv core <exe> <corefile> command.

Dependencies

To achieve this the following additional changes were made:

    Implement the onStepBackRequest and onReverseContinueRequest methods on service/dap
    Adapt onLaunchRequest with the requried validations and logic for these new modes
    Use CapabilitiesEvent responses to enable the StepBack controls on the supported scenarios (see dicussion here)
    Add the corresponding launch.json support on vs code: 

Support for replay and core modes golang/vscode-go#1268
2021-07-21 07:38:04 -07:00
polinasok
af378d396f
service/dap: add backend launch/attach attribute (#2567)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-07-18 11:37:41 +02:00
polinasok
5459034a98
cmd/dap: server - always headless, target - always foregrounded (#2589)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-07-16 09:49:16 -07:00
polinasok
4fd6c483e1
dap: update dlv dap --help (#2558)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-06-29 15:15:47 +02:00
Hyang-Ah Hana Kim
669fc2d8d3
dap: add sameuser check (#2494)
On linux, delve RPC server allows only connections from the same user
if --only-same-user is set (true, by default). Do the same for DAP
server.

Moved the sameuser check logic to service/internal/sameuser.
Considered importing service/rpccommon from the dap server,
but when we eventually migrate to multiplex rpc and dap from one
port, I am afraid that can cause cyclic imports.
2021-05-19 10:29:05 -07:00
Alessandro Arzilli
0da1c9a9d7
Documentation: document passing arguments to the test program (#2459)
Add documentation on how to pass arguments to the program generated by
`dlv test`.

Fixes #2458
2021-05-04 12:37:09 -07:00
Suzy Mueller
1c9a10529e
service/dap: use specified working directory for launch requests (#2360)
* service/dap: use specified working directory for launch requests

If a user specifies a working directory in the launch request,
then the process should use that working directory. This may
affect how the program runs and the user should be able to have
control over this.

* service/dap: add tests for launch with working dir

Added tests to make sure the working directory is set correctly.

* service/dap: fix TestWorkingDir on windows

* service/dap: use %q to print quoted string

* cmd/dlv: update dap warning about working dir

* service/dap: change the launch argument to be wd`

* update warning to specify only launch request
2021-03-22 20:06:09 -07:00
Alessandro Arzilli
2c1a822632
terminal,service,proc/*: adds dump command (gcore equivalent) (#2173)
* proc/core: off-by-one error reading ELF core files

core.(*splicedMemory).ReadMemory checked the entry interval
erroneously when dealing with contiguous entries.

* terminal,service,proc/*: adds dump command (gcore equivalent)

Adds the `dump` command that creates a core file from the target process.

Backends will need to implement a new, optional, method `MemoryMap` that
returns a list of mapped memory regions.
Additionally the method `DumpProcessNotes` can be implemented to write out
to the core file notes describing the target process and its threads. If
DumpProcessNotes is not implemented `proc.Dump` will write a description of
the process and its threads in a OS/arch-independent format (that only Delve
understands).

Currently only linux/amd64 implements `DumpProcessNotes`.

Core files are only written in ELF, there is no minidump or macho-o writers.

# Conflicts:
#	pkg/proc/proc_test.go
2021-01-29 13:39:33 -08:00
polinasok
1b2357092c
cmd: update dlv dap --help (#2299)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2021-01-13 13:10:15 +01:00
Alex Zamai
433eafb280
*: Expand --build-flags= description in the document (#2273)
add example for multiple  --build-flags

add example description to --build-flags
2021-01-05 10:57:30 -08:00
Alessandro Arzilli
9a3c9ebad1
proc/*: add launch option to disable ASLR (#2202)
Fixes #1847
2020-10-21 12:50:52 -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
Alessandro Arzilli
936c76b08c
cmd/dlv: print error when build fails in 'dlv test' (#2127)
Fixes #2126
2020-08-31 10:46:42 -07:00
Alessandro Arzilli
ab5713d3ec
Documentation: clarify API version status (#2068)
Clarify that the currently supported version of the API is 2 and that
the preferred method for selecting it is sending a SetApiVersion
command after connection.

Fixes #2066
2020-06-11 14:32:36 -07:00
Álex Sáez
95e7cafd0c
terminal/command: Add 'reload' command (#1971)
* terminal/command: Add 'reload' command

These changes add the 'reload' command, which allows us to rebuild the project
and start the debugging session again. Currently, if the project's code is
updated while debugging it, Delve shows the new source code, but it's still
running the old one. With 'reload', the whole binary is rebuilt, and the
process starts again.

Fixes #1551

* Remove unnecessary print

Changes to be committed:
      modified:   pkg/terminal/command.go

* Add tests and refactor the code

Changes to be committed:
      modified:   cmd/dlv/cmds/commands.go
      modified:   go.mod
      modified:   pkg/terminal/command.go
      modified:   service/config.go
      modified:   service/debugger/debugger.go
      modified:   service/test/integration2_test.go

* Fix typo in the comment

Changes to be committed:
      modified:   service/debugger/debugger.go

* Fix typo in the name of the variables

The variables are local therefore the capitalization is not needed

Changes to be committed:
      modified:   cmd/dlv/cmds/commands.go

* Call GoTestBuild

Also, remove the := to avoid redeclaration

* Change the Kind in the tests

Change from debugger.ExecutingGeneratedTest to
debugger.ExecutingGeneratedFile for consistency.
We are generating a real binary instead of a test
one so ExecutingGeneratedFile makes more sense here.

Changes to be committed:
      modified:   service/test/integration2_test.go

* Avoid breakpoints based on addresses

Changes to be committed:
      modified:   service/debugger/debugger.go

* Update the rebuild behaviour

There are a few cases where we can't rebuild the binary because we don't
know how it was build.

Changes to be committed:
      modified:   service/debugger/debugger.go

* Fix typos and update documentation

Changes to be committed:
      modified:   Documentation/cli/README.md
      modified:   pkg/terminal/command.go
      modified:   service/config.go
      modified:   service/debugger/debugger.go

* Fix typo

* Remove variables

They were added to the debugger.Config

* Rename variable

Rename Kind to ExecuteKind to make it more accurate

Changes to be committed:
      modified:   cmd/dlv/cmds/commands.go
      modified:   service/debugger/debugger.go
      modified:   service/test/integration2_test.go
2020-06-05 11:03:09 -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
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
e5d24a96bf *: Consolidate service/debugger config
Embed the debugger config object in the service config object to avoid needless duplication of fields.
2020-04-14 21:02:38 +02:00
Darren Rambaud
b13fe990bd cmds/commands: Add --continue flag to attach
Add --continue as a valid flag for the attach command by decorating attachCommand
with the continueOnStart variable.

Fixes #1995
2020-04-10 10:48:30 -07:00
Derek Parker
3e60ae202b *: Add --tty flag for debug / exec
This flag allows users on UNIX systems to set the tty for the program
being debugged by Delve. This is useful for debugging command line
applications which need access to their own TTY, and also for
controlling the output of the debugged programs so that IDEs may open a
dedicated terminal to show the output for the process.
2020-04-10 09:53:13 -07:00
Derek Parker
3cf685e5ea cmd/dlv: Unexport flag variables 2020-04-01 10:28:52 +02:00
Derek Parker
ad75f78c4e
*: Fix go vet complaints (#1935)
* *: Fix go vet struct complaints

* *: Fix struct vet issue on linux

* *: Ignore proc/native in go vet check

We have to do some unsafe pointer manipulation that will never make go
vet happy within the proc/native package. Ignore it for runs of go vet.
2020-03-18 09:25:32 -07:00
MinJae Kwon
25d8856cd1
*: run gofmt (#1928) 2020-03-16 09:38:15 -07:00
polinasok
f863be0a17
service/dap: Add support for debug and test modes (#1901)
* service/dap: Add support for debug and test modes

* Address code review comments

* Remove //dap comment

* OptFlags() => optfalgs()

* If mode => switch mode
2020-03-04 09:22:51 -08:00
polinasok
fbc4623c08
service/dap: Initial implementation for 'dlv dap' (#1858)
* Initial implementation for 'dlv dap'

* Fix Travis and AppVeyor failures

* Address review comments

* Address review comments

* Regenrate documentation

* Replace dap server printfs with log.Error

* Update 'dap log'

* Fix typos

* Revert logflags changes that got mixed in by accident
2020-02-15 11:52:53 -08:00
Alessandro Arzilli
81a86086dd
cmd/dlv: Fix same-user check and add flag to disable it (#1839)
* service: also search IPv6 connections when checking user

When checking if the user is allowed to connect to this Delve instance
also search IPv6 connections even though the local address is IPv4.

Fixes #1835

* cmd: add flag to disable same-user check

Fixes #1835
2020-02-11 09:06:29 -08:00
nd
3c26681075 cmd/dlv: Don't stop headless server on SIGINT on windows (go-delve#1745) (#1746)
This allows to execute and debug signal handlers in inferior.
2019-11-13 09:39:14 -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
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
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
Alessandro Arzilli
79e0f543c0 cmd/dlv: add Go version check (#1533)
Before doing anything check that the version of Go is compatible with
the current version of Delve.
This will improve the error message in the case that  another change as
disruptive as Go1.11 dwarf compression, happens.
2019-04-26 10:24:21 -07:00
Alessandro Arzilli
48f1f51ef9 Miscellaneous logging improvements (#1525)
* *: use loglevel to control what gets logged instead of output redirection

This stops logrus from doing all the formatting just to discard it
immediately afterwards.

* logflags: replace default formatter of logrus

The default formatter of logrus emits logs in two different formats
depending on whether or not the output is going to a terminal. The
output format for non-terminals is indented to be machine readable, but
we mostly read logs ourselves and the excessive quoting makes that
format unreadable.
When outputting to terminals it uses ANSI escape codes unconditionally,
without checking whether the terminal it is connected to actually
supports colors.

This commit replaces the default formatter with a much simpler
formatter that always uses a more readable format, doesn't use colors
and places the key-value pairs at the beginning of the line (which is a
better match for how we use them).

* cmd/dlv: add command line options to redirect logs

Adds two options, --log-to-file and --log-to-fd, to redirect logs to a
file or to a file descriptor.

When one of those two options is specified the "API server listening
at:" message will also be redirected to the specified file/file
descriptor.
This allows clients that want to use the "API server listening at:"
message to do so even if they want to redirect the target's stdout to
another file or device.

Implements #1179, #1523
2019-03-27 14:58:36 -07:00
Aurélien
a86711f547 Documentation: update recommended compiler flags for 'exec' command
On Go 1.10 -gcflags='all=-N -l' should be preferred, update the
documentation of 'exec' command to reflect this.
2019-01-08 10:26:47 -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
aarzilli
85e4ba439c proc/core: add support for windows minidumps
Minidumps are the windows equivalent of unix core files.
This commit updates pkg/proc/core so that it can open and read windows
minidumps.

Updates #794
2018-11-21 12:17:16 -08:00
Derek Parker
51c342c6b7 pkg/prog: Improve support for external debug info
Adds a config file option to allow specifying a list of directories to
search in when looking for seperate external debug info files.

Fixes #1353
2018-11-08 10:16:42 -08:00
Derek Parker
3129aa7330 *: Show return values on CLI trace
This patch allows the `trace` CLI subcommand to display return values of
a function. Additionally, it will also display information on where the
function exited, which could also be helpful in determining the path
taken during function execution.

Fixes #388
2018-10-19 20:32:27 +02:00
Derek Parker
ff760d87aa cmd: Add --exec and --test flags for trace sub cmd
Adds an --exec flag for the trace subcommand allowing users to specify a
pre-compiled binary to exec and trace.

Also adds a --test flag as a convienance for compiling and tracing a
test binary.

Fixes #1073
2018-10-18 11:46:03 +02:00
Derek Parker
c920630082 cmd: Fix trace bug when no package specified
Fix a bug where the regexp would be used as a package string
incorrectly. This would manifest when trying to execute the trace
subcommand as `dlv trace <regexp>` without specifying a package
identifier. The `<regexp>` would be passed to the Go build command
causing an error.
2018-10-18 11:42:25 +02:00
chainhelen
ea54a6b2af cmd,service: remove temporary def of Server interface in func
Use the defination of Server interface in service package, instead of
temporary in func.
2018-10-09 07:56:48 -07:00
aarzilli
ca0596724f cmd,service: in non-headless mode use an in-memory connection
Replace the socket connection with an in-memory connection (created by net.Pipe) for non-headless uses of delve.
This is faster and more secure.

Fixes #1332
2018-10-08 15:11:13 -07:00
chainhelen
0af7d6d362 cmd/dlv: support multifile when dlv debug, trace and test
This changes make `dlv` support multifile specifically when dlv `debug`,
`trace` and `test`. Just like `dlv debug a.go b.go`. Corresponding to
`go build a.go b.go`.(a.go and b.go are  belong to `main` package).

Fix #984.
2018-09-20 11:47:57 +02:00
Derek Parker
c3f50742b9 *: Misc refactors, and doc additions
Refactors some code, adds a bunch of docstrings and just generally fixes
a bunch of linter complaints.
2018-09-19 20:59:35 +02:00
aarzilli
f342d2784c cmd/dlv: use the same connect code whether or not we started the server
Use the same connect code path whether we started the server (with
debug/exec/test) or we didn't (i.e. the 'connect' subcommand).
This fixes a bug where the init file was ignored with the 'connect'
subcommand and hopefully prevents future divergence between the
behavior of 'connect' and the other subcommands.

Fixes #1301
2018-08-14 12:23:28 -07:00
aarzilli
2925c0310a *: function call injection for go 1.11
Implements the function call injection protocol introduced in go 1.11
by https://go-review.googlesource.com/c/go/+/109699.

This is only the basic support, see TODO comments in pkg/proc/fncall.go
for a list of missing features.

Updates #119
2018-07-13 13:37:54 -07:00