1
0
Fork 0

Auto follow operand in stack

This commit is contained in:
torusrxxx 2020-11-28 21:47:39 +08:00
parent d2f426f9de
commit a1df9922e3
No known key found for this signature in database
GPG Key ID: A795C73A0F1CFADD
9 changed files with 138 additions and 80 deletions

View File

@ -188,7 +188,7 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
for(int i = 0, j = start; i < instr.argcount && j < 2; i++)
{
DISASM_ARG arg = instr.arg[i];
const DISASM_ARG & arg = instr.arg[i];
QString argMnemonic = QString(arg.mnemonic);
if(bUpper)
argMnemonic = argMnemonic.toUpper();

View File

@ -554,8 +554,10 @@ void CPUStack::stackDumpAt(duint addr, duint csp)
}
BridgeFree(callstack.entries);
}
bool isInvisible;
isInvisible = (addr < mMemPage->va(getTableOffsetRva())) || (addr >= mMemPage->va(getTableOffsetRva() + getViewableRowsCount() * getBytePerRowCount()));
printDumpAt(addr);
printDumpAt(addr, true, true, isInvisible || addr == csp);
}
void CPUStack::updateSlot()
@ -588,6 +590,29 @@ void CPUStack::updateSlot()
}
}
void CPUStack::disasmSelectionChanged(dsint parVA)
{
// When the selected instruction is changed, select the argument that is in the stack.
DISASM_INSTR instr;
if(!DbgIsDebugging() || !DbgMemIsValidReadPtr(parVA))
return;
DbgDisasmAt(parVA, &instr);
for(int i = 0; i < instr.argcount; i++)
{
const DISASM_ARG & arg = instr.arg[i];
if(arg.type == arg_memory)
{
if(arg.value >= mMemPage->getBase() && arg.value < mMemPage->getBase() + mMemPage->getSize())
{
//TODO: When the stack is unaligned?
stackDumpAt(arg.value & (~(sizeof(void*) - 1)), mCsp);
return;
}
}
}
}
void CPUStack::gotoCspSlot()
{
DbgCmdExec("sdump csp");

View File

@ -54,6 +54,7 @@ public slots:
void realignSlot();
void freezeStackSlot();
void dbgStateChangedSlot(DBGSTATE state);
void disasmSelectionChanged(dsint parVA);
void updateSlot();
private:

View File

@ -83,6 +83,9 @@ CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget)
mStack = new CPUStack(mDump, 0); //stack widget
ui->mBotRightFrameLayout->addWidget(mStack);
if(Config()->getBool("Gui", "AutoFollowInStack"))
connect(mDisas, SIGNAL(selectionChanged(dsint)), mStack, SLOT(disasmSelectionChanged(dsint)));
connect(Config(), SIGNAL(guiOptionsUpdated()), this, SLOT(guiOptionsUpdated()));
// load column config
mDisas->loadColumnFromConfig("CPUDisassembly");
@ -160,6 +163,14 @@ void CPUWidget::setDefaultDisposition()
ui->mTopLeftUpperHSplitter->setStretchFactor(1, 64);
}
void CPUWidget::guiOptionsUpdated()
{
if(Config()->getBool("Gui", "AutoFollowInStack"))
connect(mDisas, SIGNAL(selectionChanged(dsint)), mStack, SLOT(disasmSelectionChanged(dsint)), Qt::UniqueConnection);
else
disconnect(mDisas, SIGNAL(selectionChanged(dsint)), mStack, SLOT(disasmSelectionChanged(dsint)));
}
void CPUWidget::setDisasmFocus()
{
if(disasMode == 1)

View File

@ -66,6 +66,7 @@ private:
private slots:
void splitterMoved(int pos, int index);
void guiOptionsUpdated();
void attachGraph(QWidget* widget);
void detachGraph();
};

View File

