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)
char * targetDir;
char * targetFile;
-
+
GdbExecution gdbExecution;
DebuggerUserAction userAction;
DebuggerState state;
GdbDataStop stopItem;
GdbDataBreakpoint bpItem;
Frame activeFrame;
-
+
List<Breakpoint> sysBPs { };
Breakpoint bpRunToCursor;
Breakpoint intBpEntry;
targetDir = null;
targetFile = null;
-
+
_ChangeState(none);
event = none;
breakType = none;
stopItem = null;
bpItem = null;
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;
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)
}
else
ChangeWorkingDir(ide.workspace.projectDir);
-
+
ide.SetPath(true, compiler, config, bitDepth);
// TODO: This pollutes the environment, but at least it works
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 '~':
class Watch : struct
{
class_no_expansion;
-
+
Type type;
char * expression;
char * value;