Commit Graph

1695 Commits

Author SHA1 Message Date
Alessandro Arzilli
14733084a8
dwarf/line: fix TestDebugLinePrologueParser test for Go 1.14 (#1891)
Go 1.14 has more fake file names, apparently (also go fmt).
2020-02-26 20:38:31 -08:00
chainhelen
7560c33819
pkg,service: Use PCToFunc instead of PCToLine if it only needs func (#1894) 2020-02-25 21:01:37 -08:00
Eli Bendersky
23b8e59ab9
service/dap: Add panic guard to DAP handlers (#1895)
* Panic guard for DAP request handling

* Use GetSeq

* Re-vendor new version of go-dap

* Remove comment

* Update error message

* Reuse er.Message in Format
2020-02-25 21:00:54 -08:00
Alessandro Arzilli
897d5c4288
debugger: CreateBreakpoint should delete existing breakpoints (#1892)
Fixes a bug introduced by the logical breakpoint change, where creating
the same breakpoint twice deletes the breakpoint.
2020-02-25 12:29:20 -08:00
Alessandro Arzilli
d925f6b719
proc,service: allow printing registers for arbitrary frames (#1875)
Adds an optional scope prefix to the `regs` command which allows
printing registers for any stack frame (as long as they were somehow
saved). Issue #1838 is not yet to be closed since we are still not
recovering the registers of a segfaulting frame.

Updates #1838
2020-02-24 10:47:02 -08:00
Alessandro Arzilli
186786235f
terminal: add ability to print goroutine labels (#1879) 2020-02-24 09:47:54 -08:00
Alessandro Arzilli
ade20a4d4d
proc/native: better error message when building on unsupported systems (#1883)
As we rearrange the code and the Go compiler changes the error message
returned by the compiler on unsupported architectures will change too,
making it un-googlable. Since the error message tends to be rather
obscure too this regularly confuses newbies.

This is an effort to make the error message for unsupported GOOS/GOARCH
combinations the same across all unsupported combinations and to make
it more user friendly.

Directories containing Go source code are supposed to contain a single
package. This property happens to be checked by cmd/go itself so it
will happen even before the syntax is fully checked and therefore has a
high probability of being the first (and only) error message being
print.

Here we take advantage of this by adding to the pkg/proc/native
directory a file with a bad package line that only gets compiled in on
unsupported GOOS/GOARCH combinations.

At present the error message for compiling Delve on unsupported systems
will be:

service/debugger/debugger.go:21:2: found packages native (proc.go) and your_operating_system_and_architecture_combination_is_not_supported_by_delve (support_sentinel.go) in $PATH_TO_DELVE/pkg/proc/native
2020-02-24 09:39:51 -08:00
Eli Bendersky
7f14f6ab11
service/dap: avoid hardcoded []byte slices in DAP tests (#1881)
* Remove hardcoded tests

* Cleanup - consistent naming, simplify some code, remove unused func

* Address review comments

* Add Seq checks back

* Address more review comments

* Remove hardcoded tests

* Cleanup - consistent naming, simplify some code, remove unused func

* Address review comments

* Add Seq checks back

* Address more review comments

* Make more consistent

* More consistency

* Simplify Except* methods with a helper

Mark t.Helper() where appropriate
2020-02-24 09:36:34 -08:00
chainhelen
d0b21fbbf2 pkg/proc: Fix ThreadId when ErrNoGoroutine on g0 stack in GetG
Avoid always showing `no G executing on thread 0` when ErrNoGoroutine on
g0 stack in GetG.
2020-02-24 09:32:27 -08:00
Koichi Shiraishi
9239013e39 scripts: support macOS 10.15 or later
macOS hasn't /usr/include/sys/types.h header with Canalina or later.
switch types.h path to CommandLineTools if kernel minor version up to 15 or later.
2020-02-24 09:30:47 -08:00
Hyang-Ah Hana Kim
44c644ccf2
service/dap: minor cosmetic changes (#1882)
- Move package doc comments so they are recognized as package doc.
- Use t.Helper when appropriate.
2020-02-21 09:05:30 -08:00
Klemens Morgenstern
17f2fa7908
dwarf/line: Fixed DirIdx (index starts at one) (#1873)
* Fixed DirIdx (index starts at one)

I am using the elf to load C++ based elf and there the index starts at one and not zero, hence the minor fix.

* Added test

* Added proper test for c-generated elf & replaced index offset by adding build dir

* Changed other IncludeDir test

* Format fix & replace print with actual test

* Format fixes @derekparker requested.
2020-02-21 09:00:34 -08:00
Alessandro Arzilli
fcba291125
proc: remove support for parsing interfaces in Go 1.8 and earlier (#1878)
Go 1.8 has been out of date for a while and the code to support it is
potentially dangerous if a future version of Go removes the runtime
types from debug_info and also changes their representation.
2020-02-20 10:52:48 -08:00
Derek Parker
4136512ef3 pkg/proc: Allow function calls on non-struct types
Removes the restriction that the DWARF type for the receiver of a method
must be a TypeDef. This seems reasonable in practice, but it turns out
Go DWARF does not consider

```
type X int
```

to be a typedef. This patch also allows for calling a method where the
receiver is not used or passed in, such as:

```
func (_ X) Method() { println("why") }
```
2020-02-20 10:31:48 +01:00
chainhelen
4f04b81c28
pkg/proc: Judge the validity of addr ranges when disasm. (#1872)
Avoid panic if start addr is greater than end addr when disasm.
2020-02-19 08:46:03 -08:00
Sylvain Rabot
8db632e55b
*: Fix typo in Makefile (#1869)
Signed-off-by: Sylvain Rabot <s.rabot@lectra.com>
2020-02-18 10:02:04 -08:00
ossdev07
a83d1c1409
proc/core: implementing coredump functionality for ARM64 (#1774)
* proc/native: optimize native.status through buffering (#1865)

Benchmark before:

BenchmarkConditionalBreakpoints-4              1        15649407130 ns/op

Benchmark after:

BenchmarkConditionalBreakpoints-4   	       1	14586710018 ns/op

Conditional breakpoint evaluation 1.56ms -> 1.45ms

Updates #1549

* proc/core: Review Comments Incorporated

Signed-off-by: ossdev07 <ossdev@puresoftware.com>

Co-authored-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
2020-02-17 09:29:17 -08:00
Alessandro Arzilli
ecea2e1814
proc: optimize parseG (#1866)
runtime.g is a large and growing struct, we only need a few fields.
Instead of using loadValue to load the full contents of g, cache its
memory and then only load the fields we care about.

Benchmark before:

BenchmarkConditionalBreakpoints-4              1        14586710018 ns/op

Benchmark after:

BenchmarkConditionalBreakpoints-4   	       1	12476166303 ns/op

Conditional breakpoint evaluation: 1.45ms -> 1.24ms

Updates #1549
2020-02-17 09:27:56 -08:00
Alessandro Arzilli
c272212baa
proc/native: optimize native.status through buffering (#1865)
Benchmark before:

BenchmarkConditionalBreakpoints-4              1        15649407130 ns/op

Benchmark after:

BenchmarkConditionalBreakpoints-4   	       1	14586710018 ns/op

Conditional breakpoint evaluation 1.56ms -> 1.45ms

Updates #1549
2020-02-15 11:55:19 -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
8fa6d82177
logflags: reduce default loglevel to Error (#1864)
Logged errors should be visible even if the corresponding flag was not
selected.
2020-02-14 13:13:50 -08:00
Derek Parker
a277b15def proc/gdbserial: Reload thread registers on demand
Instead of reloading the registers for every thread every time the
process executes, reload the registers on demand for individual threads
and memoize the result.
2020-02-13 18:30:32 +01:00
chainhelen
a5d9dbee79
pkg,service: add cmd examinemem(x) for examining memory. (#1814)
According to #1800 #1584 #1038, `dlv` should enable the user to dive into
memory. User can print binary data in specific memory address range.
But not support for sepecific variable name or structures temporarily.(Because
I have no idea that modify `print` command.)

Close #1584.
2020-02-13 09:29:21 -08:00
Alessandro Arzilli
5b4f4a81b1
proc: do not load g0 until it's needed when stacktracing (#1863)
The stacktrace code occasionally needs the value of g.m.g0.sched.sp to
switch stacks. Since this is only needed rarely and calling parseG is
relatively expensive we should delay doing it until we know it will be
needed.

Benchmark before:

BenchmarkConditionalBreakpoints-4              1        17326345671 ns/op

Benchmark after:

BenchmarkConditionalBreakpoints-4   	       1	15649407130 ns/op

Reduces conditional breakpoint latency from 1.7ms to 1.56ms.

Updates #1549
2020-02-13 09:12:59 -08:00
Alessandro Arzilli
b9d0ddd82c
proc: only format registers value when it's necessary (#1860)
A significant amount of time is spent generating the string
representation for the proc.Registers object of each thread, since this
field is rarely used (only when the Registers API is called) it should
be generated on demand.

Also by changing the internal representation of proc.Register to be
closer to that of op.DwarfRegister it will help us implement #1838
(when Delve will need to be able to display the registers of an
internal frame, which we currently represent using op.DwarfRegister
objects).

Benchmark before:

BenchmarkConditionalBreakpoints-4   	       1	22292554301 ns/op

Benchmark after:

BenchmarkConditionalBreakpoints-4   	       1	17326345671 ns/op

Reduces conditional breakpoint latency from 2.2ms to 1.7ms.

Updates #1549, #1838
2020-02-12 13:31:48 -08:00
vpsx
abb57ff017
terminal/docgen: Specify all possible config locations (#1859)
Changes docs to reflect different possible locations for config/history files.
2020-02-12 08:59:37 -08:00
Kirides
d8c31af4b0
*: Update CHANGELOG.md - fix v1.4.0's date being 2019 (#1861)
I think that should've been 2020 ;)
2020-02-12 08:59:18 -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
aarzilli
99532c405a all: bump version number and release notes
Thank you to: @stapelberg, @hengwu0, @tykcd996, @chainhelen,
@alexbrainman, @nd and @stigok.
2020-02-11 11:38:41 +01:00
chainhelen
bd279cb9da
pkg/proc: optimize code for supporting different arch in the future. (#1849) 2020-02-10 17:32:50 -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
Stig Otnes Kolstad
bc9d95d615
Documentation/cli: add info for element limit config keys (#1853) 2020-01-29 16:13:41 +01:00
chainhelen
f925d3c8d7
pkg/proc: remove meanless code in dwarf_expr_test.go. (#1850) 2020-01-29 16:12:44 +01:00
aarzilli
7eddfb77b9 dwarf/reader: precalcStack does not need to read past the first entry
It was reading all the way to the end of the debug_info section,
slowing down stacktraces substantially.

Benchmark before:

BenchmarkConditionalBreakpoints-4   	       1	80344642562 ns/op

Benchmark after:

BenchmarkConditionalBreakpoints-4   	       1	22218288218 ns/op

i.e. a reduction of the cost of a breakpoint hit from 8ms to 2.2ms

Updates #1549
2020-01-28 11:32:53 +01:00
aarzilli
fc3e01bb5b tests: add benchmark for conditional breakpoints 2020-01-28 11:32:53 +01:00
aarzilli
279c29a37c proc: remove CX method from proc.Registers
It is not used anymore besides internally by the proc/gdbserial
backend.
2020-01-28 11:32:53 +01:00
chainhelen
dee267b68b pkg/proc: fix typo in the comment of PtraceGetFpRegset (#1848) 2020-01-27 10:20:56 +01:00
chainhelen
ff5734a0d8 pkg: fix abbreviation of Flag Register on amd64 (#1845) 2020-01-22 11:35:11 -08:00
Derek Parker
75d7266dc0 *: Update AppVeyor badge
It seems the project in AppVeyor moved from go-delve to my AppVeyor account and I'm not sure how that happened. However, it did break the badge rendering on the README so this patch fixes it with the current correct link.
2020-01-22 11:55:30 +01:00
Derek Parker
94a20d57da
pkg/proc: Introduce Target and remove CommonProcess (#1834)
* pkg/proc: Introduce Target

* pkg/proc: Remove Common.fncallEnabled

Realistically we only block it on recorded backends.

* pkg/proc: Move fncallForG to Target

* pkg/proc: Remove CommonProcess

Remove final bit of functionality stored in CommonProcess and move it to
*Target.

* pkg/proc: Add SupportsFunctionCall to Target
2020-01-21 12:41:24 -08:00
hengwu0
3f7571ec30 proc: implement stacktrace of arm64 (#1780)
* proc: separate amd64-arch code

separate amd64 code about stacktrace, so we can add arm64 stacktrace code.

* proc: implemente stacktrace of arm64

* delve now can use stack, frame commands on arm64-arch debug.

Co-authored-by: tykcd996 <tang.yuke@zte.com.cn>
Co-authored-by: hengwu0 <wu.heng@zte.com.cn>

* test: remove skip-code of stacktrace on arm64

* add LR DWARF register and remove skip-code for fixed tests

* proc: fix the Continue command after the hardcoded breakpoint on arm64

Arm64 use hardware breakpoint, and it will not set PC to the next instruction like amd64. We should move PC in both runtime.breakpoints and hardcoded breakpoints(probably cgo).

* proc: implement cgo stacktrace on arm64

* proc: combine amd64_stack.go and arm64_stack.go file

* proc: reorganize the stacktrace code

* move SwitchStack function arch-related
* fix Continue command after manual stop on arm64
* add timeout flag to make.go to enable infinite timeouts

Co-authored-by: aarzilli <alessandro.arzilli@gmail.com>
Co-authored-by: hengwu0 <wu.heng@zte.com.cn>

Co-authored-by: tykcd996 <56993522+tykcd996@users.noreply.github.com>
Co-authored-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
2020-01-21 09:11:20 -08:00
Dmitry Neverov
7fe81ca1d6 cache computed labels 2020-01-21 09:08:36 -08:00
Dmitry Neverov
ca3fe88899 proc,service: expose goroutine pprof labels in api
Labels can help in identifying a particular goroutine during debugging.

Fixes #1763
2020-01-21 09:08:36 -08:00
chainhelen
1ac990c705 README: Remove gitter chat link.
Abandon gitter chat link, just leave the mailing list.

Fix #1842
2020-01-21 09:06:53 -08:00
chainhelen
f5608c7712 pkg/terminal: tolerate spurious spaces between arguments of cli.
Expression such as:
   config show-location-expr  true
   disassemble -a  0x4a23a0 0x4a23f2
   disassemble -a 0x4a23a0  0x4a23f2
should all execute correctly.

Extend #795.
2020-01-20 10:47:56 -08:00
aarzilli
9af1eac341 proc: cache goroutine objects
Adds a cache mapping goroutine IDs to goroutine objects, this allows
speeding up FindGoroutine and makes commands like 'goroutines -t' not
be accidentally quadratic in the number of goroutines.
2020-01-16 10:14:14 -08:00
chainhelen
666a618f47 service/test: Fix a wrong judgment about err.
Should judge `state.Err` instead of `err`.
2020-01-14 11:08:46 +01:00
Derek Parker
2d7b926c60 *: Update go.mod version to 1.11
We've dropped support for 1.11 in our CI runs, we should also update the
minimum require Go version in the mod file as well.

Resolves #1813
2020-01-14 11:07:30 +01:00
Alex Brainman
db88d2e91d pkg/prog: Make sure Attach is executed on a single thread
Specifically, make sure that both DebugActiveProcess and
WaitForDebugEvent Windows APIs are executed on the same thread.

Otherwise WaitForDebugEvent fails with ERROR_INVALID_HANDLE as per its
documentation

https://docs.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-waitfordebugevent

'... Only the thread that created the process being debugged can call
WaitForDebugEvent. ...'

Fixes #1825
2020-01-13 09:44:47 -08:00
aarzilli
adb1746c60 proc: fix inlined stack reading for midstack inlined calls
Due to a bug in the Go compiler midstack inlined calls do not report
their ranges correctly. We can't check if an address is in the range of
a DIE by simply looking at that DIE's range, we should also recursively
check the DIE's children's ranges.

Also fixes the way stacktraces of midstack inlined calls are reported
(they used to be inverted, with the deepest inlined stack frame
reported last).

Fixes #1795
2020-01-10 09:04:48 +01:00