This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Unwinding on Sparc/Solaris: MD_FALLBACK_FRAME_STATE_FOR
- From: Geert Bosch <bosch at gnat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 23 Jan 2003 13:04:42 -0500
- Subject: Unwinding on Sparc/Solaris: MD_FALLBACK_FRAME_STATE_FOR
I am trying to get GCC to correctly unwind through
SPARC/Solaris signal frames. When the GCC unwinder encounters
a frame without unwind info, it will execute the code
given by the MD_FALLBACK_FRAME_STATE_FOR macro, which
is not defined yet.
The problem however is finding out what signal frames look like
and where the information to unwind through them can be found,
such as saved stack pointer, return address etc.
Since GDB can display a correct backtrace when breaking in
a signal handler, I have looked there for inspiration.
The GDB 5.1 code to handle this are in gdb/sparc-tdep.c,
function sparc_init_extra_frame_info and sparc_frame_saved_pc.
However, most of the 3212 lines in this file seem related to tracing
through these frames without DWARF info, and it's a bit of a mess
that I have not been able to untangle.
The Sparc/Linux signal frames are quite different (no surprise)
so the code for MD_FALLBACK_FRAME_STATE_FOR of that port does
not help much.
If anyone could point me to information on how to unwind
these signal frames that would be great.
-Geert
PS. Below follows information I extracted from the Sparc/Linux kernel
sources, but it appears outdated/incorrect as it doesn't match
what I see on the actual stack.
/* A SunOS signal frame basically looks as follows.
*
* ---------------------------------- <-- %sp at signal time
* Struct sigcontext
* Signal address
* Ptr to sigcontext area above
* Signal code
* The signal number itself
* One register window
* ---------------------------------- <-- New %sp
*/
#define SUNOS_MAXWIN 31
#define _NSIG_WORDS 2 /* Just a guess, is right ??? */
struct reg_window {
unsigned long locals[8];
unsigned long ins[8];
};
struct sigcontext {
int sigc_onstack; /* state to restore */
int sigc_mask; /* sigmask to restore */
int sigc_sp; /* stack pointer */
int sigc_pc; /* program counter */
int sigc_npc; /* next program counter */
int sigc_psr; /* for condition codes etc */
int sigc_g1; /* User uses these two registers */
int sigc_o0; /* within the trampoline code. */
/* Now comes information regarding the users window set
at the time of the signal. */
int sigc_oswins; /* outstanding windows */
/* stack ptrs for each regwin buf */
char *sigc_spbuf[SUNOS_MAXWIN];
/* Windows to restore after signal */
struct reg_window sigc_wbuf[SUNOS_MAXWIN];
};
struct signal_sframe {
struct reg_window sig_window;
int sig_num;
int sig_code;
struct sigcontext *sig_scptr;
int sig_address;
struct sigcontext sig_context;
unsigned int extramask[_NSIG_WORDS - 1];
}