diff options
Diffstat (limited to 'scripts/gdb/linux/utils.py')
| -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.""" | |||
| 67 | elementname.string()) | 67 | elementname.string()) |
| 68 | 68 | ||
| 69 | ContainerOf() | 69 | ContainerOf() |
| 70 | |||
| 71 | |||
| 72 | BIG_ENDIAN = 0 | ||
| 73 | LITTLE_ENDIAN = 1 | ||
| 74 | target_endianness = None | ||
| 75 | |||
| 76 | |||
| 77 | def get_target_endianness(): | ||
| 78 | global target_endianness | ||
| 79 | if target_endianness is None: | ||
| 80 | endian = gdb.execute("show endian", to_string=True) | ||
| 81 | if "little endian" in endian: | ||
| 82 | target_endianness = LITTLE_ENDIAN | ||
| 83 | elif "big endian" in endian: | ||
| 84 | target_endianness = BIG_ENDIAN | ||
| 85 | else: | ||
| 86 | raise gdb.GdgError("unknown endianness '{0}'".format(endian)) | ||
| 87 | return target_endianness | ||
