[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Retrieving PC from (traversing) the stack on Alpha
- From: "Joseph A. Martin" <jmartin linux08 mro dec com>
- To: axp-list redhat com
- Subject: Re: Retrieving PC from (traversing) the stack on Alpha
- Date: Fri, 17 Dec 1999 12:51:20 -0500
>Okay, after some research, I think I figured out how to get at the needed
>Alpha registers:
>
>register unsigned long fptr __asm__("$15"); /* get frame pointer? */
>register unsigned long sptr __asm__("$30"); /* get stack pointer? */
If there is a frame pointer, that's how you'd find it. However, there
often isn't. It depends on the compiler, and it depends on whether
there are references to some outer scope or perhaps arguments passed
on the stack. (I may be thinking of SPARC here, so don't take me too
seriously about the argument thing.) More often than not there is no
frame pointer and integer register 15 is treated as "s6" not "fp".
To find the size of the (previous/next higher) stack frame:
/* Warning: untested, uncompiled code fragment */
typdef unsigned int instruction;
/*
* Of course, assembly code writers and compilers I haven't seen may
* thwart this heuristic.
*/
#define is_lda_of_neg_from_30_to_30(X) (((X) & 0xffff8000) == 0x23de8000)
/* This one assumes that the low 3 bits of the literal are zero. */
#define is_stack_subq(X) (((X) & 0xffe0ffff) == 0x43c0153e)
void stack_crawler(void)
{
register unsigned long ra __asm__("$26");
register unsigned long sp __asm__("$30");
int frame_size;
instruction * instr = (instruction *)ra;
/* Look for certain kinds of instructions. */
for(;;) {
--instr;
if (is_lda_of_neg_from_30_to_30(*instr)) {
frame_size = 0x10000 - (*instr & 0xffff);
break;
}
if (is_stack_subq(*instr)) {
frame_size = (*instr >> 13) & 0xff;
break;
}
}
/*
*To tell which regs are stored where, travel forward looking
* for STQs onto the stack.
*/
}
\Joe [Joseph.Martin@Compaq.com Joseph A. Martin
Compaq Computer Corporation
200 Forest Street MRO1-2/K20
(508) 467-2100 Marlboro, MA 01752 U.S.A.
]
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[]