Commit Graph

22 Commits

Author SHA1 Message Date
aarzilli
a357ce0638 tests: fix typecheckrpc.go and convert it to a test
We forgot to run typecheckrpc.go periodically and it didn't work
anymore and there were some minor errors in service/rpc2/client.go.

Rewrite typecheckrpc.go using go/packages, so that it works with go1.11
and go.mod, and fix the issues in client.go
2019-01-07 11:47:49 -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
zavla
a4a5d4b7f6 main_test: Fix "gopath mode" detection in projectRoot() (#1426)
* main_test: Fix "gopath mode" detection in projectRoot()

Fails detect that this is a "gopath mode" when GOPATH contains several paths ex. "d:\\dir\\gopath;f:\\dir\\gopath2"
2018-11-28 19:22:11 +01:00
Derek Parker
d61cd1c0d7 pkg/proc: Refactor process post initialization
This patch is a slight refactor to share more code used for genericprocess initialization. There will always be OS/backend specificinitialization, but as much as can be shared should be to preventduplicating of any logic (setting internal breakpoints, loading bininfo,etc).
2018-11-15 18:16:16 +01:00
Derek Parker
91953dd49c cmd/dlv: Fix tests for use with modules 2018-11-14 09:00:49 +01:00
aarzilli
087431f029 Makefile: replace makefile with a script
We were using our makefile not for the intended purpose of makefiles
but to multiplex a series of small scripts.
We can easily achieve the same result in a more reasonable programming
language and as a bonus we don't need to install a version of make on
windows anymore.
Additionally our test script had become fairly complicated and will
become even more complicated when testing of PIE buildmode is
introduced.
Allows the tests to run on Windows without having to install Mingw
(although we still want it installed so that we can run cgo tests on
Windows).

Fixes building when GOPATH isn't set.

Fixes #759
2018-09-18 12:06:25 -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
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
65d9255040 dlv_test: disable one of the checks of TestOutput on windows
Sometimes delve on Appveyor can't remove the built binary before
exiting and gets an "Access is denied" error when trying.
See: https://ci.appveyor.com/project/derekparker/delve/build/1527
2017-12-18 13:53:35 -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
Alex Brainman
0cfe539052 proc/native: make sure debugged executable can be deleted on windows (#890)
* proc/native: make sure debugged executable can be deleted on windows

Delve opens debugged executable to read binary info it
contains, but it never closes the file. Windows will not
let you delete file that is opened. So close Process.bi
in Process.postExit, and actually call Process.postExit
from windows Process.Kill.

Also Windows sends some debugging events
(EXIT_PROCESS_DEBUG_EVENT event in particular) after Delve
calls TerminateProcess. The events need to be consumed by
debugger before debugged process will be released by
Windows. So call Process.waitForDebugEvent after
TerminateProcess in Process.Kill.

Fixes #398

* cmd/dlv: make TestIssue398 pass on darwin

* cmd/dlv: add comment for TestIssue398

* proc/native: wait for debuggee to exit before returning from windows Process.Kill

* proc/native: close process handle before returning from windows killProcess

* proc/native: remove not used Process.Process
2017-07-26 12:51:44 -06:00
Alessandro Arzilli
50f6382307 dlv: make headless servers quit automatically when client disconnects (#895) 2017-06-26 11:45:13 -07:00
Hyang-Ah Hana Kim
c67986ed7d cmd/dlv: fix race in test (#805)
% go test -race -v -short

=== RUN   TestBuild
==================
WARNING: DATA RACE
Write at 0x00c4201379a0 by goroutine 9:
  os.(*file).close()
      /usr/local/go/src/os/file_unix.go:143 +0x10a
  os.(*File).Close()
      /usr/local/go/src/os/file_unix.go:132 +0x55
  os/exec.(*Cmd).closeDescriptors()
      /usr/local/go/src/os/exec/exec.go:263 +0x67
  os/exec.(*Cmd).Wait()
      /usr/local/go/src/os/exec/exec.go:448 +0x2b8
  github.com/derekparker/delve/cmd/dlv.TestBuild.func1()
      /home/kbuilder/go/src/github.com/derekparker/delve/cmd/dlv/dlv_test.go:82 +0x8e
  github.com/derekparker/delve/cmd/dlv.TestBuild()
      /home/kbuilder/go/src/github.com/derekparker/delve/cmd/dlv/dlv_test.go:104 +0xb6a
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107

Previous read at 0x00c4201379a0 by goroutine 12:
  os.(*File).Read()
      /usr/local/go/src/os/file.go:98 +0x70
  bufio.(*Scanner).Scan()
      /usr/local/go/src/bufio/scan.go:207 +0x539
  github.com/derekparker/delve/cmd/dlv.TestBuild.func2()
      /home/kbuilder/go/src/github.com/derekparker/delve/cmd/dlv/dlv_test.go:93 +0x38

Change-Id: I09d188dbf964fe4af0b33b6a8fcfe51396176b7e
2017-04-26 12:03:26 -07:00
aarzilli
329bc7e69d dlv_test: fix test on macOS for new Makefile 2017-04-18 13:25:11 -07:00
aarzilli
c8d9352522 proc: Implement target.Interface for gdbserver backend 2017-04-18 13:25:11 -07:00
Hyang-Ah Hana Kim
ab7367ed2b Minor fixes to make some tests build and run (#752)
* cmd/dlv: fall back to go env GOPATH when GOPATH envvar is unset.

Since Go 1.8, GOPATH environment variable has a default value if the
environment variable is unset so not setting GOPATH is perfectly ok.
Depend on `go env` command to query Go related environment variable.

* build: update references to moved packages
2017-03-13 10:59:34 -07:00
aarzilli
1a68f8d351 proc/windows: handle delayed events
Sometimes windows will send us events about breakpoints we have
already removed from the code despite the fact that we go to great
lengths to avoid this already.

Change waitForDebugEvent to check that when we receive a breakpoint
event the corresponding memory actually contains an INT 3
instruction, if it doesn't ignore the event and restart the thread.
2017-02-22 20:39:28 +01:00
Derek Parker
53f0d24057 Move top-level packages into pkg 2017-02-08 12:17:19 -08:00
aarzilli
ee6d2734c9 tests: fix TestBuild on macOS, windows 2016-12-17 10:53:30 +01: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