2024-07-30 11:42:36 +00:00
|
|
|
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
|
|
|
|
// SPDX-License-Identifier: GPL-3.0+
|
2022-12-24 06:51:44 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ui_DisassemblyWidget.h"
|
|
|
|
|
|
|
|
#include "pcsx2/DebugTools/DebugInterface.h"
|
|
|
|
#include "pcsx2/DebugTools/DisassemblyManager.h"
|
|
|
|
|
|
|
|
#include <QtWidgets/QWidget>
|
|
|
|
#include <QtWidgets/QMenu>
|
|
|
|
#include <QtGui/QPainter>
|
|
|
|
|
|
|
|
class DisassemblyWidget final : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
DisassemblyWidget(QWidget* parent);
|
|
|
|
~DisassemblyWidget();
|
|
|
|
|
|
|
|
// Required because our constructor needs to take no extra arguments.
|
|
|
|
void SetCpu(DebugInterface* cpu);
|
|
|
|
|
|
|
|
// Required for the breakpoint list (ugh wtf)
|
|
|
|
QString GetLineDisasm(u32 address);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent* event);
|
|
|
|
void mousePressEvent(QMouseEvent* event);
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent* event);
|
|
|
|
void wheelEvent(QWheelEvent* event);
|
|
|
|
void keyPressEvent(QKeyEvent* event);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void customMenuRequested(QPoint pos);
|
|
|
|
|
|
|
|
// Context menu actions
|
|
|
|
// When called, m_selectedAddressStart will be the 'selected' instruction
|
|
|
|
// Of course, m_selectedAddressEnd will be the end of the selection when required
|
|
|
|
void contextCopyAddress();
|
|
|
|
void contextCopyInstructionHex();
|
|
|
|
void contextCopyInstructionText();
|
2023-11-21 04:29:01 +00:00
|
|
|
void contextCopyFunctionName();
|
2022-12-24 06:51:44 +00:00
|
|
|
void contextAssembleInstruction();
|
2023-01-01 04:24:39 +00:00
|
|
|
void contextNoopInstruction();
|
2023-10-10 01:02:07 +00:00
|
|
|
void contextRestoreInstruction();
|
2022-12-24 06:51:44 +00:00
|
|
|
void contextRunToCursor();
|
|
|
|
void contextJumpToCursor();
|
|
|
|
void contextToggleBreakpoint();
|
|
|
|
void contextFollowBranch();
|
|
|
|
void contextGoToAddress();
|
|
|
|
void contextAddFunction();
|
|
|
|
void contextRenameFunction();
|
|
|
|
void contextRemoveFunction();
|
2023-10-10 00:31:49 +00:00
|
|
|
void contextStubFunction();
|
2023-10-10 01:02:07 +00:00
|
|
|
void contextRestoreFunction();
|
2024-02-21 23:51:10 +00:00
|
|
|
void contextShowOpcode();
|
2023-10-10 00:31:49 +00:00
|
|
|
|
2024-08-26 19:23:03 +00:00
|
|
|
void gotoAddressAndSetFocus(u32 address);
|
|
|
|
void gotoAddress(u32 address, bool should_set_focus);
|
2022-12-24 06:51:44 +00:00
|
|
|
|
2023-10-10 01:52:12 +00:00
|
|
|
void setDemangle(bool demangle) { m_demangleFunctions = demangle; };
|
2022-12-24 06:51:44 +00:00
|
|
|
signals:
|
|
|
|
void gotoInMemory(u32 address);
|
|
|
|
void breakpointsChanged();
|
|
|
|
void VMUpdate();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::DisassemblyWidget ui;
|
|
|
|
|
|
|
|
DebugInterface* m_cpu;
|
|
|
|
u32 m_visibleStart = 0x00336318; // The address of the first opcode shown(row 0)
|
|
|
|
u32 m_visibleRows;
|
|
|
|
u32 m_selectedAddressStart = 0;
|
|
|
|
u32 m_selectedAddressEnd = 0;
|
|
|
|
u32 m_rowHeight = 0;
|
|
|
|
|
2023-10-10 01:02:07 +00:00
|
|
|
std::map<u32, u32> m_nopedInstructions;
|
|
|
|
std::map<u32, std::tuple<u32, u32>> m_stubbedFunctions;
|
|
|
|
|
2023-10-10 01:52:12 +00:00
|
|
|
bool m_demangleFunctions = true;
|
2024-02-21 23:51:10 +00:00
|
|
|
bool m_showInstructionOpcode = true;
|
2022-12-24 06:51:44 +00:00
|
|
|
DisassemblyManager m_disassemblyManager;
|
|
|
|
|
2023-10-10 01:38:04 +00:00
|
|
|
inline QString DisassemblyStringFromAddress(u32 address, QFont font, u32 pc, bool selected);
|
2022-12-24 06:51:44 +00:00
|
|
|
QColor GetAddressFunctionColor(u32 address);
|
|
|
|
enum class SelectionInfo
|
|
|
|
{
|
|
|
|
ADDRESS,
|
|
|
|
INSTRUCTIONHEX,
|
|
|
|
INSTRUCTIONTEXT,
|
|
|
|
};
|
|
|
|
QString FetchSelectionInfo(SelectionInfo selInfo);
|
2023-10-10 01:02:07 +00:00
|
|
|
|
|
|
|
bool AddressCanRestore(u32 start, u32 end);
|
|
|
|
bool FunctionCanRestore(u32 address);
|
2022-12-24 06:51:44 +00:00
|
|
|
};
|