Skip to content

Fix big-endian register parsing for GDB RSP adapter#1003

Merged
xusheng6 merged 2 commits intodevfrom
fix/issue-1000-bigendian-registers
Feb 27, 2026
Merged

Fix big-endian register parsing for GDB RSP adapter#1003
xusheng6 merged 2 commits intodevfrom
fix/issue-1000-bigendian-registers

Conversation

@xusheng6
Copy link
Copy Markdown
Member

Summary

  • Add big-endian register read/write support to GDB, Corellium, and esReven RSP adapters
  • Detect endianness from the target description XML (<endian> element) with fallback to architecture-based detection (PowerPC, SPARC, m68k, S/390)
  • Fix parseBigEndianHexToUint512 to right-justify bytes in the 64-byte buffer before intx::be::load, which previously placed a 4-byte register value like 0x4082e4c0 into the top 32 bits of a 512-bit number

Fixes #1002

Test plan

  • Debug a big-endian PowerPC target via GDB RSP and verify register values (e.g. PC) display correctly
  • Debug a little-endian target (x86/ARM) and verify no regressions in register display
  • Test writing registers on a big-endian target

🤖 Generated with Claude Code

xusheng6 and others added 2 commits February 26, 2026 17:27
When connecting to big-endian targets like PowerPC via QEMU, register
values were being incorrectly parsed using little-endian byte order.
This caused wrong PC values and prevented proper memory reads.

Changes:
- Parse <endian> element from target description XML when available
- Add IsBigEndianArchitecture() fallback for known BE architectures
  (PowerPC, SPARC, M68K, S/390)
- Add m_isBigEndian member variable to track target endianness
- Add parseBigEndianHexToUint512() for reading BE register values
- Add uint512ToBigEndianHex() for writing BE register values
- Update ReadAllRegisters() and WriteRegister() to use correct
  endianness based on target

Fixes #1000 (partial - the crash fix was in PR #1001, this addresses
the endianness issue that remained after the crash was fixed)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…rations

Right-justify bytes in the 64-byte buffer before calling intx::be::load,
which expects MSB at buffer[0] for a full 512-bit value. Without this,
a 4-byte register like PC=0x4082e4c0 was placed at buffer[0..3] and
interpreted as the top 32 bits of a 512-bit number.

Also add forward declarations for IsBigEndianArchitecture to fix
compilation errors (function defined after first use in LoadRegisterInfo).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@xusheng6 xusheng6 merged commit b8b213a into dev Feb 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GDB RSP adapter reports wrong register values for big endian arch

1 participant