mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 01:27:16 +08:00
service/dap: fix bugs in stdout/stderr handling (#3522)
Fixes bugs introduced in v1.21.1 * Avoid dropping the last bytes from stderr/stdout when Read returns an error. (Read returns n>0). And skip sending Output event if Read returns n==0. * Fix the bug that drops all stdout in the existing noDebug mode. For #3253
This commit is contained in:
committed by
GitHub
parent
b041bd8e98
commit
f90ede4653
@ -1050,6 +1050,15 @@ func (s *Session) onLaunchRequest(request *dap.LaunchRequest) {
|
||||
var out [1024]byte
|
||||
for {
|
||||
n, err := reader.Read(out[:])
|
||||
if n > 0 {
|
||||
outs := string(out[:n])
|
||||
s.send(&dap.OutputEvent{
|
||||
Event: *newEvent("output"),
|
||||
Body: dap.OutputEventBody{
|
||||
Output: outs,
|
||||
Category: category,
|
||||
}})
|
||||
}
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
return
|
||||
@ -1057,13 +1066,6 @@ func (s *Session) onLaunchRequest(request *dap.LaunchRequest) {
|
||||
s.config.log.Errorf("failed read by %s - %v ", category, err)
|
||||
return
|
||||
}
|
||||
outs := string(out[:n])
|
||||
s.send(&dap.OutputEvent{
|
||||
Event: *newEvent("output"),
|
||||
Body: dap.OutputEventBody{
|
||||
Output: outs,
|
||||
Category: category,
|
||||
}})
|
||||
}
|
||||
}
|
||||
|
||||
@ -1186,7 +1188,7 @@ func (s *Session) newNoDebugProcess(program string, targetArgs []string, wd stri
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
cmd.Stdout, cmd.Stderr = os.Stdin, os.Stderr
|
||||
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
|
||||
}
|
||||
|
||||
if err = cmd.Start(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user