• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
__builtin_frame_address()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

__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

  • Follow-Ups:
    • Re: __builtin_frame_address()
      • From: Jason Molenda <email@hidden>
    • Re: __builtin_frame_address()
      • From: Steve Checkoway <email@hidden>
  • Prev by Date: Re: GCC 4.0 version
  • Next by Date: Re: Bizarre out of memory bug
  • Previous by thread: Re: xattr on SMB and NTFS
  • Next by thread: Re: __builtin_frame_address()
  • Index(es):
    • Date
    • Thread