2020-12-05 13:08:24 +01:00
|
|
|
#include "call_stack_list.h"
|
2020-03-31 02:46:37 +02:00
|
|
|
|
2020-12-22 09:42:57 +01:00
|
|
|
#include "Utilities/StrFmt.h"
|
|
|
|
|
|
2023-06-05 07:51:40 +02:00
|
|
|
#include <QKeyEvent>
|
2024-09-02 21:57:33 +02:00
|
|
|
#include <QMouseEvent>
|
2023-06-05 07:51:40 +02:00
|
|
|
|
2020-03-31 02:46:37 +02:00
|
|
|
call_stack_list::call_stack_list(QWidget* parent) : QListWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
|
|
|
|
|
|
// connects
|
2023-06-05 09:53:11 +02:00
|
|
|
connect(this, &QListWidget::itemDoubleClicked, this, &call_stack_list::ShowItemAddress);
|
2022-06-21 23:42:42 +02:00
|
|
|
|
|
|
|
|
// Hide until used in order to allow as much space for registers panel as possible
|
|
|
|
|
hide();
|
2020-03-31 02:46:37 +02:00
|
|
|
}
|
|
|
|
|
|
2023-06-05 07:51:40 +02:00
|
|
|
void call_stack_list::keyPressEvent(QKeyEvent* event)
|
|
|
|
|
{
|
|
|
|
|
QListWidget::keyPressEvent(event);
|
|
|
|
|
event->ignore(); // Propagate the event to debugger_frame
|
2023-06-05 09:53:11 +02:00
|
|
|
|
|
|
|
|
if (!event->modifiers() && event->key() == Qt::Key_Return)
|
|
|
|
|
{
|
|
|
|
|
ShowItemAddress();
|
|
|
|
|
}
|
2023-06-05 07:51:40 +02:00
|
|
|
}
|
|
|
|
|
|
2021-04-07 23:05:18 +02:00
|
|
|
void call_stack_list::HandleUpdate(const std::vector<std::pair<u32, u32>>& call_stack)
|
2020-03-31 02:46:37 +02:00
|
|
|
{
|
|
|
|
|
clear();
|
|
|
|
|
|
2020-07-03 06:56:55 +02:00
|
|
|
for (const auto& addr : call_stack)
|
2020-03-31 02:46:37 +02:00
|
|
|
{
|
2024-09-24 02:37:34 +02:00
|
|
|
const QString text = QString::fromStdString(fmt::format("0x%08llx (sp=0x%08llx)", addr.first, addr.second));
|
2021-03-23 20:39:39 +01:00
|
|
|
QListWidgetItem* call_stack_item = new QListWidgetItem(text);
|
2025-04-05 21:50:45 +02:00
|
|
|
call_stack_item->setData(Qt::UserRole, {addr.first});
|
2021-03-23 20:39:39 +01:00
|
|
|
addItem(call_stack_item);
|
2020-03-31 02:46:37 +02:00
|
|
|
}
|
2022-06-21 23:42:42 +02:00
|
|
|
|
|
|
|
|
setVisible(!call_stack.empty());
|
2020-03-31 02:46:37 +02:00
|
|
|
}
|
|
|
|
|
|
2023-06-05 09:53:11 +02:00
|
|
|
void call_stack_list::ShowItemAddress()
|
2020-03-31 02:46:37 +02:00
|
|
|
{
|
2023-06-05 08:02:34 +02:00
|
|
|
if (QListWidgetItem* call_stack_item = currentItem())
|
|
|
|
|
{
|
|
|
|
|
const u32 address = call_stack_item->data(Qt::UserRole).value<u32>();
|
|
|
|
|
Q_EMIT RequestShowAddress(address);
|
|
|
|
|
}
|
2020-03-31 02:46:37 +02:00
|
|
|
}
|
2024-09-02 21:57:33 +02:00
|
|
|
|
|
|
|
|
void call_stack_list::mouseDoubleClickEvent(QMouseEvent* ev)
|
|
|
|
|
{
|
2025-04-05 21:50:45 +02:00
|
|
|
if (!ev)
|
|
|
|
|
return;
|
2024-09-02 21:57:33 +02:00
|
|
|
|
|
|
|
|
// Qt's itemDoubleClicked signal doesn't distinguish between mouse buttons and there is no simple way to get the pressed button.
|
|
|
|
|
// So we have to ignore this event when another button is pressed.
|
|
|
|
|
if (ev->button() != Qt::LeftButton)
|
|
|
|
|
{
|
|
|
|
|
ev->ignore();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QListWidget::mouseDoubleClickEvent(ev);
|
|
|
|
|
}
|