service/debugger: return correct exit status on manual halt (#2674)
* service/dap: add test for nonzero exit status
This commit is contained in:
parent
b50052cc17
commit
e00670b901
@ -1024,6 +1024,8 @@ func (s *Server) stopDebugSession(killProcess bool) error {
|
|||||||
s.log.Debug("halt returned state: ", exited)
|
s.log.Debug("halt returned state: ", exited)
|
||||||
}
|
}
|
||||||
if exited != nil {
|
if exited != nil {
|
||||||
|
// TODO(suzmue): log exited error when the process exits, which may have been before
|
||||||
|
// halt was called.
|
||||||
s.logToConsole(exited.Error())
|
s.logToConsole(exited.Error())
|
||||||
s.logToConsole("Detaching")
|
s.logToConsole("Detaching")
|
||||||
} else if killProcess {
|
} else if killProcess {
|
||||||
|
@ -4330,6 +4330,35 @@ func TestLaunchRequestOutputPath(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExitNonZeroStatus(t *testing.T) {
|
||||||
|
runTest(t, "pr1055", func(client *daptest.Client, fixture protest.Fixture) {
|
||||||
|
client.InitializeRequest()
|
||||||
|
client.ExpectInitializeResponseAndCapabilities(t)
|
||||||
|
|
||||||
|
client.LaunchRequest("exec", fixture.Path, !stopOnEntry)
|
||||||
|
client.ExpectInitializedEvent(t)
|
||||||
|
client.ExpectLaunchResponse(t)
|
||||||
|
|
||||||
|
client.ConfigurationDoneRequest()
|
||||||
|
client.ExpectConfigurationDoneResponse(t)
|
||||||
|
|
||||||
|
client.ExpectTerminatedEvent(t)
|
||||||
|
|
||||||
|
client.DisconnectRequest()
|
||||||
|
// Check that the process exit status is 2.
|
||||||
|
oep := client.ExpectOutputEventProcessExited(t, 2)
|
||||||
|
if oep.Body.Category != "console" {
|
||||||
|
t.Errorf("\ngot %#v\nwant Category='console'", oep)
|
||||||
|
}
|
||||||
|
oed := client.ExpectOutputEventDetaching(t)
|
||||||
|
if oed.Body.Category != "console" {
|
||||||
|
t.Errorf("\ngot %#v\nwant Category='console'", oed)
|
||||||
|
}
|
||||||
|
client.ExpectDisconnectResponse(t)
|
||||||
|
client.ExpectTerminatedEvent(t)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestNoDebug_GoodExitStatus(t *testing.T) {
|
func TestNoDebug_GoodExitStatus(t *testing.T) {
|
||||||
runTest(t, "increment", func(client *daptest.Client, fixture protest.Fixture) {
|
runTest(t, "increment", func(client *daptest.Client, fixture protest.Fixture) {
|
||||||
runNoDebugSession(t, client, func() {
|
runNoDebugSession(t, client, func() {
|
||||||
|
@ -1130,6 +1130,11 @@ func (d *Debugger) Command(command *api.DebuggerCommand, resumeNotify chan struc
|
|||||||
d.recordMutex.Lock()
|
d.recordMutex.Lock()
|
||||||
if d.stopRecording == nil {
|
if d.stopRecording == nil {
|
||||||
err = d.target.RequestManualStop()
|
err = d.target.RequestManualStop()
|
||||||
|
// The error returned from d.target.Valid will have more context
|
||||||
|
// about the exited process.
|
||||||
|
if _, valErr := d.target.Valid(); valErr != nil {
|
||||||
|
err = valErr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
d.recordMutex.Unlock()
|
d.recordMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user