Skip to content

Commit 16aaa9d

Browse files
committed
Fix gdbserver not exiting by not connecting in extended more
1 parent b15cc0e commit 16aaa9d

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

core/adapters/gdbmiadapter.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ bool GdbMiAdapter::Connect(const std::string& server, uint32_t port) {
338338
m_mi->SendCommand("-interpreter-exec console \"add-symbol-file "+symbolFile+"\"");
339339

340340
m_mi->SendCommand("-file-exec-file " + inputFile);
341-
std::string connectCmd = "-target-select extended-remote " + ipAddress + ":" + std::to_string(serverPort);
341+
// TODO: we should offer an option on whether or not to connect in extended mode
342+
std::string connectCmd = "-target-select remote " + ipAddress + ":" + std::to_string(serverPort);
342343

343344
auto result = m_mi->SendCommand(connectCmd, 1000);
344345
m_connected = (result.command == "connected");
@@ -548,13 +549,16 @@ void GdbMiAdapter::Stop()
548549

549550
bool GdbMiAdapter::Quit()
550551
{
551-
Detach();
552-
Stop();
552+
if (m_mi && m_connected) InvokeBackendCommand("kill");
553553
m_connected = false;
554554
m_targetRunningAtomic.store(false);
555555

556-
LogInfo("GDB MI adapter quit completed successfully");
557-
return true;
556+
DebuggerEvent dbgevt;
557+
dbgevt.type = TargetExitedEventType;
558+
PostDebuggerEvent(dbgevt);
559+
560+
Stop();
561+
return true;
558562
}
559563

560564
bool GdbMiAdapter::Detach() {
@@ -566,6 +570,7 @@ bool GdbMiAdapter::Detach() {
566570
dbgevt.type = DetachedEventType;
567571
PostDebuggerEvent(dbgevt);
568572

573+
Stop();
569574
return true;
570575
}
571576

0 commit comments

Comments
 (0)