import "debugFindCtx"
import "debugTools"
-//#define GDB_DEBUG_CONSOLE
+#ifdef _DEBUG
+#define GDB_DEBUG_CONSOLE
+#endif
-extern char * strrchr(char * s, char c);
+extern char * strrchr(const char * s, int c);
#define uint _uint
#include <stdarg.h>
#endif
#undef uint
-//bool eString_PathInsidePath(char * to, char * path)
-bool eString_PathInsideOf(char * path, char * of)
-{
- if(!path[0] || !of[0])
- return false; // What to do here? Ever used?
- else
- {
- char ofPart[MAX_FILENAME], ofRest[MAX_LOCATION];
- char pathPart[MAX_FILENAME], pathRest[MAX_LOCATION];
- strcpy(ofRest, of);
- strcpy(pathRest, path);
- for(; ofRest[0] && pathRest[0];)
- {
- SplitDirectory(ofRest, ofPart, ofRest);
- SplitDirectory(pathRest, pathPart, pathRest);
- if(fstrcmp(pathPart, ofPart))
- return false;
- }
- if(!ofRest[0] && !pathRest[0]) // paths are identical - should return false or true? (changed to false)
- return false;
- else if(!pathRest[0]) // not inside of, it's the other way around
- return false;
- return true;
- }
-}
public char * StripQuotes2(char * string, char * output)
{
if(escaped || ch != '\"')
{
output[d++] = ch;
- if(ch == '\\')
- escaped ^= true;
+ escaped = !escaped && ch == '\\';
}
else
quoted = false;
{
uint level = 0;
- bool quoted = false; //bool escaped = false;
- char * start = string;
+ bool quoted = false, escaped = false;
+ char * start = string, ch;
- for(; *string; string++)
+ for(; (ch = *string); string++)
{
if(!start)
start = string;
+
if(quoted)
{
- if(*string == '\"')
+ if(escaped || ch != '\"')
+ escaped = !escaped && ch == '\\';
+ else
quoted = false;
}
- else if(*string == '\"')
+ else if(ch == '\"')
quoted = true;
- else if(*string == '{' || *string == '[' || *string == '(' || *string == '<')
+ else if(ch == '{' || ch == '[' || ch == '(' || ch == '<')
level++;
- else if(*string == '}' || *string == ']' || *string == ')' || *string == '>')
+ else if(ch == '}' || ch == ']' || ch == ')' || ch == '>')
level--;
- else if(*string == seperator && !level)
+ else if(ch == seperator && !level)
{
tokens.Add(start);
*string = '\0';
enum DebuggerState { none, prompt, loaded, running, stopped, terminated };
enum DebuggerEvent { none, hit, breakEvent, signal, stepEnd, functionEnd, exit };
enum DebuggerAction { none, internal, restart, stop, selectFrame }; //, bpValidation
-enum BreakpointType { none, internalMain, internalWinMain, internalModulesLoaded, user, runToCursor };
+enum BreakpointType { none, internalMain, internalWinMain, internalModulesLoaded, user, runToCursor, internalModuleLoad };
enum DebuggerEvaluationError { none, symbolNotFound, memoryCantBeRead, unknown };
FileDialog debuggerFileDialog { type = selectDir };
static int targetProcessId;
static bool gdbReady;
+static bool breakpointError;
class Debugger
{
OldList stackFrames;
+ CompilerConfig currentCompiler;
ProjectConfig prjConfig;
CodeEditor codeEditor;
#endif
}
}
-
switch(breakType)
{
case restart:
breakType = none;
- Restart();
+ Restart(currentCompiler, prjConfig);
break;
case stop:
breakType = none;
break;
}
}
+ if(bp && bp.type != user && stopItem && stopItem.frame)
+ {
+ // In case the user put a breakpoint where an internal breakpoint is, avoid the confusion...
+ for(i : ide.workspace.breakpoints)
+ {
+ if(i.bp && i.line == stopItem.frame.line && !fstrcmp(i.absoluteFilePath, stopItem.frame.absoluteFile))
+ bp = i;
+ break;
+ }
+ }
bpHit = bp;
if(!(!userBreakOnInternBreak &&
- bp && (bp.type == internalMain || bp.type == internalWinMain || bp.type == internalModulesLoaded)))
+ bp && (bp.type == internalMain || bp.type == internalWinMain ||
+ bp.type == internalModulesLoaded || bp.type == internalModuleLoad)))
monitor = true;
hitThread = stopItem.threadid;
}
{
char * s;
signalOn = true;
- ide.outputView.debugBox.Logf("Signal received: %s - %s\n", stopItem.name, stopItem.meaning);
+ 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);
delete s;
}
// Why was SelectFrame missing here?
SelectFrame(activeFrameLevel);
GoToStackFrameLine(activeFrameLevel, curEvent == signal || curEvent == stepEnd /*false*/);
- ide.Activate();
+ ideMainFrame.Activate(); // TOFIX: ide.Activate() is not reliable (app inactive)
ide.Update(null);
if(curEvent == signal)
ide.outputView.Show();
break;
}
- if(curEvent == DebuggerEvent::breakEvent || curEvent == stepEnd || curEvent == functionEnd)
+ if(curEvent != hit)
ignoreBreakpoints = false;
if(stopItem)
void ChangeState(DebuggerState value)
{
+ bool same = value == state;
+ // if(same) PrintLn("Debugger::ChangeState -- changing to same state");
state = value;
- if(ide) ide.AdjustDebugMenus();
+ if(!same && ide) ide.AdjustDebugMenus();
}
void CleanUp()
bpRunToCursor = null;
bpHit = null;
+ delete currentCompiler;
prjConfig = null;
codeEditor = null;
sysBPs.Add(Breakpoint { type = internalWinMain, enabled = true, level = -1 });
#endif
sysBPs.Add(Breakpoint { type = internalModulesLoaded, enabled = true, level = -1 });
-
+ sysBPs.Add(Breakpoint { type = internalModuleLoad, enabled = true, level = -1 });
}
~Debugger()
if(state == running)
{
if(targetProcessId)
- {
- //ide.AdjustDebugMenus();
GdbDebugBreak(false);
- }
}
}
}
}
- void Restart()
+ void Restart(CompilerConfig compiler, ProjectConfig config)
{
switch(state)
{
GdbAbortExec();
case none:
case terminated:
- if(!GdbInit())
+ if(!GdbInit(compiler, config))
break;
case loaded:
GdbExecRun();
{
char * s;
char title[MAX_LOCATION];
-
- sprintf(title, "Provide source file location for %s", (s = CopySystemPath(frame.file)));
+ snprintf(title, sizeof(title), $"Provide source file location for %s", (s = CopySystemPath(frame.file)));
+ title[sizeof(title)-1] = 0;
delete s;
if(SourceDirDialog(title, ide.workspace.projectDir, frame.file, sourceDir))
{
targetProcessId = 0;
if(code)
- sprintf(verboseExitCode, " with exit code %s", code);
+ {
+ snprintf(verboseExitCode, sizeof(verboseExitCode), $" with exit code %s", code);
+ verboseExitCode[sizeof(verboseExitCode)-1] = 0;
+ }
else
verboseExitCode[0] = '\0';
}
}
- //ide.AdjustDebugMenus();
-
#if defined(__unix__)
progThread.terminate = true;
if(fifoFile)
char program[MAX_LOCATION];
GetSystemPathBuffer(program, targetFile);
if(!reason)
- ide.outputView.debugBox.Logf("The program %s has exited%s.\n", program, verboseExitCode);
+ ide.outputView.debugBox.Logf($"The program %s has exited%s.\n", program, verboseExitCode);
else if(!strcmp(reason, "exited-normally"))
- ide.outputView.debugBox.Logf("The program %s has exited normally%s.\n", program, verboseExitCode);
+ ide.outputView.debugBox.Logf($"The program %s has exited normally%s.\n", program, verboseExitCode);
else if(!strcmp(reason, "exited"))
- ide.outputView.debugBox.Logf("The program %s has exited%s.\n", program, verboseExitCode);
+ ide.outputView.debugBox.Logf($"The program %s has exited%s.\n", program, verboseExitCode);
else if(!strcmp(reason, "exited-signalled"))
- ide.outputView.debugBox.Logf("The program %s has exited with a signal%s.\n", program, verboseExitCode);
+ ide.outputView.debugBox.Logf($"The program %s has exited with a signal%s.\n", program, verboseExitCode);
else
- ide.outputView.debugBox.Logf("The program %s has exited (gdb provided an unknown reason)%s.\n", program, verboseExitCode);
+ ide.outputView.debugBox.Logf($"The program %s has exited (gdb provided an unknown reason)%s.\n", program, verboseExitCode);
}
ide.Update(null);
}
- void Start()
+ void Start(CompilerConfig compiler, ProjectConfig config)
{
ide.outputView.debugBox.Clear();
switch(state)
{
case none:
case terminated:
- if(!GdbInit())
+ if(!GdbInit(compiler, config))
break;
case loaded:
GdbExecRun();
}
}
- void StepInto()
+ void StepInto(CompilerConfig compiler, ProjectConfig config)
{
switch(state)
{
case none:
case terminated:
- if(!GdbInit())
+ if(!GdbInit(compiler, config))
break;
case loaded:
ide.outputView.ShowClearSelectTab(debug);
- ide.outputView.debugBox.Logf("Starting debug mode\n");
+ ide.outputView.debugBox.Logf($"Starting debug mode\n");
userBreakOnInternBreak = true;
GdbExecRun();
break;
}
}
- void StepOver(bool ignoreBkpts)
+ void StepOver(CompilerConfig compiler, ProjectConfig config, bool ignoreBkpts)
{
switch(state)
{
case none:
case terminated:
- if(!GdbInit())
+ if(!GdbInit(compiler, config))
break;
case loaded:
ide.outputView.ShowClearSelectTab(debug);
- ide.outputView.debugBox.Logf("Starting debug mode\n");
+ ide.outputView.debugBox.Logf($"Starting debug mode\n");
ignoreBreakpoints = ignoreBkpts;
userBreakOnInternBreak = true;
GdbExecRun();
}
}
- void RunToCursor(char * absoluteFilePath, int lineNumber, bool ignoreBkpts)
+ void RunToCursor(CompilerConfig compiler, ProjectConfig config, char * absoluteFilePath, int lineNumber, bool ignoreBkpts)
{
char relativeFilePath[MAX_LOCATION];
DebuggerState oldState = state;
{
case none:
case terminated:
- Start();
+ Start(compiler, config);
case stopped:
case loaded:
if(symbols)
if(state == loaded)
{
ide.outputView.ShowClearSelectTab(debug);
- ide.outputView.debugBox.Logf("Starting debug mode\n");
+ ide.outputView.debugBox.Logf($"Starting debug mode\n");
}
RunToCursorPrepare(absoluteFilePath, relativeFilePath, lineNumber);
sentBreakInsert = true;
else if(expression)
{
wh = Watch { };
- row.tag = (int)wh;
+ row.tag = (int64)wh;
ide.workspace.watches.Add(wh);
wh.row = row;
wh.expression = CopyString(expression);
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?",
- text = "Invalid Source Directory" }.Modal() == no)
+ contents = $"This is the project directory.\nWould you like to try again?",
+ text = $"Invalid Source Directory" }.Modal() == no)
return false;
else
{
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)
+ contents = $"This source directory is already specified.\nWould you like to try again?",
+ text = $"Invalid Source Directory" }.Modal() == no)
return false;
else
{
result = FileExists(file);
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)
+ contents = $"Unable to locate source file.\nWould you like to try again?",
+ text = $"Invalid Source Directory" }.Modal() == no)
return false;
}
else
else
{
// FIXED: This is how it should have been... Source locations are only for files not in project
- // if(eString_PathInsideOf(absolutePath, ide.workspace.projectDir))
+ // if(IsPathInsideOf(absolutePath, ide.workspace.projectDir))
// MakePathRelative(absolutePath, ide.workspace.projectDir, relativePath);
bool result = false;
if(prj)
char title[MAX_LOCATION];
char directory[MAX_LOCATION];
StripLastDirectory(absolutePath, directory);
- sprintf(title, "Provide source files location directory for %s", absolutePath);
+ snprintf(title, sizeof(title), $"Provide source files location directory for %s", absolutePath);
+ title[sizeof(title)-1] = 0;
while(true)
{
String srcDir = null;
for(dir : ide.workspace.sourceDirs)
{
- if(eString_PathInsideOf(absolutePath, dir))
+ if(IsPathInsideOf(absolutePath, dir))
{
MakePathRelative(absoluteFilePath, dir, relativePath);
srcDir = dir;
if(SourceDirDialog(title, directory, null, sourceDir))
{
- if(eString_PathInsideOf(absolutePath, sourceDir))
+ if(IsPathInsideOf(absolutePath, sourceDir))
{
AddSourceDir(sourceDir);
MakePathRelative(absoluteFilePath, 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?",
- text = "Invalid Source Directory" }.Modal() == no)
+ 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;
}
else if(MessageBox { type = yesNo, master = ide,
- contents = "You must provide a source directory in order to place a breakpoint in this file.\nWould you like to try again?",
- text = "No Source Directory Provided" }.Modal() == no)
+ contents = $"You must provide a source directory in order to place a breakpoint in this file.\nWould you like to try again?",
+ text = $"No Source Directory Provided" }.Modal() == no)
return;
}
}
frame.line = atoi(item.value);
else if(!strcmp(item.name, "fullname"))
{
- // New GDB is giving us a full name... Any reason why we coudln't figure it out ourselves?
+ // 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))
+ {
+ frame.file = path;
+ delete frame.absoluteFile;
+ frame.absoluteFile = ide.workspace.GetAbsolutePathFromRelative(frame.file);
+ }
+ delete path;
}
else
DebuggerProtocolUnknown("Unknown frame member name", item.name);
{
if(gdbHandle)
{
- char string[MAX_F_STRING];
-
+ // TODO: Improve this limit
+ static char string[MAX_F_STRING*3];
va_list args;
va_start(args, format);
- vsprintf(string, format, args);
+ vsnprintf(string, sizeof(string), format, args);
+ string[sizeof(string)-1] = 0;
va_end(args);
gdbReady = false;
if(ide.gdbDialog)
ide.gdbDialog.AddCommand(string);
#endif
- gdbHandle.Printf("%s\n", string);
-
+ strcat(string,"\n");
+ gdbHandle.Puts(string);
+
if(focus)
Process_ShowWindows(targetProcessId);
bool ValidateBreakpoint(Breakpoint bp)
{
- if(modules)
+ if(modules && bp.bp)
{
if(bp.bp.line != bp.line)
{
{
//if(!breakpointsInserted)
{
- DirExpression objDir = ide.project.objDir;
+ DirExpression objDir = ide.project.GetObjDir(currentCompiler, prjConfig);
for(bp : sysBPs)
{
if(!bp.inserted)
bool moduleLoadBlock = false;
File f;
ReplaceSpaces(fixedModuleName, ide.project.moduleName);
- sprintf(name, "%s.main.ec", fixedModuleName);
+ snprintf(name, sizeof(name),"%s.main.ec", fixedModuleName);
+ name[sizeof(name)-1] = 0;
strcpy(path, ide.workspace.projectDir);
PathCatSlash(path, objDir.dir);
PathCatSlash(path, name);
bp.bp = bpItem;
bpItem = null;
bp.inserted = (bp.bp && bp.bp.number != 0);
- ValidateBreakpoint(bp);
}
delete f;
}
- break;
+ }
+ else if(bp.type == internalModuleLoad && modules)
+ {
+ Project ecerePrj = null;
+ for(p : ide.workspace.projects)
+ {
+ if(!strcmp(p.topNode.name, "ecere.epj"))
+ {
+ ecerePrj = p;
+ break;
+ }
+ }
+ if(ecerePrj)
+ {
+ ProjectNode node = ecerePrj.topNode.Find("instance.c", false);
+ if(node)
+ {
+ char path[MAX_LOCATION];
+ char relative[MAX_LOCATION];
+ node.GetFullFilePath(path);
+ bp.absoluteFilePath = CopyString(path);
+ MakePathRelative(path, ecerePrj.topNode.path, relative);
+ delete bp.relativeFilePath;
+ bp.relativeFilePath = CopyString(relative);
+ sentBreakInsert = true;
+ GdbCommand(false, "-break-insert %s:InternalModuleLoadBreakpoint", bp.relativeFilePath);
+ bp.bp = bpItem;
+ bpItem = null;
+ bp.inserted = (bp.bp && bp.bp.number != 0);
+ }
+ }
}
}
}
if(!ignoreBreakpoints && bp.enabled)
{
sentBreakInsert = true;
+ breakpointError = false;
GdbCommand(false, "-break-insert %s:%d", bp.relativeFilePath, bp.line);
+ // Improve, GdbCommand should return a success value?
+ if(breakpointError)
+ {
+ char fileName[MAX_FILENAME];
+ breakpointError = false;
+ GetLastDirectory(bp.relativeFilePath, fileName);
+ sentBreakInsert = true;
+ GdbCommand(false, "-break-insert %s:%d", fileName, bp.line);
+ }
bp.bp = bpItem;
bpItem = null;
bp.inserted = (bp.bp && bp.bp.number != 0);
bp.hits = 0;
+ bp.breaks = 0;
ValidateBreakpoint(bp);
}
else
if(!frameCount)
GdbCommand(false, "-stack-info-depth 192");
if(frameCount && frameCount <= 192)
- GdbCommand(false, "-stack-list-frames 0 191");
+ GdbCommand(false, "-stack-list-frames 0 %d", Min(frameCount-1, 191));
else
{
- GdbCommand(false, "-stack-list-frames 0 95");
+ 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(false, "");
if(internal)
breakType = DebuggerAction::internal;
- if(ide)
- {
- //ide.AdjustDebugMenus();
- ide.Update(null);
- }
+ if(ide) ide.Update(null);
app.Unlock();
if(Process_Break(targetProcessId)) //GdbCommand(false, "-exec-interrupt");
serialSemaphore.Wait();
{
ChangeState(loaded);
targetProcessId = 0;
- //ide.AdjustDebugMenus();
}
app.Lock();
}
return true;
}
- bool GdbInit()
+ bool GdbInit(CompilerConfig compiler, ProjectConfig config)
{
bool result = true;
char oldDirectory[MAX_LOCATION];
char tempPath[MAX_LOCATION];
char command[MAX_LOCATION];
Project project = ide.project;
- DirExpression targetDirExp = project.targetDir;
+ DirExpression targetDirExp = project.GetTargetDir(compiler, config);
PathBackup pathBackup { };
- prjConfig = project.config;
+ if(currentCompiler != compiler)
+ {
+ delete currentCompiler;
+ currentCompiler = compiler;
+ incref currentCompiler;
+ }
+ prjConfig = config;
ChangeState(loaded);
sentKill = false;
sentBreakInsert = false;
+ breakpointError = false;
symbols = true;
targeted = false;
modules = false;
//breakpointsInserted = false;
ide.outputView.ShowClearSelectTab(debug);
- ide.outputView.debugBox.Logf("Starting debug mode\n");
+ ide.outputView.debugBox.Logf($"Starting debug mode\n");
#ifdef GDB_DEBUG_CONSOLE
Log("Starting GDB"); Log("\n");
PathCatSlash(tempPath, targetDirExp.dir);
delete targetDir;
targetDir = CopyString(tempPath);
- project.CatTargetFileName(tempPath);
+ project.CatTargetFileName(tempPath, compiler, config);
delete targetFile;
targetFile = CopyString(tempPath);
else
ChangeWorkingDir(ide.workspace.projectDir);
- ide.SetPath(true);
+ ide.SetPath(true, compiler, config);
// TODO: This pollutes the environment, but at least it works
// It shouldn't really affect the IDE as the PATH gets restored and other variables set for testing will unlikely cause problems
SetEnvironment(e.name, e.string);
}
- sprintf(command, "gdb -n -silent --interpreter=mi2"); //-async //\"%s\"
+ strcpy(command, "gdb -n -silent --interpreter=mi2"); //-async //\"%s\"
gdbTimer.Start();
gdbHandle = DualPipeOpen(PipeOpenMode { output = 1, error = 2, input = 1 }, command);
if(!gdbHandle)
{
- ide.outputView.debugBox.Logf("Debugger Fatal Error: Couldn't start GDB\n");
+ ide.outputView.debugBox.Logf($"Debugger Fatal Error: Couldn't start GDB\n");
result = false;
}
if(result)
gdbProcessId = gdbHandle.GetProcessID();
if(!gdbProcessId)
{
- ide.outputView.debugBox.Logf("Debugger Fatal Error: Couldn't get GDB process ID\n");
+ ide.outputView.debugBox.Logf($"Debugger Fatal Error: Couldn't get GDB process ID\n");
result = false;
}
if(result)
if(!GdbTargetSet())
{
//ChangeState(terminated);
- //ide.AdjustDebugMenus();
result = false;
}
else
{
//app.Lock();
- ide.outputView.debugBox.Logf("err: Unable to create FIFO %s\n", progFifoPath);
+ ide.outputView.debugBox.Logf(createFIFOMsg, progFifoPath);
//app.Unlock();
}
}
if(bpRunToCursor)
bpRunToCursor.inserted = false;
- ide.outputView.debugBox.Logf("Debugging stopped\n");
+ ide.outputView.debugBox.Logf($"Debugging stopped\n");
ClearBreakDisplay();
- //ide.AdjustDebugMenus();
ide.Update(null);
#if defined(__unix__)
{
char watchmsg[MAX_F_STRING];
if(state == stopped && !codeEditor)
- wh.value = CopyString("No source file found for selected frame");
+ wh.value = CopyString($"No source file found for selected frame");
//if(codeEditor && state == stopped || state != stopped)
else
{
switch(exp.type)
{
case symbolErrorExp:
- sprintf(watchmsg, "Symbol \"%s\" not found", exp.identifier.string);
+ snprintf(watchmsg, sizeof(watchmsg), $"Symbol \"%s\" not found", exp.identifier.string);
break;
case structMemberSymbolErrorExp:
// todo get info as in next case (ExpClassMemberSymbolError)
- sprintf(watchmsg, "Error: Struct member not found for \"%s\"", wh.expression);
+ snprintf(watchmsg, sizeof(watchmsg), $"Error: Struct member not found for \"%s\"", wh.expression);
break;
case classMemberSymbolErrorExp:
{
_class = classSym ? classSym.registered : null;
}
if(_class)
- sprintf(watchmsg, "Member \"%s\" not found in class \"%s\"", memberID ? memberID.string : "", _class.name);
+ snprintf(watchmsg, sizeof(watchmsg), $"Member \"%s\" not found in class \"%s\"", memberID ? memberID.string : "", _class.name);
else
- sprintf(watchmsg, "Member \"%s\" not found in unregistered class? (Should never get this message)", memberID ? memberID.string : "");
+ snprintf(watchmsg, sizeof(watchmsg), "Member \"%s\" not found in unregistered class? (Should never get this message)", memberID ? memberID.string : "");
}
else
- sprintf(watchmsg, "Member \"%s\" not found in no type? (Should never get this message)", memberID ? memberID.string : "");
+ snprintf(watchmsg, sizeof(watchmsg), "Member \"%s\" not found in no type? (Should never get this message)", memberID ? memberID.string : "");
}
break;
case memoryErrorExp:
// Need to ensure when set to memoryErrorExp, constant is set
- sprintf(watchmsg, "Memory can't be read at %s", /*(exp.type == constantExp) ? */exp.constant /*: null*/);
+ snprintf(watchmsg, sizeof(watchmsg), $"Memory can't be read at %s", /*(exp.type == constantExp) ? */exp.constant /*: null*/);
break;
case dereferenceErrorExp:
- sprintf(watchmsg, "Dereference failure for \"%s\"", wh.expression);
+ snprintf(watchmsg, sizeof(watchmsg), $"Dereference failure for \"%s\"", wh.expression);
break;
case unknownErrorExp:
- sprintf(watchmsg, "Unknown error for \"%s\"", wh.expression);
+ snprintf(watchmsg, sizeof(watchmsg), $"Unknown error for \"%s\"", wh.expression);
break;
case noDebuggerErrorExp:
- sprintf(watchmsg, "Debugger required for symbol evaluation in \"%s\"", wh.expression);
+ snprintf(watchmsg, sizeof(watchmsg), $"Debugger required for symbol evaluation in \"%s\"", wh.expression);
break;
case debugStateErrorExp:
- sprintf(watchmsg, "Incorrect debugger state for symbol evaluation in \"%s\"", wh.expression);
+ snprintf(watchmsg, sizeof(watchmsg), $"Incorrect debugger state for symbol evaluation in \"%s\"", wh.expression);
break;
case 0:
- sprintf(watchmsg, "Null type for \"%s\"", wh.expression);
+ snprintf(watchmsg, sizeof(watchmsg), $"Null type for \"%s\"", wh.expression);
break;
case constantExp:
case stringExp:
if(exp.expType.kind != arrayType || exp.hasAddress)
{
- uint address;
+ uint64 address;
char * string;
char value[4196];
int len;
sprintf(temp, "(char*)%s", exp.constant);*/
//evaluation = Debugger::EvaluateExpression(temp, &evalError);
- address = strtoul(exp.constant, null, 0);
+ // address = strtoul(exp.constant, null, 0);
+ address = _strtoui64(exp.constant, null, 0);
//printf("%x\n", address);
- sprintf(value, "0x%08x ", address);
+ // snprintf(value, sizeof(value), "0x%08x ", address);
+
+ if(address > 0xFFFFFFFFLL)
+ snprintf(value, sizeof(value), (GetRuntimePlatform() == win32) ? "0x%016I64x " : "0x%016llx ", address);
+ else
+ snprintf(value, sizeof(value), (GetRuntimePlatform() == win32) ? "0x%08I64x " : "0x%08llx ", address);
+ value[sizeof(value)-1] = 0;
if(!address)
- strcat(value, "Null string");
+ strcat(value, $"Null string");
else
{
int size = 4096;
}
else if(string)
{
- strcat(value, "Empty string");
+ strcat(value, $"Empty string");
delete string;
}
else
- strcat(value, "Couldn't read memory");
+ strcat(value, $"Couldn't read memory");
}
wh.value = CopyString(value);
}
if(item)
wh.value = CopyString(item.name);
else
- wh.value = CopyString("Invalid Enum Value");
+ wh.value = CopyString($"Invalid Enum Value");
result = (bool)atoi(exp.constant);
}
else if(wh.type && (wh.type.kind == charType || (wh.type.kind == classType && wh.type._class &&
charString[0] = 0;
UTF32toUTF8Len(&value, 1, charString, 5);
if(value == '\0')
- sprintf(string, "\'\\0' (0)");
+ snprintf(string, sizeof(string), "\'\\0' (0)");
else if(value == '\t')
- sprintf(string, "\'\\t' (%d)", value);
+ snprintf(string, sizeof(string), "\'\\t' (%d)", value);
else if(value == '\n')
- sprintf(string, "\'\\n' (%d)", value);
+ snprintf(string, sizeof(string), "\'\\n' (%d)", value);
else if(value == '\r')
- sprintf(string, "\'\\r' (%d)", value);
+ snprintf(string, sizeof(string), "\'\\r' (%d)", value);
else if(wh.type.kind == charType && wh.type.isSigned)
- sprintf(string, "\'%s\' (%d)", charString, signedValue);
+ snprintf(string, sizeof(string), "\'%s\' (%d)", charString, signedValue);
else if(value > 256 || wh.type.kind != charType)
{
if(value > 0x10FFFF || !GetCharCategory(value))
- sprintf(string, "Invalid Unicode Keypoint (0x%08X)", value);
+ snprintf(string, sizeof(string), $"Invalid Unicode Keypoint (0x%08X)", value);
else
- sprintf(string, "\'%s\' (U+%04X)", charString, value);
+ snprintf(string, sizeof(string), "\'%s\' (U+%04X)", charString, value);
}
else
- sprintf(string, "\'%s\' (%d)", charString, value);
+ snprintf(string, sizeof(string), "\'%s\' (%d)", charString, value);
+ string[sizeof(string)-1] = 0;
wh.value = CopyString(string);
result = true;
default:
if(exp.hasAddress)
{
- wh.value = PrintHexUInt(exp.address);
+ wh.value = PrintHexUInt64(exp.address);
result = (bool)exp.address;
}
else
{
char tempString[256];
if(exp.member.memberType == propertyMember)
- sprintf(watchmsg, "Missing property evaluation support for \"%s\"", wh.expression);
+ snprintf(watchmsg, sizeof(watchmsg), $"Missing property evaluation support for \"%s\"", wh.expression);
else
- sprintf(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;
}
}
else
- sprintf(watchmsg, "Invalid expression: \"%s\"", wh.expression);
+ snprintf(watchmsg, sizeof(watchmsg), $"Invalid expression: \"%s\"", wh.expression);
if(exp) FreeExpression(exp);
//else
// wh.value = CopyString("No source file found for selected frame");
+ watchmsg[sizeof(watchmsg)-1] = 0;
if(!wh.value)
wh.value = CopyString(watchmsg);
}
}
// to be removed... use GdbReadMemory that returns a byte array instead
- char * ::GdbReadMemoryString(uint address, int size, char format, int rows, int cols)
+ char * ::GdbReadMemoryString(uint64 address, int size, char format, int rows, int cols)
{
eval.active = true;
eval.error = none;
if(!size)
printf("GdbReadMemoryString called with size = 0!\n");
#endif
- GdbCommand(false, "-data-read-memory 0x%08x %c, %d, %d, %d", address, format, size, rows, cols);
+ // 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);
if(eval.active)
ide.outputView.debugBox.Logf("Debugger Error: GdbReadMemoryString\n");
return eval.result;
}
- byte * ::GdbReadMemory(uint address, int bytes)
+ byte * ::GdbReadMemory(uint64 address, int bytes)
{
eval.active = true;
eval.error = none;
- GdbCommand(false, "-data-read-memory 0x%08x %c, 1, 1, %d", address, 'u', bytes);
+ //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);
#ifdef _DEBUG
if(!bytes)
printf("GdbReadMemory called with bytes = 0!\n");
{
bool conditionMet = true;
Breakpoint bp = bpHit;
-
+
if(!bp && bpRunToCursor)
{
bp = bpRunToCursor;
if(bp)
{
- if(bp.type == user && bp.line != stopItem.frame.line)
+ if(bp.type == user && stopItem.frame.line && bp.line != stopItem.frame.line)
{
bp.line = stopItem.frame.line;
ide.breakpointsView.UpdateBreakpoint(bp.row);
// Why was SelectFrame missing here?
SelectFrame(activeFrameLevel);
GoToStackFrameLine(activeFrameLevel, true);
- //ide.AdjustDebugMenus();
- ide.Activate();
+ ideMainFrame.Activate(); // TOFIX: ide.Activate() is not reliable (app inactive)
ide.Update(null);
}
else
break;
case internalModulesLoaded:
modules = true;
+ GdbInsertInternalBreakpoint();
+ GdbBreakpointsInsert();
+ GdbExecContinue(false);
+ break;
+ case internalModuleLoad:
GdbBreakpointsInsert();
GdbExecContinue(false);
break;
case runToCursor:
if(bp.condition)
conditionMet = ResolveWatch(bp.condition);
- if(conditionMet && (bp.level == -1 || bp.level == frameCount))
+ bp.hits++;
+ if((bp.level == -1 || bp.level == frameCount-1) && conditionMet)
{
- bp.hits++;
- if(bp.hits > bp.ignore)
+ if(!bp.ignore)
{
+ bp.breaks++;
ignoreBreakpoints = false;
// Why was SelectFrame missing here?
SelectFrame(activeFrameLevel);
GoToStackFrameLine(activeFrameLevel, true);
- //ide.AdjustDebugMenus();
- ide.Activate();
+ ideMainFrame.Activate(); // TOFIX: ide.Activate() is not reliable (app inactive)
ide.Update(null);
if(bp.type == BreakpointType::runToCursor)
{
}
else
{
- /*bp.ignore--;
- ide.breakpointsView.UpdateBreakpoint(bp.row);*/
+ bp.ignore--;
GdbExecContinue(false);
}
}
else
GdbExecContinue(false);
+ ide.breakpointsView.UpdateBreakpoint(bp.row);
break;
}
}
ChangeState(terminated);
targetProcessId = 0;
ClearBreakDisplay();
- //ide.AdjustDebugMenus();
if(gdbHandle)
{
gdbHandle.Wait();
delete gdbHandle;
- ide.outputView.debugBox.Logf("Debugger Fatal Error: GDB lost\n");
- ide.outputView.debugBox.Logf("Debugging stopped\n");
+ ide.outputView.debugBox.Logf($"Debugger Fatal Error: GDB lost\n");
+ ide.outputView.debugBox.Logf($"Debugging stopped\n");
ide.Update(null);
}
//ChangeState(terminated);
if(strstr(output, "No debugging symbols found") || strstr(output, "(no debugging symbols found)"))
{
symbols = false;
- ide.outputView.debugBox.Logf("Target doesn't contain debug information!\n");
+ ide.outputView.debugBox.Logf($"Target doesn't contain debug information!\n");
ide.Update(null);
}
break;
}
ide.callStackView.Logf("%3d ", frame.level);
if(!strncmp(frame.func, "__ecereMethod_", strlen("__ecereMethod_")))
- ide.callStackView.Logf("%s Method, %s:%d\n", &frame.func[strlen("__ecereMethod_")], (s = CopySystemPath(frame.file)), frame.line);
+ ide.callStackView.Logf($"%s Method, %s:%d\n", &frame.func[strlen("__ecereMethod_")], (s = CopySystemPath(frame.file)), frame.line);
else if(!strncmp(frame.func, "__ecereProp_", strlen("__ecereProp_")))
- ide.callStackView.Logf("%s Property, %s:%d\n", &frame.func[strlen("__ecereProp_")], (s = CopySystemPath(frame.file)), frame.line);
+ ide.callStackView.Logf($"%s Property, %s:%d\n", &frame.func[strlen("__ecereProp_")], (s = CopySystemPath(frame.file)), frame.line);
else if(!strncmp(frame.func, "__ecereConstructor_", strlen("__ecereConstructor_")))
- ide.callStackView.Logf("%s Constructor, %s:%d\n", &frame.func[strlen("__ecereConstructor_")], (s = CopySystemPath(frame.file)), frame.line);
+ ide.callStackView.Logf($"%s Constructor, %s:%d\n", &frame.func[strlen("__ecereConstructor_")], (s = CopySystemPath(frame.file)), frame.line);
else if(!strncmp(frame.func, "__ecereDestructor_", strlen("__ecereDestructor_")))
- ide.callStackView.Logf("%s Destructor, %s:%d\n", &frame.func[strlen("__ecereDestructor_")], (s = CopySystemPath(frame.file)), frame.line);
+ ide.callStackView.Logf($"%s Destructor, %s:%d\n", &frame.func[strlen("__ecereDestructor_")], (s = CopySystemPath(frame.file)), frame.line);
else
- ide.callStackView.Logf("%s Function, %s:%d\n", frame.func, (s = CopySystemPath(frame.file)), frame.line);
+ ide.callStackView.Logf($"%s Function, %s:%d\n", frame.func, (s = CopySystemPath(frame.file)), frame.line);
delete s;
}
else
if(frame.from)
{
char * s;
- ide.callStackView.Logf("inside %s, %s\n", frame.func, (s = CopySystemPath(frame.from)));
+ ide.callStackView.Logf($"inside %s, %s\n", frame.func, (s = CopySystemPath(frame.from)));
delete s;
}
else if(frame.func)
ide.callStackView.Logf("%s\n", frame.func);
else
- ide.callStackView.Logf("unknown source\n");
+ ide.callStackView.Logf($"unknown source\n");
}
}
else
else if(!strcmp(item.name, "next-row"))
{
StripQuotes(item.value, item.value);
- eval.nextBlockAddress = strtoul(item.value, null, 0);
+ eval.nextBlockAddress = _strtoui64(item.value, null, 0);
}
else if(!strcmp(item.name, "memory"))
{
else if(!strcmp(outTokens[0], "^exit"))
{
ChangeState(terminated);
- //ide.AdjustDebugMenus();
// ide.outputView.debugBox.Logf("Exit\n");
- //ide.Update(null);
+ // ide.Update(null);
gdbReady = true;
serialSemaphore.Release();
}
if(sentBreakInsert)
{
sentBreakInsert = false;
+ breakpointError = true;
#ifdef _DEBUG
if(bpItem)
printf("problem\n");
{
ChangeState(loaded);
targetProcessId = 0;
- //ide.AdjustDebugMenus();
}
else if(!strcmp(item.value, "Function \\\"WinMain\\\" not defined."))
{
{
ChangeState(loaded);
targetProcessId = 0;
- //ide.AdjustDebugMenus();
}
else if(strstr(item.value, "No such file or directory."))
{
ChangeState(loaded);
targetProcessId = 0;
- //ide.AdjustDebugMenus();
+ }
+ else if(strstr(item.value, "During startup program exited with code "))
+ {
+ ChangeState(loaded);
+ targetProcessId = 0;
}
else
{
}
else if(!strcmp(outTokens[0], "*stopped"))
{
+ int tk;
ChangeState(stopped);
-
- if(outTokens.count > 1 && TokenizeListItem(outTokens[1], item))
+
+ for(tk = 1; tk < outTokens.count; tk++)
{
- if(!strcmp(item.name, "reason"))
+ if(TokenizeListItem(outTokens[tk], item))
{
- char * reason = item.value;
- StripQuotes(reason, reason);
- if(!strcmp(reason, "exited-normally") || !strcmp(reason, "exited") || !strcmp(reason, "exited-signalled"))
+ if(!strcmp(item.name, "reason"))
{
- char * exitCode;
- if(outTokens.count > 2 && TokenizeListItem(outTokens[2], item2))
+ char * reason = item.value;
+ StripQuotes(reason, reason);
+ if(!strcmp(reason, "exited-normally") || !strcmp(reason, "exited") || !strcmp(reason, "exited-signalled"))
{
- StripQuotes(item2.value, item2.value);
- if(!strcmp(item2.name, "exit-code"))
- exitCode = item2.value;
+ char * exitCode;
+ if(outTokens.count > tk+1 && TokenizeListItem(outTokens[tk+1], item2))
+ {
+ tk++;
+ StripQuotes(item2.value, item2.value);
+ if(!strcmp(item2.name, "exit-code"))
+ exitCode = item2.value;
+ else
+ exitCode = null;
+ }
else
exitCode = null;
+ HandleExit(reason, exitCode);
}
- else
- exitCode = null;
- HandleExit(reason, exitCode);
- }
- else if(!strcmp(reason, "breakpoint-hit"))
- {
- #ifdef _DEBUG
- if(stopItem)
- printf("problem\n");
- #endif
- stopItem = GdbDataStop { };
-
- for(i = 2; i < outTokens.count; i++)
+ else if(!strcmp(reason, "breakpoint-hit"))
{
- TokenizeListItem(outTokens[i], item);
- StripQuotes(item.value, item.value);
- if(!strcmp(item.name, "bkptno"))
- stopItem.bkptno = atoi(item.value);
- else if(!strcmp(item.name, "thread-id"))
- stopItem.threadid = atoi(item.value);
- else if(!strcmp(item.name, "frame"))
+ #ifdef _DEBUG
+ if(stopItem)
+ printf("problem\n");
+ #endif
+ stopItem = GdbDataStop { };
+
+ for(i = tk+1; i < outTokens.count; i++)
{
- item.value = StripCurlies(item.value);
- ParseFrame(stopItem.frame, item.value);
+ TokenizeListItem(outTokens[i], item);
+ StripQuotes(item.value, item.value);
+ if(!strcmp(item.name, "bkptno"))
+ stopItem.bkptno = atoi(item.value);
+ else if(!strcmp(item.name, "thread-id"))
+ stopItem.threadid = atoi(item.value);
+ else if(!strcmp(item.name, "frame"))
+ {
+ item.value = StripCurlies(item.value);
+ ParseFrame(stopItem.frame, item.value);
+ }
+ else
+ DebuggerProtocolUnknown("Unknown breakpoint hit item name", item.name);
}
- else
- DebuggerProtocolUnknown("Unknown breakpoint hit item name", item.name);
- }
- event = hit;
- }
- else if(!strcmp(reason, "end-stepping-range"))
- {
- #ifdef _DEBUG
- if(stopItem)
- printf("problem\n");
- #endif
- stopItem = GdbDataStop { };
-
- for(i = 2; i < outTokens.count; i++)
+ event = hit;
+ }
+ else if(!strcmp(reason, "end-stepping-range"))
{
- TokenizeListItem(outTokens[i], item);
- StripQuotes(item.value, item.value);
- if(!strcmp(item.name, "thread-id"))
- stopItem.threadid = atoi(item.value);
- else if(!strcmp(item.name, "frame"))
+ #ifdef _DEBUG
+ if(stopItem)
+ printf("problem\n");
+ #endif
+ stopItem = GdbDataStop { };
+
+ for(i = tk+1; i < outTokens.count; i++)
{
- item.value = StripCurlies(item.value);
- ParseFrame(stopItem.frame, item.value);
+ TokenizeListItem(outTokens[i], item);
+ StripQuotes(item.value, item.value);
+ if(!strcmp(item.name, "thread-id"))
+ stopItem.threadid = atoi(item.value);
+ else if(!strcmp(item.name, "frame"))
+ {
+ item.value = StripCurlies(item.value);
+ ParseFrame(stopItem.frame, item.value);
+ }
+ else if(!strcmp(item.name, "reason"))
+ ;
+ else if(!strcmp(item.name, "bkptno"))
+ ;
+ else
+ DebuggerProtocolUnknown("Unknown end of stepping range item name", item.name);
}
- else if(!strcmp(item.name, "reason"))
- ;
- else if(!strcmp(item.name, "bkptno"))
- ;
- else
- DebuggerProtocolUnknown("Unknown end of stepping range item name", item.name);
- }
- event = stepEnd;
- //ide.AdjustDebugMenus();
- ide.Update(null);
- }
- else if(!strcmp(reason, "function-finished"))
- {
- #ifdef _DEBUG
- if(stopItem)
- printf("problem\n");
- #endif
- stopItem = GdbDataStop { };
- stopItem.reason = CopyString(reason);
-
- for(i = 2; i < outTokens.count; i++)
+ event = stepEnd;
+ ide.Update(null);
+ }
+ else if(!strcmp(reason, "function-finished"))
{
- TokenizeListItem(outTokens[i], item);
- StripQuotes(item.value, item.value);
- if(!strcmp(item.name, "thread-id"))
- stopItem.threadid = atoi(item.value);
- else if(!strcmp(item.name, "frame"))
+ #ifdef _DEBUG
+ if(stopItem)
+ printf("problem\n");
+ #endif
+ stopItem = GdbDataStop { };
+ stopItem.reason = CopyString(reason);
+
+ for(i = tk+1; i < outTokens.count; i++)
{
- item.value = StripCurlies(item.value);
- ParseFrame(stopItem.frame, item.value);
+ TokenizeListItem(outTokens[i], item);
+ StripQuotes(item.value, item.value);
+ if(!strcmp(item.name, "thread-id"))
+ stopItem.threadid = atoi(item.value);
+ else if(!strcmp(item.name, "frame"))
+ {
+ item.value = StripCurlies(item.value);
+ ParseFrame(stopItem.frame, item.value);
+ }
+ else if(!strcmp(item.name, "gdb-result-var"))
+ stopItem.gdbResultVar = CopyString(item.value);
+ else if(!strcmp(item.name, "return-value"))
+ stopItem.returnValue = CopyString(item.value);
+ else
+ DebuggerProtocolUnknown("Unknown function finished item name", item.name);
}
- else if(!strcmp(item.name, "gdb-result-var"))
- stopItem.gdbResultVar = CopyString(item.value);
- else if(!strcmp(item.name, "return-value"))
- stopItem.returnValue = CopyString(item.value);
- else
- DebuggerProtocolUnknown("Unknown function finished item name", item.name);
- }
- event = functionEnd;
- //ide.AdjustDebugMenus();
- ide.Update(null);
- }
- else if(!strcmp(reason, "signal-received"))
- {
- #ifdef _DEBUG
- if(stopItem)
- printf("problem\n");
- #endif
- stopItem = GdbDataStop { };
- stopItem.reason = CopyString(reason);
-
- for(i = 2; i < outTokens.count; i++)
+ event = functionEnd;
+ ide.Update(null);
+ }
+ else if(!strcmp(reason, "signal-received"))
{
- TokenizeListItem(outTokens[i], item);
- StripQuotes(item.value, item.value);
- if(!strcmp(item.name, "signal-name"))
- stopItem.name = CopyString(item.value);
- else if(!strcmp(item.name, "signal-meaning"))
- stopItem.meaning = CopyString(item.value);
- else if(!strcmp(item.name, "thread-id"))
- stopItem.threadid = atoi(item.value);
- else if(!strcmp(item.name, "frame"))
+ #ifdef _DEBUG
+ if(stopItem)
+ printf("problem\n");
+ #endif
+ stopItem = GdbDataStop { };
+ stopItem.reason = CopyString(reason);
+
+ for(i = tk+1; i < outTokens.count; i++)
{
- item.value = StripCurlies(item.value);
- ParseFrame(stopItem.frame, item.value);
+ TokenizeListItem(outTokens[i], item);
+ StripQuotes(item.value, item.value);
+ if(!strcmp(item.name, "signal-name"))
+ stopItem.name = CopyString(item.value);
+ else if(!strcmp(item.name, "signal-meaning"))
+ stopItem.meaning = CopyString(item.value);
+ else if(!strcmp(item.name, "thread-id"))
+ stopItem.threadid = atoi(item.value);
+ else if(!strcmp(item.name, "frame"))
+ {
+ item.value = StripCurlies(item.value);
+ ParseFrame(stopItem.frame, item.value);
+ }
+ else
+ DebuggerProtocolUnknown("Unknown signal reveived item name", item.name);
+ }
+ if(!strcmp(stopItem.name, "SIGTRAP"))
+ {
+ switch(breakType)
+ {
+ case internal:
+ breakType = none;
+ break;
+ case restart:
+ case stop:
+ break;
+ default:
+ event = breakEvent;
+ }
}
else
- DebuggerProtocolUnknown("Unknown signal reveived item name", item.name);
- }
- if(!strcmp(stopItem.name, "SIGTRAP"))
- {
- switch(breakType)
{
- case internal:
- breakType = none;
- break;
- case restart:
- case stop:
- break;
- default:
- event = breakEvent;
- //ide.AdjustDebugMenus(); ide.Update(null);
+ event = signal;
}
}
+ else if(!strcmp(reason, "watchpoint-trigger"))
+ DebuggerProtocolUnknown("Reason watchpoint trigger not handled", "");
+ else if(!strcmp(reason, "read-watchpoint-trigger"))
+ DebuggerProtocolUnknown("Reason read watchpoint trigger not handled", "");
+ else if(!strcmp(reason, "access-watchpoint-trigger"))
+ DebuggerProtocolUnknown("Reason access watchpoint trigger not handled", "");
+ else if(!strcmp(reason, "watchpoint-scope"))
+ DebuggerProtocolUnknown("Reason watchpoint scope not handled", "");
+ else if(!strcmp(reason, "location-reached"))
+ DebuggerProtocolUnknown("Reason location reached not handled", "");
else
- {
- event = signal;
- //ide.AdjustDebugMenus(); ide.Update(null);
- }
+ DebuggerProtocolUnknown("Unknown reason", reason);
}
- else if(!strcmp(reason, "watchpoint-trigger"))
- DebuggerProtocolUnknown("Reason watchpoint trigger not handled", "");
- else if(!strcmp(reason, "read-watchpoint-trigger"))
- DebuggerProtocolUnknown("Reason read watchpoint trigger not handled", "");
- else if(!strcmp(reason, "access-watchpoint-trigger"))
- DebuggerProtocolUnknown("Reason access watchpoint trigger not handled", "");
- else if(!strcmp(reason, "watchpoint-scope"))
- DebuggerProtocolUnknown("Reason watchpoint scope not handled", "");
- else if(!strcmp(reason, "location-reached"))
- DebuggerProtocolUnknown("Reason location reached not handled", "");
- else
- DebuggerProtocolUnknown("Unknown reason", reason);
}
}
app.SignalEvent();
}
if(targetProcessId)
- {
ChangeState(running);
- //ide.AdjustDebugMenus(); ide.Update(null);
- }
else if(!oldProcessID)
{
- ide.outputView.debugBox.Logf("Debugger Error: No target process ID\n");
+ ide.outputView.debugBox.Logf($"Debugger Error: No target process ID\n");
// TO VERIFY: The rest of this block has not been thoroughly tested in this particular location
gdbHandle.Printf("-gdb-exit\n");
gdbTimer.Stop();
if(bpRunToCursor)
bpRunToCursor.inserted = false;
- ide.outputView.debugBox.Logf("Debugging stopped\n");
+ ide.outputView.debugBox.Logf($"Debugging stopped\n");
ClearBreakDisplay();
- //ide.AdjustDebugMenus(); ide.Update(null);
#if defined(__unix__)
if(FileExists(progFifoPath)) //fileCreated)
serialSemaphore.Release();
}
else
- DebuggerProtocolUnknown("Unknown prompt", output);
+ DebuggerProtocolUnknown($"Unknown prompt", output);
break;
case '&':
}
break;
default:
- DebuggerProtocolUnknown("Unknown output", output);
+ DebuggerProtocolUnknown($"Unknown output", output);
}
if(!setWaitingForPID)
waitingForPID = false;
return result;
}
- char * ::ReadMemory(uint address, int size, char format, ExpressionType * error)
+ char * ::ReadMemory(uint64 address, int size, char format, ExpressionType * error)
{
// check for state
char * result = GdbReadMemoryString(address, size, format, 1, 1);
int result;
app.Unlock();
result = gdbHandle.Read(output, 1, sizeof(output));
+ app.Lock();
if(debugger.state == terminated || !gdbHandle || gdbHandle.Eof())
break;
- app.Lock();
if(result)
{
int c;
}
}
+static define createFIFOMsg = $"err: Unable to create FIFO %s\n";
+static define openFIFOMsg = $"err: Unable to open FIFO %s for read\n";
+
#if defined(__unix__)
#define uint _uint
#include <errno.h>
else
{
app.Lock();
- ide.outputView.debugBox.Logf("err: Unable to create FIFO %s\n", progFifoPath);
+ ide.outputView.debugBox.Logf($"err: Unable to create FIFO %s\n", progFifoPath);
app.Unlock();
}*/
if(!fifoFile)
{
app.Lock();
- ide.outputView.debugBox.Logf("err: Unable to open FIFO %s for read\n", progFifoPath);
+ ide.outputView.debugBox.Logf(openFIFOMsg, progFifoPath);
app.Unlock();
}
else
{
-#ifdef BSD
- // TODO: Fix on BSD
- fd = 0;
-#else
- fd = fileno(fifoFile.input);
-#endif
+ fd = fileno((FILE *)fifoFile.input);
//fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
}
}
int line;
bool enabled;
int hits;
+ int breaks;
int ignore;
int level;
Watch condition;
char * LocationToString()
{
char location[MAX_LOCATION+20];
- sprintf(location, "%s:%d", relativeFilePath, line);
+ snprintf(location, sizeof(location), "%s:%d", relativeFilePath, line);
+ location[sizeof(location)-1] = 0;
#if defined(__WIN32__)
ChangeCh(location, '/', '\\');
#endif
bool active;
char * result;
int bytes;
- uint nextBlockAddress;
+ uint64 nextBlockAddress;
DebuggerEvaluationError error;
};