mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-20 20:26:42 +00:00
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:
parent
6c4c66fab7
commit
cc2f12f523
4 changed files with 203 additions and 25 deletions
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue