Finding the return address in a Sparc stack frame
Mon, 26 Apr 1993 15:31:50 GMT

          From comp.compilers

Related articles
Finding the return address in a Sparc stack frame (1993-04-26)
| List of all articles for this month |

Newsgroups: comp.unix.wizards,comp.sys.sun.misc,comp.compilers
Followup-To: comp.unix.wizards
Keywords: sparc, debug
Organization: AT&T Bell Laboratories, Holmdel NJ
Date: Mon, 26 Apr 1993 15:31:50 GMT


I'm trying to hack a debugging version of malloc that tracks who
called it for each piece of memory doled out. To determine who
called it, I want to figure out the return address by following
the argument's address to the stack frame.

My starting point is a version that runs on 386's and 3B2's,
which has the following unstructured hack. "nbytes" is the
argument to malloc.

#ifdef debug
/* reuse nextfree as pointer to caller */
struct header **argptr = (struct header **)&nbytes;
#if defined(i386)
blk->nextfree = *(argptr-1);
blk->nextfree = *(argptr+1); /*u3b2*/

I'm having trouble interpreting the Sparc stack frame. I've examined
stack frames using gdb and the structure found in /usr/include/frame.h
(below), but can't find anything that looks correct in fr_savpc.

struct frame {
int fr_local[8]; /* saved locals */
int fr_arg[6]; /* saved arguments [0 - 5] */
struct frame *fr_savfp; /* saved frame pointer */
int fr_savpc; /* saved program counter */
char *fr_stret; /* struct return addr */
int fr_argd[6]; /* arg dump area */
int fr_argx[1]; /* array of args past the 6th*/

I also could not decipher the gdb source. I'm guessing that there is
some indirection at some level that I'm missing. I've seen references
to "stack windows", but I've yet to find a detailed explanation.

Any help with this problem would be appreciated.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.