Skip to content

Commit

Permalink
Change the default command condition to '1' instead of '$breakpointco…
Browse files Browse the repository at this point in the history
…ndition'
  • Loading branch information
mrexodia committed Jun 9, 2023
1 parent 7b1e56b commit 165b0d3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/dbg/breakpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ static void loadStringValue(JSON value, T & dest, const char* key)
strncpy_s(dest, text, _TRUNCATE);
}

void BpCacheLoad(JSON Root)
void BpCacheLoad(JSON Root, bool migrateCommandCondition)
{
EXCLUSIVE_ACQUIRE(LockBreakpoints);

Expand Down Expand Up @@ -902,6 +902,13 @@ void BpCacheLoad(JSON Root)
loadStringValue(value, breakpoint.commandText, "commandText");
loadStringValue(value, breakpoint.commandCondition, "commandCondition");

// On 2023-06-10 the default of the command condition was changed from $breakpointcondition to 1
// If we detect an older database, try to preserve the old behavior.
if(migrateCommandCondition && *breakpoint.commandText != '\0' && *breakpoint.commandCondition == '\0')
{
strcpy_s(breakpoint.commandCondition, "$breakpointcondition");
}

// Fast resume
breakpoint.fastResume = json_boolean_value(json_object_get(value, "fastResume"));
breakpoint.silent = json_boolean_value(json_object_get(value, "silent"));
Expand Down
2 changes: 1 addition & 1 deletion src/dbg/breakpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ uint32 BpGetHitCount(duint Address, BP_TYPE Type);
bool BpResetHitCount(duint Address, BP_TYPE Type, uint32 newHitCount);
void BpToBridge(const BREAKPOINT* Bp, BRIDGEBP* BridgeBp);
void BpCacheSave(JSON Root);
void BpCacheLoad(JSON Root);
void BpCacheLoad(JSON Root, bool migrateCommandCondition);
void BpClear();
bool BpUpdateDllPath(const char* module1, BREAKPOINT** newBpInfo);

Expand Down
30 changes: 29 additions & 1 deletion src/dbg/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,34 @@ void DbLoad(DbLoadSaveType loadType, const char* dbfile)
// Multi-byte (UTF8) file path converted to UTF16
WString databasePathW = StringUtils::Utf8ToUtf16(file);

// Check if we should migrate the breakpoints
bool migrateBreakpoints = false;
{
HANDLE hFile = CreateFileW(databasePathW.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, 0);
if(hFile != INVALID_HANDLE_VALUE)
{
FILETIME written;
if(GetFileTime(hFile, nullptr, nullptr, &written))
{
// On 2023-06-10 the default of the command condition was changed
SYSTEMTIME smigration = {};
smigration.wYear = 2023;
smigration.wMonth = 6;
smigration.wDay = 10;
FILETIME migration = {};
if(SystemTimeToFileTime(&smigration, &migration))
{
if(CompareFileTime(&written, &migration) < 0)
{
dprintf(QT_TRANSLATE_NOOP("DBG", "(migrating breakpoints) "));
migrateBreakpoints = true;
}
}
}
CloseHandle(hFile);
}
}

// Decompress the file if compression was enabled
bool useCompression = !settingboolget("Engine", "DisableDatabaseCompression");
LZ4_STATUS lzmaStatus = LZ4_INVALID_ARCHIVE;
Expand Down Expand Up @@ -254,7 +282,7 @@ void DbLoad(DbLoadSaveType loadType, const char* dbfile)
XrefCacheLoad(root);
EncodeMapCacheLoad(root);
TraceRecord.loadFromDb(root);
BpCacheLoad(root);
BpCacheLoad(root, migrateBreakpoints);
WatchCacheLoad(root);

// Load notes
Expand Down
3 changes: 2 additions & 1 deletion src/dbg/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,8 +917,9 @@ static void cbGenericBreakpoint(BP_TYPE bptype, const void* ExceptionAddress = n
}
else
{
// NOTE: This behavior was changed in a breaking way, but too many people were confused
if(breakCondition != -1)
commandCondition = breakCondition; //if no condition is set, execute the command when the debugger would break
commandCondition = 1; // If no condition is set, always execute the command
else
commandCondition = 0; // Don't execute any command if an error occurs
}
Expand Down

0 comments on commit 165b0d3

Please sign in to comment.