ide;debugger; (#1003) fixed multiple issues.
authorRejean Loyer <rejean.loyer@gmail.com>
Wed, 18 Sep 2013 16:19:51 +0000 (12:19 -0400)
committerRejean Loyer <rejean.loyer@gmail.com>
Thu, 26 Sep 2013 16:16:51 +0000 (12:16 -0400)
  - invisible working breakpoint
  - insert breakpoint in generated file
  - insert breakpoint in file outside project dir
  - removed nonesense source dir message box
  - fixed bad interaction between lines with multiple breakpoints and step into

ide/src/debugger/Debugger.ec
ide/src/designer/CodeEditor.ec
ide/src/ide.ec
ide/src/project/Project.ec
ide/src/project/ProjectNode.ec
ide/src/project/ProjectView.ec
ide/src/project/Workspace.ec

index cf3e8b5..a4af8d3 100644 (file)
@@ -58,7 +58,7 @@ char * PrintNow()
 
 // use =0 to disable printing of specific channels
 #ifdef _DEBUG_INST
-static enum dplchan { none, gdbProtoIgnored=0/*1*/, gdbProtoUnknown=2, gdbOutput=0/*3*/, gdbCommand=0/*4*/, debuggerCall=0/*5*/, debuggerProblem=6,
+static enum dplchan { none, gdbProtoIgnored=0/*1*/, gdbProtoUnknown=2, gdbOutput=3/*3*/, gdbCommand=4/*4*/, debuggerCall=0/*5*/, debuggerProblem=6,
                         debuggerUserAction=7,debuggerState=8, debuggerBreakpoints=9, debuggerWatches=0/*10*/, debuggerTemp=0 };
 #else
 static enum dplchan { none, gdbProtoIgnored=0, gdbProtoUnknown=0, gdbOutput=0, gdbCommand=0, debuggerCall=0, debuggerProblem=0,
@@ -681,7 +681,7 @@ class Debugger
                      else
                         _dpl2(_dpct, dplchan::debuggerProblem, 0, "Invalid stopItem!");
                      if(bpUser && strcmp(stopItem.frame.addr, bpUser.bp.addr))
-                        bpUser = null;
+                        _dpl2(_dpct, dplchan::debuggerProblem, 0, "Breakpoint bkptno(", stopItem.bkptno, ") address missmatch!");
                   }
                   else
                      _dpl2(_dpct, dplchan::debuggerProblem, 0, "Breakpoint bkptno(", stopItem.bkptno, ") invalid or not found!");
@@ -1225,8 +1225,7 @@ class Debugger
       char relativeFilePath[MAX_LOCATION];
       _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::RunToCursor()");
       _ChangeUserAction(runToCursor);
-      if(!ide.projectView.project.GetRelativePath(absoluteFilePath, relativeFilePath))
-         strcpy(relativeFilePath, absoluteFilePath);
+      WorkspaceGetRelativePath(absoluteFilePath, relativeFilePath, null);
 
       if(bpRunToCursor && bpRunToCursor.inserted && symbols)
       {
@@ -1476,17 +1475,14 @@ class Debugger
       }
    }
 
-   void ToggleBreakpoint(char * fileName, int lineNumber, Project prj)
+   void ToggleBreakpoint(char * fileName, int lineNumber)
    {
-      char winFilePath[MAX_LOCATION];
-      char * absoluteFilePath = GetSlashPathBuffer(winFilePath, fileName);
       char absolutePath[MAX_LOCATION];
-      char relativePath[MAX_LOCATION];
-      char sourceDir[MAX_LOCATION];
       Breakpoint bp = null;
 
       _dpl2(_dpct, dplchan::debuggerBreakpoints, 0, "Debugger::ToggleBreakpoint(", fileName, ":", lineNumber, ")");
-      strcpy(absolutePath, absoluteFilePath);
+
+      GetSlashPathBuffer(absolutePath, fileName);
       for(i : ide.workspace.breakpoints; i.type == user && i.absoluteFilePath && !fstrcmp(i.absoluteFilePath, absolutePath) && i.line == lineNumber)
       {
          bp = i;
@@ -1504,20 +1500,16 @@ class Debugger
       }
       else
       {
-         // FIXED: This is how it should have been... Source locations are only for files not in project
-         // if(IsPathInsideOf(absolutePath, ide.workspace.projectDir))
-         //   MakePathRelative(absolutePath, ide.workspace.projectDir, relativePath);
-         bool result = false;
-         if(prj)
-            result = prj.GetRelativePath(absolutePath, relativePath);
-         else
-            result = ide.projectView.project.GetRelativePath(absolutePath, relativePath);
-         //if(ide.projectView.project.GetRelativePath(absolutePath, relativePath));
-         //else
-         if(!result)
+         Project owner;
+         char relativePath[MAX_LOCATION];
+
+         WorkspaceGetRelativePath(absolutePath, relativePath, &owner);
+
+         if(!owner)
          {
             char title[MAX_LOCATION];
             char directory[MAX_LOCATION];
+            char sourceDir[MAX_LOCATION];
             StripLastDirectory(absolutePath, directory);
             snprintf(title, sizeof(title), $"Provide source files location directory for %s", absolutePath);
             title[sizeof(title)-1] = 0;
@@ -1528,7 +1520,7 @@ class Debugger
                {
                   if(IsPathInsideOf(absolutePath, dir))
                   {
-                     MakePathRelative(absoluteFilePath, dir, relativePath);
+                     MakePathRelative(absolutePath, dir, relativePath);
                      srcDir = dir;
                      break;
                   }
@@ -1541,7 +1533,7 @@ class Debugger
                   if(IsPathInsideOf(absolutePath, sourceDir))
                   {
                      AddSourceDir(sourceDir);
-                     MakePathRelative(absoluteFilePath, sourceDir, relativePath);
+                     MakePathRelative(absolutePath, sourceDir, relativePath);
                      break;
                   }
                   else if(MessageBox { type = yesNo, master = ide, 
@@ -1549,14 +1541,12 @@ class Debugger
                                  text = $"Invalid Source Directory" }.Modal() == no)
                      return;
                }
-               else if(MessageBox { type = yesNo, master = ide, 
-                                 contents = $"You must provide a source directory in order to place a breakpoint in this file.\nWould you like to try again?", 
-                                 text = $"No Source Directory Provided" }.Modal() == no)
+               else
                   return;
             }
          }
          ide.workspace.bpCount++;
-         bp = { line = lineNumber, type = user, enabled = true, level = -1, project = prj };
+         bp = { line = lineNumber, type = user, enabled = true, level = -1, project = owner };
          ide.workspace.breakpoints.Add(bp);
          bp.absoluteFilePath = absolutePath;
          bp.relativeFilePath = relativePath;
@@ -2013,25 +2003,31 @@ class Debugger
       breakpointError = false;
       if(symbols && bp.enabled && (!bp.project || bp.project == ide.project || projectsLibraryLoaded[bp.project.name]))
       {
-         char * location = bp.CopyLocationString(removePath);
          sentBreakInsert = true;
-         GdbCommand(false, "-break-insert %s", location);
-         delete location;
+         if(bp.address)
+            GdbCommand(false, "-break-insert *%s", bp.address);
+         else
+         {
+            char * location = bp.CopyLocationString(removePath);
+            GdbCommand(false, "-break-insert %s", location);
+            delete location;
+         }
          if(!breakpointError)
          {
+            char * address = null;
             if(bpItem && bpItem.multipleBPs && bpItem.multipleBPs.count)
             {
                int count = 0;
                GdbDataBreakpoint first = null;
                for(n : bpItem.multipleBPs)
                {
-                  if(!fstrcmp(n.fullname, bp.absoluteFilePath))
+                  if(!fstrcmp(n.fullname, bp.absoluteFilePath) && !first)
                   {
                      count++;
-                     if(!first)
-                        first = n;
+                     first = n;
+                     break;
                   }
-                  else
+                  /*else
                   {
                      if(n.enabled)
                      {
@@ -2040,29 +2036,38 @@ class Debugger
                      }
                      else
                         _dpl2(_dpct, dplchan::debuggerProblem, 0, "Debugger::SetBreakpoint -- error breakpoint already disabled.");
-                  }
+                  }*/
                }
                if(first)
                {
+                  address = CopyString(first.addr);
                   bpItem.addr = first.addr;
                   bpItem.func = first.func;
                   bpItem.file = first.file;
                   bpItem.fullname = first.fullname;
                   bpItem.line = first.line;
-                  //bpItem.thread-groups = first.thread-groups;
-                  bpItem.multipleBPs.Free();
-                  delete bpItem.multipleBPs;
+                  //bpItem.thread-groups = first.thread-groups;*/
                }
                else if(count == 0)
                   _dpl2(_dpct, dplchan::debuggerProblem, 0, "Debugger::SetBreakpoint -- error multiple breakpoints all disabled.");
                else
                   _dpl2(_dpct, dplchan::debuggerProblem, 0, "Debugger::SetBreakpoint -- error multiple breakpoints in exact same file not supported.");
+               bpItem.multipleBPs.Free();
+               delete bpItem.multipleBPs;
             }
             bp.bp = bpItem;
             bpItem = null;
             bp.inserted = (bp.bp && bp.bp.number && strcmp(bp.bp.number, "0"));
             if(bp.inserted)
                ValidateBreakpoint(bp);
+
+            if(address)
+            {
+               UnsetBreakpoint(bp);
+               bp.address = address;
+               delete address;
+               SetBreakpoint(bp, removePath);
+            }
          }
       }
       return !breakpointError;
@@ -2203,8 +2208,7 @@ class Debugger
       GdbExecCommon();
       if(absoluteFilePath)
       {
-         if(!ide.projectView.project.GetRelativePath(absoluteFilePath, relativeFilePath))
-            strcpy(relativeFilePath, absoluteFilePath);
+         WorkspaceGetRelativePath(absoluteFilePath, relativeFilePath, null);
          GdbCommand(true, "-exec-until %s:%d", relativeFilePath, lineNumber);
       }
       else
@@ -2219,8 +2223,7 @@ class Debugger
       GdbExecCommon();
       if(lineNumber)
       {
-         if(!ide.projectView.project.GetRelativePath(absoluteFilePathOrLocation, relativeFilePath))
-            strcpy(relativeFilePath, absoluteFilePathOrLocation);
+         WorkspaceGetRelativePath(absoluteFilePathOrLocation, relativeFilePath, null);
          GdbCommand(true, "advance %s:%d", relativeFilePath, lineNumber); // should use -exec-advance -- GDB/MI implementation missing
       }
       else
@@ -2562,21 +2565,12 @@ class Debugger
       if(ide.workspace)
       {
          for(bp : ide.workspace.breakpoints)
-         {
-            bp.inserted = false;
-            delete bp.bp;
-         }
+            bp.Reset();
       }
       for(bp : sysBPs)
-      {
-         bp.inserted = false;
-         delete bp.bp;
-      }
+         bp.Reset();
       if(bpRunToCursor)
-      {
-         bpRunToCursor.inserted = false;
-         delete bpRunToCursor.bp;
-      }
+         bpRunToCursor.Reset();
       
       ide.outputView.debugBox.Logf($"Debugging stopped\n");
       ClearBreakDisplay();
@@ -4568,6 +4562,8 @@ class Breakpoint : struct
    DataRow row;
    GdbDataBreakpoint bp;
    Project project;
+   char * address;
+   property char * address { set { delete address; if(value) address = CopyString(value); } }
 
    void ParseLocation()
    {
@@ -4576,7 +4572,6 @@ class Breakpoint : struct
       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];
@@ -4602,10 +4597,8 @@ class Breakpoint : struct
          {
             if(!strcmp(prjName, prj.name))
             {
-               node = prj.topNode.FindWithPath(filePath, false);
-               if(node)
+               if(ProjectGetAbsoluteFromRelativePath(prj, filePath, fullPath))
                {
-                  node.GetFullFilePath(fullPath);
                   property::absoluteFilePath = fullPath;
                   project = prj;
                   break;
@@ -4617,13 +4610,12 @@ class Breakpoint : struct
       }
       else
       {
-         node = ide.projectView.project.topNode.Find(filePath, false);
-         if(node)
+         Project prj = ide.project;
+         if(ProjectGetAbsoluteFromRelativePath(prj, filePath, fullPath))
          {
-            node.GetFullFilePath(fullPath);
             property::absoluteFilePath = fullPath;
+            project = prj;
          }
-         project = ide.project;
       }
       if(!absoluteFilePath)
          property::absoluteFilePath = "";
@@ -4661,12 +4653,15 @@ class Breakpoint : struct
       char * location;
       char * loc = CopyLocationString(false);
       Project prj = null;
-      for(p : ide.workspace.projects; p != ide.workspace.projects.firstIterator.data)
+      if(absoluteFilePath)
       {
-         if(p.topNode.FindByFullPath(absoluteFilePath, false))
+         for(p : ide.workspace.projects; p != ide.workspace.projects.firstIterator.data)
          {
-            prj = p;
-            break;
+            if(p.topNode.FindByFullPath(absoluteFilePath, false))
+            {
+               prj = p;
+               break;
+            }
          }
       }
       if(prj)
@@ -4693,15 +4688,22 @@ class Breakpoint : struct
 
    void Free()
    {
-      if(bp)
-         bp.Free();
-      delete bp;
+      Reset();
       delete function;
       delete relativeFilePath;
       delete absoluteFilePath;
       delete location;
    }
 
+   void Reset()
+   {
+      inserted = false;
+      delete address;
+      if(bp)
+         bp.Free();
+      delete bp;
+   }
+
    ~Breakpoint()
    {
       Free();
@@ -4819,3 +4821,101 @@ void GDBFallBack(Expression exp, String expString)
       exp.type = constantExp;
    }
 }
+
+static Project WorkspaceGetFileOwner(char * absolutePath)
+{
+   Project owner = null;
+   for(prj : ide.workspace.projects)
+   {
+      if(prj.topNode.FindByFullPath(absolutePath, false))
+      {
+         owner = prj;
+         break;
+      }
+   }
+   if(!owner)
+      WorkspaceGetObjectFileNode(absolutePath, &owner);
+   return owner;
+}
+
+static ProjectNode WorkspaceGetObjectFileNode(char * filePath, Project * project)
+{
+   ProjectNode node = null;
+   char ext[MAX_EXTENSION];
+   GetExtension(filePath, ext);
+   if(ext[0])
+   {
+      IntermediateFileType type = IntermediateFileType::FromExtension(ext);
+      if(type)
+      {
+         char fileName[MAX_FILENAME];
+         GetLastDirectory(filePath, fileName);
+         if(fileName[0])
+         {
+            DotMain dotMain = DotMain::FromFileName(fileName);
+            for(prj : ide.workspace.projects)
+            {
+               if((node = prj.FindNodeByObjectFileName(fileName, type, dotMain, null)))
+               {
+                  if(project)
+                     *project = prj;
+                  break;
+               }
+            }
+         }
+      }
+   }
+   return node;
+}
+
+static ProjectNode ProjectGetObjectFileNode(Project project, char * filePath)
+{
+   ProjectNode node = null;
+   char ext[MAX_EXTENSION];
+   GetExtension(filePath, ext);
+   if(ext[0])
+   {
+      IntermediateFileType type = IntermediateFileType::FromExtension(ext);
+      if(type)
+      {
+         char fileName[MAX_FILENAME];
+         GetLastDirectory(filePath, fileName);
+         if(fileName[0])
+         {
+            DotMain dotMain = DotMain::FromFileName(fileName);
+            node = project.FindNodeByObjectFileName(fileName, type, dotMain, null);
+         }
+      }
+   }
+   return node;
+}
+
+static void WorkspaceGetRelativePath(char * absolutePath, char * relativePath, Project * owner)
+{
+   Project prj = WorkspaceGetFileOwner(absolutePath);
+   if(owner)
+      *owner = prj;
+   if(!prj)
+      prj = ide.workspace.projects.firstIterator.data;
+   if(prj)
+   {
+      MakePathRelative(absolutePath, prj.topNode.path, relativePath);
+      MakeSlashPath(relativePath);
+   }
+   else
+      relativePath[0] = '\0';
+}
+
+static bool ProjectGetAbsoluteFromRelativePath(Project project, char * relativePath, char * absolutePath)
+{
+   ProjectNode node = project.topNode.FindWithPath(relativePath, false);
+   if(!node)
+      node = ProjectGetObjectFileNode(project, relativePath);
+   if(node)
+   {
+      strcpy(absolutePath, node.project.topNode.path);
+      PathCat(absolutePath, relativePath);
+      MakeSlashPath(absolutePath);
+   }
+   return node != null;
+}
index 218604c..6338c7d 100644 (file)
@@ -1965,30 +1965,7 @@ class CodeEditor : Window
          if(projectView && fileName)
          {
             int line = editBox.lineNumber + 1;
-            Project prj = null;
-            if(ide && ide.workspace)
-            {
-               for(p : ide.workspace.projects)
-               {
-                  if(p.topNode.FindByFullPath(fileName, false))
-                  {
-                     prj = p;
-                     break;
-                  }
-               }
-               if(!prj)
-               {
-                  for(p : ide.workspace.projects)
-                  {
-                     if(IsPathInsideOf(fileName, p.topNode.path))
-                     {
-                        prj = p;
-                        break;
-                     }
-                  }
-               }
-            }
-            ide.debugger.ToggleBreakpoint(fileName, line, prj);
+            ide.debugger.ToggleBreakpoint(fileName, line);
             Update(null);
          }
          return true;
index f11f276..8c2d331 100644 (file)
@@ -482,33 +482,7 @@ class IDEWorkSpace : Window
          if(debugger.activeFrame && debugger.activeFrame.absoluteFile)
          {
             int line = debugger.activeFrame.line;
-            char name[MAX_LOCATION];
-            Project prj = null;
-            // TOFIX: Improve on this, don't use only filename, make a function
-            GetLastDirectory(debugger.activeFrame.absoluteFile, name);
-            if(ide && ide.workspace)
-            {
-               for(p : ide.workspace.projects)
-               {
-                  if(p.topNode.Find(name, false))
-                  {
-                     prj = p;
-                     break;
-                  }
-               }
-               if(!prj)
-               {
-                  for(p : ide.workspace.projects)
-                  {
-                     if(IsPathInsideOf(debugger.activeFrame.absoluteFile, p.topNode.path))
-                     {
-                        prj = p;
-                        break;
-                     }
-                  }
-               }
-            }
-            debugger.ToggleBreakpoint(debugger.activeFrame.absoluteFile, line, prj);
+            debugger.ToggleBreakpoint(debugger.activeFrame.absoluteFile, line);
             Update(null);
             {
                CodeEditor codeEditor = (CodeEditor)ide.FindWindow(debugger.activeFrame.absoluteFile);
index a64a22d..896cf87 100644 (file)
@@ -890,7 +890,7 @@ private:
    String lastBuildConfigName;
    String lastBuildCompilerName;
 
-   Map<String, NameCollisionInfo> lastBuildNamesInfo;
+   Map<String, Map<String, NameCollisionInfo>> configsNameCollisions { };
 
 #ifndef MAKEFILE_GENERATOR
    FileMonitor fileMonitor
@@ -997,7 +997,9 @@ private:
       delete name;
       delete lastBuildConfigName;
       delete lastBuildCompilerName;
-      if(lastBuildNamesInfo) { lastBuildNamesInfo.Free(); delete lastBuildNamesInfo; }
+      for(map : configsNameCollisions)
+         map.Free();
+      configsNameCollisions.Free();
    }
 
    ~Project()
@@ -1059,9 +1061,13 @@ private:
    ProjectNode FindNodeByObjectFileName(char * fileName, IntermediateFileType type, bool dotMain, ProjectConfig config)
    {
       ProjectNode result;
-      if(!lastBuildNamesInfo)
+      char * cfgName;
+      if(!config)
+         config = this.config;
+      cfgName = config ? config.name : "";
+      if(!configsNameCollisions[cfgName])
          ProjectLoadLastBuildNamesInfo(this, config);
-      result = topNode.FindByObjectFileName(fileName, type, dotMain, lastBuildNamesInfo);
+      result = topNode.FindByObjectFileName(fileName, type, dotMain, configsNameCollisions[cfgName]);
       return result;
    }
 
@@ -1244,63 +1250,6 @@ private:
    }
 #endif
 
-   // This method is only called from Debugger, should be moved to Debugger class?
-#ifndef MAKEFILE_GENERATOR
-   bool GetRelativePath(char * filePath, char * relativePath)
-   {
-      ProjectNode node;
-      char moduleName[MAX_FILENAME];
-      GetLastDirectory(filePath, moduleName);
-      // try with workspace dir first?
-      if((node = topNode.Find(moduleName, false)))
-      {
-         strcpy(relativePath, strcmp(node.path, ".") ? node.path : "");
-         PathCatSlash(relativePath, node.name);
-         return true;
-      }
-      else
-      {
-         // Tweak for automatically resolving symbol loader modules
-         char * sl = strstr(moduleName, ".main.ec");
-         if(sl && (*sl = 0, !strcmpi(moduleName, name)))
-         {
-            char objDir[MAX_LOCATION];
-            DirExpression objDirExp;
-            CompilerConfig compiler = ide.debugger.currentCompiler;
-            ProjectConfig config = ide.debugger.prjConfig;
-            int bitDepth = ide.debugger.bitDepth;
-            // This is not perfect, as multiple source files exist for the symbol loader module...
-            // We try to set it in the debug config object directory.
-            if(!compiler || !config)
-            {
-               // If we're not currently debugging, set a breakpoint in the active compiler/config
-               compiler = GetCompilerConfig();
-               config = this.config;
-               // If the current config is not debuggable, set it in the first debuggable config found
-               if(config && !config.options.debug)
-               {
-                  for(c : configurations; c.options.debug)
-                  {
-                     config = c;
-                     break;
-                  }
-               }
-            }
-            objDirExp = GetObjDir(compiler, config, bitDepth);
-            strcpy(objDir, objDirExp.dir);
-            delete objDirExp;
-            ChangeCh(objDir, '\\', '/'); // TODO: this is a hack, paths should never include win32 path seperators - fix this in ProjectSettings and ProjectLoad instead
-            ReplaceSpaces(relativePath, objDir);
-            *sl = '.';
-            PathCatSlash(relativePath, moduleName);
-            return true;
-         }
-      }
-      // WARNING: On failure, relative path is uninitialized
-      return false;   
-   }
-#endif
-
    void CatTargetFileName(char * string, CompilerConfig compiler, ProjectConfig config)
    {
       TargetTypes targetType = GetTargetType(config);
@@ -1437,10 +1386,26 @@ private:
 
    void ModifiedAllConfigs(bool making, bool compiling, bool linking, bool symbolGen)
    {
+      Map<String, NameCollisionInfo> cfgNameCollision = configsNameCollisions[""];
+      if(cfgNameCollision)
+      {
+         cfgNameCollision.Free();
+         delete cfgNameCollision;
+         configsNameCollisions[""] = null;
+      }
       for(cfg : configurations)
       {
          if(making)
+         {
             cfg.makingModified = true;
+            cfgNameCollision = configsNameCollisions[cfg.name];
+            if(cfgNameCollision)
+            {
+               cfgNameCollision.Free();
+               delete cfgNameCollision;
+               configsNameCollisions[cfg.name] = null;
+            }
+         }
          if(compiling)
             cfg.compilingModified = true;
          if(linking)
@@ -2053,12 +2018,14 @@ private:
       int numJobs = compiler.numJobs;
       char command[MAX_F_STRING*4];
       char * compilerName = CopyString(compiler.name);
+      Map<String, NameCollisionInfo> cfgNameCollisions;
 
       delete lastBuildConfigName;
       lastBuildConfigName = CopyString(config ? config.name : "Common");
       delete lastBuildCompilerName;
       lastBuildCompilerName = CopyString(compiler.name);
       ProjectLoadLastBuildNamesInfo(this, config);
+      cfgNameCollisions = configsNameCollisions[config ? config.name : ""];
 
       CamelCase(compilerName);
 
@@ -2113,8 +2080,8 @@ private:
                else
                {
                   if(!eC_Debug)
-                     node.DeleteIntermediateFiles(compiler, config, bitDepth, lastBuildNamesInfo, mode == cObject ? true : false);
-                  node.GetTargets(config, lastBuildNamesInfo, objDirExp.dir, makeTargets);
+                     node.DeleteIntermediateFiles(compiler, config, bitDepth, cfgNameCollisions, mode == cObject ? true : false);
+                  node.GetTargets(config, cfgNameCollisions, objDirExp.dir, makeTargets);
                }
             }
          }
@@ -3662,13 +3629,15 @@ private:
 
 static inline void ProjectLoadLastBuildNamesInfo(Project prj, ProjectConfig cfg)
 {
-   if(prj.lastBuildNamesInfo)
+   char * cfgName = cfg ? cfg.name : "";
+   Map<String, NameCollisionInfo> cfgNameCollisions = prj.configsNameCollisions[cfgName];
+   if(cfgNameCollisions)
    {
-      prj.lastBuildNamesInfo.Free();
-      delete prj.lastBuildNamesInfo;
+      cfgNameCollisions.Free();
+      delete cfgNameCollisions;
    }
-   prj.lastBuildNamesInfo = { };
-   prj.topNode.GenMakefileGetNameCollisionInfo(prj.lastBuildNamesInfo, cfg);
+   prj.configsNameCollisions[cfgName] = cfgNameCollisions = { };
+   prj.topNode.GenMakefileGetNameCollisionInfo(cfgNameCollisions, cfg);
 }
 
 Project LegacyBinaryLoadProject(File f, char * filePath)
index 77af10e..fa5bff7 100644 (file)
@@ -177,7 +177,56 @@ class TwoStrings : struct
    }
 }
 
-enum IntermediateFileType { none, ec, c, sym, imp, bowl, o };
+class DotMain : bool
+{
+   //property char * { set { } }
+   DotMain ::FromFileName(char * fileName)
+   {
+      DotMain dotMain = false;
+      if(fileName && fileName[0])
+      {
+         char ext[MAX_EXTENSION];
+         GetExtension(fileName, ext);
+         if(!strcmp(ext, "c") || !strcmp(ext, "ec"))
+         {
+            char stripExt[MAX_LOCATION];
+            strcpy(stripExt, fileName);
+            StripExtension(stripExt);
+            GetExtension(stripExt, ext);
+            if(!strcmp(ext, "main"))
+               dotMain = true;
+         }
+      }
+      return dotMain;
+   }
+}
+
+enum IntermediateFileType
+{
+   none, ec, c, sym, imp, bowl, o;
+
+   //property char * { set { } }
+   IntermediateFileType ::FromExtension(char * extension)
+   {
+      IntermediateFileType type = none;
+      if(extension && extension[0])
+      {
+         if(!fstrcmp(extension, "ec"))
+            type = ec;
+         else if(!fstrcmp(extension, "c"))
+            type = c;
+         else if(!fstrcmp(extension, "sym"))
+            type = sym;
+         else if(!fstrcmp(extension, "imp"))
+            type = imp;
+         else if(!fstrcmp(extension, "bowl"))
+            type = bowl;
+         else if(!fstrcmp(extension, "o"))
+            type = o;
+      }
+      return type;
+   }
+};
 
 class ProjectNode : ListItem
 {
@@ -497,7 +546,8 @@ private:
 
          if(dotMain)
          {
-            ReplaceSpaces(buffer, project.moduleName);
+            Project prj = property::project;
+            ReplaceSpaces(buffer, prj.moduleName);
             StripExtension(buffer);
             strcat(buffer, ".main.ec");
          }
@@ -1049,11 +1099,11 @@ private:
             {
                if(child.type != file)
                   result = child.InternalFindByFullPath(path, includeResources, lastDirName);
-               else if(child.name && !strcmpi(lastDirName, child.name))
+               else if(child.name && !fstrcmp(lastDirName, child.name))
                {
                   char p[MAX_LOCATION];
                   child.GetFullFilePath(p);
-                  if(!strcmpi(p, path))
+                  if(!fstrcmp(p, path))
                   {
                      result = child;
                      break;
@@ -1074,7 +1124,7 @@ private:
       if(dotMain == true && this.type == project)
       {
          GetObjectFileName(p, namesInfo, type, dotMain);
-         if(!strcmpi(p, fileName))
+         if(!fstrcmp(p, fileName))
             result = this;
       }
       else if(files)
@@ -1086,7 +1136,7 @@ private:
             else if(child.type == file && child.name)
             {
                child.GetObjectFileName(p, namesInfo, type, dotMain);
-               if(!strcmpi(p, fileName))
+               if(!fstrcmp(p, fileName))
                {
                   result = child;
                   break;
index d301ac5..21171aa 100644 (file)
@@ -1690,7 +1690,6 @@ class ProjectView : Window
 
             if(!colon && !filePath[0])
             {
-               bool dotMain = false;
                // Check if it's one of our modules
                node = project.topNode.Find(moduleName, false);
                if(node)
@@ -1700,30 +1699,12 @@ class ProjectView : Window
                }
                else
                {
-                  IntermediateFileType type = none;
-                  ProjectConfig config;
-                  if(ext[0])
+                  char ext[MAX_EXTENSION];
+                  GetExtension(fileName, ext);
                   {
-                     char ext2[MAX_EXTENSION];
-                     char stripExt[MAX_LOCATION];
-                     strcpy(stripExt, moduleName);
-                     StripExtension(stripExt);
-                     GetExtension(stripExt, ext2);
-                     if(ext2[0] && !strcmp(ext2, "main"))
-                        dotMain = true;
-                     if(!strcmp(ext, "ec"))
-                        type = ec;
-                     else if(!strcmp(ext, "c"))
-                        type = c;
-                     else if(!strcmp(ext, "sym"))
-                        type = sym;
-                     else if(!strcmp(ext, "imp"))
-                        type = imp;
-                     else if(!strcmp(ext, "bowl"))
-                        type = bowl;
-                     else if(!strcmp(ext, "o"))
-                        type = o;
-
+                     DotMain dotMain = DotMain::FromFileName(moduleName);
+                     IntermediateFileType type = IntermediateFileType::FromExtension(ext);
+                     ProjectConfig config = null;
                      if(type)
                      {
                         for(prj : ide.workspace.projects; prj.lastBuildConfigName)
@@ -1734,23 +1715,23 @@ class ProjectView : Window
                               break;
                         }
                      }
-                  }
-                  if(node)
-                  {
-                     char name[MAX_FILENAME];
-                     Project project = node.project;
-                     CompilerConfig compiler = ideSettings.GetCompilerConfig(project.lastBuildCompilerName);
-                     if(compiler)
+                     if(node)
                      {
-                        int bitDepth = ide.workspace.bitDepth;
-                        DirExpression objDir = project.GetObjDir(compiler, config, bitDepth);
-                        strcpy(filePath, project.topNode.path);
-                        PathCatSlash(filePath, objDir.dir);
-                        node.GetObjectFileName(name, project.lastBuildNamesInfo, type, dotMain);
-                        PathCatSlash(filePath, name);
-                        delete objDir;
+                        char name[MAX_FILENAME];
+                        Project project = node.project;
+                        CompilerConfig compiler = ideSettings.GetCompilerConfig(project.lastBuildCompilerName);
+                        if(compiler)
+                        {
+                           int bitDepth = ide.workspace.bitDepth;
+                           DirExpression objDir = project.GetObjDir(compiler, config, bitDepth);
+                           strcpy(filePath, project.topNode.path);
+                           PathCatSlash(filePath, objDir.dir);
+                           node.GetObjectFileName(name, project.configsNameCollisions[config ? config.name : ""], type, dotMain);
+                           PathCatSlash(filePath, name);
+                           delete objDir;
+                        }
+                        delete compiler;
                      }
-                     delete compiler;
                   }
                }
                if(!node)
index ad1f9f5..e2ed155 100644 (file)
@@ -731,7 +731,7 @@ public:
       }
       ide.breakpointsView.Update(null);
    }
-
+   
    void Free()
    {
       delete workspaceFile;