未验证 提交 e00670b9 编写于 作者: S Suzy Mueller 提交者: GitHub

service/debugger: return correct exit status on manual halt (#2674)

* service/dap: add test for nonzero exit status
上级 b50052cc
......@@ -1024,6 +1024,8 @@ func (s *Server) stopDebugSession(killProcess bool) error {
s.log.Debug("halt returned state: ", exited)
}
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("Detaching")
} 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) {
runTest(t, "increment", func(client *daptest.Client, fixture protest.Fixture) {
runNoDebugSession(t, client, func() {
......
......@@ -1130,6 +1130,11 @@ func (d *Debugger) Command(command *api.DebuggerCommand, resumeNotify chan struc
d.recordMutex.Lock()
if d.stopRecording == nil {
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()
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册