diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2015-02-17 13:47:18 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-17 14:34:54 -0800 |
commit | a4d86792c78d23257ab8ddd29ca16ce597361403 (patch) | |
tree | 1380a114f8d72d23063c518553293cf4efb54fa6 /scripts/gdb | |
parent | cf7492e933c0df200f8fa46c3684e8bd20890ab2 (diff) | |
download | linux-a4d86792c78d23257ab8ddd29ca16ce597361403.tar.bz2 |
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 <jan.kiszka@siemens.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Ben Widawsky <ben@bwidawsk.net>
Cc: Borislav Petkov <bp@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/gdb')
-rw-r--r-- | scripts/gdb/linux/utils.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py index 71ee48ceb2b2..a4a16403dc56 100644 --- a/scripts/gdb/linux/utils.py +++ b/scripts/gdb/linux/utils.py @@ -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_QEMU = 0 +GDBSERVER_KGDB = 1 +gdbserver_type = None + + +def get_gdbserver_type(): + def exit_handler(event): + global gdbserver_type + gdbserver_type = None + gdb.events.exited.disconnect(exit_handler) + + def probe_qemu(): + try: + return gdb.execute("monitor info version", to_string=True) != "" + except: + return False + + def probe_kgdb(): + try: + thread_info = gdb.execute("info thread 2", to_string=True) + return "shadowCPU0" in thread_info + except: + 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'): + gdb.events.exited.connect(exit_handler) + return gdbserver_type |