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

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: 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 7b599ef5
......@@ -67,3 +67,21 @@ Note that TYPE and ELEMENT have to be quoted as strings."""
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
raise gdb.GdgError("unknown endianness '{0}'".format(endian))
return target_endianness
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