@ -86,6 +86,7 @@ void SettingsDialog::LoadSettings()
settings.guiNoForegroundWindow = true;
settings.guiLoadSaveTabOrder = true;
settings.guiDisableAutoComplete = false;
settings.guiAutoFollowInStack = true;
//Events tab
GetSettingBool("Events", "SystemBreakpoint", &settings.eventSystemBreakpoint);
@ -269,6 +270,7 @@ void SettingsDialog::LoadSettings()
GetSettingBool("Gui", "GraphZoomMode", &settings.guiGraphZoomMode);
GetSettingBool("Gui", "ShowExitConfirmation", &settings.guiShowExitConfirmation);
GetSettingBool("Gui", "DisableAutoComplete", &settings.guiDisableAutoComplete);
GetSettingBool("Gui", "AutoFollowInStack", &settings.guiAutoFollowInStack);
ui->chkFpuRegistersLittleEndian->setChecked(settings.guiFpuRegistersLittleEndian);
ui->chkSaveColumnOrder->setChecked(settings.guiSaveColumnOrder);
ui->chkNoCloseDialog->setChecked(settings.guiNoCloseDialog);
@ -280,6 +282,7 @@ void SettingsDialog::LoadSettings()
ui->chkGraphZoomMode->setChecked(settings.guiGraphZoomMode);
ui->chkShowExitConfirmation->setChecked(settings.guiShowExitConfirmation);
ui->chkDisableAutoComplete->setChecked(settings.guiDisableAutoComplete);
ui->chkAutoFollowInStack->setChecked(settings.guiAutoFollowInStack);
//Misc tab
if(DbgFunctions()->GetJit)
@ -429,6 +432,7 @@ void SettingsDialog::SaveSettings()
BridgeSettingSetUint("Gui", "GraphZoomMode", settings.guiGraphZoomMode);
BridgeSettingSetUint("Gui", "ShowExitConfirmation", settings.guiShowExitConfirmation);
BridgeSettingSetUint("Gui", "DisableAutoComplete", settings.guiDisableAutoComplete);
BridgeSettingSetUint("Gui", "AutoFollowInStack", settings.guiAutoFollowInStack);
//Misc tab
if(DbgFunctions()->GetJit)
@ -832,6 +836,12 @@ void SettingsDialog::on_chkNoCloseDialog_toggled(bool checked)
settings.guiNoCloseDialog = checked;
}
void SettingsDialog::on_chkAutoFollowInStack_toggled(bool checked)
{
bGuiOptionsUpdated = true;
settings.guiAutoFollowInStack = checked;
}
void SettingsDialog::on_chkSkipInt3Stepping_toggled(bool checked)
{
settings.engineSkipInt3Stepping = checked;

View File

@ -94,6 +94,7 @@ private slots:
void on_chkNoForegroundWindow_toggled(bool checked);
void on_chkShowExitConfirmation_toggled(bool checked);
void on_chkDisableAutoComplete_toggled(bool checked);
void on_chkAutoFollowInStack_toggled(bool checked);
//Misc tab
void on_chkSetJIT_stateChanged(int arg1);
void on_chkConfirmBeforeAtt_stateChanged(int arg1);
@ -202,6 +203,7 @@ private:
bool guiGraphZoomMode;
bool guiShowExitConfirmation;
bool guiDisableAutoComplete;
bool guiAutoFollowInStack;
//Misc Tab
bool miscSetJIT;
bool miscSetJITAuto;

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>381</width>
<width>386</width>
<height>525</height>
</rect>
</property>
@ -40,6 +40,37 @@
<string>Events</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<widget class="QCheckBox" name="chkEntryBreakpoint">
<property name="text">
<string>Entry Breakpoint*</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="chkThreadStart">
<property name="text">
<string>Thread Start</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QCheckBox" name="chkDllLoadSystem">
<property name="text">
<string>System DLL Load</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="chkThreadEntry">
<property name="text">
<string>Thread Entry</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QCheckBox" name="chkDllUnloadSystem">
<property name="text">
@ -47,7 +78,7 @@
</property>
</widget>
</item>
<item row="12" column="0">
<item row="13" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -60,20 +91,48 @@
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="chkEntryBreakpoint">
<item row="2" column="0">
<widget class="QCheckBox" name="chkNtTerminateProcess">
<property name="text">
<string>Entry Breakpoint*</string>
<string>NtTerminateProcess*</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="chkTlsCallbacks">
<property name="text">
<string>TLS Callbacks*</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="chkDllEntrySystem">
<item row="3" column="1">
<widget class="QCheckBox" name="chkThreadEnd">
<property name="text">
<string>System DLL Entry</string>
<string>Thread End</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="chkDllEntry">
<property name="text">
<string>DLL Entry</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="chkDllLoad">
<property name="text">
<string>DLL Load</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblBreakOn">
<property name="text">
<string>Break on:</string>
</property>
</widget>
</item>
@ -87,55 +146,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="chkNtTerminateProcess">
<property name="text">
<string>NtTerminateProcess*</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QCheckBox" name="chkDllLoadSystem">
<property name="text">
<string>System DLL Load</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="chkThreadStart">
<property name="text">
<string>Thread Start</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblBreakOn">
<property name="text">
<string>Break on:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="chkThreadEnd">
<property name="text">
<string>Thread End</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="chkDebugStrings">
<property name="text">
<string>Debug Strings</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="chkThreadEntry">
<property name="text">
<string>Thread Entry</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="chkTlsCallbacksSystem">
<property name="text">
@ -143,37 +153,27 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="chkTlsCallbacks">
<item row="8" column="1">
<widget class="QCheckBox" name="chkDllEntrySystem">
<property name="text">
<string>TLS Callbacks*</string>
</property>
<property name="checked">
<bool>false</bool>
<string>System DLL Entry</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="chkDllEntry">
<property name="text">
<string>DLL Entry</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="chkDllLoad">
<property name="text">
<string>DLL Load</string>
</property>
</widget>
</item>
<item row="9" column="0">
<item row="11" column="0">
<widget class="QCheckBox" name="chkDllUnload">
<property name="text">
<string>DLL Unload</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QCheckBox" name="chkDebugStrings">
<property name="text">
<string>Debug Strings</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabEngine">
@ -775,6 +775,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkAutoFollowInStack">
<property name="text">
<string>Auto follow operand in stack</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkShowExitConfirmation">
<property name="text">

View File

@ -284,6 +284,7 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
guiBool.insert("DisableAutoComplete", false);
guiBool.insert("CaseSensitiveAutoComplete", false);
guiBool.insert("AutoRepeatOnEnter", false);
guiBool.insert("AutoFollowInStack", true);
//Named menu settings
insertMenuBuilderBools(&guiBool, "CPUDisassembly", 50); //CPUDisassembly
insertMenuBuilderBools(&guiBool, "CPUDump", 50); //CPUDump