Closed mwachs5 closed 7 years ago
I don't think gdb knows how to set breakpoints in compressed code yet.
Tim
On Mon, Dec 5, 2016 at 8:51 AM, Megan Wachs notifications@github.com wrote:
The current FE300 systems support the 'C' compressed extension, but the Makefile doesn't use it. Modify the Makefile to use compressed extension.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sifive/freedom-e-sdk/issues/15, or mute the thread https://github.com/notifications/unsubscribe-auth/APYH7WoyvwOmecpYGVccwlbZ6AC9uSs1ks5rFEEVgaJpZM4LEdIv .
For reference, this hack “fixes” it but will break gdb on cores that don’t support the C extension:
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index d788e33..3b56b9a 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -165,9 +165,13 @@ riscv_breakpoint_from_pc (struct gdbarch gdbarch, { / TODO: Support C.EBREAK for compressed (16-bit) insns. / / TODO: Support NOPs for >=6 byte insns. */
static const gdb_byte sbreak_insn[] = { 0x73, 0x00, 0x10, 0x00, };
*bp_size = 4;
// static const gdb_byte sbreak_insn[] = { 0x73, 0x00, 0x10, 0x00, };
// *bp_size = 4;
static const gdb_byte sbreak_insn[] = { 0x02, 0x90 };
*bp_size = 2;
return sbreak_insn; }
Tim
On Mon, Dec 5, 2016 at 10:22 AM, Tim Newsome tim@sifive.com wrote:
I don't think gdb knows how to set breakpoints in compressed code yet.
Tim
On Mon, Dec 5, 2016 at 8:51 AM, Megan Wachs notifications@github.com wrote:
The current FE300 systems support the 'C' compressed extension, but the Makefile doesn't use it. Modify the Makefile to use compressed extension.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sifive/freedom-e-sdk/issues/15, or mute the thread https://github.com/notifications/unsubscribe-auth/APYH7WoyvwOmecpYGVccwlbZ6AC9uSs1ks5rFEEVgaJpZM4LEdIv .
Thank you for the fix.
It seems that there is a better fix on the upstream. https://github.com/riscv/riscv-binutils-gdb/blob/riscv-next/gdb/riscv-tdep.c
Yes, the latest gdb now has proper support for debugging compressed code. I'm still waiting to commit the relevant tests since for some reason I haven't been able to build a working set of tools lately.
@timsifive I've tried bumping to the version of GDB as noted above, but it still doesn't seem to work if breakpoints are set at unaligned addresses. Does this need corresponding support in OpenOCD?
It shouldn't. Can you confirm that your gdb has code to read misa here: https://github.com/riscv/riscv-binutils-gdb/blob/riscv-next/gdb/riscv-tdep.c#L161
Actually it does work, I was just using an out-of-date elf file. Sorry for the false alarm.
On Thu, Jan 26, 2017 at 1:17 PM, Tim Newsome notifications@github.com wrote:
It shouldn't. Can you confirm that your gdb has code to read misa here: https://github.com/riscv/riscv-binutils-gdb/blob/riscv- next/gdb/riscv-tdep.c#L161
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sifive/freedom-e-sdk/issues/15#issuecomment-275516500, or mute the thread https://github.com/notifications/unsubscribe-auth/ARCAJKxskLWNkQ9JUS_Q6ZlUYiJvelmQks5rWQ1QgaJpZM4LEdIv .
-- Megan A. Wachs Engineer | SiFive, Inc 300 Brannan St, Suite 403 San Francisco, CA 94107 megan@sifive.com
The GDB Version is bumped now and should work. "C" extension was already enabled by default a while ago.
The current FE300 systems support the 'C' compressed extension, but the Makefile doesn't use it. Modify the Makefile to use compressed extension.