Get the target program (not the GDB host's) endianness.
()
| 98 | |
| 99 | @lru_cache() |
| 100 | def byte_order(): |
| 101 | """ |
| 102 | Get the target program (not the GDB host's) endianness. |
| 103 | """ |
| 104 | s = gdb.execute("show endian", to_string=True).strip() |
| 105 | if 'big' in s: |
| 106 | return 'big' |
| 107 | elif 'little' in s: |
| 108 | return 'little' |
| 109 | warnings.warn('Could not determine target endianness ' |
| 110 | f'from GDB\'s response:\n"""{s}"""') |
| 111 | # Fall back to host endianness |
| 112 | return sys.byteorder |
| 113 | |
| 114 | |
| 115 | def for_evaluation(val, ty=None): |