• 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: Stack trace queryable?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stack trace queryable?


  • Subject: Re: Stack trace queryable?
  • From: Sam Vaughan <email@hidden>
  • Date: Wed, 5 Jan 2005 09:27:37 +1100

On 05/01/2005, at 7:04 AM, email@hidden wrote:

El 29/12/2004, a las 15:55, Geoffrey Schmit escribió:

On 27/12/2004 at 8:08 PM, email@hidden (Christian
Schmitz) wrote:

can a function get the list of which functions called itself for debug
purpose?


You see a stack trace in the crash report every time so I ask
myself if this list of function names can be queried inside a
thread so I could add it to an exception object.

MoreBacktrace does:

<http://developer.apple.com/samplecode/MoreIsBetter/listing41.html>

Unfortunately, I wasn't able to get MoreBacktraceTest to compile, at least under Mac OS X 10.3.7/Darwin 7.7.0, so can't confirm that it works. The MoreIsBetter library itself does seem to compile, but the test program doesn't. It complains that it can't find MoreMemory.h while compiling MoreControls.cp:

../../MoreControls/MoreControls.cp:89:24: MoreMemory.h: No such file
or directory

No idea why this might be so because the other files included from MoreControls.cp are found without any problems. If I cheat by copying MoreMemory.h over into the MoreControls directory, then the project compiles but doesn't link:

ld: warning prebinding disabled because of undefined symbols
ld: Undefined symbols:
_MoreMemError

I haven't looked at the MoreBacktrace code, but you should be able to generate backtraces pretty simply with the following code:

    typedef struct stack_frame
    {
        struct stack_frame* next;
        int                 junk;
        void*               addr;
    }stack_frame_t;

    #define BT_MAX 32
    #define SF_MAX 4096
    #define BT_LOAD(bt)                                  \
    do                                                   \
    {                                                    \
        bzero(bt, sizeof(bt));                           \
        register stack_frame_t* sf;                      \
        asm volatile("mr %0,r1" : "=r" (sf));            \
        int i;                                           \
        for (i = 0; i < BT_MAX; i++)                     \
        {                                                \
            bt[i] = sf->addr;                            \
            if (sf->next < sf || sf->next > sf + SF_MAX) \
                break;                                   \
            sf = sf->next;                               \
        }                                                \
    } while(0);


Then to use it:

    void* bt[BT_MAX];
    BT_LOAD(bt);

Sam
_______________________________________________
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: Stack trace queryable?
      • From: Greg Hurrell <email@hidden>
  • Prev by Date: Re: Stack trace queryable?
  • Next by Date: Re: Stack trace queryable?
  • Previous by thread: Re: Stack trace queryable?
  • Next by thread: Re: Stack trace queryable?
  • Index(es):
    • Date
    • Thread