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>
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
{
#endif
}
}
-
switch(breakType)
{
case restart:
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;
}
// 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();
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()
{
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';
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);
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;
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);
{
// 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;
#endif
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)
{
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);
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, "");
ChangeState(loaded);
sentKill = false;
sentBreakInsert = false;
+ breakpointError = false;
symbols = true;
targeted = false;
modules = false;
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)
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");
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.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;
// Why was SelectFrame missing here?
SelectFrame(activeFrameLevel);
GoToStackFrameLine(activeFrameLevel, true);
- ide.Activate();
+ ideMainFrame.Activate(); // TOFIX: ide.Activate() is not reliable (app inactive)
ide.Update(null);
if(bp.type == BreakpointType::runToCursor)
{
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"))
{
if(sentBreakInsert)
{
sentBreakInsert = false;
+ breakpointError = true;
#ifdef _DEBUG
if(bpItem)
printf("problem\n");
}
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.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.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;
+ 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;
- }
+ 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();
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);
}
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);
}
}
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;
};