Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew STUBBS <andrew.stubbs@st.com>
To: gdb-patches@sources.redhat.com
Subject: [PATCH][SH] invalid registers
Date: Wed, 16 Nov 2005 17:09:00 -0000	[thread overview]
Message-ID: <437B5C5F.5080500@st.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 507 bytes --]

Hi,

The attached patch teaches GDB which registers are invalid in previous 
frames when the CFI does not say otherwise.

It does this using the SH4 ABI. This is backwards compatible with the 
sh1-sh3 and variants. I have not attempted to deal with the DSP 
registers as I don't know the ABI. They will be treated as ever.

The only thing this patch actually does is allow the 'info registers' 
command (and friends) to show '*invalid register*' when there is no way 
to know the true value.

Andrew Stubbs

[-- Attachment #2: invalid-registers.patch --]
[-- Type: text/plain, Size: 3226 bytes --]

2005-11-16  Andrew Stubbs  <andrew.stubbs@st.com>

	* sh-tdep.c (sh_dwarf2_frame_init_reg): New function.
	(sh_gdbarch_init): Call dwarf2_frame_set_init_reg().

Index: src/gdb/sh-tdep.c
===================================================================
--- src.orig/gdb/sh-tdep.c	2005-11-04 16:57:00.000000000 +0000
+++ src/gdb/sh-tdep.c	2005-11-04 17:55:46.000000000 +0000
@@ -2118,6 +2118,57 @@ sh_sh2a_register_sim_regno (int nr)
   return legacy_register_sim_regno (nr);
 }
 
+/* Set up the register unwinding such that call-clobbered registers are
+   not displayed in frames >0 because the true value is not certain.
+   The 'undefined' registers will show up as 'not available' unless the
+   CFI says otherwise.
+
+   This function is currently set up for SH4 and compatible only.  */
+
+static void
+sh_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
+                          struct dwarf2_frame_state_reg *reg)
+{
+  /* Mark the PC as the destination for the return address.  */
+  if (regnum == PC_REGNUM)
+    reg->how = DWARF2_FRAME_REG_RA;
+
+  /* Mark the stack pointer as the call frame address.  */
+  else if (regnum == SP_REGNUM)
+    reg->how = DWARF2_FRAME_REG_CFA;
+
+  /* The above was taken from the default init_reg in dwarf2-frame.c
+     while the below is SH specific.  */
+
+  /* Caller save registers.  */
+  else if ((regnum >= R0_REGNUM && regnum <= R0_REGNUM+7)
+	   || (regnum >= FR0_REGNUM && regnum <= FR0_REGNUM+11)
+	   || (regnum >= DR0_REGNUM && regnum <= DR0_REGNUM+5)
+	   || (regnum >= FV0_REGNUM && regnum <= FV0_REGNUM+2)
+	   || (regnum == MACH_REGNUM)
+	   || (regnum == MACL_REGNUM)
+	   || (regnum == FPUL_REGNUM)
+	   || (regnum == SR_REGNUM))
+    reg->how = DWARF2_FRAME_REG_UNDEFINED;
+
+  /* Callee save registers.  */
+  else if ((regnum >= R0_REGNUM+8 && regnum <= R0_REGNUM+15)
+	   || (regnum >= FR0_REGNUM+12 && regnum <= FR0_REGNUM+15)
+	   || (regnum >= DR0_REGNUM+6 && regnum <= DR0_REGNUM+8)
+	   || (regnum == FV0_REGNUM+3))
+    reg->how = DWARF2_FRAME_REG_SAME_VALUE;
+
+  /* Other registers.  These are not in the ABI and may or may not
+     mean anything in frames >0 so don't show them.  */
+  else if ((regnum >= R0_BANK0_REGNUM && regnum <= R0_BANK0_REGNUM+15)
+	   || (regnum == GBR_REGNUM)
+	   || (regnum == VBR_REGNUM)
+	   || (regnum == FPSCR_REGNUM)
+	   || (regnum == SSR_REGNUM)
+	   || (regnum == SPC_REGNUM))
+    reg->how = DWARF2_FRAME_REG_UNDEFINED;
+}
+
 static struct sh_frame_cache *
 sh_alloc_frame_cache (void)
 {
@@ -2502,6 +2553,8 @@ sh_gdbarch_init (struct gdbarch_info inf
 
   set_gdbarch_in_function_epilogue_p (gdbarch, sh_in_function_epilogue_p);
 
+  dwarf2_frame_set_init_reg (gdbarch, sh_dwarf2_frame_init_reg);
+
   switch (info.bfd_arch_info->mach)
     {
     case bfd_mach_sh:
Index: src/gdb/sh-tdep.h
===================================================================
--- src.orig/gdb/sh-tdep.h	2004-10-06 09:55:36.000000000 +0100
+++ src/gdb/sh-tdep.h	2005-11-04 17:50:17.000000000 +0000
@@ -41,6 +41,7 @@ enum
     FPUL_REGNUM = 23,
     /* Floating point registers */
     FPSCR_REGNUM = 24,
+    FR0_REGNUM = 25,
     FLOAT_ARG0_REGNUM = 29,
     FLOAT_ARGLAST_REGNUM = 36,
     FP_LAST_REGNUM = 40,

             reply	other threads:[~2005-11-16 16:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-16 17:09 Andrew STUBBS [this message]
2006-03-30 20:52 ` Daniel Jacobowitz
2006-04-03 12:59   ` Andrew STUBBS
2006-04-03 13:03     ` Daniel Jacobowitz
2006-04-03 14:33       ` Andrew STUBBS

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=437B5C5F.5080500@st.com \
    --to=andrew.stubbs@st.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