extras: improve debug print line (dpl) debugging tools (111d8299ce536c62d57c1dc06ea81...
[sdk] / ide / src / debugger / Debugger.ec
index c5228f8..408450e 100644 (file)
@@ -13,7 +13,7 @@ import "debugTools"
 
 #ifdef _DEBUG
 #define GDB_DEBUG_CONSOLE
-#define _DEBUG_INST
+#define _DPL_ON
 #endif
 
 extern char * strrchr(const char * s, int c);
@@ -22,7 +22,7 @@ extern char * strrchr(const char * s, int c);
 #define strlen _strlen
 #include <stdarg.h>
 #include <unistd.h>
-#include <ctype.h>
+#include <string.h> // For memchr
 
 #ifdef __APPLE__
 #define __unix__
@@ -35,36 +35,12 @@ extern char * strrchr(const char * s, int c);
 #undef uint
 #undef strlen
 
-char * PrintNow()
-{
-   int c;
-   char * s[6];
-   char * time;
-   DateTime now;
-   now.GetLocalTime();
-   for(c=0; c<6; c++)
-      s[c] = new char[8];
-   sprintf(s[0], "%04d", now.year);
-   sprintf(s[1], "%02d", now.month+1);
-   sprintf(s[2], "%02d", now.day);
-   sprintf(s[3], "%02d", now.hour);
-   sprintf(s[4], "%02d", now.minute);
-   sprintf(s[5], "%02d", now.second);
-   time = PrintString("*", s[0], s[1], s[2], "-", s[3], s[4], s[5], "*");
-   for(c=0; c<6; c++)
-      delete s[c];
-   return time;
-}
-
+#include <dpl.eh>
+#ifdef _DPL_ON
 // use =0 to disable printing of specific channels
-#ifdef _DEBUG_INST
 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,
-                        debuggerUserAction=0,debuggerState=0, debuggerBreakpoints=0, debuggerWatches=0, debuggerTemp=0 };
-#endif
-static char * _dpct[] = {
+static const char * _dpct[] = {
    null,
    "GDB Protocol Ignored",
    "GDB Protocol ***Unknown***",
@@ -79,66 +55,7 @@ static char * _dpct[] = {
    "-----> Temporary Message",
    null
 };
-
-// TODO if(strlen(item.value) < MAX_F_STRING)
-
-// Debug Print Line
-#ifdef _DEBUG_INST
-#define _dpl2(...) __dpl2(__FILE__, __LINE__, ##__VA_ARGS__)
-#else
-#define _dpl2(...)
 #endif
-static void __dpl2(char * file, int line, char ** channels, int channel, int indent, typed_object object, ...)
-{
-   bool chan = channel && channels && channels[channel];
-   if(chan || !channels)
-   {
-      char string[MAX_F_STRING];
-      int len;
-      char * time = PrintNow();
-      va_list args;
-      //ide.outputView.debugBox.Logf();
-      Logf("%s %s:% 5d: %s%s", time, file, line, chan ? channels[channel] : "", chan && channels[channel][0] ? ": " : "");
-      va_start(args, object);
-      len = PrintStdArgsToBuffer(string, sizeof(string), object, args);
-      Log(string);
-      va_end(args);
-      Log("\n");
-      delete time;
-   }
-}
-
-#define _dpl(...) __dpl(__FILE__, __LINE__, ##__VA_ARGS__)
-static void __dpl(char * file, int line, int indent, char * format, ...)
-{
-   va_list args;
-   char string[MAX_F_STRING];
-   int c;
-   char * time = PrintNow();
-   //static File f = null;
-   va_start(args, format);
-   vsnprintf(string, sizeof(string), format, args);
-   string[sizeof(string)-1] = 0;
-   /*if(!f)
-   {
-      char * time = PrintNow();
-      char * logName;
-      logName = PrintString(time, ".log");
-      delete time;
-      f = FileOpen(logName, write);
-      delete logName;
-   }*/
-   /*f.Printf("%s %s:% 5d: ", time, file, line);
-   for(c = 0; c<indent; c++)
-      f.Putc(' ');
-   f.Printf("%s\n", string);*/
-   Logf("%s %s:% 5d: ", time, file, line);
-   for(c = 0; c<indent; c++)
-      Log(" ");
-   Logf("%s\n", string);
-   va_end(args);
-   delete time;
-}
 
 public char * StripQuotes2(char * string, char * output)
 {
@@ -146,7 +63,7 @@ public char * StripQuotes2(char * string, char * output)
    int d = 0;
    bool quoted = false, escaped = false;
    char ch;
-   for(c = 0; ch = string[c]; c++)
+   for(c = 0; (ch = string[c]); c++)
    {
       if(quoted)
       {
@@ -192,20 +109,22 @@ static void strescpy(char * d, char * s)
    d[k] = '\0';
 }
 
-static char * CopyUnescapedSystemPath(char * p)
+/*static char * CopyUnescapedSystemPath(char * p)
 {
-   char * d = new char[strlen(p) + 1];
-   struscpy(d, p);
+   int len = strlen(p);
+   char * d = new char[len + 1];
+   UnescapeString(d, p, len);
 #if defined(__WIN32__)
    ChangeCh(d, '/', '\\');
 #endif
    return d;
-}
+}*/
 
 static char * CopyUnescapedUnixPath(char * p)
 {
-   char * d = new char[strlen(p) + 1];
-   struscpy(d, p);
+   int len = strlen(p);
+   char * d = new char[len + 1];
+   UnescapeString(d, p, len);
 #if defined(__WIN32__)
    ChangeCh(d, '\\', '/');
 #endif
@@ -214,47 +133,12 @@ static char * CopyUnescapedUnixPath(char * p)
 
 static char * CopyUnescapedString(char * s)
 {
-   char * d = new char[strlen(s) + 1];
-   struscpy(d, s);
+   int len = strlen(s);
+   char * d = new char[len + 1];
+   UnescapeString(d, s, len);
    return d;
 }
 
-// String Unescape Copy
-
-// TOFIX: THIS DOESN'T HANDLE NUMERIC ESCAPE CODES (OCTAL/HEXADECIMAL...)?
-// Seems very similar to ReadString in pass15.ec (which also misses numeric escape codes :) )
-
-static void struscpy(char * d, char * s)
-{
-   int j = 0, k = 0;
-   char ch;
-   while((ch = s[j]))
-   {
-      switch(ch)
-      {
-         case '\\':
-            switch(s[++j])
-            {
-               case 'n': d[k] = '\n'; break;
-               case 't': d[k] = '\t'; break;
-               case 'a': d[k] = '\a'; break;
-               case 'b': d[k] = '\b'; break;
-               case 'f': d[k] = '\f'; break;
-               case 'r': d[k] = '\r'; break;
-               case 'v': d[k] = '\v'; break;
-               case '\\': d[k] = '\\'; break;
-               case '\"': d[k] = '\"'; break;
-               default: d[k] = '\\'; d[++k] = s[j];
-            }
-            break;
-         default:
-            d[k] = s[j];
-      }
-      j++, k++;
-   }
-   d[k] = '\0';
-}
-
 static char * StripBrackets(char * string)
 {
    int length = strlen(string);
@@ -281,7 +165,7 @@ static char * StripCurlies(char * string)
       return string;
 }
 
-static int StringGetInt(char * string, int start)
+/*static int StringGetInt(char * string, int start)
 {
    char number[8];
    int i, len = strlen(string);
@@ -294,7 +178,7 @@ static int StringGetInt(char * string, int start)
          break;
    }
    return atoi(number);
-}
+}*/
 
 static int TokenizeList(char * string, const char seperator, Array<char *> tokens)
 {
@@ -525,9 +409,9 @@ class Debugger
          if(this.stopItem)
          {
             this.stopItem = null;
-#ifdef _DEBUG_INST
+#ifdef _DPL_ON
             {
-               char * s;
+               char * s = null;
                DynamicString bpReport { };
 
                for(bp : sysBPs; bp.inserted)
@@ -547,25 +431,28 @@ class Debugger
                   delete s;
                }
                s = bpReport;
-               _dpl2(_dpct, dplchan::debuggerBreakpoints, 0, "gdbTimer::DelayExpired: ", s+1);
+               _dpcl(_dpct, dplchan::debuggerBreakpoints, 0, "gdbTimer::DelayExpired: ", s+1);
 
                if(stopItem.bkptno)
                {
                   bool isInternal;
                   Breakpoint bp = GetBreakpointById(stopItem.bkptno, &isInternal);
                   if(bp)
-                     _dpl2(_dpct, dplchan::debuggerBreakpoints, 0, "gdb stopped by a breakpoint: ", bp.type, "(", s=bp.CopyLocationString(false), ")"); delete s;
+                  {
+                     _dpcl(_dpct, dplchan::debuggerBreakpoints, 0, "gdb stopped by a breakpoint: ", bp.type, "(", s=bp.CopyLocationString(false), ")");
+                     delete s;
+                  }
                }
                delete bpReport;
             }
 #endif
          }
-#ifdef _DEBUG_INST
+#ifdef _DPL_ON
          else
          {
             if(curEvent && curEvent != exit)
             {
-               _dpl(0, "No stop item");
+               _dplf(0, "No stop item");
             }
          }
 #endif
@@ -582,7 +469,7 @@ class Debugger
             case selectFrame:
             {
                breakType = none;
-               GdbCommand(false, "-stack-select-frame %d", activeFrameLevel);
+               GdbCommand(0, false, "-stack-select-frame %d", activeFrameLevel);
                for(activeFrame = stackFrames.first; activeFrame; activeFrame = activeFrame.next)
                   if(activeFrame.level == activeFrameLevel)
                      break;
@@ -590,7 +477,7 @@ class Debugger
             }
             //case bpValidation:
             //   breakType = none;
-            //   GdbCommand(false, "-break-info %s", bpItem.number);
+            //   GdbCommand(0, false, "-break-info %s", bpItem.number);
             //   break;
          }
 
@@ -629,12 +516,12 @@ class Debugger
                         }
                      }
                      else
-                        _dpl2(_dpct, dplchan::debuggerProblem, 0, "Invalid stopItem!");
-                     if(bpUser && strcmp(stopItem.frame.addr, bpUser.bp.addr))
-                        _dpl2(_dpct, dplchan::debuggerProblem, 0, "Breakpoint bkptno(", stopItem.bkptno, ") address missmatch!");
+                        _dpcl(_dpct, dplchan::debuggerProblem, 0, "Invalid stopItem!");
+                     if(bpUser && stopItem.frame.addr && strcmp(stopItem.frame.addr, bpUser.bp.addr))
+                        _dpcl(_dpct, dplchan::debuggerProblem, 0, "Breakpoint bkptno(", stopItem.bkptno, ") address missmatch!");
                   }
                   else
-                     _dpl2(_dpct, dplchan::debuggerProblem, 0, "Breakpoint bkptno(", stopItem.bkptno, ") invalid or not found!");
+                     _dpcl(_dpct, dplchan::debuggerProblem, 0, "Breakpoint bkptno(", stopItem.bkptno, ") invalid or not found!");
                   if((bpUser && !ignoreBreakpoints) || (bpInternal && userAction.breaksOnInternalBreakpoint))
                      monitor = true;
                   hitThread = stopItem.threadid;
@@ -660,7 +547,7 @@ class Debugger
 
          if(curEvent == signal)
          {
-            char * s;
+            char * s = null;
             signalOn = true;
             ide.outputView.debugBox.Logf($"Signal received: %s - %s\n", stopItem.name, stopItem.meaning);
             ide.outputView.debugBox.Logf("    %s:%d\n", (s = CopySystemPath(stopItem.frame.file)), stopItem.frame.line);
@@ -706,7 +593,7 @@ class Debugger
          {
             GdbGetStack();
             activeThread = stopItem.threadid;
-            GdbCommand(false, "-thread-list-ids");
+            GdbCommand(0, false, "-thread-list-ids");
             InternalSelectFrame(activeFrameLevel);
             GoToStackFrameLine(activeFrameLevel, true, false);
             EvaluateWatches();
@@ -732,29 +619,31 @@ class Debugger
    ProgramThread progThread { };
 #endif
 
-#ifdef _DEBUG_INST
+#ifdef _DPL_ON
 #define _ChangeUserAction(value) ChangeUserAction(__FILE__, __LINE__, value)
-   void ChangeUserAction(char * file, int line, DebuggerUserAction value)
+   void ChangeUserAction(const char * file, int line, DebuggerUserAction value)
    {
+#if 0
       bool same = value == userAction;
-      __dpl2(file, line, _dpct, dplchan::debuggerUserAction, 0, userAction, /*same ? " *** == *** " : */" -> ", value);
+      __dpl(file, line, _dpct, dplchan::debuggerUserAction, 0, userAction, /*same ? " *** == *** " : */" -> ", value);
+#endif
       userAction = value;
    }
 #else
 #define _ChangeUserAction(value) userAction = value
 #endif
 
-#ifdef _DEBUG_INST
+#ifdef _DPL_ON
 #define _ChangeState(value) ChangeState(__FILE__, __LINE__, value)
-   void ChangeState(char * file, int line, DebuggerState value)
+   void ChangeState(const char * file, int line, DebuggerState value)
 #else
 #define _ChangeState(value) ChangeState(value)
    void ChangeState(DebuggerState value)
 #endif
    {
       bool same = value == state;
-#ifdef _DEBUG_INST
-      __dpl2(file, line, _dpct, dplchan::debuggerState, 0, state, same ? " *** == *** " : " -> ", value);
+#if 0 //def _DPL_ON
+      __dpl(file, line, _dpct, dplchan::debuggerState, 0, state, same ? " *** == *** " : " -> ", value);
 #endif
       state = value;
       if(!same) ide.AdjustDebugMenus();
@@ -762,7 +651,7 @@ class Debugger
 
    void CleanUp()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::CleanUp");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::CleanUp");
 
       stackFrames.Free(Frame::Free);
 
@@ -816,7 +705,7 @@ class Debugger
 
    Debugger()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::constructor");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::constructor");
       ideProcessId = Process_GetCurrentProcessId();
 
       sysBPs.Add((intBpEntry = Breakpoint { type = internalEntry, enabled = false, level = -1 }));
@@ -830,7 +719,7 @@ class Debugger
 
    ~Debugger()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::destructor");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::destructor");
       sysBPs.Free();
       Stop();
       CleanUp();
@@ -843,14 +732,14 @@ class Debugger
 
    void Resume()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::Resume");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::Resume");
       _ChangeUserAction(resume);
       GdbExecContinue(true);
    }
 
    void Break()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::Break");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::Break");
       _ChangeUserAction(_break);
       if(state == running)
       {
@@ -861,7 +750,7 @@ class Debugger
 
    void Stop()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::Stop");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::Stop");
       _ChangeUserAction(stop);
       switch(state)
       {
@@ -885,7 +774,7 @@ class Debugger
 
    void Restart(CompilerConfig compiler, ProjectConfig config, int bitDepth, bool useValgrind)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::Restart");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::Restart");
       _ChangeUserAction(restart);
       if(StartSession(compiler, config, bitDepth, useValgrind, true, false) == loaded)
          GdbExecRun();
