Implement part of MacOS 10.5 additions for NSThread.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25607 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2007-11-25 14:25:26 +00:00
parent 6c4c66fab7
commit cc2f12f523
4 changed files with 203 additions and 25 deletions

View file

@ -36,6 +36,7 @@
#include "Foundation/NSThread.h"
#include "Foundation/NSLock.h"
#include "Foundation/NSDictionary.h"
#include "Foundation/NSValue.h"
#include <stdio.h>
#if defined(__MINGW32__)
@ -83,6 +84,7 @@ GSPrivateBaseAddress(void *addr, void **base)
- (NSString*) description;
- (NSEnumerator*) enumerator;
- (NSMutableArray*) frames;
- (id) frameAt: (unsigned)index;
- (unsigned) frameCount;
- (NSEnumerator*) reverseEnumerator;
@ -513,9 +515,7 @@ GSListModules()
- (oneway void) dealloc
{
[frames release];
frames = nil;
DESTROY(frames);
[super dealloc];
}
@ -550,6 +550,11 @@ GSListModules()
return [frames count];
}
- (NSMutableArray*) frames
{
return frames;
}
// grab the current stack
- (id) init
{
@ -644,6 +649,30 @@ GSListModules()
@end
/**
* Get a stack trace and convert it to an array of return addresses.
*/
@interface NSThread (Frames)
+ (NSArray*) callStackReturnAddresses;
@end
@implementation NSThread (Frames)
+ (NSArray*) callStackReturnAddresses
{
NSMutableArray *frames = [[GSStackTrace currentStack] frames];
unsigned count = [frames count];
while (count-- > 0)
{
GSFunctionInfo *info = [frames objectAtIndex: count];
NSValue *address;
address = [NSValue valueWithPointer: [info address]];
[frames replaceObjectAtIndex: count
withObject: address];
}
return frames;
}
@end