From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <856a95de7de103d9ed147d00e2fa9dde.axp-list@archive.invalid> X-Archive-Original-Message-ID: <199612020428.XAA05775@rrdjazz.nist.gov> Date: Sun, 1 Dec 1996 23:50:25 +0000 (`. ) From: Dan McGuirk Subject: How to find caller's frame pointer? Hi. I know this question isn't at quite the same level as most on this list, but if some of the more technical people here could help me out, I'd appreciate it. I'm trying to figure out how to find the caller's frame pointer in a function compiled by gcc on an Alpha under Linux. On an Intel processor, gcc-compiled functions start with pushl %ebp movl %esp,%ebp (assuming frame pointers aren't turned off). So the stack looks something like return address EBP _____ previous frame pointer ESP _____ So if I just keep dereferencing %ebp a bunch of times, I can go up as many stack frames as I want. On the Alpha it's almost the same--functions start with something like: lda $30,-32($30) .frame $15,32,$26,0 stq $26,0($30) stq $15,8($30) .mask 0x4008000,-32 bis $30,$30,$15 So that's fine--I know the old frame pointer is at 8($15), and I should be able to keep dereferencing as long as I move over eight bytes each time. But the problem is, if a function clobbers any of the registers $9-$14, they get pushed to the stack before $15, the old frame pointer, like this: lda $30,-64($30) .frame $15,64,$26,0 stq $26,0($30) stq $9,8($30) stq $15,16($30) .mask 0x4008200,-64 bis $30,$30,$15 So there doesn't seem to be any way to reliably tell where the old frame pointer is going to be relative to the current one. Or is there? Am I missing something here? Or is tracing frame pointers back like this just not a legitimate thing to do? (The reason would be either to tell how deeply nested I am, or to locate the beginning of the overall program stack.) Thanks very much for any help anyone can provide. -- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com