import "process"
import "debugFindCtx"
import "debugTools"
+import "dpl.ec"
#ifdef _DEBUG
#define GDB_DEBUG_CONSOLE
-#define _DEBUG_INST
+#define _DPL_ON
#endif
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__
#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***",
"-----> 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)
{
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)
{
d[k] = '\0';
}
-static char * CopyUnescapedSystemPath(char * p)
+/*static char * CopyUnescapedSystemPath(char * p)
{
int len = strlen(p);
char * d = new char[len + 1];
ChangeCh(d, '/', '\\');
#endif
return d;
-}
+}*/
static char * CopyUnescapedUnixPath(char * p)
{
return string;
}
-static int StringGetInt(char * string, int start)
+/*static int StringGetInt(char * string, int start)
{
char number[8];
int i, len = strlen(string);
break;
}
return atoi(number);
-}
+}*/
static int TokenizeList(char * string, const char seperator, Array<char *> tokens)
{
if(this.stopItem)
{
this.stopItem = null;
-#ifdef _DEBUG_INST
+#ifdef _DPL_ON
{
char * s = null;
DynamicString bpReport { };
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)
{
Breakpoint bp = GetBreakpointById(stopItem.bkptno, &isInternal);
if(bp)
{
- _dpl2(_dpct, dplchan::debuggerBreakpoints, 0, "gdb stopped by a breakpoint: ", bp.type, "(", s=bp.CopyLocationString(false), ")");
+ _dpcl(_dpct, dplchan::debuggerBreakpoints, 0, "gdb stopped by a breakpoint: ", bp.type, "(", s=bp.CopyLocationString(false), ")");
delete s;
}
}
}
#endif
}
-#ifdef _DEBUG_INST
+#ifdef _DPL_ON
else
{
if(curEvent && curEvent != exit)
{
- _dpl(0, "No stop item");
+ _dplf(0, "No stop item");
}
}
#endif
}
}
else
- _dpl2(_dpct, dplchan::debuggerProblem, 0, "Invalid stopItem!");
+ _dpcl(_dpct, dplchan::debuggerProblem, 0, "Invalid stopItem!");
if(bpUser && stopItem.frame.addr && strcmp(stopItem.frame.addr, bpUser.bp.addr))
- _dpl2(_dpct, dplchan::debuggerProblem, 0, "Breakpoint bkptno(", stopItem.bkptno, ") address missmatch!");
+ _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;
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)
{
- bool same = value == userAction;
#if 0
- __dpl2(file, line, _dpct, dplchan::debuggerUserAction, 0, userAction, /*same ? " *** == *** " : */" -> ", value);
+ bool same = value == userAction;
+ __dpl(file, line, _dpct, dplchan::debuggerUserAction, 0, userAction, /*same ? " *** == *** " : */" -> ", value);
#endif
userAction = value;
}
#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;
-#if 0 //def _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();
void CleanUp()
{
- _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::CleanUp");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::CleanUp");
stackFrames.Free(Frame::Free);
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 }));
~Debugger()
{
- _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::destructor");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::destructor");
sysBPs.Free();
Stop();
CleanUp();
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)
{
void Stop()
{
- _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::Stop");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::Stop");
_ChangeUserAction(stop);
switch(state)
{
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();
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)
{
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;
if(frame.absoluteFile)
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 = null;
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)
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)
{
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)
{
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(0, false, "-stack-select-frame %d", activeFrameLevel);
for(activeFrame = stackFrames.first; activeFrame; activeFrame = activeFrame.next)
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;
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;
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();
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))
{
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))
{
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))
{
void StepOut(bool ignoreBreakpoints)
{
- _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::StepOut()");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::StepOut()");
_ChangeUserAction(stepOut);
if(state == stopped)
{
}
}
- 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()");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::RunToCursor()");
_ChangeUserAction(runToCursor);
- WorkspaceGetRelativePath(absoluteFilePath, relativeFilePath, null);
+ ide.workspace.GetRelativePath(absoluteFilePath, relativeFilePath, null);
if(bpRunToCursor && bpRunToCursor.inserted && symbols)
{
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;
}
}
- 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;
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;
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);
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))
// 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;
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();
}
}
- 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)
Project owner;
char relativePath[MAX_LOCATION];
- WorkspaceGetRelativePath(absolutePath, relativePath, &owner);
+ ide.workspace.GetRelativePath(absolutePath, relativePath, &owner);
if(!owner && !FileExists(absolutePath))
{
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;
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++)
{
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();
}
Workspace ws = ide.workspace;
if(ws)
{
- String path = ide.workspace.GetPathWorkspaceRelativeOrAbsolute(item.value);
+ String path = ide.workspace.CopyUnixPathWorkspaceRelativeOrAbsolute(item.value);
if(strcmp(frame.file, path))
frame.file = 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;
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)
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++)
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;
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();
void HideDebuggerViews()
{
- //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::HideDebuggerViews()");
+ //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::HideDebuggerViews()");
ide.RepositionWindows(true);
}
- bool ::GdbCommand(Time timeOut, bool focus, char * format, ...)
+ bool ::GdbCommand(Time timeOut, bool focus, const char * format, ...)
{
bool result = false;
if(gdbHandle)
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);
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)
void BreakpointsMaintenance()
{
- //_dpl2(_dpct, dplchan::debuggerBreakpoints, 0, "Debugger::BreakpointsMaintenance()");
+ //_dpcl(_dpct, dplchan::debuggerBreakpoints, 0, "Debugger::BreakpointsMaintenance()");
if(symbols)
{
if(gdbExecution.suspendInternalBreakpoints)
{
#ifdef _DEBUG
if(bp.bp)
- _dpl(0, "problem");
+ _dplf(0, "problem");
#endif
delete bp.bp;
bp.bp = GdbDataBreakpoint { };
void UnsetBreakpoint(Breakpoint bp)
{
- char * s = null; _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(0, false, "-break-delete %s", bp.bp.number);
bool SetBreakpoint(Breakpoint bp, bool removePath)
{
- char * s = null; _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]))
{
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)
//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;
}
void GdbGetStack()
{
- _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbGetStack()");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbGetStack()");
activeFrame = null;
stackFrames.Free(Frame::Free);
GdbCommand(0, false, "-stack-info-depth");
bool GdbTargetSet()
{
- _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbTargetSet()");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbTargetSet()");
if(!targeted)
{
char escaped[MAX_LOCATION];
void GdbDebugBreak(bool internal)
{
- _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbDebugBreak()");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbDebugBreak()");
if(targetProcessId)
{
if(internal)
void GdbExecRun()
{
- _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecRun()");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecRun()");
GdbTargetSet();
if(!usingValgrind)
gdbExecution = run;
void GdbExecContinue(bool focus)
{
- _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecContinue()");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecContinue()");
gdbExecution = run;
GdbExecCommon();
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(0, true, "-exec-next");
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);
+ ide.workspace.GetRelativePath(absoluteFilePath, relativeFilePath, null);
if(!GdbCommand(0.1, true, "-exec-until %s:%d", relativeFilePath, lineNumber))
{
GetLastDirectory(relativeFilePath, relativeFilePath);
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);
+ ide.workspace.GetRelativePath(absoluteFilePathOrLocation, relativeFilePath, null);
if(!GdbCommand(0.1, true, "advance %s:%d", relativeFilePath, lineNumber)) // should use -exec-advance -- GDB/MI implementation missing
{
GetLastDirectory(relativeFilePath, relativeFilePath);
void GdbExecStep()
{
- _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecStep()");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExecStep()");
gdbExecution = step;
GdbExecCommon();
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(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)
{
void ClearBreakDisplay()
{
- //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::ClearBreakDisplay()");
+ //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::ClearBreakDisplay()");
activeThread = 0;
activeFrameLevel = -1;
hitThread = 0;
bool GdbAbortExec()
{
- _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbAbortExec()");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbAbortExec()");
sentKill = true;
GdbCommand(0, false, "-interpreter-exec console \"kill\""); // should use -exec-abort -- GDB/MI implementation incomplete
return true;
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;
}
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)
{
void GdbExit()
{
- _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExit()");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbExit()");
if(gdbHandle && gdbProcessId)
{
gdbTimer.Stop();
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();
void WatchesReleaseCodeEditor()
{
- //_dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::WatchesReleaseCodeEditor()");
+ //_dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::WatchesReleaseCodeEditor()");
if(codeEditor)
{
codeEditor.inUseDebug = false;
{
bool result = false;
- _dpl2(_dpct, dplchan::debuggerWatches, 0, "Debugger::ResolveWatch()");
+ _dpcl(_dpct, dplchan::debuggerWatches, 0, "Debugger::ResolveWatch()");
wh.Reset();
/*delete wh.value;
expString[0] = 0;
PrintExpression(exp, expString);
+ 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);
if(wh.type)
wh.type.refCount++;
DebugComputeExpression(exp);
- if(exp.expType && exp.expType.kind == classType && exp.expType._class && exp.expType._class.registered && exp.expType._class.registered.type == bitClass)
+ // 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];
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)
{
}
delete data;
}
+ */
}
if(ExpressionIsError(exp) && exp.type != functionCallErrorExp)
break;
case memberSymbolErrorExp:
{
- Class _class;
Expression memberExp = exp.member.exp;
Identifier memberID = exp.member.member;
Type type = memberExp.expType;
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;
- char string[1024];
- string[0] = 0;
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), $"Dereferencing error evaluating \"%s\"", wh.expression);
break;
case divideBy0ErrorExp:
- snprintf(watchmsg, sizeof(watchmsg), $"Integer division by 0");
+ 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);
!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 value[4196];
//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
//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)
for(start = 0; !done && start + size <= 4096; start += size)
{
- String s = null;
+ byte * s = null;
while(!done && !s)
{
// Try to read 256 bytes at a time, then half if that fails
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);
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;
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);
}
break;
}
}
+
+ SetInDebugger(false);
}
else
snprintf(watchmsg, sizeof(watchmsg), $"Invalid expression: \"%s\"", wh.expression);
void EvaluateWatches()
{
- _dpl2(_dpct, dplchan::debuggerWatches, 0, "Debugger::EvaluateWatches()");
+ _dpcl(_dpct, dplchan::debuggerWatches, 0, "Debugger::EvaluateWatches()");
WatchesLinkCodeEditor();
if(state == stopped)
{
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(0, false, "-data-evaluate-expression \"%s\"", expression);
// 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(0, false, "-data-read-memory 0x%08x %c, %d, %d, %d", address, format, size, rows, cols);
- if(GetRuntimePlatform() == win32)
- GdbCommand(0, false, "-data-read-memory 0x%016I64x %c, %d, %d, %d", address, format, size, rows, cols);
- else
- GdbCommand(0, 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;
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(0, false, "-data-read-memory 0x%08x %c, 1, 1, %d", address, 'u', bytes);
- if(GetRuntimePlatform() == win32)
- GdbCommand(0, false, "-data-read-memory 0x%016I64x %c, 1, 1, %d", address, 'u', bytes);
- else
- GdbCommand(0, 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)
{
{
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, "), ",
void ValgrindTargetThreadExit()
{
- _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::ValgrindTargetThreadExit()");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::ValgrindTargetThreadExit()");
if(vgTargetHandle)
{
vgTargetHandle.Wait();
void GdbThreadExit()
{
- _dpl2(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbThreadExit()");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "Debugger::GdbThreadExit()");
if(state != terminated)
{
_ChangeState(terminated);
#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
}
}
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);
sentBreakInsert = false;
#ifdef _DEBUG
if(bpItem)
- _dpl(0, "problem");
+ _dplf(0, "problem");
#endif
delete bpItem;
bpItem = ParseBreakpoint(item.value, outTokens);
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 = null;
}
}
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)
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;
}
}
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"))
}
}
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))
!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;
{
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;
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"))
}
}
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
{
}
}
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 '(':
serialSemaphore.Release();
}
else
- _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, $"Unknown prompt", output);
+ _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, $"Unknown prompt", output);
break;
case '&':
}
break;
default:
- _dpl2(_dpct, dplchan::gdbProtoUnknown, 0, $"Unknown output: ", output);
+ _dpcl(_dpct, dplchan::gdbProtoUnknown, 0, $"Unknown output: ", output);
}
if(!setWaitingForPID)
waitingForPID = false;
{
char path[MAX_LOCATION] = "";
char file[MAX_FILENAME] = "";
- bool symbolsLoaded = false;
+ //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))
}
else if(!strcmp(item.name, "symbols-loaded"))
{
- symbolsLoaded = (atoi(item.value) == 1);
+ //symbolsLoaded = (atoi(item.value) == 1);
}
else if(!strcmp(item.name, "shlib-info"))
{
StripQuotes(subItem.value, path);
MakeSystemPath(path);
GetLastDirectory(path, file);
- symbolsLoaded = true;
+ //symbolsLoaded = true;
}
}
}
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))
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)
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);
{
// 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
}
}
delete dynamicBuffer;
- _dpl2(_dpct, dplchan::debuggerCall, 0, "ValgrindLogThreadExit");
+ _dpcl(_dpct, dplchan::debuggerCall, 0, "ValgrindLogThreadExit");
//if(oldValgrindHandle == vgLogFile)
debugger.GdbThreadExit/*ValgrindLogThreadExit*/();
delete oldValgrindHandle;
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;
else
{
#ifdef _DEBUG
- _dpl(0, "Got end of file from GDB!");
+ _dplf(0, "Got end of file from GDB!");
#endif
}
}
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))
{
{
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);
void Print()
{
- _dpl(0, "");
+ _dplf(0, "");
PrintLn("{", "#", number, " T", type, " D", disp, " E", enabled, " H", times, " (", func, ") (", file, ":", line, ") (", fullname, ") (", addr, ") (", at, ")", "}");
}
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;
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()
{
{
if(!strcmp(prjName, prj.name))
{
- if(ProjectGetAbsoluteFromRelativePath(prj, filePath, fullPath))
+ if(prj.GetAbsoluteFromRelativePath(filePath, fullPath))
{
property::absoluteFilePath = fullPath;
project = prj;
else
{
Project prj = ide.project;
- if(ProjectGetAbsoluteFromRelativePath(prj, filePath, fullPath))
+ if(prj.GetAbsoluteFromRelativePath(filePath, fullPath))
{
property::absoluteFilePath = fullPath;
project = prj;
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)
{
{
CodeLocation codloc { line = line };
codloc.file = CopyString(loc);
- codloc.absoluteFile = ide.workspace.GetAbsolutePathFromRelative(loc);
+ codloc.absoluteFile = ide.workspace.CopyAbsolutePathFromRelative(loc);
return codloc;
}
}
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;
-}