mirror of
https://github.com/go-delve/delve.git
synced 2025-10-31 02:36:18 +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,13 +1050,7 @@ func (s *Session) onLaunchRequest(request *dap.LaunchRequest) {
|
|||||||
var out [1024]byte
|
var out [1024]byte
|
||||||
for {
|
for {
|
||||||
n, err := reader.Read(out[:])
|
n, err := reader.Read(out[:])
|
||||||
if err != nil {
|
if n > 0 {
|
||||||
if err == io.EOF {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.config.log.Errorf("failed read by %s - %v ", category, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
outs := string(out[:n])
|
outs := string(out[:n])
|
||||||
s.send(&dap.OutputEvent{
|
s.send(&dap.OutputEvent{
|
||||||
Event: *newEvent("output"),
|
Event: *newEvent("output"),
|
||||||
@ -1065,6 +1059,14 @@ func (s *Session) onLaunchRequest(request *dap.LaunchRequest) {
|
|||||||
Category: category,
|
Category: category,
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
if err == io.EOF {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s.config.log.Errorf("failed read by %s - %v ", category, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.preTerminatedWG.Add(2)
|
s.preTerminatedWG.Add(2)
|
||||||
@ -1186,7 +1188,7 @@ func (s *Session) newNoDebugProcess(program string, targetArgs []string, wd stri
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cmd.Stdout, cmd.Stderr = os.Stdin, os.Stderr
|
cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = cmd.Start(); err != nil {
|
if err = cmd.Start(); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user