aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMStackTrace.h
diff options
context:
space:
mode:
authorGravatar thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2008-08-12 17:21:32 +0000
committerGravatar thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2008-08-12 17:21:32 +0000
commit7063d76a007fbf636250d7199d6f24ec487163b1 (patch)
tree5a1f2f0a4b597f62df3e2fe858d76d37b22bbe89 /Foundation/GTMStackTrace.h
parent43982f07ba6a0a9839e32e774855c9d2068e9d5e (diff)
- Added GTMNSMakeUncollectable for forcing objects to survive in a GC world.
- Added GTMCFAutorelease to make the [GTMNSMakeCollectable(cfFoo) autorelease] simpler and clearer, it's now just GTMCFAutorelease(cfFoo), and works in both GC and non-GC world. - Added GTMIsGarbageCollectionEnabled to GTMGarbageCollection.h. See the note there for it's usage. - Disabled the unittests for things on top of NSAppleScript in a GC world since Apple has bugs and it can crash. See the unittest for a note about it. - GTMStackTrace now can figure out ObjC symbols. Downside it is now ObjC only. - GTMFourCharCode can now be used with NSAppleEventDescriptors easily. typeType, typeKeyword, typeApplSignature, and typeEnumerated all get turned into GTMFourCharCodes. - Fixed up crash in GTMLoggerRingBufferWriter when used with GC on. - Significant updates to GTMNSAppleScript+Handler allowing you to list all handlers and properties (including inherited) and cleans up several errors in how scripting was being handled.
Diffstat (limited to 'Foundation/GTMStackTrace.h')
-rw-r--r--Foundation/GTMStackTrace.h67
1 files changed, 38 insertions, 29 deletions
diff --git a/Foundation/GTMStackTrace.h b/Foundation/GTMStackTrace.h
index cfb9c95..a77ca93 100644
--- a/Foundation/GTMStackTrace.h
+++ b/Foundation/GTMStackTrace.h
@@ -22,20 +22,20 @@
extern "C" {
#endif
-/// Returns a string containing a nicely formatted stack trace.
-// The caller owns the returned CFStringRef and is responsible for releasing it.
-//
-// *****************************************************************************
-// The symbolic names returned for Objective-C methods will be INCORRECT. This
-// is because dladdr() doesn't properly resolve Objective-C names. The symbol's
-// address will be CORRECT, so will be able to use atos or gdb to get a properly
-// resolved Objective-C name. -- 5/15/2007
-// TODO: write dladdr() replacement that works with Objective-C symbols.
-// *****************************************************************************
+struct GTMAddressDescriptor {
+ const void *address; // address
+ const char *symbol; // nearest symbol to address
+ const char *class_name; // if it is an obj-c method, the method's class
+ BOOL is_class_method; // if it is an obj-c method, type of method
+ const char *filename; // file that the method came from.
+};
+
+// Returns a string containing a nicely formatted stack trace.
//
-// This function gets the stack trace for the current thread, and is safe to
-// use in production multi-threaded code. Typically this function will be used
-// along with some loggins, as in the following:
+// This function gets the stack trace for the current thread. It will
+// be from the caller of GTMStackTrace upwards to the top the calling stack.
+// Typically this function will be used along with some logging,
+// as in the following:
//
// MyAppLogger(@"Should never get here:\n%@", GTMStackTrace());
//
@@ -49,34 +49,43 @@ extern "C" {
// #5 0x00002692 tart () [/Users/me/./StackLog]
// #6 0x000025b9 tart () [/Users/me/./StackLog]
//
-// If you're using this with Objective-C, you may want to use the GTMStackTrace()
-// variant that autoreleases the returned string.
-//
-CFStringRef GTMStackTraceCreate(void);
-
-/// Wrapper that autoreleases the returned CFStringRef.
-// This is simply for the convenience of those using Objective-C.
-//
-#if __OBJC__
-#include "GTMGarbageCollection.h"
-#define GTMStackTrace() [GTMNSMakeCollectable(GTMStackTraceCreate()) autorelease]
-#endif
-/// Returns an array of program counters from the current thread's stack.
+NSString *GTMStackTrace(void);
+
+// Returns an array of program counters from the current thread's stack.
// *** You should probably use GTMStackTrace() instead of this function ***
// However, if you actually want all the PCs in "void *" form, then this
-// funtion is more convenient.
+// funtion is more convenient. This will include PCs of GTMStaceTrace and
+// its inner utility functions that you may want to strip out.
//
// Args:
// outPcs - an array of "void *" pointers to the program counters found on the
// current thread's stack.
-// size - the size of outPcs
+// count - the number of entries in the outPcs array
//
// Returns:
// The number of program counters actually added to outPcs.
//
-int GTMGetStackProgramCounters(void *outPcs[], int size);
+int GTMGetStackProgramCounters(void *outPcs[], int count);
+// Returns an array of GTMAddressDescriptors from the current thread's stack.
+// *** You should probably use GTMStackTrace() instead of this function ***
+// However, if you actually want all the PCs with symbols, this is the way
+// to get them. There is no memory allocations done, so no clean up is required
+// except for the caller to free outDescs if they allocated it themselves.
+// This will include PCs of GTMStaceTrace and its inner utility functions that
+// you may want to strip out.
+//
+// Args:
+// outDescs - an array of "struct GTMAddressDescriptor" pointers corresponding
+// to the program counters found on the current thread's stack.
+// count - the number of entries in the outDescs array
+//
+// Returns:
+// The number of program counters actually added to outPcs.
+//
+int GTMGetStackAddressDescriptors(struct GTMAddressDescriptor outDescs[],
+ int count);
#ifdef __cplusplus
}
#endif