Commit Graph

62 Commits

Author SHA1 Message Date
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
aarzilli
9a216211d3 proc,terminal,service: let headless instances run without connected clients
This pull request makes several changes to delve to allow headless
instancess that are started with the --accept-multiclient flag to
keep running even if there is no connected client. Specifically:

1. Makes a headless instance started with --accept-multiclient quit
    after one of the clients sends a Detach request (previously they
    would never ever quit, which was a bug).
2. Changes proc/gdbserial and proc/native so that they mark the
    Process as exited after they detach, even if they did not kill the
    process during detach. This prevents bugs such as #1231 where we
    attempt to manipulate a target process after we detached from it.
3. On non --accept-multiclient instances do not kill the target
    process unless we started it or the client specifically requests
    it (previously if the client did not Detach before closing the
    connection we would kill the target process unconditionally)
4. Add a -c option to the quit command that detaches from the
    headless server after restarting the target.
5. Change terminal so that, when attached to --accept-multiclient,
    pressing ^C will prompt the user to either disconnect from the
    server or pause the target process. Also extend the exit prompt to
    ask if the user wants to keep the headless server running.

Implements #245, #952, #1159, #1231
2018-06-26 10:32:40 -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
454491ce86 service,logflags: log all RPC messages
We occasionally receive bug reports from users of VSCode-go and GoLand.
GoLand has its own way of capturing the packet exchange between itself
and delve but VSCode-go (supposedly) doesn't.
So far this hasn't been a problem since all bug reports were obvious
bugs on the plugin or easy to reproduce without VSCode-go, but it might
be helpful in the future to have a way to log the packet exchange
between dlv and a frontend.

This commit adds a --log-output option to enable logging of all rpc
messages and changes service/rpccommon accordingly.
2018-06-14 09:27:38 -07:00
aarzilli
5155ef047f proc,dwarf/line: support is_stmt and prologue_end flags
Go1.11 uses the is_stmt flag of .debug_line to communicate which
assembly instructions are good places for breakpoints, we should
respect this flag.

These changes were introduced by:
* https://go-review.googlesource.com/c/go/+/102435/

Additionally when setting next breakpoints ignore all PC addresses that
belong to the same line as the one currently under at the cursor. This
matches the behavior of gdb and avoids stopping multiple times at the
heading line of a for statement with go1.11.

Change: https://go-review.googlesource.com/c/go/+/110416 adds the
prologue_end flag to the .debug_line section to communicate the end of
the stack-split prologue. We should use it instead of pattern matching
the disassembly when available.

Fixes #550

type of interfaces
'c7cde8b'.
2018-06-11 11:09:02 -07:00
aarzilli
cc86bde549 proc/native,proc/gdbserial: let target access terminal
Change the linux verison of proc/native and proc/gdbserial (with
debugserver) so that they let the target process use the terminal when
delve is launched in headless mode.

Windows already worked, proc/gdbserial (with rr) already worked.
I couldn't find a way to make proc/gdbserial (with lldb-server) work.

No tests are added because I can't think of a way to test for
foregroundness of a process.

