Skip to content

Commit fb3dae3

Browse files
committed
fix gdb controller quit command error
1 parent 13886f5 commit fb3dae3

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

pkdb/controllers/gdb_controller.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -530,22 +530,23 @@ def stop(self):
530530
try:
531531
if self.process.stdin is not None:
532532
self.process.stdin.close()
533-
except Exception:
534-
pass
533+
except Exception as e:
534+
verbose_out(f"stop: closing stdin of already-exited gdb failed: {e}")
535535
self.process = None
536536
return
537537
try:
538-
if self.process.stdin is not None:
539-
if self._is_gdb_attached:
540-
self.process.stdin.write("detach\n")
541-
self.process.stdin.flush()
542-
self.process.stdin.write("quit\n")
543-
self.process.stdin.flush()
544-
self.process.wait()
545-
except Exception:
546-
if self.process.poll() is None:
547-
self.process.terminate()
538+
if self._is_gdb_attached:
539+
os.kill(self.process.pid, signal.SIGINT)
540+
self._send_mi_command("target-detach")
541+
except Exception as e:
542+
verbose_out(f"stop: interrupt/detach failed, falling back to kill: {e}")
548543
finally:
549-
if self.process and self.process.stdin is not None:
550-
self.process.stdin.close()
544+
if self.process.poll() is None:
545+
self.process.kill()
546+
self.process.wait()
547+
if self.process.stdin is not None:
548+
try:
549+
self.process.stdin.close()
550+
except Exception as e:
551+
verbose_out(f"stop: closing gdb stdin failed: {e}")
551552
self.process = None

0 commit comments

Comments
 (0)