Fix crash when architecture string has no hyphen after colon#1001
Merged
Fix crash when architecture string has no hyphen after colon#1001
Conversation
When connecting to QEMU-PPC targets, the architecture string may be
"powerpc:common" which contains a colon but no hyphen. The code was
calling string::replace() with the result of string::find('-') without
checking if find() returned npos, causing a crash.
This fix adds a check for npos before calling replace() in all three
affected adapter files.
Fixes #1000
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
xusheng6
added a commit
that referenced
this pull request
Feb 26, 2026
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>
xusheng6
added a commit
that referenced
this pull request
Feb 27, 2026
* Fix big-endian register parsing for PowerPC and other BE targets 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> * Fix parseBigEndianHexToUint512 buffer placement and add forward declarations 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> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
powerpc:commoncontain a colon but no hyphenstring::find('-')was returningnpos, which when passed toreplace()causes a crashreplace()in all 3 affected adapters:gdbadapter.cpp,corelliumadapter.cpp, andesrevenadapter.cppFixes #1000
Test plan
powerpc:common🤖 Generated with Claude Code