@@ -894,16 +783,16 @@ class Debugger
    bool GoToCodeLine(char * location)
    {
       CodeLocation codloc;
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GoToCodeLine(", location, ")");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GoToCodeLine(", location, ")");
       codloc = CodeLocation::ParseCodeLocation(location);
       if(codloc)
       {
-         CodeEditor editor = (CodeEditor)ide.OpenFile(codloc.absoluteFile, normal, true, null, no, normal, false);
+         CodeEditor editor = (CodeEditor)ide.OpenFile(codloc.absoluteFile, false, true, null, no, normal, false);
          if(editor)
          {
             EditBox editBox = editor.editBox;
-            editBox.GoToLineNum(codloc.line - 1);
-            editBox.GoToPosition(editBox.line, codloc.line - 1, 0);
+            if(editBox.GoToLineNum(codloc.line - 1))
+               editBox.GoToPosition(editBox.line, codloc.line - 1, 0);
             return true;
          }
       }
@@ -912,10 +801,9 @@ class Debugger
 
    bool GoToStackFrameLine(int stackLevel, bool askForLocation, bool fromCallStack)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GoToStackFrameLine(", stackLevel, ", ", askForLocation, ")");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GoToStackFrameLine(", stackLevel, ", ", askForLocation, ")");
       if(ide)
       {
-         char filePath[MAX_LOCATION];
          char sourceDir[MAX_LOCATION];
          Frame frame;
          CodeEditor editor = null;
@@ -930,12 +818,12 @@ class Debugger
                ide.callStackView.Show();
 
             if(frame.absoluteFile)
-               editor = (CodeEditor)ide.OpenFile(frame.absoluteFile, normal, true, null, no, normal, false);
+               editor = (CodeEditor)ide.OpenFile(frame.absoluteFile, false, true, null, no, normal, false);
             if(!editor && frame.file)
-               frame.absoluteFile = ide.workspace.GetAbsolutePathFromRelative(frame.file);
+               frame.absoluteFile = ide.workspace.CopyAbsolutePathFromRelative(frame.file);
             if(!frame.absoluteFile && askForLocation && frame.file)
             {
-               char * s;
+               char * s = null;
                char title[MAX_LOCATION];
                snprintf(title, sizeof(title), $"Provide source file location for %s", (s = CopySystemPath(frame.file)));
                title[sizeof(title)-1] = 0;
@@ -943,11 +831,11 @@ class Debugger
                if(SourceDirDialog(title, ide.workspace.projectDir, frame.file, sourceDir))
                {
                   AddSourceDir(sourceDir);
-                  frame.absoluteFile = ide.workspace.GetAbsolutePathFromRelative(frame.file);
+                  frame.absoluteFile = ide.workspace.CopyAbsolutePathFromRelative(frame.file);
                }
             }
             if(!editor && frame.absoluteFile)
-               editor = (CodeEditor)ide.OpenFile(frame.absoluteFile, normal, true, null, no, normal, false);
+               editor = (CodeEditor)ide.OpenFile(frame.absoluteFile, false, true, null, no, normal, false);
             if(editor)
                ide.RepositionWindows(false);
             ide.Update(null);
@@ -965,7 +853,7 @@ class Debugger
 
    void SelectThread(int thread)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::SelectThread(", thread, ")");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::SelectThread(", thread, ")");
       _ChangeUserAction(selectThread);
       if(state == stopped)
       {
@@ -973,7 +861,7 @@ class Debugger
          {
             activeFrameLevel = -1;
             ide.callStackView.Clear();
-            GdbCommand(false, "-thread-select %d", thread);
+            GdbCommand(0, false, "-thread-select %d", thread);
             GdbGetStack();
             InternalSelectFrame(activeFrameLevel);
             GoToStackFrameLine(activeFrameLevel, true, false);
@@ -986,7 +874,7 @@ class Debugger
 
    void SelectFrame(int frame)
    {
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::SelectFrame(", frame, ")");
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::SelectFrame(", frame, ")");
       _ChangeUserAction(selectFrame);
       if(state == stopped)
       {
@@ -1001,9 +889,9 @@ class Debugger
 
    void InternalSelectFrame(int frame)
    {
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::InternalSelectFrame(", frame, ")");
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::InternalSelectFrame(", frame, ")");
       activeFrameLevel = frame;  // there is no active frame number in the gdb reply
-      GdbCommand(false, "-stack-select-frame %d", activeFrameLevel);
+      GdbCommand(0, false, "-stack-select-frame %d", activeFrameLevel);
       for(activeFrame = stackFrames.first; activeFrame; activeFrame = activeFrame.next)
          if(activeFrame.level == activeFrameLevel)
             break;
@@ -1011,10 +899,9 @@ class Debugger
 
    void HandleExit(char * reason, char * code)
    {
-      bool returnedExitCode = false;
       char verboseExitCode[128];
 
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::HandleExit(", reason, ", ", code, ")");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::HandleExit(", reason, ", ", code, ")");
       _ChangeState(loaded); // this state change seems to be superfluous, might be in case of gdb crash
       targetProcessId = 0;
 
@@ -1076,7 +963,7 @@ class Debugger
    DebuggerState StartSession(CompilerConfig compiler, ProjectConfig config, int bitDepth, bool useValgrind, bool restart, bool ignoreBreakpoints)
    {
       DebuggerState result = none;
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::StartSession(restart(", restart, "), ignoreBreakpoints(", ignoreBreakpoints, ")");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::StartSession(restart(", restart, "), ignoreBreakpoints(", ignoreBreakpoints, ")");
       if(restart && state == running && targetProcessId)
       {
          breakType = DebuggerAction::restart;
@@ -1117,7 +1004,7 @@ class Debugger
 
    void Start(CompilerConfig compiler, ProjectConfig config, int bitDepth, bool useValgrind)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::Start()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::Start()");
       _ChangeUserAction(start);
       if(StartSession(compiler, config, bitDepth, useValgrind, true, false) == loaded)
          GdbExecRun();
@@ -1125,7 +1012,7 @@ class Debugger
 
    void StepInto(CompilerConfig compiler, ProjectConfig config, int bitDepth, bool useValgrind)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::StepInto()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::StepInto()");
       _ChangeUserAction(stepInto);
       switch(StartSession(compiler, config, bitDepth, useValgrind, false, false))
       {
@@ -1136,7 +1023,7 @@ class Debugger
 
    void StepOver(CompilerConfig compiler, ProjectConfig config, int bitDepth, bool useValgrind, bool ignoreBreakpoints)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::StepOver()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::StepOver()");
       _ChangeUserAction(stepOver);
       switch(StartSession(compiler, config, bitDepth, useValgrind, false, ignoreBreakpoints))
       {
@@ -1147,7 +1034,7 @@ class Debugger
 
    void StepUntil(CompilerConfig compiler, ProjectConfig config, int bitDepth, bool useValgrind, bool ignoreBreakpoints)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::StepUntil()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::StepUntil()");
       _ChangeUserAction(stepUntil);
       switch(StartSession(compiler, config, bitDepth, useValgrind, false, ignoreBreakpoints))
       {
@@ -1158,7 +1045,7 @@ class Debugger
 
    void StepOut(bool ignoreBreakpoints)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::StepOut()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::StepOut()");
       _ChangeUserAction(stepOut);
       if(state == stopped)
       {
@@ -1170,12 +1057,13 @@ class Debugger
       }
    }
 
-   void RunToCursor(CompilerConfig compiler, ProjectConfig config, int bitDepth, bool useValgrind, char * absoluteFilePath, int lineNumber, bool ignoreBreakpoints, bool atSameLevel, bool oldImplementation)
+   void RunToCursor(CompilerConfig compiler, ProjectConfig config, int bitDepth, bool useValgrind, const char * absoluteFilePath, int lineNumber, bool ignoreBreakpoints, bool atSameLevel, bool oldImplementation)
    {
       char relativeFilePath[MAX_LOCATION];
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::RunToCursor()");
+      const char * objectFileExt = compiler ? compiler.objectFileExt : objectDefaultFileExt;
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::RunToCursor()");
       _ChangeUserAction(runToCursor);
-      WorkspaceGetRelativePath(absoluteFilePath, relativeFilePath, null);
+      ide.workspace.GetRelativePath(absoluteFilePath, relativeFilePath, null, objectFileExt);
 
       if(bpRunToCursor && bpRunToCursor.inserted && symbols)
       {
@@ -1219,7 +1107,7 @@ class Debugger
 
    void GetCallStackCursorLine(bool * error, int * lineCursor, int * lineTopFrame)
    {
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GetCallStackCursorLine()");
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GetCallStackCursorLine()");
       if(activeFrameLevel == -1)
       {
          *error = false;
@@ -1234,13 +1122,13 @@ class Debugger
       }
    }
 
-   int GetMarginIconsLineNumbers(char * fileName, int lines[], bool enabled[], int max, bool * error, int * lineCursor, int * lineTopFrame)
+   int GetMarginIconsLineNumbers(const char * fileName, int lines[], bool enabled[], int max, bool * error, int * lineCursor, int * lineTopFrame)
    {
       char winFilePath[MAX_LOCATION];
       char * absoluteFilePath = GetSlashPathBuffer(winFilePath, fileName);
       int count = 0;
       Iterator<Breakpoint> it { ide.workspace.breakpoints };
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GetMarginIconsLineNumbers()");
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GetMarginIconsLineNumbers()");
       while(it.Next() && count < max)
       {
          Breakpoint bp = it.data;
@@ -1282,8 +1170,8 @@ class Debugger
 
    void ChangeWatch(DataRow row, char * expression)
    {
-      Watch wh = (Watch)row.tag;
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::ChangeWatch(", expression, ")");
+      Watch wh = (Watch)(intptr)row.tag;
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::ChangeWatch(", expression, ")");
       if(wh)
       {
          delete wh.expression;
@@ -1299,7 +1187,7 @@ class Debugger
       else if(expression)
       {
          wh = Watch { };
-         row.tag = (int64)wh;
+         row.tag = (int64)(intptr)wh;
          ide.workspace.watches.Add(wh);
          wh.row = row;
          wh.expression = CopyString(expression);
@@ -1310,16 +1198,16 @@ class Debugger
          ResolveWatch(wh);
    }
 
-   void MoveIcons(char * fileName, int lineNumber, int move, bool start)
+   void MoveIcons(const char * fileName, int lineNumber, int move, bool start)
    {
       char winFilePath[MAX_LOCATION];
-      char * absoluteFilePath = GetSlashPathBuffer(winFilePath, fileName);
+      const char * absoluteFilePath = GetSlashPathBuffer(winFilePath, fileName);
 
       Link bpLink, next;
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::MoveIcons()");
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::MoveIcons()");
       for(bpLink = ide.workspace.breakpoints.first; bpLink; bpLink = next)
       {
-         Breakpoint bp = (Breakpoint)bpLink.data;
+         Breakpoint bp = (Breakpoint)(intptr)bpLink.data;
          next = bpLink.next;
 
          if(bp.type == user && bp.absoluteFilePath && !fstrcmp(bp.absoluteFilePath, absoluteFilePath))
@@ -1341,13 +1229,12 @@ class Debugger
       // moving code cursors is futile, on next step, stop, hit, cursors will be offset anyways
    }
 
-   bool SourceDirDialog(char * title, char * startDir, char * test, char * sourceDir)
+   bool SourceDirDialog(const char * title, const char * startDir, const char * test, char * sourceDir)
    {
       bool result;
-      bool retry;
       String srcDir = null;
 
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::SourceDirDialog()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::SourceDirDialog()");
       debuggerFileDialog.text = title;
       debuggerFileDialog.currentDirectory = startDir;
       debuggerFileDialog.master = ide;
@@ -1401,9 +1288,9 @@ class Debugger
       return false;
    }
 
-   void AddSourceDir(char * sourceDir)
+   void AddSourceDir(const char * sourceDir)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::AddSourceDir(", sourceDir, ")");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::AddSourceDir(", sourceDir, ")");
       ide.workspace.sourceDirs.Add(CopyString(sourceDir));
       ide.workspace.Save();
 
@@ -1417,7 +1304,7 @@ class Debugger
                   GdbDebugBreak(true);
             case stopped:
             case loaded:
-               GdbCommand(false, "-environment-directory \"%s\"", sourceDir);
+               GdbCommand(0, false, "-environment-directory \"%s\"", sourceDir);
                break;
          }
          if(oldState == running)
@@ -1425,12 +1312,12 @@ class Debugger
       }
    }
 
-   void ToggleBreakpoint(char * fileName, int lineNumber)
+   void ToggleBreakpoint(const char * fileName, int lineNumber)
    {
       char absolutePath[MAX_LOCATION];
       Breakpoint bp = null;
 
-      _dpl2(_dpct, dplchan::debuggerBreakpoints, 0, "Debugger::ToggleBreakpoint(", fileName, ":", lineNumber, ")");
+      _dpcl(_dpct, dplchan::debuggerBreakpoints, 0, "Debugger::ToggleBreakpoint(", fileName, ":", lineNumber, ")");
 
       GetSlashPathBuffer(absolutePath, fileName);
       for(i : ide.workspace.breakpoints; i.type == user && i.absoluteFilePath && !fstrcmp(i.absoluteFilePath, absolutePath) && i.line == lineNumber)
@@ -1452,8 +1339,9 @@ class Debugger
       {
          Project owner;
          char relativePath[MAX_LOCATION];
+         const char * objectFileExt = currentCompiler ? currentCompiler.objectFileExt : objectDefaultFileExt;
 
-         WorkspaceGetRelativePath(absolutePath, relativePath, &owner);
+         ide.workspace.GetRelativePath(absolutePath, relativePath, &owner, objectFileExt);
 
          if(!owner && !FileExists(absolutePath))
          {
@@ -1513,7 +1401,8 @@ class Debugger
                   GdbDebugBreak(true);
             case stopped:
             case loaded:
-               SetBreakpoint(bp, false);
+               if(!SetBreakpoint(bp, false))
+                  SetBreakpoint(bp, true);
                break;
          }
          if(oldState == running)
@@ -1525,7 +1414,7 @@ class Debugger
 
    void UpdateRemovedBreakpoint(Breakpoint bp)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::UpdateRemovedBreakpoint()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::UpdateRemovedBreakpoint()");
       if(targeted && bp.inserted)
       {
          DebuggerState oldState = state;
@@ -1555,7 +1444,7 @@ class Debugger
       DebugListItem item { };
       Argument arg;
 
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::ParseFrame()");
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::ParseFrame()");
       TokenizeList(string, ',', frameTokens);
       for(i = 0; i < frameTokens.count; i++)
       {
@@ -1597,10 +1486,10 @@ class Debugger
                               arg.val = item.value;
                            }
                            else
-                              _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "frame args item (", item.name, "=", item.value, ") is unheard of");
+                              _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "frame args item (", item.name, "=", item.value, ") is unheard of");
                         }
                         else
-                           _dpl(0, "Bad frame args item");
+                           _dplf(0, "Bad frame args item");
                      }
                      argumentTokens.RemoveAll();
                   }
@@ -1615,22 +1504,23 @@ class Debugger
             else if(!strcmp(item.name, "line"))
                frame.line = atoi(item.value);
             else if(!strcmp(item.name, "fullname"))
-               frame.absoluteFile = item.value;
-            /*{
+            {
                // GDB 6.3 on OS X is giving "fullname" and "dir", all in absolute, but file name only in 'file'
-               String path = ide.workspace.GetPathWorkspaceRelativeOrAbsolute(item.value);
-               if(strcmp(frame.file, path))
+               Workspace ws = ide.workspace;
+               if(ws)
                {
-                  frame.file = path;
-                  frame.absoluteFile = ide.workspace.GetAbsolutePathFromRelative(frame.file);
+                  String path = ide.workspace.CopyUnixPathWorkspaceRelativeOrAbsolute(item.value);
+                  if(strcmp(frame.file, path))
+                     frame.file = path;
+                  delete path;
                }
-               delete path;
-            }*/
+               frame.absoluteFile = item.value;
+            }
             else
-               _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "frame member (", item.name, "=", item.value, ") is unheard of");
+               _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "frame member (", item.name, "=", item.value, ") is unheard of");
          }
          else
-            _dpl(0, "Bad frame");
+            _dplf(0, "Bad frame");
       }
 
       delete frameTokens;
@@ -1642,7 +1532,7 @@ class Debugger
    Breakpoint GetBreakpointById(int id, bool * isInternal)
    {
       Breakpoint bp = null;
-      //_dpl2(_dpct, dplchan::debuggerBreakpoints, 0, "Debugger::GetBreakpointById(", id, ")");
+      //_dpcl(_dpct, dplchan::debuggerBreakpoints, 0, "Debugger::GetBreakpointById(", id, ")");
       if(isInternal)
          *isInternal = false;
       if(id)
@@ -1674,7 +1564,7 @@ class Debugger
       GdbDataBreakpoint bp { };
       DebugListItem item { };
       Array<char *> bpTokens { minAllocSize = 16 };
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::ParseBreakpoint()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::ParseBreakpoint()");
       string = StripCurlies(string);
       TokenizeList(string, ',', bpTokens);
       for(i = 0; i < bpTokens.count; i++)
@@ -1722,9 +1612,9 @@ class Debugger
             else if(!strcmp(item.name, "times"))
                bp.times = atoi(item.value);
             else if(!strcmp(item.name, "original-location") || !strcmp(item.name, "thread-groups"))
-               _dpl2(_dpct, dplchan::gdbProtoIgnored, 0, "breakpoint member (", item.name, "=", item.value, ") is ignored");
+               _dpcl(_dpct, dplchan::gdbProtoIgnored, 0, "breakpoint member (", item.name, "=", item.value, ") is ignored");
             else
-               _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "breakpoint member (", item.name, "=", item.value, ") is unheard of");
+               _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "breakpoint member (", item.name, "=", item.value, ") is unheard of");
          }
       }
       delete bpTokens;
@@ -1734,7 +1624,7 @@ class Debugger
 
    void ShowDebuggerViews()
    {
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::ShowDebuggerViews()");
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::ShowDebuggerViews()");
       ide.outputView.Show();
       ide.outputView.SelectTab(debug);
       ide.threadsView.Show();
@@ -1745,14 +1635,16 @@ class Debugger
 
    void HideDebuggerViews()
    {
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::HideDebuggerViews()");
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::HideDebuggerViews()");
       ide.RepositionWindows(true);
    }
 
-   void ::GdbCommand(bool focus, char * format, ...)
+   bool ::GdbCommand(Time timeOut, bool focus, const char * format, ...)
    {
+      bool result = false;
       if(gdbHandle)
       {
+         Time startTime;
          // TODO: Improve this limit
          static char string[MAX_F_STRING*4];
          va_list args;
@@ -1765,7 +1657,7 @@ class Debugger
          ide.debugger.serialSemaphore.TryWait();
 
 #ifdef GDB_DEBUG_CONSOLE
-         _dpl2(_dpct, dplchan::gdbCommand, 0, string);
+         _dpcl(_dpct, dplchan::gdbCommand, 0, string);
 #endif
 #ifdef GDB_DEBUG_OUTPUT
          ide.outputView.gdbBox.Logf("cmd: %s\n", string);
@@ -1782,14 +1674,39 @@ class Debugger
             Process_ShowWindows(targetProcessId);
 
          app.Unlock();
-         ide.debugger.serialSemaphore.Wait();
+
+         if(timeOut)
+         {
+            startTime = GetTime();
+            while(true)
+            {
+               if(ide.debugger.serialSemaphore.TryWait())
+               {
+                  result = true;
+                  break;
+               }
+               else
+               {
+                  if(GetTime() - startTime > timeOut)
+                     break;
+                  Sleep(0.01);
+               }
+            }
+         }
+         else
+         {
+            ide.debugger.serialSemaphore.Wait();
+            result = true;
+         }
+
          app.Lock();
       }
+      return result;
    }
 
    bool ValidateBreakpoint(Breakpoint bp)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::ValidateBreakpoint()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::ValidateBreakpoint()");
       if(modules && bp.line && bp.bp)
       {
          if(bp.bp.line != bp.line)
@@ -1817,7 +1734,7 @@ class Debugger
 
    void BreakpointsMaintenance()
    {
-      //_dpl2(_dpct, dplchan::debuggerBreakpoints, 0, "Debugger::BreakpointsMaintenance()");
+      //_dpcl(_dpct, dplchan::debuggerBreakpoints, 0, "Debugger::BreakpointsMaintenance()");
       if(symbols)
       {
          if(gdbExecution.suspendInternalBreakpoints)
@@ -1901,7 +1818,10 @@ class Debugger
                else
                   insert = true;
                if(insert)
-                  SetBreakpoint(bp, false);
+               {
+                  if(!SetBreakpoint(bp, false))
+                     SetBreakpoint(bp, true);
+               }
             }
             delete objDir;
          }
@@ -1909,7 +1829,10 @@ class Debugger
          if(userAction != runToCursor && bpRunToCursor && bpRunToCursor.inserted)
             UnsetBreakpoint(bpRunToCursor);
          if(bpRunToCursor && !bpRunToCursor.inserted)
-            SetBreakpoint(bpRunToCursor, false);
+         {
+            if(!SetBreakpoint(bpRunToCursor, false))
+               SetBreakpoint(bpRunToCursor, true);
+         }
 
          if(ignoreBreakpoints)
          {
@@ -1929,7 +1852,7 @@ class Debugger
                {
 #ifdef _DEBUG
                   if(bp.bp)
-                     _dpl(0, "problem");
+                     _dplf(0, "problem");
 #endif
                   delete bp.bp;
                   bp.bp = GdbDataBreakpoint { };
@@ -1941,10 +1864,10 @@ class Debugger
 
    void UnsetBreakpoint(Breakpoint bp)
    {
-      char * s; _dpl2(_dpct, dplchan::debuggerBreakpoints, 0, "Debugger::UnsetBreakpoint(", s=bp.CopyLocationString(false), ") -- ", bp.type); delete s;
+      char * s = null; _dpcl(_dpct, dplchan::debuggerBreakpoints, 0, "Debugger::UnsetBreakpoint(", s=bp.CopyLocationString(false), ") -- ", bp.type); delete s;
       if(symbols && bp.inserted)
       {
-         GdbCommand(false, "-break-delete %s", bp.bp.number);
+         GdbCommand(0, false, "-break-delete %s", bp.bp.number);
          bp.inserted = false;
          delete bp.bp;
          bp.bp = { };
@@ -1953,17 +1876,17 @@ class Debugger
 
    bool SetBreakpoint(Breakpoint bp, bool removePath)
    {
-      char * s; _dpl2(_dpct, dplchan::debuggerBreakpoints, 0, "Debugger::SetBreakpoint(", s=bp.CopyLocationString(false), ", ", removePath ? "**** removePath(true) ****" : "", ") -- ", bp.type); delete s;
+      char * s = null; _dpcl(_dpct, dplchan::debuggerBreakpoints, 0, "Debugger::SetBreakpoint(", s=bp.CopyLocationString(false), ", ", removePath ? "**** removePath(true) ****" : "", ") -- ", bp.type); delete s;
       breakpointError = false;
       if(symbols && bp.enabled && (!bp.project || bp.project.GetTargetType(bp.project.config) == staticLibrary || bp.project == ide.project || projectsLibraryLoaded[bp.project.name]))
       {
          sentBreakInsert = true;
          if(bp.address)
-            GdbCommand(false, "-break-insert *%s", bp.address);
+            GdbCommand(0, false, "-break-insert *%s", bp.address);
          else
          {
             char * location = bp.CopyLocationString(removePath);
-            GdbCommand(false, "-break-insert %s", location);
+            GdbCommand(0, false, "-break-insert %s", location);
             delete location;
          }
          if(!breakpointError)
@@ -1985,11 +1908,11 @@ class Debugger
                   {
                      if(n.enabled)
                      {
-                        GdbCommand(false, "-break-disable %s", n.number);
+                        GdbCommand(0, false, "-break-disable %s", n.number);
                         n.enabled = false;
                      }
                      else
-                        _dpl2(_dpct, dplchan::debuggerProblem, 0, "Debugger::SetBreakpoint -- error breakpoint already disabled.");
+                        _dpcl(_dpct, dplchan::debuggerProblem, 0, "Debugger::SetBreakpoint -- error breakpoint already disabled.");
                   }*/
                }
                if(first)
@@ -2003,9 +1926,9 @@ class Debugger
                   //bpItem.thread-groups = first.thread-groups;*/
                }
                else if(count == 0)
-                  _dpl2(_dpct, dplchan::debuggerProblem, 0, "Debugger::SetBreakpoint -- error multiple breakpoints all disabled.");
+                  _dpcl(_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.");
+                  _dpcl(_dpct, dplchan::debuggerProblem, 0, "Debugger::SetBreakpoint -- error multiple breakpoints in exact same file not supported.");
                bpItem.multipleBPs.Free();
                delete bpItem.multipleBPs;
             }
@@ -2024,36 +1947,37 @@ class Debugger
                SetBreakpoint(bp, removePath);
             }
          }
+         return !breakpointError;
       }
-      return !breakpointError;
+      return false;
    }
 
    void GdbGetStack()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbGetStack()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbGetStack()");
       activeFrame = null;
       stackFrames.Free(Frame::Free);
-      GdbCommand(false, "-stack-info-depth");
+      GdbCommand(0, false, "-stack-info-depth");
       if(!frameCount)
-         GdbCommand(false, "-stack-info-depth 192");
+         GdbCommand(0, false, "-stack-info-depth 192");
       if(frameCount && frameCount <= 192)
-         GdbCommand(false, "-stack-list-frames 0 %d", Min(frameCount-1, 191));
+         GdbCommand(0, false, "-stack-list-frames 0 %d", Min(frameCount-1, 191));
       else
       {
-         GdbCommand(false, "-stack-list-frames 0 %d", Min(frameCount-1, 95));
-         GdbCommand(false, "-stack-list-frames %d %d", Max(frameCount - 96, 96), frameCount - 1);
+         GdbCommand(0, false, "-stack-list-frames 0 %d", Min(frameCount-1, 95));
+         GdbCommand(0, false, "-stack-list-frames %d %d", Max(frameCount - 96, 96), frameCount - 1);
       }
-      GdbCommand(false, "");
+      GdbCommand(0, false, "");
    }
 
    bool GdbTargetSet()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbTargetSet()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbTargetSet()");
       if(!targeted)
       {
          char escaped[MAX_LOCATION];
          strescpy(escaped, targetFile);
-         GdbCommand(false, "file \"%s\"", escaped); //GDB/MI Missing Implementation in 5.1.1 but we now have -file-exec-and-symbols / -file-exec-file / -file-symbol-file
+         GdbCommand(0, false, "file \"%s\"", escaped); //GDB/MI Missing Implementation in 5.1.1 but we now have -file-exec-and-symbols / -file-exec-file / -file-symbol-file
 
          if(!symbols)
             return true;
@@ -2061,15 +1985,15 @@ class Debugger
          if(usingValgrind)
          {
             const char *vgdbCommand = "/usr/bin/vgdb"; // TODO: vgdb command config option
-            //GdbCommand(false, "-target-select remote | %s --pid=%d", "vgdb", targetProcessId);
+            //GdbCommand(0, false, "-target-select remote | %s --pid=%d", "vgdb", targetProcessId);
             printf("target remote | %s --pid=%d\n", vgdbCommand, targetProcessId);
-            GdbCommand(false, "target remote | %s --pid=%d", vgdbCommand, targetProcessId); // TODO: vgdb command config option
+            GdbCommand(0, false, "target remote | %s --pid=%d", vgdbCommand, targetProcessId); // TODO: vgdb command config option
          }
          else
-            GdbCommand(false, "info target"); //GDB/MI Missing Implementation -file-list-symbol-files and -file-list-exec-sections
+            GdbCommand(0, false, "info target"); //GDB/MI Missing Implementation -file-list-symbol-files and -file-list-exec-sections
 
          /*for(prj : ide.workspace.projects; prj != ide.workspace.projects.firstIterator.data)
-            GdbCommand(false, "-environment-directory \"%s\"", prj.topNode.path);*/
+            GdbCommand(0, false, "-environment-directory \"%s\"", prj.topNode.path);*/
 
          for(dir : ide.workspace.sourceDirs; dir && dir[0])
          {
@@ -2083,7 +2007,7 @@ class Debugger
               }
            }
            if(!interference && dir[0])
-              GdbCommand(false, "-environment-directory \"%s\"", dir);
+              GdbCommand(0, false, "-environment-directory \"%s\"", dir);
          }
 
          targeted = true;
@@ -2096,7 +2020,7 @@ class Debugger
       if(targeted)
       {
          BreakpointsDeleteAll();
-         GdbCommand(false, "file");  //GDB/MI Missing Implementation -target-detach
+         GdbCommand(0, false, "file");  //GDB/MI Missing Implementation -target-detach
          targeted = false;
          symbols = true;
       }
@@ -2104,7 +2028,7 @@ class Debugger
 
    void GdbDebugBreak(bool internal)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbDebugBreak()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbDebugBreak()");
       if(targetProcessId)
       {
          if(internal)
@@ -2112,7 +2036,7 @@ class Debugger
 
          if(ide) ide.Update(null);
          app.Unlock();
-         if(Process_Break(targetProcessId))  //GdbCommand(false, "-exec-interrupt");
+         if(Process_Break(targetProcessId))  //GdbCommand(0, false, "-exec-interrupt");
             serialSemaphore.Wait();
          else
          {
@@ -2127,7 +2051,7 @@ class Debugger
 
    void GdbExecRun()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecRun()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecRun()");
       GdbTargetSet();
       if(!usingValgrind)
          gdbExecution = run;
@@ -2135,82 +2059,126 @@ class Debugger
       ShowDebuggerViews();
       if(usingValgrind)
          GdbExecContinue(true);
-      else
-         GdbCommand(true, "-exec-run");
+      else if(!GdbCommand(3, true, "-exec-run"))
+         gdbExecution = none;
    }
 
    void GdbExecContinue(bool focus)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecContinue()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecContinue()");
       gdbExecution = run;
       GdbExecCommon();
-      GdbCommand(focus, "-exec-continue");
+      GdbCommand(0, focus, "-exec-continue");
    }
 
    void GdbExecNext()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecNext()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecNext()");
       gdbExecution = next;
       GdbExecCommon();
-      GdbCommand(true, "-exec-next");
+      GdbCommand(0, true, "-exec-next");
+   }
+
+   void ForceUpdateCurrentFrame()
+   {
+      GdbGetStack();
+      GdbCommand(0, false, "-thread-list-ids");
+      InternalSelectFrame(activeFrameLevel);
+      GoToStackFrameLine(activeFrameLevel, true, false);
+      EvaluateWatches();
+      ide.ShowCodeEditor();
+      ide.AdjustDebugMenus();
+      ideMainFrame.Activate();   // TOFIX: ide.Activate() is not reliable (app inactive)
+      ide.Update(null);
    }
 
-   void GdbExecUntil(char * absoluteFilePath, int lineNumber)
+   void GdbExecUntil(const char * absoluteFilePath, int lineNumber)
    {
+      bool forceUpdate = false;
       char relativeFilePath[MAX_LOCATION];
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecUntil()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecUntil()");
       gdbExecution = until;
       GdbExecCommon();
       if(absoluteFilePath)
       {
-         WorkspaceGetRelativePath(absoluteFilePath, relativeFilePath, null);
-         GdbCommand(true, "-exec-until %s:%d", relativeFilePath, lineNumber);
+         const char * objectFileExt = currentCompiler ? currentCompiler.objectFileExt : objectDefaultFileExt;
+         ide.workspace.GetRelativePath(absoluteFilePath, relativeFilePath, null, objectFileExt);
+         if(!GdbCommand(0.1, true, "-exec-until %s:%d", relativeFilePath, lineNumber))
+         {
+            GetLastDirectory(relativeFilePath, relativeFilePath);
+            if(GdbCommand(1, true, "-exec-until %s:%d", relativeFilePath, lineNumber))
+               forceUpdate = true;
+         }
       }
       else
-         GdbCommand(true, "-exec-until");
+         GdbCommand(0, true, "-exec-until");
+
+      // This is to handle GDB 6.3 on OS X not giving us *running then *stopped:
+      // (It may not be ideal, we may need to wait?)
+      if(forceUpdate)
+         ForceUpdateCurrentFrame();
    }
 
-   void GdbExecAdvance(char * absoluteFilePathOrLocation, int lineNumber)
+   void GdbExecAdvance(const char * absoluteFilePathOrLocation, int lineNumber)
    {
+      bool forceUpdate = false;
       char relativeFilePath[MAX_LOCATION];
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecAdvance()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecAdvance()");
       gdbExecution = advance;
       GdbExecCommon();
       if(lineNumber)
       {
-         WorkspaceGetRelativePath(absoluteFilePathOrLocation, relativeFilePath, null);
-         GdbCommand(true, "advance %s:%d", relativeFilePath, lineNumber); // should use -exec-advance -- GDB/MI implementation missing
+         const char * objectFileExt = currentCompiler ? currentCompiler.objectFileExt : objectDefaultFileExt;
+         ide.workspace.GetRelativePath(absoluteFilePathOrLocation, relativeFilePath, null, objectFileExt);
+         if(!GdbCommand(0.1, true, "advance %s:%d", relativeFilePath, lineNumber)) // should use -exec-advance -- GDB/MI implementation missing
+         {
+            GetLastDirectory(relativeFilePath, relativeFilePath);
+            if(GdbCommand(1, true, "advance %s:%d", relativeFilePath, lineNumber))
+               forceUpdate = true;
+         }
       }
       else
-         GdbCommand(true, "advance %s", absoluteFilePathOrLocation); // should use -exec-advance -- GDB/MI implementation missing
+      {
+         if(!GdbCommand(0.1, true, "advance %s", absoluteFilePathOrLocation)) // should use -exec-advance -- GDB/MI implementation missing
+         {
+            GetLastDirectory(absoluteFilePathOrLocation, relativeFilePath);
+            if(GdbCommand(1, true, "advance %s", relativeFilePath))
+               forceUpdate = true;
+         }
+      }
+
+      // This is to handle GDB 6.3 on OS X not giving us *running then *stopped:
+      // (It may not be ideal, we may need to wait?)
+      if(forceUpdate)
+         ForceUpdateCurrentFrame();
    }
 
    void GdbExecStep()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecStep()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecStep()");
       gdbExecution = step;
       GdbExecCommon();
-      GdbCommand(true, "-exec-step");
+      GdbCommand(0, true, "-exec-step");
    }
 
    void GdbExecFinish()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecFinish()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecFinish()");
       gdbExecution = finish;
       GdbExecCommon();
