From: Joel Brobecker <brobecker@adacore.com>
To: "Maciej W. Rozycki" <macro@codesourcery.com>
Cc: Mark Kettenis <mark.kettenis@xs4all.nl>, gdb-patches@sourceware.org
Subject: Re: [RFA 1/2] mips: Switch inferior function calls to ON_STACK method.
Date: Tue, 08 May 2012 22:08:00 -0000 [thread overview]
Message-ID: <20120508220805.GD15555@adacore.com> (raw)
In-Reply-To: <20120508204257.GC15555@adacore.com>
[-- Attachment #1: Type: text/plain, Size: 721 bytes --]
Attached is the latest version.
It's very very slightly different from the version you suggested,
in the fact that I didn't create a local variable for the breakpoint
address, and stored it in *bp_addr directly. I didn't see a real
purpose for having a local variable in this case. I did create
a local variable for the nop instruction address, however. I found
that it did make things a little clearer for that one.
As before, I'm attaching two patches, the first being the last
version of the patch, and the second being the changes introduced
by this iteration.
Testec on mips-irix with no regression. If we'd rather go with
AT_ENTRY_POINT instead, at least the patch is available here for
the record.
--
Joel
[-- Attachment #2: 0001-mips-Switch-inferior-function-calls-to-ON_STACK-meth.patch --]
[-- Type: text/x-diff, Size: 2944 bytes --]
From 19ebe2e03aab266ddd3771fbd7aeff430c32079a Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Wed, 2 May 2012 20:39:57 -0400
Subject: [PATCH] mips: Switch inferior function calls to ON_STACK method.
This patch switches the mips code to use the ON_STACK method
for function calls instead of AT_SYMBOL, which we want to remove.
gdb/ChangeLog:
* mips-tdep.c (mips_push_dummy_code): New function.
(mips_gdbarch_init): Set the gdbarch call_dummy_location to
ON_STACK and install mips_push_dummy_code as our gdbarch
push_dummy_code routine.
---
gdb/mips-tdep.c | 38 ++++++++++++++++++++++++++++++++++----
1 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 9a3c7fb..ebf7c48 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -3009,6 +3009,38 @@ mips_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
return align_down (addr, 16);
}
+/* Implement the "push_dummy_call" gdbarch method. */
+
+static CORE_ADDR
+mips_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
+ CORE_ADDR funaddr, struct value **args,
+ int nargs, struct type *value_type,
+ CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
+ struct regcache *regcache)
+{
+ CORE_ADDR nop_addr;
+ static gdb_byte nop_insn[] = { 0, 0, 0, 0 };
+
+ /* Reserve enough room on the stack for our breakpoint instruction. */
+ *bp_addr = sp - sizeof (nop_insn);
+
+ /* The breakpoint layer automatically adjusts the address of
+ breakpoints inserted in a branch delay slot. With enough
+ bad luck, the 4 bytes located just before our breakpoint
+ instruction could look like a branch instruction, and thus
+ trigger the adjustement, and break the function call entirely.
+ So, we reserve those 4 bytes and write a nop instruction
+ to prevent that from happening. */
+ nop_addr = *bp_addr - sizeof (nop_insn);
+ write_memory (nop_addr, nop_insn, sizeof (nop_insn));
+ sp = mips_frame_align (gdbarch, nop_addr);
+
+ /* Inferior resumes at the function entry point. */
+ *real_pc = funaddr;
+
+ return sp;
+}
+
static CORE_ADDR
mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
struct regcache *regcache, CORE_ADDR bp_addr,
@@ -6906,10 +6938,8 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* MIPS version of CALL_DUMMY. */
- /* NOTE: cagney/2003-08-05: Eventually call dummy location will be
- replaced by a command, and all targets will default to on stack
- (regardless of the stack's execute status). */
- set_gdbarch_call_dummy_location (gdbarch, AT_SYMBOL);
+ set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
+ set_gdbarch_push_dummy_code (gdbarch, mips_push_dummy_code);
set_gdbarch_frame_align (gdbarch, mips_frame_align);
set_gdbarch_convert_register_p (gdbarch, mips_convert_register_p);
--
1.7.0.4
[-- Attachment #3: 0001-More-mods-to-mips-ON_STACK-function-call.patch --]
[-- Type: text/x-diff, Size: 1629 bytes --]
From 0e907377fff968693ff42d3cab61cafa4d50521b Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Tue, 8 May 2012 17:57:56 -0400
Subject: [PATCH] More mods to mips ON_STACK function call.
---
gdb/mips-tdep.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 68ac858..ebf7c48 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -3018,11 +3018,11 @@ mips_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
struct regcache *regcache)
{
- int bp_len;
+ CORE_ADDR nop_addr;
static gdb_byte nop_insn[] = { 0, 0, 0, 0 };
- *bp_addr = sp;
- gdbarch_breakpoint_from_pc (gdbarch, bp_addr, &bp_len);
+ /* Reserve enough room on the stack for our breakpoint instruction. */
+ *bp_addr = sp - sizeof (nop_insn);
/* The breakpoint layer automatically adjusts the address of
breakpoints inserted in a branch delay slot. With enough
@@ -3031,8 +3031,9 @@ mips_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
trigger the adjustement, and break the function call entirely.
So, we reserve those 4 bytes and write a nop instruction
to prevent that from happening. */
- write_memory (*bp_addr - bp_len, nop_insn, sizeof (nop_insn));
- sp = mips_frame_align (gdbarch, *bp_addr - 2 * bp_len);
+ nop_addr = *bp_addr - sizeof (nop_insn);
+ write_memory (nop_addr, nop_insn, sizeof (nop_insn));
+ sp = mips_frame_align (gdbarch, nop_addr);
/* Inferior resumes at the function entry point. */
*real_pc = funaddr;
--
1.7.0.4
next prev parent reply other threads:[~2012-05-08 22:08 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-03 19:03 Getting rid of AT_SYMBOL inferior call method Joel Brobecker
2012-05-03 19:03 ` [RFA 1/2] mips: Switch inferior function calls to ON_STACK method Joel Brobecker
2012-05-03 21:09 ` Maciej W. Rozycki
2012-05-03 21:50 ` Joel Brobecker
2012-05-03 23:29 ` Maciej W. Rozycki
2012-05-04 20:58 ` Joel Brobecker
2012-05-04 21:19 ` Mark Kettenis
2012-05-04 23:25 ` Maciej W. Rozycki
2012-05-05 11:45 ` Mark Kettenis
2012-05-08 15:08 ` Maciej W. Rozycki
2012-05-08 16:06 ` Joel Brobecker
2012-05-08 20:26 ` Maciej W. Rozycki
2012-05-08 20:43 ` Joel Brobecker
2012-05-08 22:08 ` Joel Brobecker [this message]
2012-05-09 7:32 ` Maciej W. Rozycki
2012-05-09 8:24 ` Mark Kettenis
2012-05-09 9:14 ` Maciej W. Rozycki
2012-05-09 16:08 ` Tom Tromey
2012-05-09 14:35 ` Joel Brobecker
2012-05-14 9:44 ` Maciej W. Rozycki
2012-05-14 15:01 ` Joel Brobecker
2012-05-14 16:48 ` Maciej W. Rozycki
2012-06-11 10:14 ` Maciej W. Rozycki
2012-05-09 6:21 ` Maciej W. Rozycki
2012-05-04 22:41 ` Maciej W. Rozycki
2012-05-04 21:34 ` Mark Kettenis
2012-05-05 1:31 ` Maciej W. Rozycki
2012-05-03 21:44 ` Mark Kettenis
2012-05-03 21:58 ` Joel Brobecker
2012-05-04 2:11 ` Yao Qi
2012-05-03 22:03 ` Joel Brobecker
2012-05-03 19:03 ` [commit 2/2] Remove AT_SYMBOL Joel Brobecker
2012-05-09 14:37 ` Joel Brobecker
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=20120508220805.GD15555@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=macro@codesourcery.com \
--cc=mark.kettenis@xs4all.nl \
/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