mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-03-14 06:31:31 +00:00
* English.lproj/ProjectCenter.gorm: Minor changes.
* Framework/PCEditorManager.m: Cleanup. * Framework/PCProjectLauncher.m: Cleanup. * GNUmakefile: New module. * Headers/Protocols/CodeDebugger.h: New methods * Modules/Debuggers/ProjectCenter/GNUmakefile: Added debugger to resources. * Modules/Debuggers/ProjectCenter/PCDebugger.h * Modules/Debuggers/ProjectCenter/PCDebugger.m: Changes to talk to debugger task * Modules/Debuggers/ProjectCenter/Resources/PCDebugger.gorm: Debugger gorm file. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@27407 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
94baea2b63
commit
50ac933d43
11 changed files with 243 additions and 55 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2008-12-22 18:36-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* English.lproj/ProjectCenter.gorm: Minor changes.
|
||||
* Framework/PCEditorManager.m: Cleanup.
|
||||
* Framework/PCProjectLauncher.m: Cleanup.
|
||||
* GNUmakefile: New module.
|
||||
* Headers/Protocols/CodeDebugger.h: New methods
|
||||
* Modules/Debuggers/ProjectCenter/GNUmakefile: Added debugger
|
||||
to resources.
|
||||
* Modules/Debuggers/ProjectCenter/PCDebugger.h
|
||||
* Modules/Debuggers/ProjectCenter/PCDebugger.m: Changes to talk to
|
||||
debugger task
|
||||
* Modules/Debuggers/ProjectCenter/Resources/PCDebugger.gorm: Debugger
|
||||
gorm file.
|
||||
|
||||
2008-12-23 Sergii Stoian <stoyan255@gmail.com>
|
||||
|
||||
* Documentatio/TODO: move unfinshed tasks from 0.5 to 0.6 release
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -179,7 +179,6 @@ NSString *PCEditorDidResignActiveNotification =
|
|||
protocol:@protocol(CodeParser)
|
||||
fileName:fileName];
|
||||
[editor setParser:parser];
|
||||
|
||||
[editor openFileAtPath:filePath
|
||||
editorManager:self
|
||||
editable:editable];
|
||||
|
|
|
@ -29,11 +29,12 @@
|
|||
#include <ProjectCenter/PCProject.h>
|
||||
#include <ProjectCenter/PCProjectManager.h>
|
||||
#include <ProjectCenter/PCProjectLauncher.h>
|
||||
|
||||
#include <ProjectCenter/PCBundleManager.h>
|
||||
#include <ProjectCenter/PCButton.h>
|
||||
|
||||
#include <ProjectCenter/PCLogController.h>
|
||||
|
||||
#include <Protocols/CodeDebugger.h>
|
||||
|
||||
#ifndef NOTIFICATION_CENTER
|
||||
#define NOTIFICATION_CENTER [NSNotificationCenter defaultCenter]
|
||||
#endif
|
||||
|
@ -208,9 +209,9 @@ enum {
|
|||
NSString *fp = nil;
|
||||
NSString *pn = nil;
|
||||
NSString *gdbPath = nil;
|
||||
NSArray *args = nil;
|
||||
NSDistantObject <Terminal> *terminal;
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
PCBundleManager *bundleManager = [[project projectManager] bundleManager];
|
||||
id<CodeDebugger> debugger;
|
||||
|
||||
// Check if project type is executable
|
||||
if (![project isExecutable])
|
||||
|
@ -222,23 +223,6 @@ enum {
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: Is it possible to somehow support users that don't have
|
||||
* Terminal installed ? Maybe with reduced functionality.
|
||||
*/
|
||||
|
||||
// Get the Terminal application
|
||||
terminal = (NSDistantObject<Terminal> *)[NSConnection
|
||||
rootProxyForConnectionWithRegisteredName:@"Terminal" host:nil];
|
||||
|
||||
if (terminal == nil)
|
||||
{
|
||||
NSRunAlertPanel(@"Debug",
|
||||
@"Run Terminal application first",
|
||||
@"Close",nil,nil);
|
||||
[debugButton setState:NSOffState];
|
||||
return;
|
||||
}
|
||||
|
||||
/* We try in the order:
|
||||
* xxx.debug/xxx (gnustep-make v1, application),
|
||||
|
@ -263,17 +247,16 @@ enum {
|
|||
}
|
||||
}
|
||||
|
||||
// PCLogInfo(self, @"debug: %@", fp);
|
||||
|
||||
if ([fm isExecutableFileAtPath:fp] == NO)
|
||||
{
|
||||
NSRunAlertPanel(@"Debug",
|
||||
@"Can't execute %@!",
|
||||
@"No executable! Please build the project first.",
|
||||
@"Abort",nil,nil,pn);
|
||||
[debugButton setState:NSOffState];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Debugger
|
||||
gdbPath = [[NSUserDefaults standardUserDefaults] objectForKey:Debugger];
|
||||
if (gdbPath == nil)
|
||||
|
@ -290,17 +273,16 @@ enum {
|
|||
return;
|
||||
}
|
||||
|
||||
// Task
|
||||
args = [[NSArray alloc] initWithObjects:gdbPath, @"--args", fp, nil];
|
||||
|
||||
[terminal terminalRunProgram:AUTORELEASE(gdbPath)
|
||||
withArguments:args
|
||||
inDirectory:nil
|
||||
properties:nil];
|
||||
// Debugger
|
||||
debugger = [bundleManager objectForBundleType: @"debugger"
|
||||
protocol: @protocol(CodeDebugger)
|
||||
fileName: [fp stringByDeletingLastPathComponent]];
|
||||
[debugger debugExecutableAtPath: fp
|
||||
withDebugger: gdbPath];
|
||||
|
||||
[debugButton setState:NSOffState];
|
||||
|
||||
AUTORELEASE(args);
|
||||
// turn debug button off...
|
||||
// [debugButton setState:NSOffState];
|
||||
}
|
||||
|
||||
- (void)run:(id)sender
|
||||
|
|
|
@ -89,7 +89,8 @@ Modules/Projects/Library/Library.project \
|
|||
Modules/Projects/ResourceSet/ResourceSet.project \
|
||||
Modules/Projects/Tool/Tool.project \
|
||||
Modules/Editors/ProjectCenter/ProjectCenter.editor \
|
||||
Modules/Parsers/ProjectCenter/ProjectCenter.parser
|
||||
Modules/Parsers/ProjectCenter/ProjectCenter.parser \
|
||||
Modules/Debuggers/ProjectCenter/ProjectCenter.debugger
|
||||
|
||||
#
|
||||
# Localization
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
// ==== Initialization
|
||||
// ===========================================================================
|
||||
|
||||
- (id)initWithPath: (NSString *)filePath;
|
||||
+ (id)debugExecutableAtPath:(NSString *)filePath;
|
||||
- (void)debugExecutableAtPath:(NSString *)filePath withDebugger: (NSString *)debuggerPath;
|
||||
- (void)show;
|
||||
|
||||
// ===========================================================================
|
||||
|
|
|
@ -20,7 +20,8 @@ ProjectCenter_LIBRARIES_DEPEND_UPON +=
|
|||
# Resource files
|
||||
#
|
||||
ProjectCenter_RESOURCE_FILES= \
|
||||
|
||||
Resources/PCDebugger.gorm \
|
||||
Resources/Info.table
|
||||
#
|
||||
# Header files
|
||||
#
|
||||
|
|
|
@ -12,10 +12,15 @@
|
|||
id debuggerView;
|
||||
id debuggerWindow;
|
||||
NSString *path;
|
||||
NSString *debuggerPath;
|
||||
NSTask *debuggerTask;
|
||||
NSFileHandle *standardInput;
|
||||
NSFileHandle *standardOutput;
|
||||
FILE *stdInStream;
|
||||
NSPipe *standardInput;
|
||||
NSPipe *standardOutput;
|
||||
NSPipe *standardError;
|
||||
NSFileHandle *readHandle;
|
||||
NSFileHandle *errorReadHandle;
|
||||
BOOL _isLogging;
|
||||
BOOL _isErrorLogging;
|
||||
}
|
||||
|
||||
- (void)putChar:(unichar)ch;
|
||||
|
|
|
@ -2,10 +2,14 @@
|
|||
|
||||
#include <AppKit/AppKit.h>
|
||||
#include "PCDebugger.h"
|
||||
#import "PCDebuggerView.h"
|
||||
#include "PCDebuggerView.h"
|
||||
|
||||
#ifndef NOTIFICATION_CENTER
|
||||
#define NOTIFICATION_CENTER [NSNotificationCenter defaultCenter]
|
||||
#endif
|
||||
|
||||
@implementation PCDebugger
|
||||
- (id) initWithPath: (NSString *)filePath
|
||||
- (id) init
|
||||
{
|
||||
if((self = [super init]) != nil)
|
||||
{
|
||||
|
@ -14,14 +18,19 @@
|
|||
{
|
||||
return nil;
|
||||
}
|
||||
[(PCDebuggerView *)debuggerView setDebugger:self];
|
||||
|
||||
[(PCDebuggerView *)debuggerView setDebugger:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+(id) debugExecutableAtPath: (NSString *)filePath
|
||||
-(void) debugExecutableAtPath: (NSString *)filePath
|
||||
withDebugger: (NSString *)debugger
|
||||
{
|
||||
return [[self alloc] initWithPath: filePath];
|
||||
ASSIGN(path,filePath);
|
||||
ASSIGN(debuggerPath,debugger);
|
||||
[debuggerWindow setTitle: [NSString stringWithFormat: @"Debugger (%@)",filePath]];
|
||||
[self show];
|
||||
}
|
||||
|
||||
- (void) show
|
||||
|
@ -30,19 +39,196 @@
|
|||
[self startDebugger];
|
||||
}
|
||||
|
||||
- (void)logErrorString:(NSString *)string
|
||||
{
|
||||
/*
|
||||
NSArray *items;
|
||||
|
||||
items = [self parseErrorLine:string];
|
||||
if (items)
|
||||
{
|
||||
[errorArray addObjectsFromArray:items];
|
||||
[errorOutput reloadData];
|
||||
[errorOutput scrollRowToVisible:[errorArray count]-1];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
- (void)logString:(NSString *)str
|
||||
error:(BOOL)yn
|
||||
newLine:(BOOL)newLine
|
||||
{
|
||||
NSTextView *out = debuggerView;
|
||||
|
||||
[out replaceCharactersInRange:
|
||||
NSMakeRange([[out string] length],0) withString:str];
|
||||
|
||||
if (newLine)
|
||||
{
|
||||
[out replaceCharactersInRange:
|
||||
NSMakeRange([[out string] length], 0) withString:@"\n"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[out replaceCharactersInRange:
|
||||
NSMakeRange([[out string] length], 0) withString:@" "];
|
||||
}
|
||||
|
||||
[out scrollRangeToVisible:NSMakeRange([[out string] length], 0)];
|
||||
[out setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)logData:(NSData *)data
|
||||
error:(BOOL)yn
|
||||
{
|
||||
NSString *dataString;
|
||||
// NSRange newLineRange;
|
||||
// NSRange lineRange;
|
||||
// NSString *lineString;
|
||||
|
||||
dataString = [[NSString alloc]
|
||||
initWithData:data
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
|
||||
// Process new data
|
||||
/*
|
||||
lineRange.location = 0;
|
||||
[errorString appendString:dataString];
|
||||
while (newLineRange.location != NSNotFound)
|
||||
{
|
||||
newLineRange = [errorString rangeOfString:@"\n"];
|
||||
if (newLineRange.location < [errorString length])
|
||||
{
|
||||
lineRange.length = newLineRange.location+1;
|
||||
lineString = [errorString substringWithRange:lineRange];
|
||||
[errorString deleteCharactersInRange:lineRange];
|
||||
|
||||
// [self parseBuildLine:lineString];
|
||||
// if (yn)
|
||||
// {
|
||||
// [self logErrorString:lineString];
|
||||
// }
|
||||
|
||||
[self logString:lineString error:yn newLine:NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
newLineRange.location = NSNotFound;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
*/
|
||||
[self logString:dataString error:yn newLine:NO];
|
||||
|
||||
RELEASE(dataString);
|
||||
}
|
||||
|
||||
- (void)logStdOut:(NSNotification *)aNotif
|
||||
{
|
||||
NSData *data;
|
||||
|
||||
if ((data = [readHandle availableData]) && [data length] > 0)
|
||||
{
|
||||
[self logData:data error:NO];
|
||||
}
|
||||
|
||||
if (debuggerTask)
|
||||
{
|
||||
[readHandle waitForDataInBackgroundAndNotify];
|
||||
}
|
||||
else
|
||||
{
|
||||
_isLogging = NO;
|
||||
[NOTIFICATION_CENTER removeObserver:self
|
||||
name:NSFileHandleDataAvailableNotification
|
||||
object:readHandle];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)logErrOut:(NSNotification *)aNotif
|
||||
{
|
||||
NSData *data;
|
||||
|
||||
if ((data = [errorReadHandle availableData]) && [data length] > 0)
|
||||
{
|
||||
[self logData:data error:YES];
|
||||
}
|
||||
|
||||
if (debuggerTask)
|
||||
{
|
||||
[errorReadHandle waitForDataInBackgroundAndNotify];
|
||||
}
|
||||
else
|
||||
{
|
||||
_isErrorLogging = NO;
|
||||
[NOTIFICATION_CENTER removeObserver:self
|
||||
name:NSFileHandleDataAvailableNotification
|
||||
object:errorReadHandle];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) startDebugger
|
||||
{
|
||||
debuggerTask = [NSTask launchedTaskWithLaunchPath: @"/usr/bin/gdb"
|
||||
arguments: NULL];
|
||||
standardInput = [debuggerTask standardInput];
|
||||
standardOutput = [debuggerTask standardOutput];
|
||||
standardOutput = [NSPipe pipe];
|
||||
standardError = [NSPipe pipe];
|
||||
|
||||
readHandle = [standardOutput fileHandleForReading];
|
||||
[readHandle waitForDataInBackgroundAndNotify];
|
||||
|
||||
stdInStream = fdopen([standardInput fileDescriptor], "r");
|
||||
if (stdInStream == NULL)
|
||||
[NOTIFICATION_CENTER addObserver:self
|
||||
selector:@selector(logStdOut:)
|
||||
name:NSFileHandleDataAvailableNotification
|
||||
object:readHandle];
|
||||
|
||||
_isLogging = YES;
|
||||
standardError = [NSPipe pipe];
|
||||
errorReadHandle = [standardError fileHandleForReading];
|
||||
[errorReadHandle waitForDataInBackgroundAndNotify];
|
||||
|
||||
[NOTIFICATION_CENTER addObserver:self
|
||||
selector:@selector(logErrOut:)
|
||||
name:NSFileHandleDataAvailableNotification
|
||||
object:errorReadHandle];
|
||||
_isErrorLogging = YES;
|
||||
|
||||
// [statusField setStringValue:buildStatus];
|
||||
|
||||
// Run make task
|
||||
[debuggerView setString:@""];
|
||||
[NOTIFICATION_CENTER addObserver:self
|
||||
selector:@selector(debuggerDidTerminate:)
|
||||
name:NSTaskDidTerminateNotification
|
||||
object:nil];
|
||||
|
||||
|
||||
debuggerTask = [[NSTask alloc] init];
|
||||
[debuggerTask setArguments: [[NSArray alloc] initWithObjects: @"--args", path, nil]];
|
||||
[debuggerTask setCurrentDirectoryPath: [path stringByDeletingLastPathComponent]];
|
||||
[debuggerTask setLaunchPath: debuggerPath];
|
||||
[debuggerTask setStandardOutput: standardOutput];
|
||||
[debuggerTask setStandardError: standardError];
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
NSLog(@"Error creating file stream input to debugger");
|
||||
return;
|
||||
[debuggerTask launch];
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSRunAlertPanel(@"Problem Launching Debugger",
|
||||
[localException reason],
|
||||
@"OK", nil, nil, nil);
|
||||
|
||||
//Clean up after task is terminated
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSTaskDidTerminateNotification
|
||||
object:debuggerTask];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
|
||||
- (void) debuggerDidTerminate: (NSNotification *)notif
|
||||
{
|
||||
[self logString: @"=== Debugger Terminated ===" error: NO newLine:YES];
|
||||
}
|
||||
|
||||
- (void) awakeFromNib
|
||||
|
@ -82,6 +268,6 @@
|
|||
|
||||
- (void)putChar:(unichar)ch
|
||||
{
|
||||
fputc(ch, stdInStream);
|
||||
// fputc(ch, stdInStream);
|
||||
}
|
||||
@end
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue