Add capability to debugger to focus on file and line which has been stopped on

This commit is contained in:
Gregory John Casamento 2021-08-01 17:01:58 -04:00
parent 25f423bebd
commit 56d789e232
7 changed files with 64 additions and 1 deletions

View file

@ -554,5 +554,19 @@ NSString *PCEditorDidResignActiveNotification =
[editor scrollToLineNumber: [line integerValue]];
}
- (void)gotoFile: (NSString *)fileName atLine: (NSUInteger)line
{
id<CodeEditor> editor = [self openEditorForFile: fileName
editable: YES
windowed: NO];
PCProject *project = [_projectManager rootActiveProject];
[[project projectBrowser] setPath: fileName];
[_projectManager openFileAtPath: fileName];
// [self orderFrontEditorForFile:fileName];
[editor scrollToLineNumber: line];
}
@end

View file

@ -1124,6 +1124,7 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
// ============================================================================
- (void)openFileAtPath:(NSString *)filePath
windowed:(BOOL)windowed
{
editorManager = [self editorManager];
@ -1131,11 +1132,17 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
{
[editorManager openEditorForFile:filePath
editable:YES
windowed:YES];
windowed:windowed];
[editorManager orderFrontEditorForFile:filePath];
}
}
- (void)openFileAtPath:(NSString *)filePath
{
[self openFileAtPath: filePath windowed: YES];
}
- (void)openFile
{
NSArray *files = nil;

View file

@ -69,6 +69,7 @@
- (NSArray *)allEditors;
- (void)closeActiveEditor:(id)sender;
- (void)closeEditorForFile:(NSString *)file;
- (void)gotoFile: (NSString *)fileName atLine: (NSUInteger)line;
- (NSArray *)modifiedFiles;
- (BOOL)hasModifiedFiles;

View file

@ -164,6 +164,7 @@ extern NSString *PCActiveProjectDidChangeNotification;
// Also called by PCAppController
- (void)openFileAtPath:(NSString *)filePath;
- (void)openFileAtPath:(NSString *)filePath windowed: (BOOL)windowed;
- (void)openFile;
- (void)newFile;
- (BOOL)saveFile;

View file

@ -379,6 +379,29 @@
[debugger setLastLineNumberParsed: NSNotFound];
}
}
if ([dictionaryName isEqualToString: @"thread-selected"])
{
NSDictionary *d = [dict objectForKey: @"frame"];
NSString *fileName;
NSString *lineNum;
fileName = [d objectForKey:@"fullname"];
lineNum = [d objectForKey:@"line"];
NSLog(@"parsed from GDB thread-selected: %@:%@", fileName, lineNum);
if (fileName != nil && lineNum != nil)
{
[debugger setLastFileNameParsed: fileName];
[debugger setLastLineNumberParsed: [lineNum intValue]];
[debugger updateEditor];
}
else
{
[debugger setLastFileNameParsed: nil];
[debugger setLastLineNumberParsed: NSNotFound];
}
}
}
else
{
@ -423,6 +446,7 @@
{
[debugger setLastFileNameParsed: fileName];
[debugger setLastLineNumberParsed: [lineNum intValue]];
[debugger updateEditor];
}
else
{

View file

@ -66,5 +66,6 @@ extern NSString *PCDBDebuggerStartedNotification;
- (void) setLastFileNameParsed: (NSString *)fname;
- (NSUInteger)lastLineNumberParsed;
- (void)setLastLineNumberParsed: (NSUInteger)num;
- (void)updateEditor;
@end

View file

@ -33,6 +33,10 @@
#import "PCDebugger.h"
#import "PCDebuggerView.h"
#import <ProjectCenter/PCProjectManager.h>
#import <ProjectCenter/PCEditorManager.h>
#import "PCAppController.h"
#import "Modules/Preferences/EditorFSC/PCEditorFSCPrefs.h"
#import "PCDebuggerWrapperProtocol.h"
#import "GDBWrapper.h"
@ -306,6 +310,17 @@ NSString *PCDBDebuggerStartedNotification = @"PCDBDebuggerStartedNotification";
lastLineNumberParsed = num;
}
- (void) updateEditor
{
NSLog(@"****************** UPDATE EDITOR HIT ***********************");
PCAppController *controller = (PCAppController *)[NSApp delegate];
PCProjectManager *pm = [controller projectManager];
PCEditorManager *em = [pm editorManager];
[em gotoFile: lastFileNameParsed
atLine: lastLineNumberParsed];
NSLog(@"****************** UPDATE EDITOR HIT ***********************");
}
// kill process
- (void) interrupt
{