-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Redirect if internal console #3108
Conversation
5991d03
to
8679c98
Compare
@@ -326,7 +326,7 @@ func openRedirects(redirects [3]string, foreground bool) (stdin, stdout, stderr | |||
return dflt | |||
} | |||
var f *os.File | |||
f, err = os.Create(path) | |||
f, err = os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0o666) |
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.
This is a backwards incompatible change because you are not passsing O_TRUNC.
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.
Will add it - I still need to check whether O_TRUNC
has any bad effect when opening a fifo.
// This is a var for testing | ||
maxGoroutines = 1 << 10 | ||
) | ||
// Max number of goroutines that we will return. |
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.
Avoid unrelated reformats, they pollute blames and make merge conflicts unnecessarily harder.
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.
My editor auto-formats using gofumpt
, so it formatted some extra editted files. Will revert such changes.
@@ -1049,6 +1071,32 @@ func (s *Session) onLaunchRequest(request *dap.LaunchRequest) { | |||
return | |||
} | |||
|
|||
func() { |
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.
Why?
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.
Followed a similar pattern I've seen later on of wrapping some logic in an inline function to ease breaking, not anything special - I can export it to a different method.
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.
If you refer to this file, that pattern is to execute a defer, not to group anything.
) | ||
|
||
func generateStdioTempPipes() (res [2]string, err error) { | ||
err = errors.New("Unimplemented") |
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.
Merging this with just a linux implementation would be weird. This is enough of a prominent feature that having it implemented for one operating system implies that we have to implement it for at least the more important ones. I think it needs to support Windows and macOS.
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.
Implementing it to all platforms should be relatively easier if we can change the Redirects
to not only be paths to stdout
/stderr
, but io.Writer
s. I'll implement complete support for native
, which should be relatively easy to do soin that backend.
@@ -1049,6 +1071,32 @@ func (s *Session) onLaunchRequest(request *dap.LaunchRequest) { | |||
return | |||
} | |||
|
|||
func() { | |||
if args.Console == "internalConsole" && runtime.GOOS == "linux" && (args.Backend == "default" || args.Backend == "native") { |
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.
It's weird that using internalConsole on an unsupported configuration fails silently. It's also weird that all values of console that aren't internalConsole are accepted as valid.
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.
The current behavior is that console
is not checked, so it can also be completely invalid and dlv dap
would accept it, so I'm not sure we necessarily have to validate the console
argument.
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.
Suppose someone misspells internlaConsole, how do they notice?
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.
Usually, such syntax can be checked in VSCode itself - it can present an error such as: "internalConsole" is not a valid "console" value"
.
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.
Not everyone uses vscode with dap. I thought that was the whole point of this.
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.
Hm, true. I am not familiar with how every DAP client handles this, but adding an allowed list of declared DAP consoles (I think it is standardized) should be easy enough.
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.
it should just be the consoles that we support.
Thank you @aarzilli for the quick reply! 🙂 |
8679c98
to
750a0b4
Compare
Is this still being worked on @gfszr ? |
Yes - currently having some difficulties on developing and testing on Windows and macOS, as requested in review. |
Closing due to age. |
This PR is currently as draft to better improve implementation and pass tests.
This PR partially implements #3094, by implementing redirection of
stdout
andstderr
to the debug console via DAP'sOutputEvent
's on Linux.It partially does so as current debug backend API support receiving a path to a redirected file only, and not a
io.Writer
as an example. It also supports only thenative
backend and not other backends.Achieving full support would require adding a generalized API so that we can pass an
io.Writer
to the native backend nicely, but this can be done later on and be discussed more, while Linux support can be easily implemented.