aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/gdb
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2015-02-17 16:47:18 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-17 17:34:54 -0500
commita4d86792c78d23257ab8ddd29ca16ce597361403 (patch)
tree1380a114f8d72d23063c518553293cf4efb54fa6 /scripts/gdb
parentcf7492e933c0df200f8fa46c3684e8bd20890ab2 (diff)
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.py35
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):
119 if target_arch is None: 119 if target_arch is None:
120 target_arch = gdb.execute("show architecture", to_string=True) 120 target_arch = gdb.execute("show architecture", to_string=True)
121 return arch in target_arch 121 return arch in target_arch
122
123
124GDBSERVER_QEMU = 0
125GDBSERVER_KGDB = 1
126gdbserver_type = None
127
128
129def get_gdbserver_type():
130 def exit_handler(event):
131 global gdbserver_type
132 gdbserver_type = None
133 gdb.events.exited.disconnect(exit_handler)
134
135 def probe_qemu():
136 try:
137 return gdb.execute("monitor info version", to_string=True) != ""
138 except:
139 return False
140
141 def probe_kgdb():
142 try:
143 thread_info = gdb.execute("info thread 2", to_string=True)
144 return "shadowCPU0" in thread_info
145 except:
146 return False
147
148 global gdbserver_type
149 if gdbserver_type is None:
150 if probe_qemu():
151 gdbserver_type = GDBSERVER_QEMU
152 elif probe_kgdb():
153 gdbserver_type = GDBSERVER_KGDB
154 if not gdbserver_type is None and hasattr(gdb, 'events'):
155 gdb.events.exited.connect(exit_handler)
156 return gdbserver_type