• 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
Re: Help on Stack trace
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help on Stack trace


  • Subject: Re: Help on Stack trace
  • From: Steve Checkoway <email@hidden>
  • Date: Mon, 9 Feb 2009 11:45:31 -0800


On Feb 9, 2009, at 10:15 AM, Rick Altherr wrote:


On Feb 8, 2009, at 3:35 PM, Steve Checkoway wrote:

In particular, the FromAddr() function finds foo even though it is not an exported global symbol.

In this case, since foo() was referenced by address (the calls to FromAddr and dladdr), a symbol was generated for it. If your application just called the function instead of referencing it, the compiler will most likely inline it and has no obligation to generate a symbol for it. The debugging information will correctly show that that address within the calling function came from the lines of source where foo() is defined, but the symbol table will show it came from the calling function.

Sure, if a function has been inlined as would be the case with such a trivial function, then there's not much hope of getting that function in a stack trace since there isn't a stack frame to find for the function.


This also assumes the binary being read hasn't been stripped. If the binary has the debugging info stripped, this should still work, but if all non-global symbols have been stripped, you will get the same results as dladdr(). Worse, a production application typically has every symbol except for __start() stripped.

It is for this reason that we don't strip non-global symbols.



The attached file is very slightly adapted from <http://svn.stepmania.com/viewvc/bin/cgi/viewvc.cgi/trunk/stepmania/src/archutils/Unix/BacktraceNames.cpp?view=markup >. In particular converted from c++ to c, hence the global variables.
<a.c>

There are a few potential bugs in this implementation. The main one being that in Leopard, the segments of a binary can be slid independently. This implementation assumes that the LINKEDIT segment will have the same slide as the __TEXT segment. While this is likely (assuming minimal address space fragmentation), it isn't guaranteed.

I thought it was images that are slid, not the segments. The code finds the image containing the address uses the slide value returned from _dyld_get_image_vmaddr_slide() for the image. Are there functions for getting the slide for individual segments?


Thanks for taking a look at this.

--
Steve Checkoway

    "Anyone who says that the solution is to educate the users
    hasn't ever met an actual user." -- Bruce Schneier




Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Help on Stack trace
      • From: Rick Altherr <email@hidden>
References: 
 >Help on Stack trace (From: Arnab Ganguly <email@hidden>)
 >Re: Help on Stack trace (From: Rick Altherr <email@hidden>)
 >Re: Help on Stack trace (From: Arnab Ganguly <email@hidden>)
 >Re: Help on Stack trace (From: Peter O'Gorman <email@hidden>)
 >Re: Help on Stack trace (From: Steve Checkoway <email@hidden>)
 >Re: Help on Stack trace (From: Rick Altherr <email@hidden>)

  • Prev by Date: Re: Make "incompatible pointer type" an error, not a warning
  • Next by Date: Re: Help on Stack trace
  • Previous by thread: Re: Help on Stack trace
  • Next by thread: Re: Help on Stack trace
  • Index(es):
    • Date
    • Thread