Hi
committed in scripts.git:
https://github.com/milkymist/scripts/compare/3f19bd9...2de01de
On 11/12/2011 05:16 AM, Werner Almesberger wrote:
Stack traces (where or bt) of LM32 failed on 64 bit hosts after just
a few frames with
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
The reason for this is that stack frames weren't unwound correctly.
The bug is in LM32_IMM16, which tries to do sign expansion by
shifting the value to the left edge of a long, expecting it to
be 32 bits.
This problems exists in at least gdb versions 7.1 through 7.3.1.
The patch below delegates the work of figuring out such details to
the compiler. I've also taken the liberty of protecting all the
macro arguments, just in case.
- Werner
--- gdb-7.3.1/gdb/lm32-tdep.c.orig 2011-11-11 18:03:54.000000000 -0300
+++ gdb-7.3.1/gdb/lm32-tdep.c 2011-11-11 18:04:24.000000000 -0300
@@ -40,11 +40,11 @@
#include "gdb_string.h"
/* Macros to extract fields from an instruction. */
-#define LM32_OPCODE(insn) ((insn>> 26)& 0x3f)
-#define LM32_REG0(insn) ((insn>> 21)& 0x1f)
-#define LM32_REG1(insn) ((insn>> 16)& 0x1f)
-#define LM32_REG2(insn) ((insn>> 11)& 0x1f)
-#define LM32_IMM16(insn) ((((long)insn& 0xffff)<< 16)>> 16)
+#define LM32_OPCODE(insn) (((insn)>> 26)& 0x3f)
+#define LM32_REG0(insn) (((insn)>> 21)& 0x1f)
+#define LM32_REG1(insn) (((insn)>> 16)& 0x1f)
+#define LM32_REG2(insn) (((insn)>> 11)& 0x1f)
+#define LM32_IMM16(insn) ((long) (int16_t) (insn))
struct gdbarch_tdep
{
_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode
_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode