Removed redundant BpUpdateDllPath

This commit is contained in:
Duncan Ogilvie 2024-10-07 22:35:51 +02:00
parent dc120752c8
commit bb54515ef2
3 changed files with 15 additions and 65 deletions

View File

@ -310,53 +310,6 @@ bool BpGetAny(BP_TYPE Type, const char* Name, BREAKPOINT* Bp)
return false;
}
bool BpUpdateDllPath(const char* module1, BREAKPOINT** newBpInfo)
{
const char* dashPos1 = max(strrchr(module1, '\\'), strrchr(module1, '/'));
EXCLUSIVE_ACQUIRE(LockBreakpoints);
for(auto & i : breakpoints)
{
BREAKPOINT & bpRef = i.second;
if(bpRef.type == BPDLL && bpRef.enabled)
{
char mod[MAX_MODULE_SIZE] = "";
if(_stricmp(bpRef.module.c_str(), module1) == 0)
{
BREAKPOINT temp;
temp = bpRef;
strcpy_s(mod, module1);
_strlwr_s(mod, strlen(mod) + 1);
temp.module = mod;
temp.addr = ModHashFromName(module1);
breakpoints.erase(i.first);
auto newItem = breakpoints.emplace(BreakpointKey(BPDLL, temp.addr), temp);
*newBpInfo = &newItem.first->second;
return true;
}
const char* dashPos = max(strrchr(bpRef.module.c_str(), '\\'), strrchr(bpRef.module.c_str(), '/'));
if(dashPos == nullptr)
dashPos = bpRef.module.c_str();
else
dashPos += 1;
if(dashPos1 != nullptr && _stricmp(dashPos, dashPos1 + 1) == 0) // filename matches
{
BREAKPOINT temp;
temp = bpRef;
strcpy_s(mod, dashPos1 + 1);
_strlwr_s(mod, strlen(mod) + 1);
temp.module = mod;
temp.addr = ModHashFromName(dashPos1 + 1);
breakpoints.erase(i.first);
auto newItem = breakpoints.emplace(BreakpointKey(BPDLL, temp.addr), temp);
*newBpInfo = &newItem.first->second;
return true;
}
}
}
*newBpInfo = nullptr;
return false;
}
duint BpGetDLLBpAddr(const char* fileName)
{
const char* dashPos1 = max(strrchr(fileName, '\\'), strrchr(fileName, '/'));
@ -1022,6 +975,7 @@ void BpCacheLoad(JSON Root, bool migrateCommandCondition)
else
{
key = BpGetDLLBpAddr(breakpoint.module.c_str());
breakpoint.addr = key;
}
breakpoints[BreakpointKey(breakpoint.type, key)] = breakpoint;
}

View File

@ -79,7 +79,6 @@ void BpToBridge(const BREAKPOINT* Bp, BRIDGEBP* BridgeBp);
void BpCacheSave(JSON Root);
void BpCacheLoad(JSON Root, bool migrateCommandCondition);
void BpClear();
bool BpUpdateDllPath(const char* module1, BREAKPOINT** newBpInfo);
void BpLogFileAcquire(const std::string & logFile);
void BpLogFileRelease(const std::string & logFile);
HANDLE BpLogFileOpen(const std::string & logFile);

View File

@ -854,24 +854,21 @@ static void cbGenericBreakpoint(BP_TYPE bptype, const void* ExceptionAddress = n
break;
}
varset("$breakpointexceptionaddress", breakpointExceptionAddress, true);
if(!(bpPtr && bpPtr->enabled)) //invalid / disabled breakpoint hit (most likely a bug)
if(bpPtr == nullptr || !bpPtr->enabled) //invalid / disabled breakpoint hit (most likely a bug)
{
if(bptype != BPDLL || !BpUpdateDllPath(reinterpret_cast<const char*>(ExceptionAddress), &bpPtr))
{
// release the breakpoint lock to prevent deadlocks during the wait
EXCLUSIVE_RELEASE();
dputs(QT_TRANSLATE_NOOP("DBG", "Breakpoint reached not in list!"));
DebugUpdateGuiSetStateAsync(GetContextDataEx(hActiveThread, UE_CIP), paused);
//lock
lock(WAITID_RUN);
// Plugin callback
PLUG_CB_PAUSEDEBUG pauseInfo = { nullptr };
plugincbcall(CB_PAUSEDEBUG, &pauseInfo);
dbgsetforeground();
dbgsetskipexceptions(false);
wait(WAITID_RUN);
return;
}
// release the breakpoint lock to prevent deadlocks during the wait
EXCLUSIVE_RELEASE();
dputs(QT_TRANSLATE_NOOP("DBG", "Breakpoint reached not in list!"));
DebugUpdateGuiSetStateAsync(GetContextDataEx(hActiveThread, UE_CIP), paused);
//lock
lock(WAITID_RUN);
// Plugin callback
PLUG_CB_PAUSEDEBUG pauseInfo = { nullptr };
plugincbcall(CB_PAUSEDEBUG, &pauseInfo);
dbgsetforeground();
dbgsetskipexceptions(false);
wait(WAITID_RUN);
return;
}
// increment hit count