Skip to content

Commit b24e2d2

Browse files
jan-kiszkatorvalds
authored andcommitted
scripts/gdb: add is_target_arch helper
This helper caches to result of "show architecture" and matches the provided arch (sub-)string against that output. 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>
1 parent 4752871 commit b24e2d2

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎scripts/gdb/linux/utils.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,16 @@ def read_u64(buffer):
106106
return read_u32(buffer[0:4]) + (read_u32(buffer[4:8]) << 32)
107107
else:
108108
return read_u32(buffer[4:8]) + (read_u32(buffer[0:4]) << 32)
109+
110+
111+
target_arch = None
112+
113+
114+
def is_target_arch(arch):
115+
if hasattr(gdb.Frame, 'architecture'):
116+
return arch in gdb.newest_frame().architecture().name()
117+
else:
118+
global target_arch
119+
if target_arch is None:
120+
target_arch = gdb.execute("show architecture", to_string=True)
121+
return arch in target_arch

0 commit comments

Comments
 (0)