diff options
Diffstat (limited to 'src/citra_qt/debugger/callstack.cpp')
| -rw-r--r-- | src/citra_qt/debugger/callstack.cpp | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/citra_qt/debugger/callstack.cpp b/src/citra_qt/debugger/callstack.cpp index 1a3077495..a87046acb 100644 --- a/src/citra_qt/debugger/callstack.cpp +++ b/src/citra_qt/debugger/callstack.cpp | |||
| @@ -9,13 +9,12 @@ | |||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "common/symbols.h" | 10 | #include "common/symbols.h" |
| 11 | 11 | ||
| 12 | #include "core/core.h" | ||
| 13 | #include "core/memory.h" | ||
| 14 | #include "core/arm/arm_interface.h" | 12 | #include "core/arm/arm_interface.h" |
| 15 | #include "core/arm/disassembler/arm_disasm.h" | 13 | #include "core/arm/disassembler/arm_disasm.h" |
| 14 | #include "core/core.h" | ||
| 15 | #include "core/memory.h" | ||
| 16 | 16 | ||
| 17 | CallstackWidget::CallstackWidget(QWidget* parent): QDockWidget(parent) | 17 | CallstackWidget::CallstackWidget(QWidget* parent) : QDockWidget(parent) { |
| 18 | { | ||
| 19 | ui.setupUi(this); | 18 | ui.setupUi(this); |
| 20 | 19 | ||
| 21 | callstack_model = new QStandardItemModel(this); | 20 | callstack_model = new QStandardItemModel(this); |
| @@ -27,29 +26,26 @@ CallstackWidget::CallstackWidget(QWidget* parent): QDockWidget(parent) | |||
| 27 | ui.treeView->setModel(callstack_model); | 26 | ui.treeView->setModel(callstack_model); |
| 28 | } | 27 | } |
| 29 | 28 | ||
| 30 | void CallstackWidget::OnDebugModeEntered() | 29 | void CallstackWidget::OnDebugModeEntered() { |
| 31 | { | ||
| 32 | // Stack pointer | 30 | // Stack pointer |
| 33 | const u32 sp = Core::g_app_core->GetReg(13); | 31 | const u32 sp = Core::g_app_core->GetReg(13); |
| 34 | 32 | ||
| 35 | Clear(); | 33 | Clear(); |
| 36 | 34 | ||
| 37 | int counter = 0; | 35 | int counter = 0; |
| 38 | for (u32 addr = 0x10000000; addr >= sp; addr -= 4) | 36 | for (u32 addr = 0x10000000; addr >= sp; addr -= 4) { |
| 39 | { | ||
| 40 | if (!Memory::IsValidVirtualAddress(addr)) | 37 | if (!Memory::IsValidVirtualAddress(addr)) |
| 41 | break; | 38 | break; |
| 42 | 39 | ||
| 43 | const u32 ret_addr = Memory::Read32(addr); | 40 | const u32 ret_addr = Memory::Read32(addr); |
| 44 | const u32 call_addr = ret_addr - 4; //get call address??? | 41 | const u32 call_addr = ret_addr - 4; // get call address??? |
| 45 | 42 | ||
| 46 | if (!Memory::IsValidVirtualAddress(call_addr)) | 43 | if (!Memory::IsValidVirtualAddress(call_addr)) |
| 47 | break; | 44 | break; |
| 48 | 45 | ||
| 49 | /* TODO (mattvail) clean me, move to debugger interface */ | 46 | /* TODO (mattvail) clean me, move to debugger interface */ |
| 50 | u32 insn = Memory::Read32(call_addr); | 47 | u32 insn = Memory::Read32(call_addr); |
| 51 | if (ARM_Disasm::Decode(insn) == OP_BL) | 48 | if (ARM_Disasm::Decode(insn) == OP_BL) { |
| 52 | { | ||
| 53 | std::string name; | 49 | std::string name; |
| 54 | // ripped from disasm | 50 | // ripped from disasm |
| 55 | u8 cond = (insn >> 28) & 0xf; | 51 | u8 cond = (insn >> 28) & 0xf; |
| @@ -63,26 +59,29 @@ void CallstackWidget::OnDebugModeEntered() | |||
| 63 | i_offset += 8; | 59 | i_offset += 8; |
| 64 | const u32 func_addr = call_addr + i_offset; | 60 | const u32 func_addr = call_addr + i_offset; |
| 65 | 61 | ||
| 66 | callstack_model->setItem(counter, 0, new QStandardItem(QString("0x%1").arg(addr, 8, 16, QLatin1Char('0')))); | 62 | callstack_model->setItem( |
| 67 | callstack_model->setItem(counter, 1, new QStandardItem(QString("0x%1").arg(ret_addr, 8, 16, QLatin1Char('0')))); | 63 | counter, 0, new QStandardItem(QString("0x%1").arg(addr, 8, 16, QLatin1Char('0')))); |
| 68 | callstack_model->setItem(counter, 2, new QStandardItem(QString("0x%1").arg(call_addr, 8, 16, QLatin1Char('0')))); | 64 | callstack_model->setItem(counter, 1, new QStandardItem(QString("0x%1").arg( |
| 65 | ret_addr, 8, 16, QLatin1Char('0')))); | ||
| 66 | callstack_model->setItem(counter, 2, new QStandardItem(QString("0x%1").arg( | ||
| 67 | call_addr, 8, 16, QLatin1Char('0')))); | ||
| 69 | 68 | ||
| 70 | name = Symbols::HasSymbol(func_addr) ? Symbols::GetSymbol(func_addr).name : "unknown"; | 69 | name = Symbols::HasSymbol(func_addr) ? Symbols::GetSymbol(func_addr).name : "unknown"; |
| 71 | callstack_model->setItem(counter, 3, new QStandardItem(QString("%1_%2").arg(QString::fromStdString(name)) | 70 | callstack_model->setItem( |
| 72 | .arg(QString("0x%1").arg(func_addr, 8, 16, QLatin1Char('0'))))); | 71 | counter, 3, new QStandardItem( |
| 72 | QString("%1_%2") | ||
| 73 | .arg(QString::fromStdString(name)) | ||
| 74 | .arg(QString("0x%1").arg(func_addr, 8, 16, QLatin1Char('0'))))); | ||
| 73 | 75 | ||
| 74 | counter++; | 76 | counter++; |
| 75 | } | 77 | } |
| 76 | } | 78 | } |
| 77 | } | 79 | } |
| 78 | 80 | ||
| 79 | void CallstackWidget::OnDebugModeLeft() | 81 | void CallstackWidget::OnDebugModeLeft() { |
| 80 | { | ||
| 81 | |||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | void CallstackWidget::Clear() | 84 | void CallstackWidget::Clear() { |
| 85 | { | ||
| 86 | for (int row = 0; row < callstack_model->rowCount(); row++) { | 85 | for (int row = 0; row < callstack_model->rowCount(); row++) { |
| 87 | for (int column = 0; column < callstack_model->columnCount(); column++) { | 86 | for (int column = 0; column < callstack_model->columnCount(); column++) { |
| 88 | callstack_model->setItem(row, column, new QStandardItem()); | 87 | callstack_model->setItem(row, column, new QStandardItem()); |