This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Backtrace prints wrong argument value


:ADDPATCH PowerPC-64:

Daniel,

Thanks for reviewing.

Yeah, i definitely had issues with my editor and the tabs ended up being
expanded to spaces. Hopefully this version is correct now. I hope my
mail client doesn't mess the tabs.

> I guess this works, then?  That's great.

Yes, it improves the situation quite a bit, since now only parameters
that are sure to be correct are displayed. If there's a chance of that
parameter being unreliable, then gdb won't display its value (optimized
out).

Best regards,

-- 
Luis Machado
IBM Linux Technology Center
e-mail: luisgpm@linux.vnet.ibm.com
2007-09-17  Luis Machado  <luisgpm@br.ibm.com>

		* rs6000-tdep.c (ppc_dwarf2_frame_init_reg): New function.
		(rs6000_gdbarch_init): Install ppc_dwarf2_frame_init_reg as 
		default dwarf2_frame_set_init_reg function.

Index: gdb/rs6000-tdep.c
===================================================================
--- gdb.orig/rs6000-tdep.c	2007-09-17 05:15:37.000000000 -0700
+++ gdb/rs6000-tdep.c	2007-09-17 05:41:23.000000000 -0700
@@ -3468,6 +3468,68 @@
   return &rs6000_frame_base;
 }
 
+/* DWARF-2 frame support.  Used to handle the detection of
+	 clobbered registers during function calls.  */
+
+static void
+ppc_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
+						struct dwarf2_frame_state_reg *reg,
+						struct frame_info *next_frame)
+{
+	struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+	/* PPC32 and PPC64 ABI's are the same regarding volatile and
+		non-volatile registers.  We will use the same code for both.  */
+
+	/* Call-saved GP registers.  */
+	if ((regnum >= tdep->ppc_gp0_regnum + 14
+			&& regnum <= tdep->ppc_gp0_regnum + 31)
+			|| (regnum == tdep->ppc_gp0_regnum + 1))
+		reg->how = DWARF2_FRAME_REG_SAME_VALUE;
+
+	/* Call-clobbered GP registers.  */
+	if ((regnum >= tdep->ppc_gp0_regnum + 3
+			&& regnum <= tdep->ppc_gp0_regnum + 12)
+			|| (regnum == tdep->ppc_gp0_regnum))
+		reg->how = DWARF2_FRAME_REG_UNDEFINED;
+
+	/* Deal with FP registers, if supported.  */
+	if (tdep->ppc_fp0_regnum >= 0)
+		{
+			/* Call-saved FP registers.  */
+			if ((regnum >= tdep->ppc_fp0_regnum + 14
+					&& regnum <= tdep->ppc_fp0_regnum + 31))
+				reg->how = DWARF2_FRAME_REG_SAME_VALUE;
+
+			/* Call-clobbered FP registers.  */
+			if ((regnum >= tdep->ppc_fp0_regnum
+					&& regnum <= tdep->ppc_fp0_regnum + 13))
+				reg->how = DWARF2_FRAME_REG_UNDEFINED;
+		}
+
+	/* Deal with ALTIVEC registers, if supported.  */
+	if (tdep->ppc_vr0_regnum > 0 && tdep->ppc_vrsave_regnum > 0)
+		{
+			/* Call-saved Altivec registers.  */
+			if ((regnum >= tdep->ppc_vr0_regnum + 20
+					&& regnum <= tdep->ppc_vr0_regnum + 31)
+					|| regnum == tdep->ppc_vrsave_regnum)
+				reg->how = DWARF2_FRAME_REG_SAME_VALUE;
+
+			/* Call-clobbered Altivec registers.  */
+			if ((regnum >= tdep->ppc_vr0_regnum
+					&& regnum <= tdep->ppc_vr0_regnum + 19))
+				reg->how = DWARF2_FRAME_REG_UNDEFINED;
+		}
+
+	/* Handle PC register and Stack Pointer correctly.  */
+	if (regnum == gdbarch_pc_regnum (current_gdbarch))
+		reg->how = DWARF2_FRAME_REG_RA;
+	else if (regnum == gdbarch_sp_regnum (current_gdbarch))
+		reg->how = DWARF2_FRAME_REG_CFA;
+}
+
+
 /* Initialize the current architecture based on INFO.  If possible, re-use an
    architecture from ARCHES, which is a list of architectures already created
    during this debugging session.
@@ -3774,6 +3836,9 @@
   frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer);
   dwarf2_frame_set_adjust_regnum (gdbarch, rs6000_adjust_frame_regnum);
 
+	/* Frame handling.  */
+	dwarf2_frame_set_init_reg (gdbarch, ppc_dwarf2_frame_init_reg);
+
   /* Hook in ABI-specific overrides, if they have been registered.  */
   gdbarch_init_osabi (info, gdbarch);
 
@@ -3790,6 +3855,7 @@
           tdep->ppc_vr0_regnum = 71;
           tdep->ppc_vrsave_regnum = 104;
         }
+
       /* Fall Thru */
     case GDB_OSABI_NETBSD_AOUT:
     case GDB_OSABI_NETBSD_ELF:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]