Hi All,

Just came back from holliday and working on something else than GNUstep.
Although today I intend to finish this stack trace utility.

Thanks to Win Oudshoorn who provided me with some good groundwork and API research I was able to come out with a nice and clean solution which easily give me the stack trace in my code. (see the 2 attached [.hm] files, and there is a demo project in the .tgz, with the original file from Wind Oudshoorn as well).

However this doesn't give me the function information for code in Gnustep.
I have to manually load GNUstep's DLL with
[GSStackTrace loadModule: @"C:\\GNUstep\\System\\Tools\\gnustep-base.dll"];

I would like to load this information automatically by using whatever path information GNUstep has. In fact I know there is some function to locate, say, gnustep-base.dll I just can't remember it.....

So: How do I get the path to theGNUstep's DLL? (gnustep-base.dll & gnustep-gui.dll)

Additionaly:
I would hack my version of GNUstep so that Zombie method call and exception raise dump this information.
I think that would be a nice feature to add to GNUstep to.
#import <Foundation/Foundation.h>
#include <bfd.h>

@interface GSFunctionInfo : NSObject
{
        void*    _address;
        NSString *_fileName;
        NSString *_functionName;
        int       _lineNo;
}
- initWithAddress:(void*)address file:(NSString*)file function:(NSString*)function line:(int)lineNo;

- (void*) address;
- (int) lineNumber;
- (NSString *) fileName;
- (NSString *) function;

@end


@interface GSBinaryFileInfo : NSObject
{
        NSString * _filename;
        bfd     *_abfd;
        asymbol **_symbols;
        long    _symbolCount;
}
// return info for an executable (.EXE or .DLL) // but not for any of its dependency (i.e. required DLL)
- initWithBinaryFile: (NSString *)filename;
- init; // return info for the current executing process

- (NSString *) filename;

- (GSFunctionInfo *) functionForAddress: (void*) address;

@end


@interface GSStackTrace : NSObject
{
        NSMutableArray *frames;
}
// initialize stack trace info
+ (void) loadModule:(NSString *)filename;

// query the stack
+ (GSStackTrace*) currentStack;

- (unsigned) frameCount;
- (GSFunctionInfo*) frameAt:(unsigned) index;

- (NSString*) description;

- (NSEnumerator*) enumerator;
- (NSEnumerator*) reverseEnumerator;

@end

Attachment: StackTrace.m
Description: Binary data

Attachment: stack.tgz
Description: Binary data

_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to