move debugger arguments down into the wrapper, since they are GDB specific. Interpret now the Path as the executable path, requiring the debugger path to be set earlier in the wrapper setup

This commit is contained in:
Riccardo Mottola 2021-07-15 00:03:48 +02:00
parent 08cd658b6d
commit 725da9e9c8
7 changed files with 28 additions and 11 deletions

View file

@ -44,6 +44,7 @@ typedef enum PCDebuggerOutputType_enum {
@interface GDBWrapper : NSObject <PCDebuggerWrapperProtocol> @interface GDBWrapper : NSObject <PCDebuggerWrapperProtocol>
{ {
NSString *debuggerPath;
PCDebugger *debugger; PCDebugger *debugger;
NSTextView *tView; NSTextView *tView;
NSTask *task; NSTask *task;

View file

@ -91,6 +91,21 @@
} }
} }
- (NSString *)debuggerPath
{
return debuggerPath;
}
- (void)setDebuggerPath:(NSString *)path
{
if (debuggerPath != path)
{
[debuggerPath release];
debuggerPath = path;
[debuggerPath retain];
}
}
- (BOOL)debuggerStarted - (BOOL)debuggerStarted
{ {
return debuggerStarted; return debuggerStarted;
@ -677,16 +692,19 @@
*/ */
- (void) runProgram: (NSString *)path - (void) runProgram: (NSString *)path
inCurrentDirectory: (NSString *)directory inCurrentDirectory: (NSString *)directory
withArguments: (NSArray *)array
logStandardError: (BOOL)logError logStandardError: (BOOL)logError
{ {
NSPipe *inPipe; NSPipe *inPipe;
NSPipe *outPipe; NSPipe *outPipe;
NSArray *argArray;
argArray = [[NSArray alloc] initWithObjects: @"--interpreter=mi", @"-f", path, nil];
task = [[NSTask alloc] init]; task = [[NSTask alloc] init];
[task setArguments: array]; [task setArguments: argArray];
[argArray release];
[task setCurrentDirectoryPath: directory]; [task setCurrentDirectoryPath: directory];
[task setLaunchPath: path]; [task setLaunchPath: debuggerPath];
inPipe = [NSPipe pipe]; inPipe = [NSPipe pipe];
outPipe = [NSPipe pipe]; outPipe = [NSPipe pipe];
@ -767,6 +785,7 @@
[debuggerColor release]; [debuggerColor release];
[messageColor release]; [messageColor release];
[errorColor release]; [errorColor release];
[debuggerPath release];
[debugger release]; [debugger release];
[tView release]; [tView release];
[super dealloc]; [super dealloc];

View file

@ -44,7 +44,6 @@ extern NSString *PCDBDebuggerStartedNotification;
id debuggerWindow; id debuggerWindow;
id statusField; id statusField;
NSString *executablePath; NSString *executablePath;
NSString *debuggerPath;
int subProcessId; int subProcessId;
NSDictionary *lastInfoParsed; NSDictionary *lastInfoParsed;
NSString *lastFileNameParsed; NSString *lastFileNameParsed;

View file

@ -171,7 +171,7 @@ NSString *PCDBDebuggerStartedNotification = @"PCDBDebuggerStartedNotification";
withDebugger: (NSString *)debugger withDebugger: (NSString *)debugger
{ {
ASSIGN(executablePath,filePath); ASSIGN(executablePath,filePath);
ASSIGN(debuggerPath,debugger); [debuggerWrapper setDebuggerPath: debugger];
[debuggerWindow setTitle: [NSString stringWithFormat: @"Debugger (%@)",filePath]]; [debuggerWindow setTitle: [NSString stringWithFormat: @"Debugger (%@)",filePath]];
[self show]; [self show];
} }
@ -185,9 +185,8 @@ NSString *PCDBDebuggerStartedNotification = @"PCDBDebuggerStartedNotification";
- (void) startDebugger - (void) startDebugger
{ {
[debuggerView runProgram: debuggerPath [debuggerView runProgram: executablePath
inCurrentDirectory: [executablePath stringByDeletingLastPathComponent] inCurrentDirectory: [executablePath stringByDeletingLastPathComponent]
withArguments: [[NSArray alloc] initWithObjects: @"--interpreter=mi", @"-f", executablePath, nil] // FIXME gdb dependent - should be generalized in the wrapepr
logStandardError: YES]; logStandardError: YES];
} }

View file

@ -39,7 +39,6 @@
- (void) runProgram: (NSString *)path - (void) runProgram: (NSString *)path
inCurrentDirectory: (NSString *)directory inCurrentDirectory: (NSString *)directory
withArguments: (NSArray *)array
logStandardError: (BOOL)logError; logStandardError: (BOOL)logError;
- (void) putString: (NSString *)string; - (void) putString: (NSString *)string;

View file

@ -72,12 +72,10 @@
*/ */
- (void) runProgram: (NSString *)path - (void) runProgram: (NSString *)path
inCurrentDirectory: (NSString *)directory inCurrentDirectory: (NSString *)directory
withArguments: (NSArray *)array
logStandardError: (BOOL)logError logStandardError: (BOOL)logError
{ {
[[debugger debuggerWrapper] runProgram: path [[debugger debuggerWrapper] runProgram: path
inCurrentDirectory: directory inCurrentDirectory: directory
withArguments: array
logStandardError: logError]; logStandardError: logError];
} }

View file

@ -42,11 +42,13 @@
- (PCDebugger *)debugger; - (PCDebugger *)debugger;
- (void)setDebugger:(PCDebugger *)dbg; - (void)setDebugger:(PCDebugger *)dbg;
- (NSString *)debuggerPath;
- (void)setDebuggerPath:(NSString *)path;
- (BOOL)debuggerStarted; - (BOOL)debuggerStarted;
- (void) runProgram: (NSString *)path - (void) runProgram: (NSString *)path
inCurrentDirectory: (NSString *)directory inCurrentDirectory: (NSString *)directory
withArguments: (NSArray *)array
logStandardError: (BOOL)logError; logStandardError: (BOOL)logError;
- (void)logString:(NSString *)str - (void)logString:(NSString *)str