Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: __builtin_frame_address()




On May 25, 2005, at 7:57 PM, Steve Checkoway wrote:

Is __builtin_frame_address() broken? I have some backtracing code that walks the stack essentially using:


Something like

bt ()
{
  void **fp = (void **) __builtin_frame_address (0);
  void *saved_pc = __builtin_return_address (0);
  void *saved_fp = __builtin_frame_address (1);
  int depth = 0;

  printf ("[%d] pc == %p fp == %p\n", depth++, saved_pc, saved_fp);
  fp = saved_fp;
  while (fp != NULL)
    {
      saved_fp = *fp;
      fp = saved_fp;
      if (*fp == NULL)
        break;
      saved_pc = *(fp + 2);
      printf ("[%d] pc == %p fp == %p\n", depth++, saved_pc, saved_fp);
    }
}

seems to work OK for me. Maybe that can point you in the right direction.

J
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden
References: 
 >__builtin_frame_address() (From: Steve Checkoway <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.