-      GdbCommand(true, "-exec-finish");
+      GdbCommand(0, true, "-exec-finish");
    }
 
    void GdbExecCommon()
    {
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecCommon()");
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecCommon()");
       BreakpointsMaintenance();
    }
 
 #ifdef GDB_DEBUG_GUI
-   void SendGDBCommand(char * command)
+   void SendGDBCommand(const char * command)
    {
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::SendGDBCommand()");
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::SendGDBCommand()");
       DebuggerState oldState = state;
       switch(state)
       {
@@ -2219,7 +2187,7 @@ class Debugger
                GdbDebugBreak(true);
          case stopped:
          case loaded:
-            GdbCommand(false, command);
+            GdbCommand(0, false, command);
             break;
       }
       if(oldState == running)
@@ -2229,7 +2197,7 @@ class Debugger
 
    void ClearBreakDisplay()
    {
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::ClearBreakDisplay()");
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::ClearBreakDisplay()");
       activeThread = 0;
       activeFrameLevel = -1;
       hitThread = 0;
@@ -2249,9 +2217,9 @@ class Debugger
 
    bool GdbAbortExec()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbAbortExec()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbAbortExec()");
       sentKill = true;
-      GdbCommand(false, "-interpreter-exec console \"kill\""); // should use -exec-abort -- GDB/MI implementation incomplete
+      GdbCommand(0, false, "-interpreter-exec console \"kill\""); // should use -exec-abort -- GDB/MI implementation incomplete
       return true;
    }
 
@@ -2264,8 +2232,9 @@ class Debugger
       Project project = ide.project;
       DirExpression targetDirExp = project.GetTargetDir(compiler, config, bitDepth);
       PathBackup pathBackup { };
+      Map<String, String> envBackup { };
 
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbInit()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbInit()");
       if(currentCompiler != compiler)
       {
          delete currentCompiler;
@@ -2285,6 +2254,7 @@ class Debugger
       targeted = false;
       modules = false;
       needReset = false;
+      entryPoint = false;
       projectsLibraryLoaded.Free();
 
       ide.outputView.ShowClearSelectTab(debug);
@@ -2321,6 +2291,8 @@ class Debugger
       // gdb set environment commands don't seem to take effect
       for(e : ide.workspace.environmentVars)
       {
+         // Backing up the environment variables until we use DualPipeOpenEnv()
+         envBackup[e.name] = CopyString(getenv(e.name));
          SetEnvironment(e.name, e.string);
       }
 
@@ -2349,11 +2321,10 @@ class Debugger
          }
          if(result)
          {
-            char * vgRedzoneSizeFlag = vgRedzoneSize == -1 ? "" : PrintString(" --redzone-size=", vgRedzoneSize);
+            char * vgRedzoneSizeFlag = PrintString(" --redzone-size=", vgRedzoneSize);
             sprintf(command, "%s --vgdb=yes --vgdb-error=0 --log-file=%s --leak-check=%s%s --track-origins=%s %s%s%s",
-                  valgrindCommand, vgLogPath, (char*)vgLeakCheck, vgRedzoneSizeFlag, vgTrackOrigins ? "yes" : "no", targetFile, clArgs ? " " : "", clArgs ? clArgs : "");
-            if(vgRedzoneSize != -1)
-               delete vgRedzoneSizeFlag;
+                  valgrindCommand, vgLogPath, (char*)vgLeakCheck, vgRedzoneSize > -1 ? vgRedzoneSizeFlag : "", vgTrackOrigins ? "yes" : "no", targetFile, clArgs ? " " : "", clArgs ? clArgs : "");
+            delete vgRedzoneSizeFlag;
             vgTargetHandle = DualPipeOpen(PipeOpenMode { output = true, /*error = true, */input = true }, command);
             if(!vgTargetHandle)
             {
@@ -2384,10 +2355,17 @@ class Debugger
 
       if(result)
       {
-         strcpy(command,
-            (compiler.targetPlatform == win32 && bitDepth == 64) ? "x86_64-w64-mingw32-gdb" :
-            (compiler.targetPlatform == win32 && bitDepth == 32) ? "i686-w64-mingw32-gdb" :
-            "gdb");
+         if(compiler.targetPlatform == win32)
+         {
+            strcpy(command,
+#if !((defined(__WORDSIZE) && __WORDSIZE == 8) || defined(__x86_64__))
+               1 ||
+#endif
+               bitDepth == 32 ? "i686-w64-mingw32-gdb" : "gdb");  // x86_64-w64-mingw32-gdb
+         }
+         else
+            // We really should have a box to select GDB in the compiler/toolchain options
+            strcpy(command, "gdb");
          if(!CheckCommandAvailable(command))
          {
             ide.outputView.debugBox.Logf($"Debugger Fatal Error: Command %s for GDB is not available.\n", command);
@@ -2423,13 +2401,13 @@ class Debugger
          serialSemaphore.Wait();
          app.Lock();
 
-         GdbCommand(false, "-gdb-set verbose off");
-         //GdbCommand(false, "-gdb-set exec-done-display on");
-         GdbCommand(false, "-gdb-set step-mode off");
-         GdbCommand(false, "-gdb-set unwindonsignal on");
-         //GdbCommand(false, "-gdb-set shell on");
-         GdbCommand(false, "set print elements 992");
-         GdbCommand(false, "-gdb-set backtrace limit 100000");
+         GdbCommand(0, false, "-gdb-set verbose off");
+         //GdbCommand(0, false, "-gdb-set exec-done-display on");
+         GdbCommand(0, false, "-gdb-set step-mode off");
+         GdbCommand(0, false, "-gdb-set unwindonsignal on");
+         //GdbCommand(0, false, "-gdb-set shell on");
+         GdbCommand(0, false, "set print elements 992");
+         GdbCommand(0, false, "-gdb-set backtrace limit 100000");
 
          if(!GdbTargetSet())
          {
@@ -2464,26 +2442,33 @@ class Debugger
 #endif
 
 #if defined(__WIN32__)
-         GdbCommand(false, "-gdb-set new-console on");
+         GdbCommand(0, false, "-gdb-set new-console on");
 #endif
 
 #if defined(__unix__)
          if(!usingValgrind)
-            GdbCommand(false, "-inferior-tty-set %s", progFifoPath);
+            GdbCommand(0, false, "-inferior-tty-set %s", progFifoPath);
 #endif
 
          if(!usingValgrind)
-            GdbCommand(false, "-gdb-set args %s", ide.workspace.commandLineArgs ? ide.workspace.commandLineArgs : "");
+            GdbCommand(0, false, "-gdb-set args %s", ide.workspace.commandLineArgs ? ide.workspace.commandLineArgs : "");
          /*
          for(e : ide.workspace.environmentVars)
          {
-            GdbCommand(false, "set environment %s=%s", e.name, e.string);
+            GdbCommand(0, false, "set environment %s=%s", e.name, e.string);
          }
          */
       }
 
       ChangeWorkingDir(oldDirectory);
 
+      for(e : envBackup)
+      {
+         SetEnvironment(&e, e);
+      }
+      envBackup.Free();
+      delete envBackup;
+
       delete pathBackup;
 
       if(!result)
@@ -2494,11 +2479,11 @@ class Debugger
 
    void GdbExit()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExit()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExit()");
       if(gdbHandle && gdbProcessId)
       {
          gdbTimer.Stop();
-         GdbCommand(false, "-gdb-exit");
+         GdbCommand(0, false, "-gdb-exit");
 
          if(gdbThread)
          {
@@ -2506,21 +2491,21 @@ class Debugger
             gdbThread.Wait();
             app.Lock();
          }
-         if(vgLogThread)
+         if(vgLogFile)
+            vgLogFile.CloseInput();
+         if(vgLogThread.created)
          {
             app.Unlock();
             vgLogThread.Wait();
             app.Lock();
          }
+         delete vgLogFile;
          if(vgTargetThread)
          {
             app.Unlock();
             vgTargetThread.Wait();
             app.Lock();
          }
-
-         if(vgLogFile)
-            delete vgLogFile;
          if(gdbHandle)
          {
             gdbHandle.Wait();
@@ -2529,7 +2514,6 @@ class Debugger
       }
       gdbTimer.Stop();
       _ChangeState(terminated); // this state change seems to be superfluous, is it safety for something?
-      prjConfig = null;
       needReset = false;
 
       if(ide.workspace)
@@ -2543,8 +2527,6 @@ class Debugger
          bpRunToCursor.Reset();
 
       ide.outputView.debugBox.Logf($"Debugging stopped\n");
-      ClearBreakDisplay();
-      ide.Update(null);
 
 #if defined(__unix__)
       if(!usingValgrind && FileExists(progFifoPath)) //fileCreated)
@@ -2563,18 +2545,21 @@ class Debugger
          rmdir(progFifoDir);
       }
 #endif
+
+      CleanUp();
+      ide.Update(null);
    }
 
    bool WatchesLinkCodeEditor()
    {
       bool goodFrame = activeFrame && activeFrame.absoluteFile;
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::WatchesLinkCodeEditor()");
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::WatchesLinkCodeEditor()");
       if(codeEditor && (!goodFrame || fstrcmp(codeEditor.fileName, activeFrame.absoluteFile)))
          WatchesReleaseCodeEditor();
 
       if(!codeEditor && goodFrame)
       {
-         codeEditor = (CodeEditor)ide.OpenFile(activeFrame.absoluteFile, normal, false, null, no, normal, false);
+         codeEditor = (CodeEditor)ide.OpenFile(activeFrame.absoluteFile, false, false, null, no, normal, false);
          if(codeEditor)
          {
             codeEditor.inUseDebug = true;
@@ -2586,7 +2571,7 @@ class Debugger
 
    void WatchesReleaseCodeEditor()
    {
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::WatchesReleaseCodeEditor()");
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::WatchesReleaseCodeEditor()");
       if(codeEditor)
       {
          codeEditor.inUseDebug = false;
@@ -2600,7 +2585,7 @@ class Debugger
    {
       bool result = false;
 
-      _dpl2(_dpct, dplchan::debuggerWatches, 0, "Debugger::ResolveWatch()");
+      _dpcl(_dpct, dplchan::debuggerWatches, 0, "Debugger::ResolveWatch()");
       wh.Reset();
 
       /*delete wh.value;
@@ -2613,6 +2598,7 @@ class Debugger
       if(wh.expression)
       {
          char watchmsg[MAX_F_STRING];
+         watchmsg[0] = 0;
          if(state == stopped && !codeEditor)
             wh.value = CopyString($"No source file found for selected frame");
          //if(codeEditor && state == stopped || state != stopped)
@@ -2622,7 +2608,6 @@ class Debugger
             Context backupContext;
             Class backupThisClass;
             Expression exp;
-            parseError = false;
 
             backupPrivateModule = GetPrivateModule();
             backupContext = GetCurrentContext();
@@ -2638,23 +2623,112 @@ class Debugger
 
             exp = ParseExpressionString(wh.expression);
 
-            if(exp && !parseError)
+            if(exp && !GetParseError())
             {
                char expString[4096];
                expString[0] = 0;
                PrintExpression(exp, expString);
 
-               if(GetPrivateModule())
-               {
-                  if(codeEditor)
-                     DebugFindCtxTree(codeEditor.ast, activeFrame.line, 0);
-                  ProcessExpressionType(exp);
-               }
+               SetInDebugger(true);
+
+               SetThisClass(null);
+               // NOTE: DebugFindCtxTree() should be called only once for evaluating all watches in the watch window
+               if(codeEditor && activeFrame)
+                  DebugFindCtxTree(codeEditor.ast, activeFrame.line, 0);
+               ProcessExpressionType(exp);
+
                wh.type = exp.expType;
                if(wh.type)
                   wh.type.refCount++;
                DebugComputeExpression(exp);
-               if(ExpressionIsError(exp))
+               // e.g. Meters * Degrees has no type set yet for some reason
+               if(!wh.type && exp.expType)
+               {
+                  wh.type = exp.expType;
+                  exp.expType.refCount++;
+               }
+
+               // This makes Degrees { 45 } work
+               if(exp.type == constantExp && exp.isConstant && exp.expType && exp.expType.kind == classType &&
+                  exp.expType._class && exp.expType._class.registered && exp.expType._class.registered.type == unitClass && exp.expType._class.registered.base.type == unitClass)
+               {
+                  ApplyUnitConverters(exp);
+               }
+               else if(exp.type == instanceExp && exp.instance.data)
+               {
+                  Symbol s = exp.instance._class ? exp.instance._class.symbol : null;
+                  Class c = s ? s.registered : null;
+                  if(c)
+                  {
+                     char tmp[4096];
+                     bool needClass = false;
+                     char * s = ((char * (*)(void *, void *, void *, void *, void *))(void *)c._vTbl[__ecereVMethodID_class_OnGetString])(c, exp.instance.data, tmp, null, &needClass);
+                     if(s)
+                     {
+                        FreeExpContents(exp);
+                        exp.type = constantExp;
+                        exp.isConstant = true;
+                        exp.constant = CopyString(s);
+                     }
+                  }
+               }
+               else if(exp.expType && exp.expType.kind == classType && exp.expType._class && exp.expType._class.registered && exp.expType._class.registered.type == bitClass)
+               {
+                  Class c = exp.expType._class.registered;
+                  char tmp[4096];
+                  bool needClass = false;
+                  Operand op = GetOperand(exp);
+                  char * s = null;
+                  char * (* onGetString)(void *, void *, void *, void *, void *) = (void *)c._vTbl[__ecereVMethodID_class_OnGetString];
+                  if(op.type)
+                  {
+                     if(op.type) op.type.refCount++;
+                     switch(op.kind)
+                     {
+                        case charType: s = onGetString(c, &op.c, tmp, null, &needClass); break;
+                        case shortType: s = onGetString(c, &op.s, tmp, null, &needClass); break;
+                        case intType: s = onGetString(c, &op.i, tmp, null, &needClass); break;
+                        case int64Type: s = onGetString(c, &op.i64, tmp, null, &needClass); break;
+                     }
+                  }
+                  if(s)
+                  {
+                     FreeExpContents(exp);
+                     exp.type = constantExp;
+                     exp.isConstant = true;
+                     exp.constant = CopyString(s);
+                  }
+                  FreeType(op.type);
+               }
+               else if(exp.expType && exp.expType.kind == classType && exp.expType._class && exp.expType._class.registered && exp.expType._class.registered.type == structClass && exp.hasAddress)
+               {
+                  Class c = exp.expType._class.registered;
+                  char structString[1024];
+                  strcpy(structString, "*(struct ");
+                  FullClassNameCat(structString, c.fullName, false);
+                  strcat(structString, " *)");
+                  strcatf(structString, "0x%p", exp.address);
+                  GDBFallBack(exp, structString);
+                  /*
+                  byte * data = GdbReadMemory(exp.address, c.structSize);
+                  if(data)
+                  {
+                     char tmp[4096];
+                     bool needClass = false;
+                     char * s = ((char * (*)(void *, void *, void *, void *, void *))(void *)c._vTbl[__ecereVMethodID_class_OnGetString])(c, data, tmp, null, &needClass);
+                     if(s)
+                     {
+                        FreeExpContents(exp);
+                        exp.type = constantExp;
+                        exp.isConstant = true;
+                        exp.constant = CopyString(s);
+                     }
+                     delete data;
+                  }
+                  */
+               }
+
+               if(ExpressionIsError(exp) && exp.type != functionCallErrorExp)
                {
                   GDBFallBack(exp, expString);
                }
@@ -2795,22 +2869,27 @@ class Debugger
                   case symbolErrorExp:
                      snprintf(watchmsg, sizeof(watchmsg), $"Symbol \"%s\" not found", exp.identifier.string);
                      break;
-                  case structMemberSymbolErrorExp:
-                     // todo get info as in next case (ExpClassMemberSymbolError)
-                     snprintf(watchmsg, sizeof(watchmsg), $"Error: Struct member not found for \"%s\"", wh.expression);
-                     break;
-                  case classMemberSymbolErrorExp:
+                  case memberSymbolErrorExp:
+                  {
+                     Expression memberExp = exp.member.exp;
+                     Identifier memberID = exp.member.member;
+                     Type type = memberExp.expType;
+                     if(type)
                      {
-                        Class _class;
-                        Expression memberExp = exp.member.exp;
-                        Identifier memberID = exp.member.member;
-                        Type type = memberExp.expType;
-                        if(type)
+                        if(type.kind == structType || type.kind == unionType)
                         {
-                           _class = (memberID && memberID.classSym) ? memberID.classSym.registered : ((type.kind == classType && type._class) ? type._class.registered : null);
+                           char string[1024] = "";
+                           if(!type.name)
+                              PrintTypeNoConst(type, string, false, true);
+                           snprintf(watchmsg, sizeof(watchmsg), $"Member \"%s\" not found in %s \"%s\"",
+                              memberID ? memberID.string : "", type.kind == unionType ? "union" : "struct", type.name ? type.name : string);
+                        }
+                        else
+                        {
+                           Class _class = (memberID && memberID.classSym) ? memberID.classSym.registered : ((type.kind == classType && type._class) ? type._class.registered : null);
+                           char string[1024] = "";
                            if(!_class)
                            {
-                              char string[256] = "";
                               Symbol classSym;
                               PrintTypeNoConst(type, string, false, true);
                               classSym = FindClass(string);
@@ -2819,33 +2898,58 @@ class Debugger
                            if(_class)
                               snprintf(watchmsg, sizeof(watchmsg), $"Member \"%s\" not found in class \"%s\"", memberID ? memberID.string : "", _class.name);
                            else
-                              snprintf(watchmsg, sizeof(watchmsg), "Member \"%s\" not found in unregistered class? (Should never get this message)", memberID ? memberID.string : "");
+                              // NOTE: This should probably never happen, only classes and struct can be dereferenced, a dereferenceErrorExp should be displayed instead
+                              snprintf(watchmsg, sizeof(watchmsg), $"Member \"%s\" not found in type \"%s\"", memberID ? memberID.string : "", string);
                         }
-                        else
-                           snprintf(watchmsg, sizeof(watchmsg), "Member \"%s\" not found in no type? (Should never get this message)", memberID ? memberID.string : "");
                      }
+                     else
+                        // NOTE: This should probably never happen, the error causing the unresolved expression should be displayed instead
+                        snprintf(watchmsg, sizeof(watchmsg), $"Accessing member \"%s\" from unresolved expression", memberID ? memberID.string : "");
+                     break;
+                  }
+                  case memberPropertyErrorExp:
+                  {
+                     Expression memberExp = exp.member.exp;
+                     Identifier memberID = exp.member.member;
+                     Type type = memberExp.expType;
+                     Class _class = (type && memberID) ? (memberID && memberID.classSym) ? memberID.classSym.registered : ((type.kind == classType && type._class) ? type._class.registered : null) : null;
+                     if(_class && memberID && memberID.string)
+                        snprintf(watchmsg, sizeof(watchmsg), $"Missing property evaluation for \"%s\" in class \"%s\"", memberID.string, _class.name);
+                     else
+                        snprintf(watchmsg, sizeof(watchmsg), $"Missing property evaluation for \"%s\"", wh.expression);
+                     break;
+                  }
+                  case functionCallErrorExp:
+                     if(exp.call.exp && exp.call.exp.type == identifierExp && exp.call.exp.identifier.string)
+                        snprintf(watchmsg, sizeof(watchmsg), $"Missing function evaluation for call to \"%s\"", exp.call.exp.identifier.string);
+                     else
+                        snprintf(watchmsg, sizeof(watchmsg), $"Missing function evaluation for \"%s\"", wh.expression);
                      break;
                   case memoryErrorExp:
                      // Need to ensure when set to memoryErrorExp, constant is set
                      snprintf(watchmsg, sizeof(watchmsg), $"Memory can't be read at %s", /*(exp.type == constantExp) ? */exp.constant /*: null*/);
                      break;
                   case dereferenceErrorExp:
-                     snprintf(watchmsg, sizeof(watchmsg), $"Dereference failure for \"%s\"", wh.expression);
+                     snprintf(watchmsg, sizeof(watchmsg), $"Dereferencing error evaluating \"%s\"", wh.expression);
                      break;
-                  case unknownErrorExp:
-                     snprintf(watchmsg, sizeof(watchmsg), $"Unknown error for \"%s\"", wh.expression);
+                  case divideBy0ErrorExp:
+                     snprintf(watchmsg, sizeof(watchmsg), "%s", $"Integer division by 0");
                      break;
                   case noDebuggerErrorExp:
                      snprintf(watchmsg, sizeof(watchmsg), $"Debugger required for symbol evaluation in \"%s\"", wh.expression);
                      break;
-                  case debugStateErrorExp:
-                     snprintf(watchmsg, sizeof(watchmsg), $"Incorrect debugger state for symbol evaluation in \"%s\"", wh.expression);
+                  case unknownErrorExp:
+                     // NOTE: This should never happen
+                     snprintf(watchmsg, sizeof(watchmsg), $"Error evaluating \"%s\"", wh.expression);
                      break;
                   case 0:
+                     // NOTE: This should never happen
                      snprintf(watchmsg, sizeof(watchmsg), $"Null type for \"%s\"", wh.expression);
                      break;
-                  case constantExp:
                   case stringExp:
+                     wh.value = CopyString(exp.string);
+                     break;
+                  case constantExp:
                      // Temporary Code for displaying Strings
                      if((exp.expType && ((exp.expType.kind == pointerType ||
                               exp.expType.kind == arrayType) && exp.expType.type.kind == charType)) ||
@@ -2854,15 +2958,13 @@ class Debugger
                               !strcmp(wh.type._class.registered.name, "String")))
                      {
 
-                        if(exp.expType.kind != arrayType || exp.hasAddress)
+                        if(exp.expType && (exp.expType.kind != arrayType || exp.hasAddress))
                         {
                            uint64 address;
-                           char * string;
                            char value[4196];
-                           int len;
                            //char temp[MAX_F_STRING * 32];
 
-                           ExpressionType evalError = dummyExp;
+                           //ExpressionType evalError = dummyExp;
                            /*if(exp.expType.kind == arrayType)
                               sprintf(temp, "(char*)0x%x", exp.address);
                            else
@@ -2871,56 +2973,76 @@ class Debugger
                            //evaluation = Debugger::EvaluateExpression(temp, &evalError);
                            // address = strtoul(exp.constant, null, 0);
                            address = _strtoui64(exp.constant, null, 0);
-                           //_dpl(0, "0x", address);
+                           //_dplf(0, "0x", address);
                            // snprintf(value, sizeof(value), "0x%08x ", address);
 
                            if(address > 0xFFFFFFFFLL)
-                              snprintf(value, sizeof(value), (GetRuntimePlatform() == win32) ? "0x%016I64x " : "0x%016llx ", address);
+                              snprintf(value, sizeof(value), (__runtimePlatform == win32) ? "0x%016I64x " : "0x%016llx ", address);
                            else
-                              snprintf(value, sizeof(value), (GetRuntimePlatform() == win32) ? "0x%08I64x " : "0x%08llx ", address);
+                              snprintf(value, sizeof(value), (__runtimePlatform == win32) ? "0x%08I64x " : "0x%08llx ", address);
                            value[sizeof(value)-1] = 0;
 
                            if(!address)
                               strcat(value, $"Null string");
                            else
                            {
-                              int size = 4096;
-                              len = strlen(value);
-                              string = null;
-                              while(!string && size > 2)
+                              String string = new char[4097];
+                              int start = 0;
+                              bool success = false;
+                              int size = 256;
+                              bool done = false;
+
+                              for(start = 0; !done && start + size <= 4096; start += size)
                               {
-                                 string = GdbReadMemory(address, size);
-                                 size /= 2;
+                                 byte * s = null;
+                                 while(!done && !s)
+                                 {
+                                    // Try to read 256 bytes at a time, then half if that fails
+                                    s = GdbReadMemory(address + start, size);
+                                    if(s)
+                                    {
+                                       success = true;
+                                       memcpy(string + start, s, size);
+                                       string[start + size] = 0;
+                                       if(size == 1 || memchr(s, 0, size))
+                                          done = true;
+                                    }
+                                    else if(size > 1)
+                                       size /= 2;
+                                    else
+                                       done = true;
+                                 }
+                                 delete s;
                               }
-                              if(string && string[0])
+                              if(success)
                               {
-                                 value[len++] = '(';
-                                 if(UTF8Validate(string))
+                                 if(string[0])
                                  {
-                                    int c;
-                                    char ch;
+                                    int len = strlen(value);
+                                    value[len++] = '(';
+                                    if(UTF8Validate(string))
+                                    {
+                                       int c;
+                                       char ch;
 
-                                    for(c = 0; (ch = string[c]) && c<4096; c++)
-                                       value[len++] = ch;
-                                    value[len++] = ')';
-                                    value[len++] = '\0';
+                                       for(c = 0; (ch = string[c]); c++)
+                                          value[len++] = ch;
+                                       value[len++] = ')';
+                                       value[len++] = '\0';
 
+                                    }
+                                    else
+                                    {
+                                       ISO8859_1toUTF8(string, value + len, strlen(value) - len - 30);
+                                       strcat(value, ") (ISO8859-1)");
+                                    }
                                  }
                                  else
-                                 {
-                                    ISO8859_1toUTF8(string, value + len, 4096 - len - 30);
-                                    strcat(value, ") (ISO8859-1)");
-                                 }
-
-                                 delete string;
-                              }
-                              else if(string)
-                              {
-                                 strcat(value, $"Empty string");
-                                 delete string;
+                                    strcat(value, $"Empty string");
                               }
                               else
                                  strcat(value, $"Couldn't read memory");
+                              delete string;
                            }
                            wh.value = CopyString(value);
                         }
@@ -2928,21 +3050,30 @@ class Debugger
                      else if(wh.type && wh.type.kind == classType && wh.type._class &&
                               wh.type._class.registered && wh.type._class.registered.type == enumClass)
                      {
-                        uint64 value = strtoul(exp.constant, null, 0);
                         Class enumClass = eSystem_FindClass(GetPrivateModule(), wh.type._class.registered.name);
                         EnumClassData enumeration = (EnumClassData)enumClass.data;
-                        NamedLink item;
+                        NamedLink64 item;
+                        int64 value;
+
+                        if(!strcmp(enumClass.dataTypeString, "uint64"))
+                        {
+                           uint64 v = strtoull(exp.constant, null, 0);
+                           value = *(int64*)&v;
+                        }
+                        else
+                           value = strtoll(exp.constant, null, 0);
+
                         for(item = enumeration.values.first; item; item = item.next)
-                           if((int)item.data == value)
+                           if(item.data == value)
                               break;
                         if(item)
                            wh.value = CopyString(item.name);
                         else
-                           wh.value = CopyString($"Invalid Enum Value");
+                           wh.value = PrintString($"Invalid Enum Value (", value, ")");
                         result = true;
                      }
                      else if(wh.type && (wh.type.kind == charType || (wh.type.kind == classType && wh.type._class &&
-                              wh.type._class.registered && !strcmp(wh.type._class.registered.fullName, "ecere::com::unichar"))) )
+                              wh.type._class.registered && !strcmp(wh.type._class.registered.fullName, "unichar"))) )
                      {
                         unichar value;
                         int signedValue;
@@ -3000,7 +3131,7 @@ class Debugger
                         else if(value > 256 || wh.type.kind != charType)
                         {
                            if(value > 0x10FFFF || !GetCharCategory(value))
-                              snprintf(string, sizeof(string), $"Invalid Unicode Keypoint (0x%08X)", value);
+                              snprintf(string, sizeof(string), $"Invalid Unicode Codepoint (0x%08X)", value);
                            else
                               snprintf(string, sizeof(string), "\'%s\' (U+%04X)", charString, value);
                         }
@@ -3018,22 +3149,48 @@ class Debugger
                      }
                      break;
                   default:
-                     if(exp.hasAddress)
-                     {
-                        wh.value = PrintHexUInt64(exp.address);
-                        result = true;
-                     }
-                     else
+                  {
+                     bool genericError = true;
+                     if(exp.expType && exp.hasAddress)
                      {
-                        char tempString[256];
-                        if(exp.member.memberType == propertyMember)
-                           snprintf(watchmsg, sizeof(watchmsg), $"Missing property evaluation support for \"%s\"", wh.expression);
-                        else
-                           snprintf(watchmsg, sizeof(watchmsg), $"Evaluation failed for \"%s\" of type \"%s\"", wh.expression,
-                                 exp.type.OnGetString(tempString, null, null));
+                        bool showAddress = false;
+                        switch(exp.expType.kind)
+                        {
+                           case pointerType:
+                           case functionType:
+                           case methodType:
+                           case arrayType:
+                           case subClassType:
+                           case thisClassType:
+                              showAddress = true;
+                              break;
+                           case classType:
+                           {
+                              Symbol s = exp.expType._class;
+                              if(s)
+                              {
+                                 Class c = s.registered;
+                                 if(c.type == noHeadClass || c.type == normalClass)
+                                    showAddress = true;
+                              }
+                              break;
+                           }
+                        }
+                        if(showAddress)
+                        {
+                           wh.value = PrintHexUInt64(exp.address);
+                           result = true;
+                           genericError = false;
+                        }
                      }
+                     if(genericError)
+                        // NOTE: This should ideally be handled with a specific error message
+                        snprintf(watchmsg, sizeof(watchmsg), $"Error evaluating \"%s\"", wh.expression);
                      break;
+                  }
                }
+
+               SetInDebugger(false);
             }
             else
                snprintf(watchmsg, sizeof(watchmsg), $"Invalid expression: \"%s\"", wh.expression);
@@ -3059,7 +3216,7 @@ class Debugger
 
    void EvaluateWatches()
    {
-      _dpl2(_dpct, dplchan::debuggerWatches, 0, "Debugger::EvaluateWatches()");
+      _dpcl(_dpct, dplchan::debuggerWatches, 0, "Debugger::EvaluateWatches()");
       WatchesLinkCodeEditor();
       if(state == stopped)
       {
@@ -3070,10 +3227,10 @@ class Debugger
 
    char * ::GdbEvaluateExpression(char * expression)
    {
-      _dpl2(_dpct, dplchan::debuggerWatches, 0, "Debugger::GdbEvaluateExpression(", expression, ")");
+      _dpcl(_dpct, dplchan::debuggerWatches, 0, "Debugger::GdbEvaluateExpression(", expression, ")");
       eval.active = true;
       eval.error = none;
-      GdbCommand(false, "-data-evaluate-expression \"%s\"", expression);
+      GdbCommand(0, false, "-data-evaluate-expression \"%s\"", expression);
       if(eval.active)
          ide.outputView.debugBox.Logf("Debugger Error: GdbEvaluateExpression\n");
       return eval.result;
@@ -3082,18 +3239,15 @@ class Debugger
    // to be removed... use GdbReadMemory that returns a byte array instead
    char * ::GdbReadMemoryString(uint64 address, int size, char format, int rows, int cols)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbReadMemoryString(", address, ")");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbReadMemoryString(", address, ")");
       eval.active = true;
       eval.error = none;
 #ifdef _DEBUG
       if(!size)
-         _dpl(0, "GdbReadMemoryString called with size = 0!");
+         _dplf(0, "GdbReadMemoryString called with size = 0!");
 #endif
-      // GdbCommand(false, "-data-read-memory 0x%08x %c, %d, %d, %d", address, format, size, rows, cols);
-      if(GetRuntimePlatform() == win32)
-         GdbCommand(false, "-data-read-memory 0x%016I64x %c, %d, %d, %d", address, format, size, rows, cols);
-      else
-         GdbCommand(false, "-data-read-memory 0x%016llx %c, %d, %d, %d", address, format, size, rows, cols);
+      GdbCommand(0, false,
+         (__runtimePlatform == win32) ? "-data-read-memory 0x%016I64x %c, %d, %d, %d" : "-data-read-memory 0x%016llx %c, %d, %d, %d", address, format, size, rows, cols);
       if(eval.active)
          ide.outputView.debugBox.Logf("Debugger Error: GdbReadMemoryString\n");
       return eval.result;
@@ -3101,24 +3255,22 @@ class Debugger
 
    byte * ::GdbReadMemory(uint64 address, int bytes)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbReadMemory(", address, ")");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbReadMemory(", address, ")");
       eval.active = true;
       eval.error = none;
-      //GdbCommand(false, "-data-read-memory 0x%08x %c, 1, 1, %d", address, 'u', bytes);
-      if(GetRuntimePlatform() == win32)
-         GdbCommand(false, "-data-read-memory 0x%016I64x %c, 1, 1, %d", address, 'u', bytes);
-      else
-         GdbCommand(false, "-data-read-memory 0x%016llx %c, 1, 1, %d", address, 'u', bytes);
+      GdbCommand(0, false,
+         (__runtimePlatform == win32) ? "-data-read-memory 0x%016I64x %c, 1, 1, %d" : "-data-read-memory 0x%016llx %c, 1, 1, %d",
+         address, 'u', bytes);
 #ifdef _DEBUG
       if(!bytes)
-         _dpl(0, "GdbReadMemory called with bytes = 0!");
+         _dplf(0, "GdbReadMemory called with bytes = 0!");
 #endif
       if(eval.active)
          ide.outputView.debugBox.Logf("Debugger Error: GdbReadMemory\n");
       else if(eval.result && strcmp(eval.result, "N/A"))
       {
          byte * result = new byte[bytes];
-         byte * string = eval.result;
+         char * string = eval.result;
          int c = 0;
          while(true)
          {
@@ -3133,6 +3285,7 @@ class Debugger
             else
                break;
          }
+         delete eval.result;
          return result;
       }
       return null;
@@ -3142,7 +3295,7 @@ class Debugger
    {
       bool result = true;
       char * s1 = null; char * s2 = null;
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::BreakpointHit(",
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::BreakpointHit(",
             "bpInternal(", bpInternal ? s1=bpInternal.CopyLocationString(false) : null, "), ",
             "bpUser(", bpUser ? s2=bpUser.CopyLocationString(false) : null, ")) -- ",
             "ignoreBreakpoints(", ignoreBreakpoints, "), ",
@@ -3211,7 +3364,7 @@ class Debugger
 
    void ValgrindTargetThreadExit()
    {
-      ide.outputView.debugBox.Logf($"ValgrindTargetThreadExit\n");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::ValgrindTargetThreadExit()");
       if(vgTargetHandle)
       {
          vgTargetHandle.Wait();
@@ -3222,15 +3375,14 @@ class Debugger
 
    void GdbThreadExit()
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbThreadExit()");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbThreadExit()");
       if(state != terminated)
       {
          _ChangeState(terminated);
          targetProcessId = 0;
          ClearBreakDisplay();
 
-         if(vgLogFile)
-            delete vgLogFile;
+         delete vgLogFile;
          if(gdbHandle)
          {
             serialSemaphore.Release();
@@ -3259,7 +3411,7 @@ class Debugger
 
 #if defined(GDB_DEBUG_CONSOLE) || defined(GDB_DEBUG_GUI)
 #ifdef GDB_DEBUG_CONSOLE
-      // _dpl2(_dpct, dplchan::gdbOutput, 0, output);
+      // _dpcl(_dpct, dplchan::gdbOutput, 0, output);
       puts(output);
 #endif
 #ifdef GDB_DEBUG_OUTPUT
@@ -3355,7 +3507,7 @@ class Debugger
                            }
                         }
                         else
-                           _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "kill reply (", item.name, "=", item.value, ") is unheard of");
+                           _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "kill reply (", item.name, "=", item.value, ") is unheard of");
                      }
                      else
                         HandleExit(null, null);
@@ -3368,7 +3520,7 @@ class Debugger
                      sentBreakInsert = false;
 #ifdef _DEBUG
                      if(bpItem)
-                        _dpl(0, "problem");
+                        _dplf(0, "problem");
 #endif
                      delete bpItem;
                      bpItem = ParseBreakpoint(item.value, outTokens);
@@ -3401,10 +3553,10 @@ class Debugger
                               item.value = StripCurlies(item.value);
                               ParseFrame(frame, item.value);
                               if(frame.file && frame.from)
-                                 _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "unexpected frame file and from members present");
+                                 _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "unexpected frame file and from members present");
                               if(frame.file)
                               {
-                                 char * s;
+                                 char * s = null;
                                  if(activeFrameLevel == -1)
                                  {
                                     if(ide.projectView.IsModuleInProject(frame.file));
@@ -3438,7 +3590,7 @@ class Debugger
 
                                  if(frame.from)
                                  {
-                                    char * s;
+                                    char * s = null;
                                     ide.callStackView.Logf($"inside %s, %s\n", frame.func, (s = CopySystemPath(frame.from)));
                                     delete s;
                                  }
@@ -3449,7 +3601,7 @@ class Debugger
                               }
                            }
                            else
-                              _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "stack content (", item.name, "=", item.value, ") is unheard of");
+                              _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "stack content (", item.name, "=", item.value, ") is unheard of");
                         }
                      }
                      if(activeFrameLevel == -1)
@@ -3484,7 +3636,7 @@ class Debugger
                               ide.threadsView.Logf("%3d \n", value);
                            }
                            else
-                              _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "threads content (", item.name, "=", item.value, ") is unheard of");
+                              _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "threads content (", item.name, "=", item.value, ") is unheard of");
                         }
                         if(!i)
                            break;
@@ -3549,9 +3701,9 @@ class Debugger
                      }
                   }
                   else if(!strcmp(item.name, "source-path") || !strcmp(item.name, "BreakpointTable"))
-                     _dpl2(_dpct, dplchan::gdbProtoIgnored, 0, "command reply (", item.name, "=", item.value, ") is ignored");
+                     _dpcl(_dpct, dplchan::gdbProtoIgnored, 0, "command reply (", item.name, "=", item.value, ") is ignored");
                   else
-                     _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "command reply (", item.name, "=", item.value, ") is unheard of");
+                     _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "command reply (", item.name, "=", item.value, ") is unheard of");
                }
             }
             else if(!strcmp(outTokens[0], "^running"))
@@ -3631,7 +3783,7 @@ class Debugger
 #ifdef _DEBUG
                         if(strlen(item.value) < MAX_F_STRING)
                         {
-                           char * s;
+                           char * s = null;
                            ide.outputView.debugBox.Logf("GDB: %s\n", (s = CopyUnescapedString(item.value)));
                            delete s;
                         }
@@ -3642,32 +3794,34 @@ class Debugger
                   }
                }
                else
-                  _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "error content (", item.name, "=", item.value, ") is unheard of");
+                  _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "error content (", item.name, "=", item.value, ") is unheard of");
             }
             else
-               _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "result-record: ", outTokens[0]);
+               _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "result-record: ", outTokens[0]);
             outTokens.RemoveAll();
             break;
          case '+':
-            _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "status-async-output: ", outTokens[0]);
+            _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "status-async-output: ", outTokens[0]);
             break;
          case '=':
             if(TokenizeList(output, ',', outTokens))
             {
                if(!strcmp(outTokens[0], "=library-loaded"))
-                  FGODetectLoadedLibraryForAddedProjectIssues(outTokens);
+                  FGODetectLoadedLibraryForAddedProjectIssues(outTokens, false);
+               else if(!strcmp(outTokens[0], "=shlibs-added"))
+                  FGODetectLoadedLibraryForAddedProjectIssues(outTokens, true);
                else if(!strcmp(outTokens[0], "=thread-group-created") || !strcmp(outTokens[0], "=thread-group-added") ||
                         !strcmp(outTokens[0], "=thread-group-started") || !strcmp(outTokens[0], "=thread-group-exited") ||
                         !strcmp(outTokens[0], "=thread-created") || !strcmp(outTokens[0], "=thread-exited") ||
                         !strcmp(outTokens[0], "=cmd-param-changed") || !strcmp(outTokens[0], "=library-unloaded") ||
                         !strcmp(outTokens[0], "=breakpoint-modified"))
-                  _dpl2(_dpct, dplchan::gdbProtoIgnored, 0, outTokens[0], outTokens.count>1 ? outTokens[1] : "",
+                  _dpcl(_dpct, dplchan::gdbProtoIgnored, 0, outTokens[0], outTokens.count>1 ? outTokens[1] : "",
                            outTokens.count>2 ? outTokens[2] : "", outTokens.count>3 ? outTokens[3] : "",
                            outTokens.count>4 ? outTokens[4] : "", outTokens.count>5 ? outTokens[5] : "",
                            outTokens.count>6 ? outTokens[6] : "", outTokens.count>7 ? outTokens[7] : "",
                            outTokens.count>8 ? outTokens[8] : "", outTokens.count>9 ? outTokens[9] : "");
                else
-                  _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "notify-async-output: ", outTokens[0]);
+                  _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "notify-async-output: ", outTokens[0]);
             }
             outTokens.RemoveAll();
             break;
@@ -3718,7 +3872,7 @@ class Debugger
                            {
                               char r = reason[0];
 #ifdef _DEBUG
-                              if(stopItem) _dpl(0, "problem");
+                              if(stopItem) _dplf(0, "problem");
 #endif
                               stopItem = GdbDataStop { };
                               stopItem.reason = r == 'b' ? breakpointHit : r == 'f' ? functionFinished : r == 'e' ? endSteppingRange : r == 'l' ? locationReached : signalReceived;
@@ -3745,13 +3899,13 @@ class Debugger
                                  else if(stopItem.reason == signalReceived && !strcmp(item.name, "signal-meaning"))
                                     stopItem.meaning = CopyString(item.value);
                                  else if(!strcmp(item.name, "stopped-threads"))
-                                    _dpl2(_dpct, dplchan::gdbProtoIgnored, 0, reason, ": Advanced thread debugging not handled");
+                                    _dpcl(_dpct, dplchan::gdbProtoIgnored, 0, reason, ": Advanced thread debugging not handled");
                                  else if(!strcmp(item.name, "core"))
-                                    _dpl2(_dpct, dplchan::gdbProtoIgnored, 0, reason, ": Information (core) not used");
+                                    _dpcl(_dpct, dplchan::gdbProtoIgnored, 0, reason, ": Information (core) not used");
                                  else if(!strcmp(item.name, "disp"))
-                                    _dpl2(_dpct, dplchan::gdbProtoIgnored, 0, reason, ": (", item.name, "=", item.value, ")");
+                                    _dpcl(_dpct, dplchan::gdbProtoIgnored, 0, reason, ": (", item.name, "=", item.value, ")");
                                  else
-                                    _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "Unknown ", reason, " item name (", item.name, "=", item.value, ")");
+                                    _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "Unknown ", reason, " item name (", item.name, "=", item.value, ")");
                               }
 
                               if(stopItem.reason == signalReceived && !strcmp(stopItem.name, "SIGTRAP"))
@@ -3775,15 +3929,15 @@ class Debugger
                               }
                            }
                            else if(!strcmp(reason, "watchpoint-trigger"))
-                              _dpl2(_dpct, dplchan::gdbProtoIgnored, 0, "Reason watchpoint trigger not handled");
+                              _dpcl(_dpct, dplchan::gdbProtoIgnored, 0, "Reason watchpoint trigger not handled");
                            else if(!strcmp(reason, "read-watchpoint-trigger"))
-                              _dpl2(_dpct, dplchan::gdbProtoIgnored, 0, "Reason read watchpoint trigger not handled");
+                              _dpcl(_dpct, dplchan::gdbProtoIgnored, 0, "Reason read watchpoint trigger not handled");
                            else if(!strcmp(reason, "access-watchpoint-trigger"))
-                              _dpl2(_dpct, dplchan::gdbProtoIgnored, 0, "Reason access watchpoint trigger not handled");
+                              _dpcl(_dpct, dplchan::gdbProtoIgnored, 0, "Reason access watchpoint trigger not handled");
                            else if(!strcmp(reason, "watchpoint-scope"))
-                              _dpl2(_dpct, dplchan::gdbProtoIgnored, 0, "Reason watchpoint scope not handled");
+                              _dpcl(_dpct, dplchan::gdbProtoIgnored, 0, "Reason watchpoint scope not handled");
                            else
-                              _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "Unknown reason: ", reason);
+                              _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "Unknown reason: ", reason);
                         }
                         else
                         {
@@ -3797,7 +3951,7 @@ class Debugger
                }
             }
             else
-               _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "Unknown exec-async-output: ", outTokens[0]);
+               _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, "Unknown exec-async-output: ", outTokens[0]);
             outTokens.RemoveAll();
             break;
          case '(':
@@ -3805,6 +3959,7 @@ class Debugger
             {
                if(waitingForPID)
                {
+                  Time startTime = GetTime();
                   char exeFile[MAX_LOCATION];
                   int oldProcessID = targetProcessId;
                   GetLastDirectory(targetFile, exeFile);
@@ -3812,8 +3967,12 @@ class Debugger
                   while(!targetProcessId/*true*/)
                   {
                      targetProcessId = Process_GetChildExeProcessId(gdbProcessId, exeFile);
-                     if(targetProcessId || gdbHandle.Peek()) break;
+                     if(targetProcessId) break;
+                     // Can't break on Peek(), GDB is giving us =library and other info before the process is listed in /proc
+                     // if(gdbHandle.Peek()) break;
                      Sleep(0.01);
+                     if(gdbHandle.Peek() && GetTime() - startTime > 2.5)  // Give the process 2.5 seconds to show up in /proc
+                        break;
                   }
 
                   if(targetProcessId)
@@ -3864,7 +4023,7 @@ class Debugger
                serialSemaphore.Release();
             }
             else
-               _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, $"Unknown prompt", output);
+               _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, $"Unknown prompt", output);
 
             break;
          case '&':
@@ -3878,7 +4037,7 @@ class Debugger
                   content++;
                if(content)
                {
-                  char * s;
+                  char * s = null;
                   ide.outputView.debugBox.LogRaw((s = CopyUnescapedString(content)));
                   delete s;
                   ide.Update(null);
@@ -3886,7 +4045,7 @@ class Debugger
             }
             break;
          default:
-            _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, $"Unknown output: ", output);
+            _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, $"Unknown output: ", output);
       }
       if(!setWaitingForPID)
          waitingForPID = false;
@@ -3899,13 +4058,13 @@ class Debugger
    }
 
    // From GDB Output functions
-   void FGODetectLoadedLibraryForAddedProjectIssues(Array<char *> outTokens)
+   void FGODetectLoadedLibraryForAddedProjectIssues(Array<char *> outTokens, bool shlibs)
    {
       char path[MAX_LOCATION] = "";
       char file[MAX_FILENAME] = "";
-      bool symbolsLoaded;
+      //bool symbolsLoaded = false;
       DebugListItem item { };
-      //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::FGODetectLoadedLibraryForAddedProjectIssues()");
+      //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::FGODetectLoadedLibraryForAddedProjectIssues()");
       for(token : outTokens)
       {
          if(TokenizeListItem(token, item))
@@ -3918,7 +4077,30 @@ class Debugger
             }
             else if(!strcmp(item.name, "symbols-loaded"))
             {
-               symbolsLoaded = (atoi(item.value) == 1);
+               //symbolsLoaded = (atoi(item.value) == 1);
+            }
+            else if(!strcmp(item.name, "shlib-info"))
+            {
+               DebugListItem subItem { };
+               Array<char *> tokens { minAllocSize = 50 };
+               item.value = StripBrackets(item.value);
+               TokenizeList(item.value, ',', tokens);
+               for(t : tokens)
+               {
+                  if(TokenizeListItem(t, subItem))
+                  {
+                     if(!strcmp(subItem.name, "path"))
+                     {
+                        StripQuotes(subItem.value, path);
+                        MakeSystemPath(path);
+                        GetLastDirectory(path, file);
+                        //symbolsLoaded = true;
+                     }
+                  }
+               }
+               tokens.RemoveAll();
+               delete tokens;
+               delete subItem;
             }
          }
       }
@@ -3989,7 +4171,7 @@ class Debugger
 
    void FGOBreakpointModified(Array<char *> outTokens)
    {
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::FGOBreakpointModified() -- TODO only if needed: support breakpoint modified");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::FGOBreakpointModified() -- TODO only if needed: support breakpoint modified");
 #if 0
       DebugListItem item { };
       if(outTokens.count > 1 && TokenizeListItem(outTokens[1], item))
@@ -4006,7 +4188,7 @@ class Debugger
 
    ExpressionType ::DebugEvalExpTypeError(char * result)
    {
-      _dpl2(_dpct, dplchan::debuggerWatches, 0, "Debugger::DebugEvalExpTypeError()");
+      _dpcl(_dpct, dplchan::debuggerWatches, 0, "Debugger::DebugEvalExpTypeError()");
       if(result)
          return dummyExp;
       switch(eval.error)
@@ -4022,7 +4204,7 @@ class Debugger
    char * ::EvaluateExpression(char * expression, ExpressionType * error)
    {
       char * result;
-      _dpl2(_dpct, dplchan::debuggerWatches, 0, "Debugger::EvaluateExpression(", expression, ")");
+      _dpcl(_dpct, dplchan::debuggerWatches, 0, "Debugger::EvaluateExpression(", expression, ")");
       if(ide.projectView && ide.debugger.state == stopped)
       {
          result = GdbEvaluateExpression(expression);
@@ -4040,7 +4222,7 @@ class Debugger
    {
       // check for state
       char * result = GdbReadMemoryString(address, size, format, 1, 1);
-      _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::ReadMemory(", address, ")");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::ReadMemory(", address, ")");
       if(!result || !strcmp(result, "N/A"))
          *error = memoryErrorExp;
       else
@@ -4056,18 +4238,20 @@ class ValgrindLogThread : Thread
    unsigned int Main()
    {
       static char output[4096];
+      bool lastLineEmpty = true;
       Array<char> dynamicBuffer { minAllocSize = 4096 };
       File oldValgrindHandle = vgLogFile;
       incref oldValgrindHandle;
 
       app.Lock();
-      while(debugger.state != terminated && vgLogFile)
+      while(debugger.state != terminated && vgLogFile && vgLogFile.input)
       {
-         int result;
+         int result = 0;
          app.Unlock();
-         result = vgLogFile.Read(output, 1, sizeof(output));
+         if(vgLogFile)
+            result = vgLogFile.Read(output, 1, sizeof(output));
          app.Lock();
-         if(debugger.state == terminated || !vgLogFile/* || vgLogFile.Eof()*/)
+         if(debugger.state == terminated || !vgLogFile) // || vgLogFile.Eof()
             break;
          if(result)
          {
@@ -4082,55 +4266,83 @@ class ValgrindLogThread : Thread
                   dynamicBuffer.size += c - start;
                   memcpy(&dynamicBuffer[pos], output + start, c - start);
                   if(dynamicBuffer.count && dynamicBuffer[dynamicBuffer.count - 1] != '\r')
-                  // COMMENTED OUT DUE TO ISSUE #135, FIXED
-                  //if(dynamicBuffer.array[dynamicBuffer.count - 1] != '\r')
                      dynamicBuffer.size++;
                   dynamicBuffer[dynamicBuffer.count - 1] = '\0';
 #ifdef _DEBUG
                   // printf("%s\n", dynamicBuffer.array);
 #endif
-                  if(strstr(&dynamicBuffer[0], "vgdb me"))
+                  if(strstr(&dynamicBuffer[0], "vgdb me ..."))
                      debugger.serialSemaphore.Release();
                   {
-                     char * msg = strstr(&dynamicBuffer[0], "==");
-                     if(msg)
-                        msg = strstr(msg+2, "== ");
-                     if(msg)
+                     char * s = strstr(&dynamicBuffer[0], "==");
+                     if(s)
+                        s = strstr(s+2, "== ");
+                     if(s)
+                     {
+                        s += 3;
+                        if(s[0] == '\0' && !lastLineEmpty)
+                        {
+                           s = null;
+                           lastLineEmpty = true;
+                           dynamicBuffer[0] = '\0';
+                        }
+                     }
+                     if(s)
                      {
-                        msg += 3;
-                        switch(msg[0])
+                        char * t = s;
+                        switch(s[0])
                         {
                            case '(':
-                              msg = strstr(msg, "(action ");
-                              if(msg)
+                              if(strstr(s, "vgdb me ..."))
                               {
-                                 msg += 8;
-                                 if(!strstr(msg, "at startup) vgdb me ...") || !strstr(msg, "on error) vgdb me ..."))
-                                    msg = null;
+                                 if(strstr(s, "(action on error) vgdb me ..."))
+                                    ide.outputView.debugBox.Logf($"...breaked on Valgrind error (F5 to resume)\n");
+                                 s[0] = '\0';
                               }
+                              else
+                                 s = null;
                               break;
                            case 'T':
-                              if(!strstr(msg, "TO DEBUG THIS PROCESS USING GDB: start GDB like this"))
-                                 msg = null;
+                              if(strstr(s, "TO DEBUG THIS PROCESS USING GDB: start GDB like this"))
+                                 s[0] = '\0';
+                              else
+                                 s = null;
                               break;
                            case 'a':
-                              if(!strstr(msg, "and then give GDB the following command"))
-                                 msg = null;
+                              if(strstr(s, "and then give GDB the following command"))
+                                 s[0] = '\0';
+                              else
+                                 s = null;
                               break;
                            case ' ':
-                              if(!strstr(msg, "/path/to/gdb") && !strstr(msg, "target remote | /usr/lib/valgrind/../../bin/vgdb --pid="))
-                                 msg = null;
+                              if(strstr(s, "/path/to/gdb") || strstr(s, "target remote | /usr/lib/valgrind/../../bin/vgdb --pid="))
+                                 s[0] = '\0';
+                              else
+                                 s = null;
                               break;
                            case '-':
-                              if(!strstr(msg, "--pid is optional if only one valgrind process is running"))
-                                 msg = null;
+                              if(strstr(s, "--pid is optional if only one valgrind process is running"))
+                                 s[0] = '\0';
+                              else
+                                 s = null;
+                              break;
+                           case 'U':
+                              if((s = strstr(s, "; rerun with -h for copyright info")))
+                              {
+                                 s[0] = '\0';
+                                 s = null;
+                              }
+                              break;
+                           case '\0':
                               break;
                            default:
-                              msg = null;
+                              s = null;
                               break;
                         }
+                        if(lastLineEmpty && t[0] != '\0')
+                           lastLineEmpty = false;
                      }
-                     if(!msg)
+                     if(!s)
                         ide.outputView.debugBox.Logf("%s\n", &dynamicBuffer[0]);
                   }
                   dynamicBuffer.size = 0;
@@ -4155,7 +4367,7 @@ class ValgrindLogThread : Thread
          }
       }
       delete dynamicBuffer;
-      ide.outputView.debugBox.Logf($"ValgrindLogThreadExit\n");
+      _dpcl(_dpct, dplchan::debuggerCall, 0, "ValgrindLogThreadExit");
       //if(oldValgrindHandle == vgLogFile)
          debugger.GdbThreadExit/*ValgrindLogThreadExit*/();
       delete oldValgrindHandle;
@@ -4271,7 +4483,7 @@ class GdbThread : Thread
                      dynamicBuffer.size++;
                   dynamicBuffer[dynamicBuffer.count - 1] = '\0';
 #ifdef _DEBUG
-                  // _dpl(0, dynamicBuffer.array);
+                  // _dplf(0, dynamicBuffer.array);
 #endif
                   debugger.GdbThreadMain(&dynamicBuffer[0]);
                   dynamicBuffer.size = 0;
@@ -4288,7 +4500,7 @@ class GdbThread : Thread
          else
          {
 #ifdef _DEBUG
-            _dpl(0, "Got end of file from GDB!");
+            _dplf(0, "Got end of file from GDB!");
 #endif
          }
       }
@@ -4319,11 +4531,11 @@ class ProgramThread : Thread
    bool terminate;
    unsigned int Main()
    {
-      bool result = true;
-      bool fileCreated = false;
-      mode_t mask = 0600;
+      //bool result = true;
+      //bool fileCreated = false;
+      //mode_t mask = 0600;
       static char output[1000];
-      int fd;
+      int fd = 0;
 
       /*if(!mkfifo(progFifoPath, mask))
       {
@@ -4356,14 +4568,14 @@ class ProgramThread : Thread
       {
          fd_set rs, es;
          struct timeval time;
-         int selectResult;
+         //int selectResult;
          time.tv_sec = 1;
          time.tv_usec = 0;
          FD_ZERO(&rs);
          FD_ZERO(&es);
          FD_SET(fd, &rs);
          FD_SET(fd, &es);
-         selectResult = select(fd + 1, &rs, null, null, &time);
+         /*selectResult = */select(fd + 1, &rs, null, null, &time);
          if(FD_ISSET(fd, &rs))
          {
             int result = (int)read(fd, output, sizeof(output)-1);
@@ -4530,7 +4742,7 @@ class GdbDataBreakpoint : struct
 
    void Print()
    {
-   _dpl(0, "");
+   _dplf(0, "");
       PrintLn("{", "#", number, " T", type, " D", disp, " E", enabled, " H", times, " (", func, ") (", file, ":", line, ") (", fullname, ") (", addr, ") (", at, ")", "}");
    }
 
@@ -4559,13 +4771,13 @@ class Breakpoint : struct
    class_no_expansion;
 
    char * function;
-   property char * function { set { delete function; if(value) function = CopyString(value); } }
+   property const char * function { set { delete function; if(value) function = CopyString(value); } }
    char * relativeFilePath;
-   property char * relativeFilePath { set { delete relativeFilePath; if(value) relativeFilePath = CopyString(value); } }
+   property const char * relativeFilePath { set { delete relativeFilePath; if(value) relativeFilePath = CopyString(value); } }
    char * absoluteFilePath;
-   property char * absoluteFilePath { set { delete absoluteFilePath; if(value) absoluteFilePath = CopyString(value); } }
+   property const char * absoluteFilePath { set { delete absoluteFilePath; if(value) absoluteFilePath = CopyString(value); } }
    char * location;
-   property char * location { set { delete location; if(value) location = CopyString(value); } }
+   property const char * location { set { delete location; if(value) location = CopyString(value); } }
    int line;
    bool enabled;
    int hits;
@@ -4579,7 +4791,7 @@ class Breakpoint : struct
    GdbDataBreakpoint bp;
    Project project;
    char * address;
-   property char * address { set { delete address; if(value) address = CopyString(value); } }
+   property const char * address { set { delete address; if(value) address = CopyString(value); } }
 
    void ParseLocation()
    {
@@ -4613,7 +4825,7 @@ class Breakpoint : struct
          {
             if(!strcmp(prjName, prj.name))
             {
-               if(ProjectGetAbsoluteFromRelativePath(prj, filePath, fullPath))
+               if(prj.GetAbsoluteFromRelativePath(filePath, fullPath, null))
                {
                   property::absoluteFilePath = fullPath;
                   project = prj;
@@ -4627,7 +4839,7 @@ class Breakpoint : struct
       else
       {
          Project prj = ide.project;
-         if(ProjectGetAbsoluteFromRelativePath(prj, filePath, fullPath))
+         if(prj.GetAbsoluteFromRelativePath(filePath, fullPath, null))
          {
             property::absoluteFilePath = fullPath;
             project = prj;
@@ -4792,7 +5004,7 @@ class CodeLocation : struct
          char * temp;
          char loc[MAX_LOCATION];
          strcpy(loc, location);
-         for(temp = loc; temp = strstr(temp, ":"); temp++)
+         for(temp = loc; (temp = strstr(temp, ":")); temp++)
             colon = temp;
          if(colon)
          {
@@ -4805,7 +5017,7 @@ class CodeLocation : struct
                {
                   CodeLocation codloc { line = line };
                   codloc.file = CopyString(loc);
-                  codloc.absoluteFile = ide.workspace.GetAbsolutePathFromRelative(loc);
+                  codloc.absoluteFile = ide.workspace.CopyAbsolutePathFromRelative(loc);
                   return codloc;
                }
             }
@@ -4833,105 +5045,8 @@ void GDBFallBack(Expression exp, String expString)
    result = Debugger::EvaluateExpression(expString, &evalError);
    if(result)
    {
+      FreeExpContents(exp);
       exp.constant = result;
       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;
-}