提交 7f994963 编写于 作者: J Jan Kiszka 提交者: Linus Torvalds

scripts/gdb: add get_target_endianness helper

Parse the target endianness from the output of "show endian" and cache the
result to return it via the new helper get_target_endiannes.  We will need
it for reading integers from buffers that contain target memory.
Signed-off-by: NJan 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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 7b599ef5
......@@ -67,3 +67,21 @@ Note that TYPE and ELEMENT have to be quoted as strings."""
elementname.string())
ContainerOf()
BIG_ENDIAN = 0
LITTLE_ENDIAN = 1
target_endianness = None
def get_target_endianness():
global target_endianness
if target_endianness is None:
endian = gdb.execute("show endian", to_string=True)
if "little endian" in endian:
target_endianness = LITTLE_ENDIAN
elif "big endian" in endian:
target_endianness = BIG_ENDIAN
else:
raise gdb.GdgError("unknown endianness '{0}'".format(endian))
return target_endianness
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册