mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Fixed hot thread state issue with thread creation during hot swap
This commit is contained in:
parent
b811f5daf8
commit
d9b81daac8
2 changed files with 25 additions and 11 deletions
|
@ -1073,7 +1073,8 @@ void WinDebugger::HotLoad(const Array<String>& objectFiles, int hotIdx)
|
||||||
SetAndRestoreValue<WdThreadInfo*> prevActiveThread(mActiveThread, threadInfo);
|
SetAndRestoreValue<WdThreadInfo*> prevActiveThread(mActiveThread, threadInfo);
|
||||||
BfLogDbg("SuspendThread %d\n", threadInfo->mThreadId);
|
BfLogDbg("SuspendThread %d\n", threadInfo->mThreadId);
|
||||||
::SuspendThread(threadInfo->mHThread);
|
::SuspendThread(threadInfo->mHThread);
|
||||||
PopulateRegisters(&mHotThreadStates[threadIdx]);
|
mHotThreadStates[threadIdx].mThreadId = threadInfo->mThreadId;
|
||||||
|
PopulateRegisters(&mHotThreadStates[threadIdx].mRegisters);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto address : mTempBreakpoint)
|
for (auto address : mTempBreakpoint)
|
||||||
|
@ -1130,9 +1131,13 @@ void WinDebugger::HotLoad(const Array<String>& objectFiles, int hotIdx)
|
||||||
CheckBreakpoint(breakpoint);
|
CheckBreakpoint(breakpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int threadIdx = 0; threadIdx < (int)mThreadList.size(); threadIdx++)
|
for (int hotThreadIdx = 0; hotThreadIdx < (int)mHotThreadStates.size(); hotThreadIdx++)
|
||||||
{
|
{
|
||||||
WdThreadInfo* threadInfo = mThreadList[threadIdx];
|
auto& hotThreadState = mHotThreadStates[hotThreadIdx];
|
||||||
|
WdThreadInfo* threadInfo = NULL;
|
||||||
|
if (!mThreadMap.TryGetValue((uint32)hotThreadState.mThreadId, &threadInfo))
|
||||||
|
continue;
|
||||||
|
|
||||||
BfLogDbg("ResumeThread %d\n", threadInfo->mThreadId);
|
BfLogDbg("ResumeThread %d\n", threadInfo->mThreadId);
|
||||||
::ResumeThread(threadInfo->mHThread);
|
::ResumeThread(threadInfo->mHThread);
|
||||||
}
|
}
|
||||||
|
@ -5099,14 +5104,17 @@ bool WinDebugger::SetHotJump(DbgSubprogram* oldSubprogram, addr_target newTarget
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldSubprogram->mHotReplaceKind != DbgSubprogram::HotReplaceKind_Replaced)
|
if (oldSubprogram->mHotReplaceKind != DbgSubprogram::HotReplaceKind_Replaced)
|
||||||
{
|
{
|
||||||
for (int threadIdx = 0; threadIdx < (int)mThreadList.size(); threadIdx++)
|
for (int hotThreadIdx = 0; hotThreadIdx < (int)mHotThreadStates.size(); hotThreadIdx++)
|
||||||
{
|
{
|
||||||
CPURegisters* cpuRegisters = &mHotThreadStates[threadIdx];
|
auto& hotThreadState = mHotThreadStates[hotThreadIdx];
|
||||||
|
WdThreadInfo* threadInfo = NULL;
|
||||||
|
if (!mThreadMap.TryGetValue((uint32)hotThreadState.mThreadId, &threadInfo))
|
||||||
|
continue;
|
||||||
|
|
||||||
int tryStart = GetTickCount();
|
int tryStart = GetTickCount();
|
||||||
|
|
||||||
while ((cpuRegisters->GetPC() >= jmpInstStart) && (cpuRegisters->GetPC() < jmpInstEnd))
|
while ((hotThreadState.mRegisters.GetPC() >= jmpInstStart) && (hotThreadState.mRegisters.GetPC() < jmpInstEnd))
|
||||||
{
|
{
|
||||||
if (GetTickCount() - tryStart >= 8000)
|
if (GetTickCount() - tryStart >= 8000)
|
||||||
{
|
{
|
||||||
|
@ -5114,11 +5122,11 @@ bool WinDebugger::SetHotJump(DbgSubprogram* oldSubprogram, addr_target newTarget
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BfLogDbg("SetHotJump skipping through %p\n", cpuRegisters->GetPC());
|
BfLogDbg("SetHotJump skipping through %p\n", hotThreadState.mRegisters.GetPC());
|
||||||
|
|
||||||
bool removedBreakpoint = false;
|
bool removedBreakpoint = false;
|
||||||
|
|
||||||
mActiveThread = mThreadList[threadIdx];
|
mActiveThread = threadInfo;
|
||||||
if ((mActiveThread->mStoppedAtAddress >= jmpInstStart) && (mActiveThread->mStoppedAtAddress < jmpInstEnd))
|
if ((mActiveThread->mStoppedAtAddress >= jmpInstStart) && (mActiveThread->mStoppedAtAddress < jmpInstEnd))
|
||||||
{
|
{
|
||||||
for (addr_target addr = jmpInstStart; addr < jmpInstEnd; addr++)
|
for (addr_target addr = jmpInstStart; addr < jmpInstEnd; addr++)
|
||||||
|
@ -5184,7 +5192,7 @@ bool WinDebugger::SetHotJump(DbgSubprogram* oldSubprogram, addr_target newTarget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PopulateRegisters(cpuRegisters);
|
PopulateRegisters(&hotThreadState.mRegisters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -378,13 +378,19 @@ struct DbgPendingDebugInfoLoad
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct WinHotThreadState
|
||||||
|
{
|
||||||
|
CPURegisters mRegisters;
|
||||||
|
int mThreadId;
|
||||||
|
};
|
||||||
|
|
||||||
class WinDebugger : public Debugger
|
class WinDebugger : public Debugger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SyncEvent mContinueEvent;
|
SyncEvent mContinueEvent;
|
||||||
|
|
||||||
Array<HotTargetMemory> mHotTargetMemory;
|
Array<HotTargetMemory> mHotTargetMemory;
|
||||||
Array<CPURegisters> mHotThreadStates;
|
Array<WinHotThreadState> mHotThreadStates;
|
||||||
int mActiveHotIdx;
|
int mActiveHotIdx;
|
||||||
|
|
||||||
volatile bool mShuttingDown;
|
volatile bool mShuttingDown;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue