ide;debugger; (#1003) fixed multiple issues.
[sdk] / ide / src / project / Workspace.ec
index aedad2f..e2ed155 100644 (file)
@@ -22,6 +22,29 @@ import "ide"
 }*/
 
 enum OpenedFileState { unknown, opened, closed };
+enum ValgrindLeakCheck
+{
+   no, summary, yes, full;
+
+   property char *
+   {
+      get { return OnGetString(null, null, null); }
+   }
+
+   char * OnGetString(char * tempString, void * fieldData, bool * needClass)
+   {
+      if(this >= no && this <= full)
+      {
+         if(tempString)
+            strcpy(tempString, valgrindLeakCheckNames[this]);
+         return valgrindLeakCheckNames[this];
+      }
+      if(tempString && tempString[0])
+         tempString[0] = '\0';
+      return null;
+   }
+};
+static const char * valgrindLeakCheckNames[ValgrindLeakCheck] = { "no", "summary", "yes", "full" };
 
 class OpenedFileInfo
 {
@@ -178,8 +201,14 @@ public:
 private:
    String compiler;
    int bitDepth;
+   // TODO: save these new settings when json format is ready
    bool useValgrind;
-   bool vgFullLeakCheck;
+   ValgrindLeakCheck vgLeakCheck;
+   bool vgTrackOrigins;
+   int vgRedzoneSize;
+
+   vgRedzoneSize = -1;
+   vgLeakCheck = summary;
 
 public:
    void Save()
@@ -440,7 +469,7 @@ public:
       for(s : dirs)
          sourceDirs.Add(CopyString(s));
       
-      DropInvalidBreakpoints();
+      DropInvalidBreakpoints(null);
 
       delete dirs;
    }
@@ -451,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);
@@ -460,6 +490,30 @@ public:
       delete project;
    }
 
+   void SelectActiveConfig(char * configName)
+   {
+      bool change = false;
+      for(prj : ide.workspace.projects)
+      {
+         for(cfg : prj.configurations)
+         {
+            if(cfg.name && !strcmp(cfg.name, configName))
+            {
+               prj.config = cfg;
+               change = true;
+               break;
+            }
+         }
+      }
+      if(change)
+      {
+         modified = true;
+         ide.UpdateToolBarActiveConfigs(true);
+         ide.projectView.Update(null);
+         Save();
+      }
+   }
+
    bool FindPath(ProjectNode node, char * path)
    {
       if(node.type == file)
@@ -489,13 +543,18 @@ public:
       Breakpoint bp = (Breakpoint)row.tag;
       if(bp)
       {
-         char * currentLoc = bp.LocationToString();
+         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;
       }
@@ -596,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)
@@ -606,50 +674,64 @@ public:
 
          if(bp.type == user)
          {
-            Project project = null;
-            for(p : projects)
+            if(removedProject)
             {
-               if(FindPath(p.topNode, bp.absoluteFilePath))
+               if(bp.project == removedProject)
                {
-                  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;
-                  }
+                  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);
+                  }
                }
             }
          }
       }
       ide.breakpointsView.Update(null);
    }
-
+   
    void Free()
    {
       delete workspaceFile;
@@ -820,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 = CopyString(strFile);
-                     bp.absoluteFilePath = workspace.GetAbsolutePathFromRelative(strFile);
-                     if(!bp.absoluteFilePath)
-                        bp.absoluteFilePath = CopyString("");
+                     bp.location = strFile;
                   }
                }
             }
@@ -1081,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 = CopyString(relPath);
-                                          bp.absoluteFilePath = workspace.GetAbsolutePathFromRelative(relPath);
-                                          if(!bp.absoluteFilePath)
-                                             bp.absoluteFilePath = CopyString("");
+                                          bp.location = relPath;
                                        }
                                     }
                                  }