__builtin_frame_address()
__builtin_frame_address()
- Subject: __builtin_frame_address()
- From: Steve Checkoway <email@hidden>
- Date: Wed, 25 May 2005 19:57:02 -0700
Is __builtin_frame_address() broken? I have some backtracing code
that walks the stack essentially using:
struct Frame
{
struct Frame *sp;
long cr;
void *lr;
};
register void *r1 __asm__("r1");
Frame *frame = (Frame *)r1;
while (frame)
{
if (frame->lr)
/* Do something with the return address */
frame = frame->sp;
}
It seems to me that I could remove the register void *r1 __asm__
("r1"); and change r1 in the next line to __builtin_frame_address(0);
but this doesn't seem to work. The value returned is completely bizarre.
If it makes any difference, I am doing this in c++.
On a slightly related note, the first few values that frame->lr holds
are in unrelated functions that are not on the stack at the time.
This is new in gcc 4. Prior versions seemed to provide sane
addresses. After the first few functions, the stack seems correct.
- Steve
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden