2008-12-25 15:46:41 +00:00
|
|
|
/*
|
|
|
|
** PCDebugger
|
|
|
|
**
|
|
|
|
** Copyright (c) 2008
|
|
|
|
**
|
|
|
|
** Author: Gregory Casamento <greg_casamento@yahoo.com>
|
|
|
|
**
|
|
|
|
** This program is free software; you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation; either version 2 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This program is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with this program; if not, write to the Free Software
|
|
|
|
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
2008-12-16 21:31:41 +00:00
|
|
|
|
|
|
|
#include <AppKit/AppKit.h>
|
|
|
|
#include "PCDebugger.h"
|
2008-12-22 23:45:43 +00:00
|
|
|
#include "PCDebuggerView.h"
|
|
|
|
|
|
|
|
#ifndef NOTIFICATION_CENTER
|
|
|
|
#define NOTIFICATION_CENTER [NSNotificationCenter defaultCenter]
|
|
|
|
#endif
|
2008-12-16 21:31:41 +00:00
|
|
|
|
|
|
|
@implementation PCDebugger
|
2008-12-22 23:45:43 +00:00
|
|
|
- (id) init
|
2008-12-16 21:31:41 +00:00
|
|
|
{
|
2008-12-22 00:09:23 +00:00
|
|
|
if((self = [super init]) != nil)
|
2008-12-16 21:31:41 +00:00
|
|
|
{
|
|
|
|
// initialization here...
|
2008-12-22 00:09:23 +00:00
|
|
|
if([NSBundle loadNibNamed: @"PCDebugger" owner: self] == NO)
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
2008-12-22 23:45:43 +00:00
|
|
|
|
|
|
|
[(PCDebuggerView *)debuggerView setDebugger:self];
|
2008-12-16 21:31:41 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2008-12-22 23:45:43 +00:00
|
|
|
-(void) debugExecutableAtPath: (NSString *)filePath
|
2008-12-25 15:46:41 +00:00
|
|
|
withDebugger: (NSString *)debugger
|
2008-12-22 00:09:23 +00:00
|
|
|
{
|
2008-12-22 23:45:43 +00:00
|
|
|
ASSIGN(path,filePath);
|
|
|
|
ASSIGN(debuggerPath,debugger);
|
|
|
|
[debuggerWindow setTitle: [NSString stringWithFormat: @"Debugger (%@)",filePath]];
|
|
|
|
[self show];
|
2008-12-22 00:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) show
|
|
|
|
{
|
|
|
|
[debuggerWindow makeKeyAndOrderFront: self];
|
|
|
|
[self startDebugger];
|
|
|
|
}
|
|
|
|
|
2008-12-16 21:31:41 +00:00
|
|
|
- (void) startDebugger
|
|
|
|
{
|
2008-12-25 15:46:41 +00:00
|
|
|
[debuggerView runProgram: debuggerPath
|
|
|
|
inCurrentDirectory: [path stringByDeletingLastPathComponent]
|
2008-12-27 05:43:41 +00:00
|
|
|
withArguments: [[NSArray alloc] initWithObjects: @"-f", @"--args", path, nil]
|
2008-12-25 15:46:41 +00:00
|
|
|
logStandardError: YES];
|
2008-12-22 23:45:43 +00:00
|
|
|
}
|
|
|
|
|
2008-12-16 21:31:41 +00:00
|
|
|
- (void) awakeFromNib
|
|
|
|
{
|
2008-12-22 00:09:23 +00:00
|
|
|
[debuggerView setFont: [NSFont userFixedPitchFontOfSize: 0]];
|
2008-12-25 15:46:41 +00:00
|
|
|
[debuggerWindow setFrameAutosaveName: @"PCDebuggerWindow"];
|
2008-12-22 00:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSWindow *)debuggerWindow
|
|
|
|
{
|
|
|
|
return debuggerWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setDebuggerWindow: (NSWindow *)window
|
|
|
|
{
|
2008-12-25 15:46:41 +00:00
|
|
|
debuggerWindow = window;
|
2008-12-22 00:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSView *)debuggerView
|
|
|
|
{
|
|
|
|
return debuggerView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setDebuggerView: (id)view
|
|
|
|
{
|
2008-12-25 15:46:41 +00:00
|
|
|
debuggerView = view;
|
2008-12-22 00:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)path
|
|
|
|
{
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setPath:(NSString *)p
|
|
|
|
{
|
|
|
|
ASSIGN(path,p);
|
2008-12-16 21:31:41 +00:00
|
|
|
}
|
|
|
|
@end
|