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

View file

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

View file

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

View file

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

View file

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

View file

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