Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Corinna Vinschen <vinschen@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH] m32c-tdep.c: Add virtual_frame_pointer function
Date: Thu, 29 Jun 2006 13:08:00 -0000	[thread overview]
Message-ID: <20060629130844.GF18873@calimero.vinschen.de> (raw)
In-Reply-To: <20060629105116.GD18873@calimero.vinschen.de>

On Jun 29 12:51, Corinna Vinschen wrote:
> I see the point.  I rewrote the m32c_virtual_frame_pointer function to
> return a valid register/offset pair from the banked fb resp. sp
> registers.  Does that look ok?

Oops!  There was a copy/paste error in my patch, sorry about that.
New patch below.


Corinna


 	* m32c-tdep.c (m32c_banked_register): New function.
 	(m32c_banked_read): Use m32c_banked_register function to evaluate
 	real register number.
 	(m32c_banked_write): Ditto.
 	(m32c_virtual_frame_pointer): New function.
 	(m32c_gdbarch_init): Add set_gdbarch_virtual_frame_pointer call.
 
 
Index: m32c-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/m32c-tdep.c,v
retrieving revision 1.1
diff -u -p -r1.1 m32c-tdep.c
--- m32c-tdep.c	20 Apr 2006 23:18:48 -0000	1.1
+++ m32c-tdep.c	29 Jun 2006 13:07:25 -0000
@@ -340,6 +340,14 @@ m32c_read_flg (struct regcache *cache)
 }
 
 
+/* Evaluate the real register number of a banked register.  */
+static struct m32c_reg *
+m32c_banked_register (struct m32c_reg *reg, struct regcache *cache)
+{
+  return ((m32c_read_flg (cache) & reg->n) ? reg->ry : reg->rx);
+}
+
+
 /* Move the value of a banked register from CACHE to BUF.
    If the value of the 'flg' register in CACHE has any of the bits
    masked in REG->n set, then read REG->ry.  Otherwise, read
@@ -347,8 +355,7 @@ m32c_read_flg (struct regcache *cache)
 static void
 m32c_banked_read (struct m32c_reg *reg, struct regcache *cache, void *buf)
 {
-  struct m32c_reg *bank_reg
-    = ((m32c_read_flg (cache) & reg->n) ? reg->ry : reg->rx);
+  struct m32c_reg *bank_reg = m32c_banked_register (reg, cache);
   regcache_raw_read (cache, bank_reg->num, buf);
 }
 
@@ -360,8 +367,7 @@ m32c_banked_read (struct m32c_reg *reg, 
 static void
 m32c_banked_write (struct m32c_reg *reg, struct regcache *cache, void *buf)
 {
-  struct m32c_reg *bank_reg
-    = ((m32c_read_flg (cache) & reg->n) ? reg->ry : reg->rx);
+  struct m32c_reg *bank_reg = m32c_banked_register (reg, cache);
   regcache_raw_write (cache, bank_reg->num, (const void *) buf);
 }
 
@@ -2475,6 +2481,40 @@ m32c_m16c_pointer_to_address (struct typ
   return ptr;
 }
 
+void
+m32c_virtual_frame_pointer (CORE_ADDR pc,
+			    int *frame_regnum,
+			    LONGEST *frame_offset)
+{
+  char *name;
+  CORE_ADDR func_addr, func_end, sal_end;
+  struct m32c_prologue p;
+
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+  
+  if (!find_pc_partial_function (pc, &name, &func_addr, &func_end))
+    internal_error (__FILE__, __LINE__, _("No virtual frame pointer available"));
+
+  m32c_analyze_prologue (current_gdbarch, func_addr, pc, &p);
+  switch (p.kind)
+    {
+    case prologue_with_frame_ptr:
+      *frame_regnum = m32c_banked_register (tdep->fb, current_regcache)->num;
+      *frame_offset = p.frame_ptr_offset;
+      break;
+    case prologue_sans_frame_ptr:
+      *frame_regnum = m32c_banked_register (tdep->sp, current_regcache)->num;
+      *frame_offset = p.frame_size;
+      break;
+    default:
+      *frame_regnum = m32c_banked_register (tdep->sp, current_regcache)->num;
+      *frame_offset = 0;
+      break;
+    }
+  /* Sanity check */
+  if (*frame_regnum > NUM_REGS)
+    internal_error (__FILE__, __LINE__, _("No virtual frame pointer available"));
+}
 
 \f
 /* Initialization.  */
@@ -2539,6 +2579,8 @@ m32c_gdbarch_init (struct gdbarch_info i
   /* Trampolines.  */
   set_gdbarch_skip_trampoline_code (arch, m32c_skip_trampoline_code);
 
+  set_gdbarch_virtual_frame_pointer (arch, m32c_virtual_frame_pointer);
+
   return arch;
 }
 

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


  reply	other threads:[~2006-06-29 13:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-28 13:29 Corinna Vinschen
2006-06-28 21:29 ` Mark Kettenis
2006-06-28 21:34   ` DJ Delorie
2006-06-29  2:34   ` Daniel Jacobowitz
2006-06-29 10:51     ` Corinna Vinschen
2006-06-29 13:08       ` Corinna Vinschen [this message]
2006-07-12 19:13         ` Daniel Jacobowitz
2006-07-13 12:01           ` Corinna Vinschen
2006-06-29 13:18       ` Daniel Jacobowitz

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=20060629130844.GF18873@calimero.vinschen.de \
    --to=vinschen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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