[Converted from Gnats 797] There are two bugs in examine_prologue in h8300-tdep.c 1. Address of pushed register shoult be stored in fsr->regs[<regnum>] but variable r is not set and old value (form clearing loop) is used. r should be set according to push instruction. 2. when pushing multiple registers (with stm instruction), loop count is invalid. comparison in for statement should be <, not <=. This bug breaks backtracing in functions containing stm in prologue. Patch was tested only in cases where gdb did not work previously. After patch backtracing works. Release: GNU gdb 5.1.1 Environment: h8300 target How-To-Repeat: use backtrace in function containing stm.l in prologue. This prologue is generated (at least) by gcc-3.2 with optimizations.
Fix: --- /usr/src/toolchain/gdb-5.1.1/gdb/h8300-tdep.c 2001-03-16 23:34:45.000000000 +0100 +++ h8300-tdep.c 2002-10-10 04:10:23.000000000 +0200 @@ -359,6 +359,7 @@ if (IS_PUSH (insn_word)) { + r = insn_word&0x07; /* remember pushed register number! */ ip = next_ip; next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn_word); fsr->regs[r] = after_prolog_fp + auto_depth; @@ -376,7 +377,7 @@ next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn_word); start = insn_word & 0x7; - for (i = start; i <= start + count; i++) + for (i = start; i < start + count; i++) { fsr->regs[i] = after_prolog_fp + auto_depth; auto_depth += 4;
That code was deleted in this commit: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=9445aa303f19ea3f4bfad8843eca987c8f3eaf03