Fixes #65
2018-05-18 09:53:29 -07: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
4e177bb99a proc/gdbserial,dlv/cmds: make logGdbWire command line configurable 2018-04-13 15:31:02 -07:00
Yasushi Saito
c5c41f6352 command/terminal: allow restart to change process args (#1060)
* command/terminal: allow restart to change process args

Add -args flag to "restart" command. For example, "restart -args a b c" will
pass args a b c to the new process.

Add "-c" flag to pass the checkpoint name. This is needed to disambiguate the
checkpoint name and arglist.

Reverted unnecessary changes.

* Applied reviewer comments.

Vendored argv.

Change the syntax of restart. When the target is is in recording mode, it always
interprets the args as a checkpoint. Otherwise, it interprets the args as
commandline args. The flag "-args" is still there, to handle the case in which
the user wants to pass an empty args on restart.

* Add restartargs.go.

Change "restart -args" to "restart -noargs" to clarify that this flag is used to
start a process with an empty arg.
2018-01-18 14:16:11 -08:00
aarzilli
b723f50b4a dlv: disable -a for go1.10
Go 1.10 new method of caching packages means that there is no need to
specify 1.10.
2017-12-13 12:18:18 -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
aarzilli
48288edd18 terminal: add config command
Fixes #927, #644
2017-09-08 10:27:32 -07:00
aarzilli
ec8e6c4af3 cmd/dlv: use -a flag with go1.9
By specifying the -a flag we insure that all packages are recompiled
with -gcflags='-N -l'. Previously -a could not be specified because the
compiler could not compile runtime without optimizations.

Fixes #738
2017-08-01 11:20:25 -06:00
aarzilli
1128c26b87 cmd/dlv: do not pass "linkmode internal" for windows on go1.9 and later
go1.9 no longer needs "linkmode internal" on windows.

Fixes #755
Fixes #477
Fixes #631
2017-08-01 11:20:25 -06:00
Alessandro Arzilli
d7a92b58ce cmd/dlv: delete trace directory when we delete the built executable (#856)
Mozilla RR will create a trace directory that can be reused with the
replay verb, however if we delete the executable file the trace
directory will become useless, so delete that too before exit.

Users that wish to reuse a recording should build the executable
themselves and then use either dlv exec or rr record to do the
recording.
2017-07-26 12:53:43 -06:00
Florin Pățan
32a005de2b Fix various issues detected by megacheck (#880)
* Fix various issues detected by megacheck

I've ran honnef.co/go/tools/cmd/megacheck and fixed a few of the
things that came up there.

* Cleanup using Gogland
2017-06-29 11:15:59 -07:00
Alessandro Arzilli
50f6382307 dlv: make headless servers quit automatically when client disconnects (#895) 2017-06-26 11:45:13 -07:00
Alessandro Arzilli
a90893f532 path/to/binary is the required argument (#847 fixed) (#884)
* cmd: include replay command in docs even if rr is not installed.

* path/to/binary is the required argument

Replaces #847
2017-06-20 10:36:07 -07:00
Alessandro Arzilli
a843f7944e proc/gdbserial: mozilla rr support (#804)
Implements #727
2017-05-05 15:17:52 -07:00
aarzilli
86a59c52a6 terminal: bugfix: tolerate spurious spaces after command prefixes
Expressions such as:

 frame 0    list
 frame   0   list
 on abreakpoint     print x
 goroutine    1    frame     0     list

should all execute correctly

Fixes #712
2017-04-19 09:58:36 -07:00
aarzilli
c8d9352522 proc: Implement target.Interface for gdbserver backend 2017-04-18 13:25:11 -07:00
aarzilli
c1879472a1 proc: implement target.Interface for core files 2017-04-18 13:25:11 -07:00
Derek Parker
01a1b35620 cmd/dlv: Use Printf over Println
Fixes #783
2017-04-06 15:32:44 -07:00
Jason Biegel
cd2a875459 Add flag support documentation (#740) 2017-02-16 11:05:48 -08:00
Derek Parker
53f0d24057 Move top-level packages into pkg 2017-02-08 12:17:19 -08:00
Evgeny L
4064d6acc0 Flag to set working directory (#650)
* proc: Add `wd` to Launch

This change adds the `wd` arg which specify working directory of the
program.

Fixes #295

* service/debugger: Add `Wd` field to debugger.Config

This change adds the `Wd` field which specify working directory of the
program launched by debugger.

Fixes #295

* service: Add `Wd` to service.Config

This change adds the `Wd` field which specify working directory of the
program debugger will launch.

Fixes #295

* cmd/dlv: Add `Wd` flag

This change adds `Wd` flag which specify working directory of the
program which launched by debugger.

Fixes #295

* only set the Linux working directory if it is set,
stub out param in darwin and windows

* set working directory for Windows
https://godoc.org/golang.org/x/sys/windows#CreateProcess
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx

* Windows workingDir must be an *uint16

* attempt to chdir on darwin via @yuntan

* proc/exec_darwin.c: fix working directory for darwin

* Add tests to check if working directory works.
* Fix darwin implementation of fork/exec, which paniced if
  child fork returned.

* cmd, service: rename Wd to WorkingDir
2016-11-01 12:58:42 -07: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
Koichi Shiraishi
2fad5abe74 cmd: Support space separate flags for build-flags (#619)
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
2016-09-12 11:13:21 -07:00