From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: [RFA] Rewrite mips_get_saved_register()
Date: Thu, 08 Aug 2002 17:37:00 -0000 [thread overview]
Message-ID: <1020809003710.ZM26327@localhost.localdomain> (raw)
This patch depends on the following (as of yet) unapproved patches:
http://sources.redhat.com/ml/gdb-patches/2002-08/msg00189.html
http://sources.redhat.com/ml/gdb-patches/2002-08/msg00195.html
http://sources.redhat.com/ml/gdb-patches/2002-08/msg00196.html
Okay to commit?
* mips-tdep.c (mips_get_saved_register): Rewrite to use
frame_register_unwind() instead of find_saved_register().
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.93
diff -u -p -r1.93 mips-tdep.c
--- mips-tdep.c 8 Aug 2002 23:32:52 -0000 1.93
+++ mips-tdep.c 9 Aug 2002 00:26:00 -0000
@@ -4241,53 +4246,48 @@ mips_get_saved_register (char *raw_buffe
int regnum,
enum lval_type *lval)
{
- CORE_ADDR addr;
+ int realnum;
+ int scratch_optimized;
+ enum lval_type scratch_lval;
+ CORE_ADDR scratch_addr;
if (!target_has_registers)
error ("No registers.");
- /* Normal systems don't optimize out things with register numbers. */
- if (optimized != NULL)
- *optimized = 0;
- addr = find_saved_register (frame, regnum);
- if (addr != 0)
- {
- if (lval != NULL)
- *lval = lval_memory;
- if (regnum == SP_REGNUM)
- {
- if (raw_buffer != NULL)
- {
- /* Put it back in target format. */
- store_address (raw_buffer, REGISTER_RAW_SIZE (regnum),
- (LONGEST) addr);
- }
- if (addrp != NULL)
- *addrp = 0;
- return;
- }
- if (raw_buffer != NULL)
- {
- LONGEST val;
- if (regnum < 32)
- /* Only MIPS_SAVED_REGSIZE bytes of GP registers are
- saved. */
- val = read_memory_integer (addr, MIPS_SAVED_REGSIZE);
- else
- val = read_memory_integer (addr, REGISTER_RAW_SIZE (regnum));
- store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), val);
- }
- }
- else
- {
- if (lval != NULL)
- *lval = lval_register;
- addr = REGISTER_BYTE (regnum);
- if (raw_buffer != NULL)
- read_register_gen (regnum, raw_buffer);
+ /* frame_register_unwind() requires ``optimized'', ``lval'', ``addrp'',
+ and ``realnum'' to be non-NULL. So use the scratch variables, if
+ necessary. (Note that realnum isn't a problem since we pass the
+ address of local storage directly.) */
+ if (optimized == NULL)
+ optimized = &scratch_optimized;
+ if (addrp == NULL)
+ addrp = &scratch_addr;
+ if (lval == NULL)
+ lval = &scratch_lval;
+
+ /* Fetch register REGNUM from an inner (callee) frame. */
+ frame_register_unwind (get_next_frame (frame), regnum, optimized,
+ lval, addrp, &realnum, raw_buffer);
+
+ /* Only MIPS_SAVED_REGSIZE bytes of GP registers are saved on the
+ stack. If this differs from the raw size, then frame_register_unwind()
+ fetched too much. Adjust value fetched and save back into the buffer.
+ (The excess is thus discarded.)
+
+ The SP register is handled specially. Its value will have been
+ set correctly by frame_register_unwind(), so don't attempt to adjust
+ it. */
+ if (*addrp != 0 /* Register must be saved on stack, */
+ && regnum < 32 /* must be a GP register, */
+ && regnum != SP_REGNUM /* but not SP. */
+ && MIPS_SAVED_REGSIZE < REGISTER_RAW_SIZE (regnum))
+ {
+ LONGEST val;
+
+ val = extract_signed_integer (raw_buffer, MIPS_SAVED_REGSIZE);
+ store_signed_integer (raw_buffer, REGISTER_RAW_SIZE (regnum),
+ val);
}
- if (addrp != NULL)
- *addrp = addr;
}
/* Immediately after a function call, return the saved pc.
next reply other threads:[~2002-08-09 0:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-08 17:37 Kevin Buettner [this message]
2002-08-09 9:13 ` Andrew Cagney
2002-08-09 13:59 ` Kevin Buettner
2002-08-09 20:26 ` Andrew Cagney
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=1020809003710.ZM26327@localhost.localdomain \
--to=kevinb@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