Commit a4d86792 authored by Jan Kiszka's avatar Jan Kiszka Committed by Linus Torvalds
Browse files

scripts/gdb: add get_gdbserver_type helper

This helper probes the type of the gdb server.  Supported are QEMU and
KGDB so far.  Knowledge about the gdb server is required e.g.  to
retrieve the current CPU or current task.
Signed-off-by: Jan Kiszka's avatarJan Kiszka <>
Cc: Thomas Gleixner <>
Cc: Jason Wessel <>
Cc: Andi Kleen <>
Cc: Ben Widawsky <>
Cc: Borislav Petkov <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent cf7492e9
......@@ -119,3 +119,38 @@ def is_target_arch(arch):
if target_arch is None:
target_arch = gdb.execute("show architecture", to_string=True)
return arch in target_arch
gdbserver_type = None
def get_gdbserver_type():
def exit_handler(event):
global gdbserver_type
gdbserver_type = None
def probe_qemu():
return gdb.execute("monitor info version", to_string=True) != ""
return False
def probe_kgdb():
thread_info = gdb.execute("info thread 2", to_string=True)
return "shadowCPU0" in thread_info
return False
global gdbserver_type
if gdbserver_type is None:
if probe_qemu():
gdbserver_type = GDBSERVER_QEMU
elif probe_kgdb():
gdbserver_type = GDBSERVER_KGDB
if not gdbserver_type is None and hasattr(gdb, 'events'):
return gdbserver_type
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment