From: Rejean Loyer Date: Fri, 6 Sep 2013 16:00:25 +0000 (-0400) Subject: ide;debugger; (#968) handle breakpoints by project correctly. X-Git-Tag: 0.44.09.9~241 X-Git-Url: https://ecere.com/cgi-bin/gitweb.cgi?p=sdk;a=commitdiff_plain;h=0de8ceef742f54e87f1c2f43158548efbef0ce72 ide;debugger; (#968) handle breakpoints by project correctly. - wait for libraries to be loaded before setting breakpoints in added projects. - drop all breakpoints from removed project --- diff --git a/ide/src/debugger/Debugger.ec b/ide/src/debugger/Debugger.ec index b7b9c2c..10ece58 100644 --- a/ide/src/debugger/Debugger.ec +++ b/ide/src/debugger/Debugger.ec @@ -551,6 +551,7 @@ class Debugger GdbThread gdbThread { debugger = this }; bool entryPoint; + Map projectsLibraryLoaded { }; Timer gdbTimer { @@ -863,6 +864,7 @@ class Debugger codeEditor = null; entryPoint = false; + projectsLibraryLoaded.Free(); /*GdbThread gdbThread Timer gdbTimer*/ @@ -1568,7 +1570,7 @@ class Debugger } } ide.workspace.bpCount++; - bp = { line = lineNumber, type = user, enabled = true, level = -1 }; + bp = { line = lineNumber, type = user, enabled = true, level = -1, project = prj }; ide.workspace.breakpoints.Add(bp); bp.absoluteFilePath = absolutePath; bp.relativeFilePath = relativePath; @@ -2023,7 +2025,7 @@ class Debugger { char * s; _dpl2(_dpct, dplchan::debuggerBreakpoints, 0, "Debugger::SetBreakpoint(", s=bp.CopyLocationString(false), ", ", removePath ? "**** removePath(true) ****" : "", ") -- ", bp.type); delete s; breakpointError = false; - if(symbols && bp.enabled) + if(symbols && bp.enabled && (!bp.project || bp.project == ide.project || projectsLibraryLoaded[bp.project.name])) { char * location = bp.CopyLocationString(removePath); sentBreakInsert = true; @@ -2342,7 +2344,8 @@ class Debugger targeted = false; modules = false; needReset = false; - + projectsLibraryLoaded.Free(); + ide.outputView.ShowClearSelectTab(debug); ide.outputView.debugBox.Logf($"Starting debug mode\n"); @@ -4032,7 +4035,9 @@ class Debugger match = !fstrcmp(prjTargetPath, path); } } - if(!match) + if(match) + projectsLibraryLoaded[prj.name] = true; + else ide.outputView.debugBox.Logf($"Loaded library %s doesn't match the %s target of the %s added project.\n", path, prjTargetPath, prj.topNode.name); break; } @@ -4574,6 +4579,8 @@ class Breakpoint : struct property char * relativeFilePath { set { delete relativeFilePath; if(value) relativeFilePath = CopyString(value); } } char * absoluteFilePath; property char * absoluteFilePath { set { delete absoluteFilePath; if(value) absoluteFilePath = CopyString(value); } } + char * location; + property char * location { set { delete location; if(value) location = CopyString(value); } } int line; bool enabled; int hits; @@ -4585,6 +4592,69 @@ class Breakpoint : struct BreakpointType type; DataRow row; GdbDataBreakpoint bp; + Project project; + + void ParseLocation() + { + char * prjName = null; + char * filePath = null; + char * file; + char * line; + char fullPath[MAX_LOCATION]; + ProjectNode node; + if(location[0] == '\(' && location[1] && (file = strchr(location+2, '\)')) && file[1]) + { + prjName = new char[file-location]; + strncpy(prjName, location+1, file-location-1); + prjName[file-location-1] = '\0'; + file++; + } + else + file = location; + if((line = strchr(file+1, ':'))) + { + filePath = new char[strlen(file)+1]; + strncpy(filePath, file, line-file); + filePath[line-file] = '\0'; + line++; + } + else + filePath = CopyString(file); + property::relativeFilePath = filePath; + if(prjName) + { + for(prj : ide.workspace.projects) + { + if(!strcmp(prjName, prj.name)) + { + node = prj.topNode.FindWithPath(filePath, false); + if(node) + { + node.GetFullFilePath(fullPath); + property::absoluteFilePath = fullPath; + project = prj; + break; + } + } + } + if(line[0]) + this.line = atoi(line); + } + else + { + node = ide.projectView.project.topNode.Find(filePath, false); + if(node) + { + node.GetFullFilePath(fullPath); + property::absoluteFilePath = fullPath; + } + project = ide.project; + } + if(!absoluteFilePath) + property::absoluteFilePath = ""; + delete prjName; + delete filePath; + } char * CopyLocationString(bool removePath) { @@ -4616,7 +4686,7 @@ class Breakpoint : struct char * location; char * loc = CopyLocationString(false); Project prj = null; - for(p : ide.workspace.projects) + for(p : ide.workspace.projects; p != ide.workspace.projects.firstIterator.data) { if(p.topNode.FindByFullPath(absoluteFilePath, false)) { @@ -4638,7 +4708,9 @@ class Breakpoint : struct { if(relativeFilePath && relativeFilePath[0]) { - f.Printf(" * %d,%d,%d,%d,%s\n", enabled ? 1 : 0, ignore, level, line, relativeFilePath); + char * location = CopyUserLocationString(); + f.Printf(" * %d,%d,%d,%d,%s\n", enabled ? 1 : 0, ignore, level, line, location); + delete location; if(condition) f.Printf(" ~ %s\n", condition.expression); } @@ -4652,6 +4724,7 @@ class Breakpoint : struct delete function; delete relativeFilePath; delete absoluteFilePath; + delete location; } ~Breakpoint() diff --git a/ide/src/ide.ec b/ide/src/ide.ec index fa2957b..518179c 100644 --- a/ide/src/ide.ec +++ b/ide/src/ide.ec @@ -2262,7 +2262,8 @@ class IDEWorkSpace : Window CreateProjectView(workspace, filePath); document = projectView; - workspace.DropInvalidBreakpoints(); + workspace.ParseLoadedBreakpoints(); + workspace.DropInvalidBreakpoints(null); workspace.Save(); ide.projectView.ShowOutputBuildLog(true); diff --git a/ide/src/project/Workspace.ec b/ide/src/project/Workspace.ec index 9e67fe6..ad1f9f5 100644 --- a/ide/src/project/Workspace.ec +++ b/ide/src/project/Workspace.ec @@ -469,7 +469,7 @@ public: for(s : dirs) sourceDirs.Add(CopyString(s)); - DropInvalidBreakpoints(); + DropInvalidBreakpoints(null); delete dirs; } @@ -480,7 +480,8 @@ public: if(it.Find(project)) it.Remove(); - DropInvalidBreakpoints(); + for(bp : breakpoints) + DropInvalidBreakpoints(project); modified = true; ide.findInFilesDialog.RemoveProjectItem(project); ide.UpdateToolBarActiveConfigs(false); @@ -545,10 +546,15 @@ public: char * currentLoc = bp.CopyUserLocationString(); if(strcmp(location, currentLoc)) { - // todo, parse location - // if good, make changes to breakpoint, according to execution state delete and place breakpoint - ide.breakpointsView.UpdateBreakpoint(row); // this is the else - //Save(); + char * newLoc; + bp.location = location; + bp.ParseLocation(); + newLoc = bp.CopyUserLocationString(); + if(strcmp(newLoc, currentLoc)) + { + ide.breakpointsView.UpdateBreakpoint(row); + Save(); + } } delete currentLoc; } @@ -649,7 +655,16 @@ public: delete bp; } - void DropInvalidBreakpoints() + void ParseLoadedBreakpoints() + { + for(bp : breakpoints; bp.location) + { + bp.ParseLocation(); + ide.breakpointsView.UpdateBreakpoint(bp.row); + } + } + + void DropInvalidBreakpoints(Project removedProject) { Link bpLink, next; for(bpLink = breakpoints.first; bpLink; bpLink = next) @@ -659,43 +674,57 @@ public: if(bp.type == user) { - Project project = null; - for(p : projects) + if(removedProject) { - if(FindPath(p.topNode, bp.absoluteFilePath)) - { - project = p; - break; - } - // Handle symbol loader modules: + if(bp.project == removedProject) { - char moduleName[MAX_FILENAME]; - char * sl; - GetLastDirectory(bp.absoluteFilePath, moduleName); - // Tweak for automatically resolving symbol loader modules - sl = strstr(moduleName, ".main.ec"); - if(sl && (*sl = 0, !strcmpi(moduleName, p.name))) - { - project = p; - break; - } + ide.breakpointsView.RemoveBreakpoint(bp); + RemoveBreakpoint(bp); } } - if(!project) + else { - bool found = false; - for(dir : sourceDirs) + Project project = bp.project; + if(!project) { - if(IsPathInsideOf(bp.absoluteFilePath, dir)) + for(p : projects) { - found = true; - break; + if(FindPath(p.topNode, bp.absoluteFilePath)) + { + project = p; + break; + } + // Handle symbol loader modules: + { + char moduleName[MAX_FILENAME]; + char * sl; + GetLastDirectory(bp.absoluteFilePath, moduleName); + // Tweak for automatically resolving symbol loader modules + sl = strstr(moduleName, ".main.ec"); + if(sl && (*sl = 0, !strcmpi(moduleName, p.name))) + { + project = p; + break; + } + } } } - if(!found) + if(!project) { - ide.breakpointsView.RemoveBreakpoint(bp); - RemoveBreakpoint(bp); + bool found = false; + for(dir : sourceDirs) + { + if(IsPathInsideOf(bp.absoluteFilePath, dir)) + { + found = true; + break; + } + } + if(!found) + { + ide.breakpointsView.RemoveBreakpoint(bp); + RemoveBreakpoint(bp); + } } } } @@ -873,10 +902,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile) bp = { type = user, enabled = enabled, ignore = ignore, level = level, line = line }; workspace.breakpoints.Add(bp); - bp.relativeFilePath = strFile; - bp.absoluteFilePath = workspace.GetAbsolutePathFromRelative(strFile); - if(!bp.absoluteFilePath) - bp.absoluteFilePath = CopyString(""); + bp.location = strFile; } } } @@ -1134,10 +1160,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile) bp = { type = user, enabled = enabled, level = -1 }; workspace.breakpoints.Add(bp); bp.line = atoi(lineNum); - bp.relativeFilePath = relPath; - bp.absoluteFilePath = workspace.GetAbsolutePathFromRelative(relPath); - if(!bp.absoluteFilePath) - bp.absoluteFilePath = ""; + bp.location = relPath; } } }