// String Escape Copy
static void strescpy(char * d, char * s)
{
- int j, k;
- j = k = 0;
- while(s[j])
+ int j = 0, k = 0;
+ char ch;
+ while((ch = s[j]))
{
- switch(s[j])
+ switch(ch)
{
- case '\n':
- d[k] = '\\';
- d[++k] = 'n';
- break;
- case '\t':
- d[k] = '\\';
- d[++k] = 't';
- break;
- case '\a':
- d[k] = '\\';
- d[++k] = 'a';
- break;
- case '\b':
- d[k] = '\\';
- d[++k] = 'b';
- break;
- case '\f':
- d[k] = '\\';
- d[++k] = 'f';
- break;
- case '\r':
- d[k] = '\\';
- d[++k] = 'r';
- break;
- case '\v':
- d[k] = '\\';
- d[++k] = 'v';
- break;
- case '\\':
- d[k] = '\\';
- d[++k] = '\\';
- break;
- case '\"':
- d[k] = '\\';
- d[++k] = '\"';
- break;
- default:
- d[k] = s[j];
+ case '\n': d[k] = '\\'; d[++k] = 'n'; break;
+ case '\t': d[k] = '\\'; d[++k] = 't'; break;
+ case '\a': d[k] = '\\'; d[++k] = 'a'; break;
+ case '\b': d[k] = '\\'; d[++k] = 'b'; break;
+ case '\f': d[k] = '\\'; d[++k] = 'f'; break;
+ case '\r': d[k] = '\\'; d[++k] = 'r'; break;
+ case '\v': d[k] = '\\'; d[++k] = 'v'; break;
+ case '\\': d[k] = '\\'; d[++k] = '\\'; break;
+ case '\"': d[k] = '\\'; d[++k] = '\"'; break;
+ default: d[k] = s[j];
}
- ++j;
- ++k;
+ j++, k++;
}
- d[k] = s[j];
+ d[k] = '\0';
}
static char * CopyUnescapedSystemPath(char * p)
static void struscpy(char * d, char * s)
{
- int j, k;
- j = k = 0;
- while(s[j])
+ int j = 0, k = 0;
+ char ch;
+ while((ch = s[j]))
{
- switch(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];
+ 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;
+ j++, k++;
}
- d[k] = s[j];
+ d[k] = '\0';
}
static char * StripBrackets(char * string)
static int TokenizeList(char * string, const char seperator, Array<char *> tokens)
{
uint level = 0;
-
+
bool quoted = false, escaped = false;
char * start = string, ch;
-
+
for(; (ch = *string); string++)
{
if(!start)
*equal = '\0';
equal++;
item.value = equal;
- equal = null;
return true;
}
- else
- return false;
+ return false;
}
static bool CheckCommandAvailable(const char * command)
if(fl.stats.attribs.isFile && !fstrcmp(fl.name, name))
{
available = true;
+ fl.Stop();
break;
}
}
char * targetDir;
char * targetFile;
-
+
GdbExecution gdbExecution;
DebuggerUserAction userAction;
DebuggerState state;
GdbDataStop stopItem;
GdbDataBreakpoint bpItem;
Frame activeFrame;
-
+
List<Breakpoint> sysBPs { };
Breakpoint bpRunToCursor;
Breakpoint intBpEntry;
if(bp)
_dpl2(_dpct, dplchan::debuggerBreakpoints, 0, "gdb stopped by a breakpoint: ", bp.type, "(", s=bp.CopyLocationString(false), ")"); delete s;
}
+ delete bpReport;
}
#endif
}
targetDir = null;
targetFile = null;
-
+
_ChangeState(none);
event = none;
breakType = none;
- stopItem = null;
- bpItem = null;
+ delete stopItem;
+ delete bpItem;
activeFrame = 0;
-
+
bpRunToCursor = null;
delete currentCompiler;
/*GdbThread gdbThread
Timer gdbTimer*/
}
-
+
Debugger()
{
_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::constructor");
{
bool returnedExitCode = false;
char verboseExitCode[128];
-
+
_dpl2(_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;
}
else
verboseExitCode[0] = '\0';
-
+
event = exit;
// ClearBreakDisplay();
}
ide.Update(null);
}
-
+
DebuggerState StartSession(CompilerConfig compiler, ProjectConfig config, int bitDepth, bool useValgrind, bool restart, bool ignoreBreakpoints)
{
DebuggerState result = none;
*lineTopFrame = stopItem.frame.line;
else
*lineTopFrame = 0;
-
+
if(*lineTopFrame == *lineCursor && *lineTopFrame)
*lineTopFrame = 0;
}
}
}
}
-
+
// moving code cursors is futile, on next step, stop, hit, cursors will be offset anyways
}
while(debuggerFileDialog.Modal())
{
strcpy(sourceDir, debuggerFileDialog.filePath);
- if(!fstrcmp(ide.workspace.projectDir, sourceDir) &&
- MessageBox { type = yesNo, master = ide,
- contents = $"This is the project directory.\nWould you like to try again?",
+ if(!fstrcmp(ide.workspace.projectDir, sourceDir) &&
+ MessageBox { type = yesNo, master = ide,
+ contents = $"This is the project directory.\nWould you like to try again?",
text = $"Invalid Source Directory" }.Modal() == no)
return false;
else
break;
}
}
-
- if(srcDir &&
- MessageBox { type = yesNo, master = ide,
- contents = $"This source directory is already specified.\nWould you like to try again?",
+
+ if(srcDir &&
+ MessageBox { type = yesNo, master = ide,
+ contents = $"This source directory is already specified.\nWould you like to try again?",
text = $"Invalid Source Directory" }.Modal() == no)
return false;
else
strcpy(file, sourceDir);
PathCat(file, test);
result = FileExists(file);
- if(!result &&
- MessageBox { type = yesNo, master = ide,
- contents = $"Unable to locate source file.\nWould you like to try again?",
+ if(!result &&
+ MessageBox { type = yesNo, master = ide,
+ contents = $"Unable to locate source file.\nWould you like to try again?",
text = $"Invalid Source Directory" }.Modal() == no)
return false;
}
else
result = true;
-
+
if(result)
return true;
}
_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::AddSourceDir(", sourceDir, ")");
ide.workspace.sourceDirs.Add(CopyString(sourceDir));
ide.workspace.Save();
-
+
if(targeted)
{
DebuggerState oldState = state;
}
if(srcDir)
break;
-
+
if(SourceDirDialog(title, directory, null, sourceDir))
{
if(IsPathInsideOf(absolutePath, sourceDir))
MakePathRelative(absolutePath, sourceDir, relativePath);
break;
}
- else if(MessageBox { type = yesNo, master = ide,
- contents = $"You must provide a valid source directory in order to place a breakpoint in this file.\nWould you like to try again?",
+ else if(MessageBox { type = yesNo, master = ide,
+ contents = $"You must provide a valid source directory in order to place a breakpoint in this file.\nWould you like to try again?",
text = $"Invalid Source Directory" }.Modal() == no)
return;
}
Array<char *> argumentTokens { minAllocSize = 50 };
DebugListItem item { };
Argument arg;
-
+
//_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::ParseFrame()");
TokenizeList(string, ',', frameTokens);
for(i = 0; i < frameTokens.count; i++)
else
_dpl(0, "Bad frame");
}
-
+
delete frameTokens;
delete argsTokens;
delete argumentTokens;
_dpl2(_dpct, dplchan::gdbProtoUnknown, 0, "breakpoint member (", item.name, "=", item.value, ") is unheard of");
}
}
+ delete bpTokens;
+ delete item;
return bp;
}
vsnprintf(string, sizeof(string), format, args);
string[sizeof(string)-1] = 0;
va_end(args);
-
+
gdbReady = false;
ide.debugger.serialSemaphore.TryWait();
app.Unlock();
ide.debugger.serialSemaphore.Wait();
app.Lock();
- }
+ }
}
bool ValidateBreakpoint(Breakpoint bp)
if(bp.bp)
_dpl(0, "problem");
#endif
+ delete bp.bp;
bp.bp = GdbDataBreakpoint { };
}
}
{
GdbCommand(false, "-break-delete %s", bp.bp.number);
bp.inserted = false;
+ delete bp.bp;
bp.bp = { };
}
}
bpItem.multipleBPs.Free();
delete bpItem.multipleBPs;
}
+ delete bp.bp;
bp.bp = bpItem;
bpItem = null;
bp.inserted = (bp.bp && bp.bp.number && strcmp(bp.bp.number, "0"));
}
else
ChangeWorkingDir(ide.workspace.projectDir);
-
+
ide.SetPath(true, compiler, config, bitDepth);
// TODO: This pollutes the environment, but at least it works
gdbThread.Wait();
app.Lock();
}
+ if(vgLogThread)
+ {
+ app.Unlock();
+ vgLogThread.Wait();
+ app.Lock();
+ }
+ if(vgTargetThread)
+ {
+ app.Unlock();
+ vgTargetThread.Wait();
+ app.Lock();
+ }
+
+ if(vgLogFile)
+ delete vgLogFile;
if(gdbHandle)
{
gdbHandle.Wait();
bp.Reset();
if(bpRunToCursor)
bpRunToCursor.Reset();
-
+
ide.outputView.debugBox.Logf($"Debugging stopped\n");
ClearBreakDisplay();
ide.Update(null);
progThread.Wait();
app.Lock();
delete fifoFile;
- }
+ }
DeleteFile(progFifoPath);
progFifoPath[0] = '\0';
rmdir(progFifoDir);
bool ResolveWatch(Watch wh)
{
bool result = false;
-
+
_dpl2(_dpct, dplchan::debuggerWatches, 0, "Debugger::ResolveWatch()");
wh.Reset();
/*delete wh.value;
- if(wh.type)
+ if(wh.type)
{
FreeType(wh.type);
wh.type = null;
SetGlobalContext(codeEditor.globalContext);
SetGlobalData(&codeEditor.globalData);
}
-
+
exp = ParseExpressionString(wh.expression);
-
+
if(exp && !parseError)
{
char expString[4096];
long v = (long)exp.val.f;
sprintf(temp, "%i", v);
break;
- }
+ }
case doubleType:
{
long v = (long)exp.val.d;
long v = (long)exp.val.f;
sprintf(temp, "0x%x", v);
break;
- }
+ }
case doubleType:
{
long v = (long)exp.val.d;
long v = (long)exp.val.f;
sprintf(temp, "0o%o", v);
break;
- }
+ }
case doubleType:
{
long v = (long)exp.val.d;
case constantExp:
case stringExp:
// Temporary Code for displaying Strings
- if((exp.expType && ((exp.expType.kind == pointerType ||
- exp.expType.kind == arrayType) && exp.expType.type.kind == charType)) ||
- (wh.type && wh.type.kind == classType && wh.type._class &&
+ if((exp.expType && ((exp.expType.kind == pointerType ||
+ exp.expType.kind == arrayType) && exp.expType.type.kind == charType)) ||
+ (wh.type && wh.type.kind == classType && wh.type._class &&
wh.type._class.registered && wh.type._class.registered.type == normalClass &&
!strcmp(wh.type._class.registered.name, "String")))
{
else
snprintf(value, sizeof(value), (GetRuntimePlatform() == win32) ? "0x%08I64x " : "0x%08llx ", address);
value[sizeof(value)-1] = 0;
-
+
if(!address)
strcat(value, $"Null string");
else
{
int c;
char ch;
-
+
for(c = 0; (ch = string[c]) && c<4096; c++)
- value[len++] = ch;
+ value[len++] = ch;
value[len++] = ')';
value[len++] = '\0';
-
+
}
else
{
wh.value = CopyString(value);
}
}
- else if(wh.type && wh.type.kind == classType && wh.type._class &&
+ 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);
wh.value = CopyString($"Invalid Enum Value");
result = true;
}
- else if(wh.type && (wh.type.kind == charType || (wh.type.kind == classType && wh.type._class &&
+ 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"))) )
{
unichar value;
else
snprintf(string, sizeof(string), "\'%s\' (%d)", charString, value);
string[sizeof(string)-1] = 0;
-
+
wh.value = CopyString(string);
result = true;
}
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,
+ snprintf(watchmsg, sizeof(watchmsg), $"Evaluation failed for \"%s\" of type \"%s\"", wh.expression,
exp.type.OnGetString(tempString, null, null));
}
break;
snprintf(watchmsg, sizeof(watchmsg), $"Invalid expression: \"%s\"", wh.expression);
if(exp) FreeExpression(exp);
-
+
SetPrivateModule(backupPrivateModule);
SetCurrentContext(backupContext);
SetTopContext(backupContext);
SetGlobalContext(backupContext);
SetThisClass(backupThisClass);
}
- //else
+ //else
// wh.value = CopyString("No source file found for selected frame");
-
+
watchmsg[sizeof(watchmsg)-1] = 0;
if(!wh.value)
wh.value = CopyString(watchmsg);
gdbTimer.Stop();
gdbHandle.Wait();
delete gdbHandle;
-
+
ide.outputView.debugBox.Logf($"Debugger Fatal Error: GDB lost\n");
ide.outputView.debugBox.Logf($"Debugging stopped\n");
ide.Update(null);
DebugListItem item { };
DebugListItem item2 { };
bool setWaitingForPID = false;
-
+
#if defined(GDB_DEBUG_CONSOLE) || defined(GDB_DEBUG_GUI)
#ifdef GDB_DEBUG_CONSOLE
// _dpl2(_dpct, dplchan::gdbOutput, 0, output);
if(ide.gdbDialog) ide.gdbDialog.AddOutput(output);
#endif
#endif
-
+
switch(output[0])
{
case '~':
if(bpItem)
_dpl(0, "problem");
#endif
+ delete bpItem;
bpItem = ParseBreakpoint(item.value, outTokens);
//breakType = bpValidation;
}
DirExpression targetDirExp = prj.GetTargetDir(currentCompiler, prj.config, bitDepth);
strcpy(prjTargetPath, prj.topNode.path);
PathCat(prjTargetPath, targetDirExp.dir);
+ delete targetDirExp;
prjTargetFile[0] = '\0';
prj.CatTargetFileName(prjTargetFile, currentCompiler, prj.config);
PathCat(prjTargetPath, prjTargetFile);
delete at;
if(multipleBPs) multipleBPs.Free();
delete multipleBPs;
+ delete number;
+ delete fullname;
}
~GdbDataBreakpoint()
class Watch : struct
{
class_no_expansion;
-
+
Type type;
char * expression;
char * value;