* Re: Retrieving PC from (traversing) the stack on Alpha
1999-12-19 16:41 ` Brian Hall
@ 1999-12-17 17:51 ` Joseph A. Martin
0 siblings, 0 replies; 3+ messages in thread
From: Joseph A. Martin @ 1999-12-17 17:51 UTC (permalink / raw)
To: axp-list
>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.
]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Retrieving PC from (traversing) the stack on Alpha
[not found] <Pine.SGI.3.94.991213130230.334794A-100000@awesome.engr.sgi.com>
@ 1999-12-19 16:41 ` Brian Hall
1999-12-17 17:51 ` Joseph A. Martin
0 siblings, 1 reply; 3+ messages in thread
From: Brian Hall @ 1999-12-19 16:41 UTC (permalink / raw)
To: axp-list
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? */
Now, my understanding of the problem is that I need to go back two frames on
the stack to get the PC of interest, and three for the RA of interest. How do I
do this? I haven't had much luck yet trying to figure out how to navigate the
kernel stack. I see the pt_regs structure, but I'm not exactly sure how to
figure the frame size, since that can vary with each frame.
On 13-Dec-1999 Matt Robinson wrote:
> The problem is from panic(), you don't have the registers, so you
> need to grab them. That way the 'lcrash' code has a point to start
> with as far as the failing process is concerned. Hence the "if (regs)"
> stuff.
--
Brian Hall <brianw.hall@compaq.com>
Linux Consultant
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: Retrieving PC from (traversing) the stack on Alpha
[not found] <XFMail.19991218145151.brianw.hall@compaq.com>
@ 1999-12-23 19:55 ` Brian Hall
0 siblings, 0 replies; 3+ messages in thread
From: Brian Hall @ 1999-12-23 19:55 UTC (permalink / raw)
To: axp-list; +Cc: lkcd, comp.os.linux.alpha, Matt Robinson
Well, it's not clear to me how to get the PC and RA of interest off the stack
when we are in the vmdump functions. We could retreive the RA from register 26
in the panic() function itself, and pass that to the dump_execute function.
Then the dump code could at least tell where panic was called from. Is this
sufficient, or at least a start?
On 18-Dec-1999 Brian Hall wrote:
> 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? */
>
> Now, my understanding of the problem is that I need to go back two frames on
> the stack to get the PC of interest, and three for the RA of interest. How do
> I
> do this? I haven't had much luck yet trying to figure out how to navigate the
> kernel stack. I see the pt_regs structure, but I'm not exactly sure how to
> figure the frame size, since that can vary with each frame.
>
> On 13-Dec-1999 Matt Robinson wrote:
>> The problem is from panic(), you don't have the registers, so you
>> need to grab them. That way the 'lcrash' code has a point to start
>> with as far as the failing process is concerned. Hence the "if (regs)"
>> stuff.
--
Brian Hall <brianw.hall@compaq.com>
Linux Consultant
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1999-12-21 19:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <XFMail.19991218145151.brianw.hall@compaq.com>
1999-12-23 19:55 ` Retrieving PC from (traversing) the stack on Alpha Brian Hall
[not found] <Pine.SGI.3.94.991213130230.334794A-100000@awesome.engr.sgi.com>
1999-12-19 16:41 ` Brian Hall
1999-12-17 17:51 ` Joseph A. Martin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox