Permalink
Browse files

Merge pull request #6765 from aldelaro5/Qt-debugger-fixes

Qt/debugger: fix a bunch of things
  • Loading branch information...
leoetlino committed May 12, 2018
2 parents ad5a69b + 5c688b2 commit 66c1b909c2697e3f3b3f306904e40204a443c7b2
@@ -40,8 +40,16 @@ BreakpointWidget::BreakpointWidget(QWidget* parent) : QDockWidget(parent)
if (!Settings::Instance().IsDebugModeEnabled())
return;
m_load->setEnabled(Core::IsRunning());
m_save->setEnabled(Core::IsRunning());
bool is_initialised = state != Core::State::Uninitialized;
m_new->setEnabled(is_initialised);
m_load->setEnabled(is_initialised);
m_save->setEnabled(is_initialised);
if (!is_initialised)
{
PowerPC::breakpoints.Clear();
PowerPC::memchecks.Clear();
Update();
}
});
connect(&Settings::Instance(), &Settings::BreakpointsVisibilityChanged,
@@ -77,8 +85,18 @@ void BreakpointWidget::CreateWidgets()
m_table->setColumnCount(5);
m_table->setSelectionMode(QAbstractItemView::SingleSelection);
m_table->setSelectionBehavior(QAbstractItemView::SelectRows);
m_table->setEditTriggers(QAbstractItemView::NoEditTriggers);
m_table->verticalHeader()->hide();
connect(m_table, &QTableWidget::itemClicked, [this](QTableWidgetItem* item) {
if (m_table->selectedItems()[0]->row() == item->row() &&
Core::GetState() == Core::State::Paused)
{
auto address = m_table->selectedItems()[0]->data(Qt::UserRole).toUInt();
emit SelectedBreakpoint(address);
}
});
auto* layout = new QVBoxLayout;
layout->addWidget(m_toolbar);
@@ -91,6 +109,7 @@ void BreakpointWidget::CreateWidgets()
m_load = AddAction(m_toolbar, tr("Load"), this, &BreakpointWidget::OnLoad);
m_save = AddAction(m_toolbar, tr("Save"), this, &BreakpointWidget::OnSave);
m_new->setEnabled(false);
m_load->setEnabled(false);
m_save->setEnabled(false);
@@ -122,6 +141,7 @@ void BreakpointWidget::Update()
{tr("Active"), tr("Type"), tr("Function"), tr("Address"), tr("Flags")});
int i = 0;
m_table->setRowCount(i);
auto create_item = [this](const QString string = QStringLiteral("")) {
QTableWidgetItem* item = new QTableWidgetItem(string);
@@ -206,15 +226,19 @@ void BreakpointWidget::OnDelete()
auto address = m_table->selectedItems()[0]->data(Qt::UserRole).toUInt();
PowerPC::breakpoints.Remove(address);
Settings::Instance().blockSignals(true);
PowerPC::memchecks.Remove(address);
Settings::Instance().blockSignals(false);
Update();
}
void BreakpointWidget::OnClear()
{
PowerPC::debug_interface.ClearAllBreakpoints();
Settings::Instance().blockSignals(true);
PowerPC::debug_interface.ClearAllMemChecks();
Settings::Instance().blockSignals(false);
m_table->setRowCount(0);
Update();
@@ -247,7 +271,9 @@ void BreakpointWidget::OnLoad()
if (ini.GetLines("MemoryBreakPoints", &newmcs, false))
{
PowerPC::memchecks.Clear();
Settings::Instance().blockSignals(true);
PowerPC::memchecks.AddFromStrings(newmcs);
Settings::Instance().blockSignals(false);
}
Update();
@@ -283,7 +309,9 @@ void BreakpointWidget::AddAddressMBP(u32 addr, bool on_read, bool on_write, bool
check.log_on_hit = do_log;
check.break_on_hit = do_break;
Settings::Instance().blockSignals(true);
PowerPC::memchecks.Add(check);
Settings::Instance().blockSignals(false);
Update();
}
@@ -301,7 +329,9 @@ void BreakpointWidget::AddRangedMBP(u32 from, u32 to, bool on_read, bool on_writ
check.log_on_hit = do_log;
check.break_on_hit = do_break;
Settings::Instance().blockSignals(true);
PowerPC::memchecks.Add(check);
Settings::Instance().blockSignals(false);
Update();
}
@@ -29,6 +29,7 @@ class BreakpointWidget : public QDockWidget
signals:
void BreakpointsChanged();
void SelectedBreakpoint(u32 address);
protected:
void closeEvent(QCloseEvent*) override;
@@ -39,12 +39,12 @@ CodeViewWidget::CodeViewWidget()
setShowGrid(false);
setContextMenuPolicy(Qt::CustomContextMenu);
setSelectionMode(QAbstractItemView::SingleSelection);
setSelectionBehavior(QAbstractItemView::SelectRows);
verticalScrollBar()->setHidden(true);
for (int i = 0; i < columnCount(); i++)
{
horizontalHeader()->setSectionResizeMode(i, i == 0 ? QHeaderView::Fixed :
QHeaderView::ResizeToContents);
horizontalHeader()->setSectionResizeMode(i, QHeaderView::Fixed);
}
verticalHeader()->hide();
@@ -56,6 +56,7 @@ CodeViewWidget::CodeViewWidget()
Update();
connect(this, &CodeViewWidget::customContextMenuRequested, this, &CodeViewWidget::OnContextMenu);
connect(this, &CodeViewWidget::itemSelectionChanged, this, &CodeViewWidget::OnSelectionChanged);
connect(&Settings::Instance(), &Settings::DebugFontChanged, this, &QWidget::setFont);
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this] {
m_address = PC;
@@ -119,6 +120,23 @@ void CodeViewWidget::Update()
auto* param_item = new QTableWidgetItem(QString::fromStdString(param));
auto* description_item = new QTableWidgetItem(QString::fromStdString(desc));
for (auto* item : {bp_item, addr_item, ins_item, param_item, description_item})
{
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
item->setData(Qt::UserRole, addr);
if (color != 0xFFFFFF)
{
item->setForeground(QColor(Qt::black));
item->setBackground(QColor(color));
}
if (addr == pc && item != bp_item)
{
item->setBackground(QColor(Qt::green));
item->setForeground(QColor(Qt::black));
}
}
// look for hex strings to decode branches
std::string hex_str;
size_t pos = param.find("0x");
@@ -137,20 +155,6 @@ void CodeViewWidget::Update()
if (ins == "blr")
ins_item->setForeground(Qt::darkGreen);
for (auto* item : {bp_item, addr_item, ins_item, param_item, description_item})
{
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
item->setData(Qt::UserRole, addr);
if (color != 0xFFFFFF)
item->setBackground(QColor(color).darker(110));
if (addr == pc && item != bp_item)
{
item->setBackground(QColor(Qt::green).darker(110));
}
}
if (PowerPC::debug_interface.IsBreakpoint(addr))
{
bp_item->setData(Qt::DecorationRole,
@@ -165,10 +169,11 @@ void CodeViewWidget::Update()
if (addr == GetAddress())
{
addr_item->setSelected(true);
selectRow(addr_item->row());
}
}
resizeColumnsToContents();
setColumnWidth(0, 24 + 5);
g_symbolDB.FillInCallers();
@@ -182,13 +187,14 @@ u32 CodeViewWidget::GetAddress() const
return m_address;
}
void CodeViewWidget::SetAddress(u32 address)
void CodeViewWidget::SetAddress(u32 address, SetAddressUpdate update)
{
if (m_address == address)
return;
m_address = address;
Update();
if (update == SetAddressUpdate::WithUpdate)
Update();
}
void CodeViewWidget::ReplaceAddress(u32 address, bool blr)
@@ -362,7 +368,7 @@ void CodeViewWidget::OnFollowBranch()
if (!branch_addr)
return;
SetAddress(branch_addr);
SetAddress(branch_addr, SetAddressUpdate::WithUpdate);
}
void CodeViewWidget::OnRenameSymbol()
@@ -387,6 +393,19 @@ void CodeViewWidget::OnRenameSymbol()
}
}
void CodeViewWidget::OnSelectionChanged()
{
if (m_address == PowerPC::ppcState.pc)
{
setStyleSheet(QString::fromStdString(
"QTableView::item:selected {background-color: #00FF00; color: #000000;}"));
}
else if (!styleSheet().isEmpty())
{
setStyleSheet(QString::fromStdString(""));
}
}
void CodeViewWidget::OnSetSymbolSize()
{
const u32 addr = GetContextAddress();
@@ -515,7 +534,7 @@ void CodeViewWidget::mousePressEvent(QMouseEvent* event)
if (column(item) == 0)
ToggleBreakpoint();
else
SetAddress(addr);
SetAddress(addr, SetAddressUpdate::WithUpdate);
Update();
break;
@@ -18,11 +18,17 @@ class CodeViewWidget : public QTableWidget
{
Q_OBJECT
public:
enum class SetAddressUpdate
{
WithUpdate,
WithoutUpdate
};
explicit CodeViewWidget();
u32 GetAddress() const;
u32 GetContextAddress() const;
void SetAddress(u32 address);
void SetAddress(u32 address, SetAddressUpdate update);
void Update();
@@ -49,6 +55,7 @@ class CodeViewWidget : public QTableWidget
void OnCopyCode();
void OnCopyHex();
void OnRenameSymbol();
void OnSelectionChanged();
void OnSetSymbolSize();
void OnSetSymbolEndAddress();
void OnRunToHere();
Oops, something went wrong.

0 comments on commit 66c1b90

Please sign in to comment.