Skip to content

Commit ce3daae

Browse files
committed
DBG: possibility to lock the stack (set bFreezeStack to true to freeze on automatic stack updates as CSP changes)
1 parent 087362d commit ce3daae

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

src/dbg/debugger.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static bool isDetachedByUser = false;
3333
static bool bIsAttached = false;
3434
static bool bSkipExceptions = false;
3535
static bool bBreakOnNextDll = false;
36+
static bool bFreezeStack = false;
3637
static int ecount = 0;
3738
static std::vector<ExceptionRange> ignoredExceptionRange;
3839
static HANDLE hEvent = 0;
@@ -214,7 +215,7 @@ void DebugUpdateGui(duint disasm_addr, bool stack)
214215
}
215216
duint csp = GetContextDataEx(hActiveThread, UE_CSP);
216217
if(stack)
217-
GuiStackDumpAt(csp, csp);
218+
DebugUpdateStack(csp, csp);
218219
static duint cacheCsp = 0;
219220
if(csp != cacheCsp)
220221
{
@@ -233,6 +234,17 @@ void DebugUpdateGui(duint disasm_addr, bool stack)
233234
GuiUpdateAllViews();
234235
}
235236

237+
void DebugUpdateStack(duint dumpAddr, duint csp, bool forceDump)
238+
{
239+
if (!forceDump && bFreezeStack)
240+
{
241+
SELECTIONDATA selection;
242+
if (GuiSelectionGet(GUI_STACK, &selection))
243+
dumpAddr = selection.start;
244+
}
245+
GuiStackDumpAt(dumpAddr, csp);
246+
}
247+
236248
void cbUserBreakpoint()
237249
{
238250
hActiveThread = ThreadGetHandle(((DEBUG_EVENT*)GetDebugData())->dwThreadId);

src/dbg/debugger.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ bool dbgisrunning();
6969
bool dbgisdll();
7070
void dbgsetattachevent(HANDLE handle);
7171
void DebugUpdateGui(duint disasm_addr, bool stack);
72+
void DebugUpdateStack(duint dumpAddr, duint csp, bool forceDump = false);
7273
void dbgsetskipexceptions(bool skip);
7374
void dbgsetstepping(bool stepping);
7475
void dbgsetispausedbyuser(bool b);

src/dbg/debugger_commands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ CMDRESULT cbDebugStackDump(int argc, char* argv[])
10451045
duint size = 0;
10461046
duint base = MemFindBaseAddr(csp, &size);
10471047
if(base && addr >= base && addr < (base + size))
1048-
GuiStackDumpAt(addr, csp);
1048+
DebugUpdateStack(addr, csp, true);
10491049
else
10501050
dputs("Invalid stack address!");
10511051
return STATUS_CONTINUE;

src/dbg/instruction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ CMDRESULT cbInstrPush(int argc, char* argv[])
767767
}
768768
Script::Stack::Push(value);
769769
duint csp = GetContextDataEx(hActiveThread, UE_CSP);
770-
GuiStackDumpAt(csp, csp);
770+
DebugUpdateStack(csp, csp);
771771
GuiUpdateRegisterView();
772772
return STATUS_CONTINUE;
773773
}
@@ -776,7 +776,7 @@ CMDRESULT cbInstrPop(int argc, char* argv[])
776776
{
777777
duint value = Script::Stack::Pop();
778778
duint csp = GetContextDataEx(hActiveThread, UE_CSP);
779-
GuiStackDumpAt(csp, csp);
779+
DebugUpdateStack(csp, csp);
780780
GuiUpdateRegisterView();
781781
if (argc > 1)
782782
{

src/dbg/value.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2180,7 +2180,7 @@ bool valtostring(const char* string, duint value, bool silent)
21802180
else if(strstr(regName(), "sp")) //update stack
21812181
{
21822182
duint csp = GetContextDataEx(hActiveThread, UE_CSP);
2183-
GuiStackDumpAt(csp, csp);
2183+
DebugUpdateStack(csp, csp);
21842184
GuiUpdateRegisterView();
21852185
}
21862186
else

0 commit comments

Comments
 (0)