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