[patch] Add support for single register window model on SPARC

Eric Botcazou ebotcazou@adacore.com
Thu Jun 16 13:37:00 GMT 2011


Hi,

support for the single register window (aka flat) model on SPARC was just 
re-introduced in GCC: http://gcc.gnu.org/ml/gcc-patches/2011-06/msg00820.html
The -mflat option had been present in the 3.x series of compilers but was 
removed when the 4.x series debuted.  Due to renewed interest, most notably 
from the LEON folks, it will be supported again in future GCC releases.

The implementation has been almost entirely overhauled and, in particular, the 
weird register usage of the old flavor (e.g. %i7 as frame pointer) has been 
dropped.  Instead the new flavor preserves the canonical register usage and 
frame layout; the only visible change is that 'save' & 'restore' instructions 
are replaced with their "manual" equivalents in the generated code.

While CFIs are adjusted automatically by GCC, GDB has hardcoded assumptions 
about how frames are established on SPARC, which makes it unable to unwind 
the "flat" frames; in particular backtraces don't work.

The attached patch is aimed at fixing that.  It extends the frame sniffer to 
recognize the "flat" frames and decode the locations of call-saved registers.
Regtested (in normal mode) on SPARC/Solaris and SPARC64/Solaris.  It was also 
used to debug the new -mflat implementation of GCC, both 32-bit and 64-bit, so 
it works reasonably well in this mode.

OK for the mainline?


2011-06-16  Eric Botcazou  <ebotcazou@adacore.com>

	* sparc-tdep.h (struct sparc_frame_cache): Add frame_offset,
	saved_regs_mask and copied_regs_mask fields.
	(sparc_record_save_insn): New prototype.
	* sparc-tdep.c (sparc_alloc_frame_cache): Initialize the new fields.
	(sparc_record_save_insn): New function.
	(sparc_analyze_prologue): Add head comment.  Recognize store insns
	of call-saved registers.  Use OFFSET consistently.  Recognize flat
	frames and cache their settings.
	(sparc32_skip_prologue): Handle flat frames.
	(sparc_frame_cache): Add frame_offset to the base address.
	(sparc32_frame_cache): Adjust to new frame description.
	(sparc32_frame_prev_register): Likewise.
	* sparc64-tdep.c (sparc64_frame_prev_register): Likewise.
	* sparc-sol2-tdep.c (sparc32_sol2_sigtramp_frame_cache): Likewise.
	* sparc64-sol2-tdep.c (sparc64_sol2_sigtramp_frame_cache): Likewise.
	* sparcnbsd-tdep.c (sparc32nbsd_sigcontext_frame_cache): Force the
	frame by calling sparc_record_save_insn.
	* sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_frame_cache): Likewise.
	* sparcobsd-tdep.c (sparc32obsd_sigtramp_frame_cache): Likewise.
	* sparc64obsd-tdep.c (sparc64obsd_frame_cache): Likewise.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdb-mflat.diff
Type: text/x-diff
Size: 17233 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20110616/50604279/attachment.bin>


More information about the Gdb-patches mailing list