-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supports sending output to clients when running programs remotely #3253
Merged
+399
−66
Merged
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
4a06698
wip: Support sending output when remote debug
tttoad 6968a79
wip: Support local output and remote output
tttoad 105696d
wip: fix stderr and stdout assignment error
tttoad 444eeb1
wip: optimize code
tttoad 3869956
wip: Only if outputMode is "remote" is the redirected console output
tttoad 8a43523
wip: Redirected debugMode output(Not tested on windows)
tttoad 4e47c69
wip: support remote debugging output redirection of windows
tttoad 8350405
wip: real-time write back output
tttoad 9c96fbe
wip: support for windows
tttoad c4b8ce2
wip: fix windows remote debug not output
tttoad a605ff9
wip: fix truncated output redirection
tttoad d56ac9f
Merge branch 'master' of github.com:tttoad/delve into feat-console
tttoad 984e012
wip: delete printfln
tttoad 63341e7
wip: use debugger.Config to pass redirect(macOS)
tttoad d5f5fb3
wip: use debugger.Config to pass redirect(linux)
tttoad 4621f4c
wip: Change redirect to a concrete type
tttoad f433b23
wip: s.wg.wait before sending "terminated"
tttoad ffad8a4
wip: add proc/redirect test(darwin and linux)
tttoad a1467d6
Merge branch 'master' of github.com:tttoad/delve into feat-console
tttoad 70216a5
Merge branch 'master' of github.com:tttoad/delve into feat-console
tttoad 902235d
wip: Fix test failure on windows
tttoad 9e08369
fix: undefined: proc.Redirects
tttoad 0b3c066
fix: compile failure
tttoad 38958bc
wip: Remove useless code
tttoad fc89882
fix: filename error
tttoad e6a0c78
Merge branch 'master' of github.com:tttoad/delve into feat-console
tttoad 359ee2c
fix: os.file not close
tttoad ad0dec1
test: add server_test.redirect
tttoad 73c7076
fix: Remove 'eol' from end of file
tttoad 61092e2
fix: gdbserial: File not closed in file mode.
tttoad bdd13c9
feat: Remove "only-remote". Fix spelling mistakes.
tttoad f43b3d3
fix: spelling mistakes
tttoad 28cea47
refactor: redirect
tttoad c0b0d07
fix: stdout and stderr are not set to default values
tttoad 4617c1f
fix: Restore code logic for rr.openRedirects()
tttoad 123de13
fix: Optimization Code
tttoad 980d430
fix: utiltest
tttoad 72c6718
fix: execpt out
tttoad f83ec15
fix: Resource release for redirects
tttoad 31dba49
fix: build failure
tttoad 8ebdb9d
fix: clean->clear
tttoad 7d441c2
fix: build failure
tttoad dfa96ba
Merge branch 'master' of github.com:tttoad/delve into feat-console
tttoad ca76f9d
fix: test failure
tttoad 36d0e92
fix: Optimization Code
6e33d4a
style: remove useless code
tttoad 702341d
refactor: namedpipe
tttoad 5aeb3f8
refactor: namedpipe, launch ...
tttoad 10e0a66
fix: freebsd compile failure
tttoad 1e3701b
fix: proc_darwin compile failure
tttoad 4c8f86b
style: remove useless code
tttoad c016bc1
Merge branch 'master' of github.com:tttoad/delve into feat-console
tttoad a4f0491
feat: add d.config.Stdxx check on debug.Restart
tttoad 0c2f3ad
style: formatting and adding comments
tttoad 02d96ec
style: formatting and adding comments
tttoad 44fa283
feat: add d.config.Stdxx check on debug.Restart
tttoad 768fad8
style: namedpipe->redirector
tttoad f27bfcf
Merge branch 'feat-console' of github.com:tttoad/delve into feat-console
tttoad 7dd6f49
style: namedPipe->redirector
tttoad 7725eae
Merge branch 'master' into feat-console
tttoad 38969ab
Merge branch 'master' of github.com:tttoad/delve into feat-console
tttoad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func main() { | ||
fmt.Println("hello world!") | ||
fmt.Fprintf(os.Stdout, "hello world!") | ||
fmt.Fprintf(os.Stderr, "hello world!\n") | ||
fmt.Fprintf(os.Stderr, "hello world! error!") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package proc | ||
|
||
import "os" | ||
|
||
// OutputRedirect Specifies where the target program output will be redirected to. | ||
// Only one of "Path" and "File" should be set. | ||
type OutputRedirect struct { | ||
derekparker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Path File path. | ||
Path string | ||
// File Redirect file. | ||
File *os.File | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package proc | ||
|
||
import ( | ||
"crypto/rand" | ||
"encoding/hex" | ||
"io" | ||
"os" | ||
"path/filepath" | ||
"syscall" | ||
) | ||
|
||
type openOnRead struct { | ||
path string | ||
rd io.ReadCloser | ||
} | ||
|
||
func (oor *openOnRead) Read(p []byte) (n int, err error) { | ||
if oor.rd != nil { | ||
return oor.rd.Read(p) | ||
} | ||
|
||
fh, err := os.OpenFile(oor.path, os.O_RDONLY, os.ModeNamedPipe) | ||
if err != nil { | ||
return 0, err | ||
} | ||
|
||
oor.rd = fh | ||
return oor.rd.Read(p) | ||
} | ||
|
||
func (oor *openOnRead) Close() error { | ||
defer os.Remove(oor.path) | ||
|
||
fh, _ := os.OpenFile(oor.path, os.O_WRONLY|syscall.O_NONBLOCK, 0) | ||
if fh != nil { | ||
fh.Close() | ||
} | ||
|
||
return oor.rd.Close() | ||
} | ||
|
||
func Redirector() (reader io.ReadCloser, output OutputRedirect, err error) { | ||
r := make([]byte, 4) | ||
if _, err = rand.Read(r); err != nil { | ||
return reader, output, err | ||
} | ||
|
||
var path = filepath.Join(os.TempDir(), hex.EncodeToString(r)) | ||
|
||
if err = syscall.Mkfifo(path, 0o600); err != nil { | ||
_ = os.Remove(path) | ||
return reader, output, err | ||
} | ||
|
||
return &openOnRead{path: path}, OutputRedirect{Path: path}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package proc | ||
|
||
import ( | ||
"io" | ||
"os" | ||
) | ||
|
||
func Redirector() (reader io.ReadCloser, output OutputRedirect, err error) { | ||
reader, output.File, err = os.Pipe() | ||
|
||
return reader, output, err | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use
stdin, stdout, stderr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stdin, stdout, stderr
is in conflict with the returned parameter name.