Skip to content

Commit

Permalink
Fix the ctrl-c issue when debugging kernel with qemu-system
Browse files Browse the repository at this point in the history
  • Loading branch information
lebr0nli committed Nov 27, 2023
1 parent 5a5941e commit b703f07
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions gdbinit-gep.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,16 @@ def single_line_py(main_cmd: str, full_cmd: str) -> bool:
full_cmd += new_line

if not quit_input_in_multiline_mode:
gdb.execute(full_cmd, from_tty=True)
except gdb.error as e:
print(e)
# This is a hack to fix the issue when debugging the kernel with qemu-system-*
# Without this hack, somehow pressing ctrl-c in GDB will not interrupt the kernel
# See #23 for more details
# TODO: Is there a better way to fix this issue?
gdb.execute(
f"""python
try: gdb.execute({full_cmd!r}, from_tty=True)
except gdb.error as e: print(e)
"""
)
except KeyboardInterrupt:
if ctrl_c_quit.value:
gdb.execute("quit")
Expand Down

0 comments on commit b703f07

Please sign in to comment.