Bug 7902 - Bugs in examine_prologue for h8300 target
Summary: Bugs in examine_prologue for h8300 target
Status: RESOLVED OBSOLETE
Alias: None
Product: gdb
Classification: Unclassified
Component: tdep (show other bugs)
Version: 5.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-11 02:18 UTC by ledvinap
Modified: 2024-01-12 13:50 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ledvinap 2002-10-11 09:18:01 UTC
[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.
Comment 1 ledvinap 2002-10-11 09:18:01 UTC
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;
Comment 2 Hannes Domani 2024-01-12 13:50:30 UTC
That code was deleted in this commit:
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=9445aa303f19ea3f4bfad8843eca987c8f3eaf03