home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Programming / GDBbundle-1.0-MIS / src / TextEdit / GdbBundle.bproj / Stack.m < prev    next >
Encoding:
Text File  |  1997-05-05  |  1.7 KB  |  77 lines

  1. /* Stack.m created by ovidiu on Sat 22-Mar-1997 */
  2.  
  3. #import <Foundation/Foundation.h>
  4. #import "GdbDisplayController.h"
  5. #import "DebuggerController_Protocol.h"
  6. #import "NSScannerAddition.h"
  7. #import "Frame.h"
  8. #import "Stack.h"
  9.  
  10. @implementation Stack
  11.  
  12. - init
  13. {
  14.   self = [super init];
  15.   frames = [NSMutableArray new];
  16.   selectedFrame = -1;
  17.   return self;
  18. }
  19.  
  20. - (void)dealloc
  21. {
  22.   [frames release];
  23.   [super dealloc];
  24. }
  25.  
  26. - (void)setGdbController:(GdbDisplayController*)object
  27. {
  28.   gdbController = object;
  29. }
  30.  
  31. - (void)createStackFromGdbBacktrace:(NSString*)gdbOutput
  32.                                type:(GdbOutputType)type
  33. {
  34.   NSScanner* scanner;
  35.  
  36.   /* Ignore other output types. */
  37.   if (type != GDB_OUTPUT_ANNOTATION)
  38.     return;
  39.  
  40.   scanner = [NSScanner scannerWithString:gdbOutput];
  41.  
  42.   [frames removeAllObjects];
  43.   while (![scanner isAtEnd]) {
  44.     NSString* functionAnnotation;
  45.     Frame* frame;
  46.  
  47.     if (![scanner scanUpToString:@"\032\032frame-end\n"
  48.                       intoString:&functionAnnotation])
  49.       break;
  50.     [scanner scanString:@"\032\032frame-end\n" intoString:NULL];
  51.  
  52.     frame = [Frame frameWithAnnotation:functionAnnotation stack:self];
  53.     if (frame)
  54.       [frames addObject:frame];
  55.   }
  56.  
  57.   [gdbController stackChanged];
  58. //  NSLog (@"%@ output = %@", NSStringFromSelector(_cmd), frames);
  59. }
  60.  
  61. - (void)setSelectedFrame:(int)newFrame
  62. {
  63.   if (selectedFrame != newFrame) {
  64.     id frameCmd = [NSString stringWithFormat:@"frame %d", newFrame];
  65.  
  66.     [[[self gdbController] gdbManager]
  67.             executeCmd:frameCmd withTty:YES withAnnotation:NO];
  68.     selectedFrame = newFrame;
  69.   }
  70. }
  71.  
  72. - (int)selectedFrame            { return selectedFrame; }
  73. - (NSArray*)frames            { return frames; }
  74. - (GdbDisplayController*)gdbController    { return gdbController; }
  75.  
  76. @end
  77.