Adium

Changeset 25619

Show
Ignore:
Timestamp:
11/24/2008 07:39:22 PM (2 months ago)
Author:
catfish_man
Message:

Add AILogBacktrace(), which does what it says on the tin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Frameworks/Adium Framework/Source/ESDebugAILog.h

    r20754 r25619  
    2020        #define AILogWithSignature(fmt, args...) AILogWithPrefix(__PRETTY_FUNCTION__, fmt, ##args); 
    2121        void AILog (NSString *format, ...); 
     22        void AILogBacktrace(); 
    2223#else 
    2324/* For a non-debug build, define it to be a comment so there is no overhead in using it liberally */ 
     
    2526        #define AILogWithSignature(fmt, ...) /**/ 
    2627        #define AILogWithPrefix(sig, fmt, ...) /**/ 
     28        #define AILogBacktrace() /**/ 
    2729#endif 
  • trunk/Frameworks/Adium Framework/Source/ESDebugAILog.m

    r24803 r25619  
    3232 */ 
    3333#ifdef DEBUG_BUILD 
     34#include <execinfo.h> 
    3435void AIAddDebugMessage(NSString *debugMessage) 
    3536{ 
     
    7778        va_end(ap); /* clean up when done */ 
    7879} 
     80 
     81void AILogBacktrace() { 
     82        void* callstack[128]; 
     83        int i, frames = backtrace(callstack, 128); 
     84        char** strs = backtrace_symbols(callstack, frames); 
     85        NSMutableString *str = [NSMutableString string]; 
     86        for (i = 0; i < frames; ++i) { 
     87                [str appendFormat:@"%s\n", strs[i]]; 
     88        } 
     89        free(strs);      
     90        AILog(@"%@", str); 
     91}; 
     92 
    7993#else 
    8094//Insert a fake symbol so that plugins using AILog() don't crash. 
     
    8397#undef AILogWithPrefix 
    8498void AILogWithPrefix (char *sig, NSString *format, ...) {}; 
     99#undef AILogBacktrace 
     100void AILogBacktrace() {}; 
    85101#endif