Commit Graph

1630 Commits

Author SHA1 Message Date
Derek Parker
f05ce09473 *: Fix use of deprecated functionality 2020-03-20 09:05:14 +01:00
Derek Parker
f80674979a *: Ignore scripts in deepsource analysis 2020-03-20 09:04:29 +01:00
Alessandro Arzilli
0cfd52787f
proc/gdbserial: add logging when Thread.Location will fail (#1937)
Add logging for Issue #1927. The bug happens during the call to
api.ConvertThread, returning an error will not suffice since
ConvertThread will not surface it.

Updates #1927
2020-03-19 12:28:27 -07:00
Alessandro Arzilli
e1cfd72795
proc: fix bad cached goroutines after a call injection (#1926)
Inserts a call to ClearAllGCache into stepInstructionOut so that cached
goroutine state is not inconsistent after an injected function call.\

Fixes #1925
2020-03-19 12:27:31 -07:00
Alessandro Arzilli
c6de961be8
terminal: add display command (#1917)
Implements #1256
2020-03-19 11:58:40 -07:00
Alessandro Arzilli
4aee281520
travis-ci: autogenerate .travis.yml (#1939)
Autogenerates .travis.yml configuration using the contents of
pkg/goversion/compat.go.
Also:
- excludes testing of windows/amd64/tip and linux/arm64/tip (Travis-CI
  can't get Go at tip for those combinations).
- Removes Go 1.11 from pkg/goversion/compat.go which we don't test
  anymore.
2020-03-19 11:09:29 -07:00
Sourya Vatsyayan
5ef973c742
*: Exclude _fixtures for DeepSource issues (#1941) 2020-03-19 11:07:54 -07:00
Derek Parker
731a7fc125 *: consolidate appends where possible 2020-03-19 10:25:09 +01:00
chainhelen
65d7f5c65f
pkg/proc: Prevent program crash when called meanless expression (#1934)
If we call one expression which is the fake method of meanless
string, `delve` will panic. Strengthen the inspection of boundary
conditions when supporting function calls on non-struct types.

Update: #1871
2020-03-18 09:26:24 -07: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
Derek Parker
edc5436fe3 *: Add DeepSource CI config 2020-03-18 14:49:34 +01:00
MinJae Kwon
25d8856cd1
*: run gofmt (#1928) 2020-03-16 09:38:15 -07:00
chainhelen
5774066ddb
*: Transfer 32-bit test into travis from cirrus (#1932) 2020-03-16 09:37:33 -07:00
Alessandro Arzilli
88a0e1727a
terminal: preserve arguments and prefixes when repeating last command (#1930) 2020-03-14 14:34:56 -07: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
chainhelen
e90a5b48ca
terminal: add -l prompt on goroutines help (#1922)
Update: #1879
2020-03-11 09:31:29 -07:00
Alessandro Arzilli
134fcb186e
proc: cache result of GetG (#1921)
Benchmark before:

BenchmarkConditionalBreakpoints-4   	       1	7031242832 ns/op

Benchmark after:

BenchmarkConditionalBreakpoints-4   	       1	5282482841 ns/op

Conditional breakpoint evaluation latency: 0.70ms -> 0.52ms

Updates #1549
2020-03-10 12:48:46 -07:00
polinasok
5613cf151e
service/dap: Add support for threads request (#1914)
* Add support for threads request

* Address review comments

* Relax threads test condition

* Address review comments

* Clean up unnecessary newline

* Respond to review comment

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2020-03-10 12:29:06 -07:00
Alessandro Arzilli
9f97edb0bb
proc,proc/*: add StopReason field to Target (#1877)
* proc,proc/*: move SelectedGoroutine to proc.Target, remove PostInitializationSetup

moves SelectedGoroutine, SwitchThread and SwitchGoroutine to
proc.Target, merges PostInitializationSetup with NewTarget.

* proc,proc/*: add StopReason field to Target

Adds a StopReason field to the Target object describing why the target
process is currently stopped. This will be useful for the DAP server
(which needs to report this reason in one of its requests) as well as
making pull request #1785 (reverse step) conformant to the new
architecture.

* proc: collect NewTarget arguments into a struct
2020-03-10 12:27:38 -07:00
chainhelen
f3a191cd73
pkg/proc,service: support linux/386 (#1884)
Implement debugging function for 386 on linux with reference to AMD64.
There are a few remaining problems that need to be solved in another time.

1. The stacktrace of cgo are not exactly as expected.
2. Not implement `core` for now.
3. Not implement `call` for now. Can't not find `runtime·debugCallV1` or
   similar function in $GOROOT/src/runtime/asm_386.s.

Update #20
2020-03-10 09:34:40 -07:00
Alessandro Arzilli
e9b2da17cb
proc/native/linuc: Better native.Process.stop performance (#1874)
* proc/native/linux: only set breakpoints on threads that receive SIGTRAP

* proc/native/linux: do not call (*Thread).Stopped inside (*Process).stop

(*Thread).Stopped is slow because it needs to open, read and parse a
file in /proc, we don't actually need to do that, we can just rely on
the value of Thread.os.running.

Benchmark before:

BenchmarkConditionalBreakpoints-4              1        12476166303 ns/op

Benchmark after:

BenchmarkConditionalBreakpoints-4   	       1	10403533675 ns/op

Conditional breakpoint evaluation: 1.24ms -> 1ms

Updates #1549
2020-03-09 10:15:45 -07:00
polinasok
17e70a908e
logflags: Add pid to server-listening-at message (#1885)
* logflags: Add pid to server-listening-at message

* Address review comments: use logger

Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
2020-03-09 10:14:34 -07:00
aarzilli
b886e8e449 terminal: divide commands into categories
There are too many commands, for clarity they should be divided into
categories when printing and generating documentation.
2020-03-09 10:11:21 -07:00
Derek Parker
12d9b8069c pkg/proc: Add doc comments to Target Restart and Detach 2020-03-06 14:21:17 +01: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
aarzilli
d1c63500e8 go.mod: remove unused dependencies, go mod tidy 2020-03-03 10:45:17 -08:00
a
23dc9f92c2 proc/gdbserial: disable async preemption on macOS
Disables async preemption on macOS

Fixes #1905
2020-03-02 12:51:26 -08:00
Derek Parker
241f242231 service/api: Refactor examine memory pretty printer
Use strings.Builder and tabwriter to format the output of the examine
memory command instead of doing direct string manipulation and
allocating.
2020-03-01 11:16:29 +01:00
Derek Parker
6319d50e94 *: Add Go 1.14 to test matrix
This also removes Go 1.11 from the test matrix.

Now that 1.14 has been released, as always it should be included in the
test matrix.
2020-03-01 11:13:39 +01:00
Josh Stone
d0d2d47885 proc/native/linux: try to use process_vm_readv/writev
This change adds `ProcessVmRead` and `ProcessVmWrite` wrappers around
the syscalls `process_vm_readv` and `process_vm_writev`, available since
Linux 3.2. These follow the same permission model as `ptrace`, but they
don't actually require being attached, which means they can be called
directly from any thread in the debugger. They also use `iovec` to write
entire blocks at once, rather than having to peek/poke each `uintptr`.

These wrappers are used in `Thread.ReadMemory` and `WriteMemory`, still
falling back to `ptrace` if that fails for any reason.  Notably,
`process_vm_writev` respects memory protection, so it can't modify
read-only memory like `ptrace`. This frequently occurs when writing
breakpoints in read-only `.text`, so to avoid a lot of wasted `EFAULT`
calls, we only try `process_vm_writev` for larger writes.
2020-02-29 08:25:31 -08:00
chainhelen
0a650a0e0f
pkg/logflags: Display warning when unknown component for --log-output (#1897) 2020-02-28 09:50:22 -08:00
polinasok
0f9b05b9f5
dlv_test: add a basic test for dap command (#1899) 2020-02-28 09:48:59 -08:00
chainhelen
b09aed17fd
pkg,service: Optimized the display of examinemem command. (#1888)
1. Don't use intelligent '#' in fmt of go because it is not always satisfying
for diffrent version of golang. Always keep one leading zero for octal and
one leading '0x' for hex manually. Then keep alignment for every byte.

2. Always keep addr alignment when the lens of two adjacent address are
different.

Update #1814.
2020-02-26 22:53:09 -08:00
Eli Bendersky
a83554863f
service/dap: clean shutdown sequence in server (#1889)
Using a stop channel to signal clean shutdown to the server's
goroutines. Also updates the tests to trigger disconnectChan.

This helps avoid spurious error logs when the client disconnects, when
Ctrl+C is pressed, etc.
2020-02-26 20:45:48 -08:00
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