[Bug tdep/34519] RISC-V: GDB crashes when disassembling elf32-bigriscv produced by -mbig-endian, and remote PC is byte-swapped

mumuxi_ll at outlook dot com via Gdb-prs <[email protected]>
Newsgroups gmane.comp.gdb.bugs.discuss
Message-ID <[email protected]/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=34519

--- Comment #5 from liu xu <mumuxi_ll at outlook dot com> ---
(In reply to Tom Tromey from comment #4)
> (In reply to liu xu from comment #3)
> 
> > > Could you try the gdb 18 pre-release or git master?
> 
> > I have reproduced a RISC-V big-endian remote debugging register endian issue
> > with GDB 18.0.90.
> 
> > Offline GDB disassembly works correctly and GDB recognizes the file as
> > elf32-bigriscv.
> 
> Ok, it sounds like upgrading gdb fixed the originally-reported bug.
> 
> > This suggests the RISC-V big-endian remote register path is applying the
> > wrong byte order for register packets. 
> 
> Can you "set debug remote 1" before the "target remote"?
> This will show a log of the remote protocol traffic.
> Maybe from this we can see if the bug is in gdb or the remote.

Hi Tom,

I followed your suggestion and reran the test with `set debug remote 1`; the
remote log shows that the remaining issue is on the remote gdbstub side, where
RISC-V big-endian register packets are encoded with the wrong byte order.

For example, after hitting a breakpoint at `0x80000010`, the `$g` packet
contains `10000080` for PC and GDB reports `pc = 0x10000080`; after `set $a0 =
0x12345678`, the next `$g` packet contains `78563412` for `a0`.

After fixing the remote gdbstub register read path to use the runtime RISC-V
endian state, LE/BE GDB against LE/BE ELF all works correctly.

Thanks for your help.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.