Skip to content

Commit

Permalink
scripts/gdb: add get_target_endianness helper
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Jason Wessel <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Ben Widawsky <[email protected]>
Cc: Borislav Petkov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
jan-kiszka authored and torvalds committed Feb 17, 2015
1 parent 7b599ef commit 7f99496
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions scripts/gdb/linux/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,21 @@ def invoke(self, ptr, typename, elementname):
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

0 comments on commit 7f99496

Please sign in to comment.