diff options
| author | Jan Kiszka <[email protected]> | 2015-02-17 21:46:58 +0000 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2015-02-17 22:34:53 +0000 |
| commit | 7f994963745b9cea89a2816dae7cc3a1fc01adcc (patch) | |
| tree | 8f100eb57664208e2f1d42fe3a35e605f9fe3cd7 /scripts/gdb | |
| parent | scripts/gdb: add internal helper and convenience function to look up a module (diff) | |
| download | kernel-7f994963745b9cea89a2816dae7cc3a1fc01adcc.tar.gz kernel-7f994963745b9cea89a2816dae7cc3a1fc01adcc.zip | |
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 <[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]>
Diffstat (limited to 'scripts/gdb')
| -rw-r--r-- | scripts/gdb/linux/utils.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/scripts/gdb/linux/utils.py b/scripts/gdb/linux/utils.py index c9d705b62bfe..10a227bdb621 100644 --- a/scripts/gdb/linux/utils.py +++ b/scripts/gdb/linux/utils.py @@ -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 |
