Commit Graph

1695 Commits

Author SHA1 Message Date
Alessandro Arzilli
9881edaa99
vendor: remove github.com/pkg/profile dependency (#2053)
It is only used in benchmarks and 'go test' now has command line
options to enable profiling as appropriate (but maybe it didn't in
2014).
2020-05-14 10:16:09 -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
Alessandro Arzilli
200994bc8f
proc/*: only load floating point registers when needed (#1981)
Changes implementations of proc.Registers interface and the
op.DwarfRegisters struct so that floating point registers can be loaded
only when they are needed.
Removes the floatingPoint parameter from proc.Thread.Registers.
This accomplishes three things:

1. it simplifies the proc.Thread.Registers interface
2. it makes it impossible to accidentally create a broken set of saved
   registers or of op.DwarfRegisters by accidentally calling
   Registers(false)
3. it improves general performance of Delve by avoiding to load
   floating point registers as much as possible

Floating point registers are loaded under two circumstances:

1. When the Slice method is called with floatingPoint == true
2. When the Copy method is called

Benchmark before:

BenchmarkConditionalBreakpoints-4   	       1	4327350142 ns/op

Benchmark after:

BenchmarkConditionalBreakpoints-4   	       1	3852642917 ns/op

Updates #1549
2020-05-13 11:56:50 -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
a33be4466f
vendor: update logrus dependency (#2048)
Fixes #2037
2020-05-11 15:44:01 -07:00
polinasok
f92afb9c17
service/dap: Adds launch request support for program args (#2040)
* Adds launch request support for program args

* Combine types of function parameters

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2020-05-11 09:52:26 -07:00
Anders Kaare
71a460fc0f
config: add option for printfile() line count (#2043)
The option is "source-list-line-count". It defaults to 5, which was previously
hardcoded in printfile(), but now you can change it dynamically, for instance:

 $ config source-list-line-count 20
 $ list
2020-05-11 09:50:25 -07:00
Alessandro Arzilli
f559c3c421
gobuild: pass-through stdout to 'go' command invocation (#2044)
When trying to compile tests in a package that does not contain tests
'go' emits an error message on stdout instead of stderr. Let the 'go'
command write to stdout too.

Fixes #2042
2020-05-11 09:44:25 -07:00
Alessandro Arzilli
0f83fa66f5
cmd/dlv: make core command limitations more prominent (#2031)
Fixes #2026
2020-05-04 10:00:33 -07:00
chainhelen
5b7d764b15
gdbserial/gdbserver: optimize the search of debugserver binary (#2005)
Unexport `GetDebugServerAbsolutePath` and avoid unnecessary repeated calls.
Remove `os.Stat` because `Exec.LookPath` has already used `os.Stat`.And Fix
some comments.
2020-05-04 09:59:34 -07:00
colinnewell
99a0468b9b
cmd,Documentation: Add some simple examples for the list command to the help (#2034) 2020-05-04 09:27:55 -07:00
polinasok
2f295f310d
service/dap: Add error handlers for unsupported and not-yet-supported requests (#1918)
* Add no-op handlers for unsupported requests

* Fix whitespace

* Add couple of missing unsupported requests

* More comments

* Separate errors for unsupported and not-yet-implemented requests.

* Fix go.mod/sum dependencies

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2020-05-01 12:24:44 -07:00
aarzilli
8f5df19948 proc: fix findCompileUnitForOffset when plugins are used
Splits the compileUnits slice between images so that we can search for
an offset inside the debug info of a specific image file.
2020-05-01 11:51:34 -07:00
aarzilli
96890bbe1e dwarf/op: return register values when they are the only piece
When there is a single piece and it's a register value just return it.
This is important for clang compiled programs which will use DW_OP_regN
to specify the value of the frame base.
2020-05-01 11:11:51 -07:00
aarzilli
c078223d56 proc: use cached packageVars in proc.(*EvalScope).PackageVariables 2020-05-01 11:01:35 -07:00
aarzilli
cf37512aed proc: move g.stackhi/g.stacklo to a struct
Mirroring the way this is implemented in the Go runtime and introducing
a type that will be useful to support the call injection changes in Go
1.15
2020-05-01 10:44:06 -07:00
aarzilli
bb2525a7d5 proc: keep debugger state consistent if callInjectionProtocol fails
pickCurrentThread should always run.
2020-05-01 10:15:29 -07:00
aarzilli
6102c31d6d terminal: clarify Ctrl-C options with multiclient servers
Fixes #2028
2020-04-27 09:15:44 -07:00
Min Zhou
3e04ad0fad proc: Find executable should follow symbol links.
On linux platform, we simply treated `/proc/$pid/exe` as the
executable of targeting process when doing `dlv attach`. The
`/proc/$pid/exe` is a symbol link of the real executable file.
Delve couldn't find the corrsponding external debug file based on the
symbol link:

```
could not attach to pid $pid: could not open debug info
```

The fix is to evaluate the symbol links to the actual executable path.
2020-04-27 09:14:58 -07:00
chainhelen
37bee98a88 pkg/config: add disassemble-flavor option for config
Allow user to specify output syntax flavor of assembly in the
disassemble command.

Close #415
2020-04-23 12:10:05 -07:00
aarzilli
9c24b56f62 proc/tests: disable TestIssue414 on linux/386/PIE
This test will occasionally hang in SetBreakpoint/WriteMemory
2020-04-20 11:08:28 -07:00
aarzilli
f9b6c43910 proc/native: report trapWaitInternal errors in nativeProcess.stop
The process could quit while we are inside stop, we should report the
error otherwise the following code will try to send on the closed
ptrace channel.
Fixes a sporadic error in TestIssue1101.
2020-04-17 09:22:18 -07:00
aarzilli
55543e2570 Makefile: reduce test timeout when TRAVIS==true
Reduces test timeout by one minute so that Go will timeout before
Travis-CI and report useful informations about the hang.
2020-04-17 09:20:55 -07:00
Derek Parker
682ee7ffd0 service/debugger: Rename processMutex to targetMutex
Fixes a long standing dangling TODO item.
2020-04-16 20:14:18 +02:00
Alessandro Arzilli
bc299a7a30
tests: properly check if cgo is enabled for cgo related tests (#2010) 2020-04-16 10:42:22 -07:00
Derek Parker
c06a1a0252 service/debugger: Fix checking for CI 2020-04-14 21:02:38 +02: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
chainhelen
ad9d13c671
proc: Don't set fileFound if there's a compileUnit without line section (#2006)
We should not return error directly which set `fileFound` to be true
if there's a compileUnit without line section.
2020-04-13 14:24:04 -07:00
aarzilli
c534677ece proc/native: disable async preemption on freebsd 2020-04-10 11:03:21 -07:00
aarzilli
ae846a51f2 proc: StepOut remove if condition that is always true 2020-04-10 10:49:19 -07:00
Darren Rambaud
49c6498512 cmd/commands: Update documentation for dlv attach
Commit changes after executing gen-usage-docs.go script

Related to #1995
2020-04-10 10:48:30 -07: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
00aab8d690 vendor: Update vendor 2020-04-10 09:53:13 -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
Alessandro Arzilli
c3a4d726e2
Miscellaneous debug_line improvements (#1999)
* dwarf/line: implement DW_LNE_set_discriminator

We don't use the discriminator field in any way but we need to at least
parse it to support debub_line programs that use it.

* dwarf/line: support parsing DWARF4 debug_line sections

There is an extra field maximum_operations_per_instruction that is used
for VLIW CPUs. We don't support this feature but we have to at least
parse the field to not crash.
2020-04-09 13:57:44 -07:00
Darren Rambaud
bc30b53926
gdbserial/gdbserver: Dynamically resolve debugserver binary (#1994)
* gdbserial/gdbserver: Dynamically resolve debugserver binary

Instead of hardcoding the absolute path to the Command Line
Tools (CLT) binary, will attempt to resolve the path at the
$PATH, or at the Xcode bundle. If none are available, will
fallback to the default CLT location.

Fixes #986

* gdbserial/gdbserver: Log outgoing executed commands

Add logging to capture the executable and associated arguments used
in LLDBLaunch and LLDBAttach

Related to #986

* gdbserial/gdbserver: Add unit tests for helper function

Define unit tests for helper function. Setup each test to temporarily make
PATH variable, and file system changes, and subsequently revert them.

Related to #986

* gdbserial/gdbserver: Lazily load function

Lazily obtain absolute path to avoid increasing load times.

Remove flaky tests.

Related to #986
2020-04-09 13:48:38 -07:00
Derek Parker
0c9846c0a4 *: Update freebsd image 2020-04-08 11:40:24 +02:00
aarzilli
3a72646782 Documentation: add modules mode note to install documentation
1. Adds a note to the documentation describing how to use 'go get' in
   modules mode
2. Removes the '-u' option which, when 'go get' is used incorrectly
   will make 'go' try to compile Delve with unsupported dependencies
3. Removed obsolete note about Go 1.5 vendor experiment.

Fixes #1988
2020-04-06 08:32:02 -07:00
aarzilli
7dedf1ed55 proc: simplify next/step/stepout condition code
Adds a library of utility functions to generated breakpoint conditions
for next, step and stepout.
2020-04-04 11:00:54 -07:00
Lukas Spieß
eac6ebed03
Use proper spelling of Xcode (#1984) 2020-04-04 13:58:06 +02:00
Derek Parker
aa0b4eb180 *: Better error launching invalid binary format
Fixes #1310
2020-04-02 18:41:16 +02:00
aarzilli
72eeb5ae84 debugger: ClearBreakpoint should clear a logical breakpoint
Clear all physical breakpoints associated with a logical breakpoint in
ClearBreakpoint.

Fixes #1955
2020-04-02 08:53:09 -07:00
polinasok
c97c04220d
service/dap: Change reason to "entry" when stopping on entry (#1976)
Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2020-04-01 12:51:31 -07:00
Derek Parker
3cf685e5ea cmd/dlv: Unexport flag variables 2020-04-01 10:28:52 +02:00
aarzilli
3c8d4d52b8 *: un-export unnecessarily public symbols 2020-03-31 14:47:29 -07:00
aarzilli
1ee8d5c218 tests: relax TestStacktraceGoroutine with Go 1.14
The test was always flaky because we can't fully control the state of
all goroutines in the target program, Go 1.14's asynchronous preemption
exacerbates the problem.

See for example:
https://travis-ci.com/github/go-delve/delve/jobs/302407282

This commit relaxes the checks made by the test to avoid irrelevante
flakiness.
2020-03-31 10:43:10 -07:00
aarzilli
a61b6c0d7c proc: avoid constructing unnecessary strings when evaluating variables
Avoids constructing:

1. name of runtime.curg fields while executing parseG
2. the location expression while evaluating any variable.

Benchmark before:

BenchmarkConditionalBreakpoints-4   	       1	4953889884 ns/op

Benchmark after:

BenchmarkConditionalBreakpoints-4   	       1	4419775128 ns/op

Updates #1549
2020-03-31 10:29:26 -07:00
aarzilli
431dea7ee6 proc: skip autogenerated wrappers when stepping in and out
Under some circumstances (methods with non-pointer receivers or from
embedded fields called through an interface) the compiler will
autogenerate wrapper functions.

This commit changes next, step and stepout to skip all autogenerated
wrappers.

Fixes #1908
2020-03-31 10:04:36 -07:00
Alessandro Arzilli
223e0a57ca
proc: convert Arch into a struct (#1972)
Replace the interface type Arch with a struct with the same
functionality.
2020-03-30 11:03:29 -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