From: Corinna Vinschen <vinschen@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: [RFA] sh-tdep.c: New patch solving gdb1291.exp (was Re: [RFA] Fix PR tdep/1291, SH prologue scanning bug)
Date: Wed, 25 Feb 2004 16:33:00 -0000 [thread overview]
Message-ID: <20040225163336.GY1587@cygbert.vinschen.de> (raw)
In-Reply-To: <200402192344.38974.fnf@ninemoons.com>
On Feb 19 23:44, Fred Fish wrote:
> This patch fixes the bug reported in PR 1291. It is based on the suggested
> patch included in the PR. I believe it is small enough to not need a
> copyright assignment, but recent events may have changed that. :-(
>
> -Fred
>
> 2004-02-19 Fred Fish <fnf@redhat.com>
>
> Fix for PR tdep/1291 as suggested by inaba@src.ricoh.co.jp
> * sh-tdep.c (IS_MOV_R3): Rename to IS_MOV_IMM_R3 and fix pattern.
> (IS_ADD_R3SP): Rename to IS_ADD_R3_SP for consistency.
> (IS_MOVW_R1): New macro.
> (IS_MOVL_R1): New macro.
> (IS_SUB_R1_SP): New macro.
> (sh_analyze_prologue): Add r1_val local var and initialize to zero.
> Use IS_MOVW_R1, IS_MOVL_R1, and IS_SUB_R1_SP to recognize use of
> stack allocation via constant loaded into r1.
I've looked into this one and found that there's a very simple patch
to solve that issue. Basically the evaluation of the memory address
to access in PC relative addressing was misbehaving. The below patch
evaluates the PC relative memory location now exactly according to the
descriptions of the PC relative addressing modes with 8 bit displacement
in the official SH documentation:
FOO.w @(disp:8,PC):
displacement = (instruction & 0xff) << 1;
address = (PC + 4) + displacement;
FOO.l @(disp:8,PC):
displacement = (instruction & 0xff) << 2;
address = ((PC & 0xfffffffc) + 4) + displacement;
I checked the entire testsuite against sh2, sh2e, sh3, sh4 and sh4-nofpu.
In all cases, the FAIL count has been reduced by exactly one, the FAIL
from gdb1291.exp.
Is that ok to checkin?
Corinna
* sh-tdep.c (sh_analyze_prologue): Align PC relative addressing
to official documentation.
Index: sh-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sh-tdep.c,v
retrieving revision 1.165
diff -u -p -r1.165 sh-tdep.c
--- sh-tdep.c 20 Feb 2004 00:16:16 -0000 1.165
+++ sh-tdep.c 25 Feb 2004 15:47:32 -0000
@@ -440,9 +440,9 @@ sh_analyze_prologue (CORE_ADDR pc, CORE_
if (reg < 14)
{
sav_reg = reg;
- offset = (((inst & 0xff) ^ 0x80) - 0x80) << 1;
+ offset = (inst & 0xff) << 1;
sav_offset =
- read_memory_integer (((pc + 4) & ~3) + offset, 2);
+ read_memory_integer ((pc + 4) + offset, 2);
}
}
}
@@ -450,13 +450,13 @@ sh_analyze_prologue (CORE_ADDR pc, CORE_
{
if (sav_reg < 0)
{
- reg = (inst & 0x0f00) >> 8;
+ reg = GET_TARGET_REG (inst);
if (reg < 14)
{
sav_reg = reg;
- offset = (((inst & 0xff) ^ 0x80) - 0x80) << 1;
+ offset = (inst & 0xff) << 2;
sav_offset =
- read_memory_integer (((pc + 4) & ~3) + offset, 4);
+ read_memory_integer (((pc & 0xfffffffc) + 4) + offset, 4);
}
}
}
--
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
next prev parent reply other threads:[~2004-02-25 16:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-20 6:44 [RFA] Fix PR tdep/1291, SH prologue scanning bug Fred Fish
2004-02-25 16:33 ` Corinna Vinschen [this message]
2004-03-05 22:36 ` [RFA] sh-tdep.c: New patch solving gdb1291.exp (was Re: [RFA] Fix PR tdep/1291, SH prologue scanning bug) Elena Zannoni
2004-03-19 0:09 ` Corinna Vinschen
2004-03-08 10:16 ` Corinna Vinschen
2004-03-19 0:09 ` Elena Zannoni
2004-03-19 0:09 ` Corinna Vinschen
2004-03-05 10:42 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040225163336.GY1587@cygbert.vinschen.de \
--to=vinschen@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox