Debian Codegraph @

Source/Core/DolphinQt/Debugger/BranchWatchDialog.h

raw symbols SCIP
1 // Copyright 2024 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <optional>
7 #include <string>
8
9 #include <QDialog>
10 #include <QIcon>
11 #include <QModelIndexList>
12
13 #include "Common/CommonTypes.h"
14
15 namespace Core
16 {
17 class BranchWatch;
18 class CPUThreadGuard;
19 enum class State;
20 class System;
21 } // namespace Core
22 class PPCSymbolDB;
23
24 class BranchWatchProxyModel;
25 class BranchWatchTableModel;
26 class CodeWidget;
27 class QAction;
28 class QMenu;
29 class QPoint;
30 class QPushButton;
31 class QStatusBar;
32 class QTableView;
33 class QTimer;
34 class QToolBar;
35 class QWidget;
36
37 namespace BranchWatchTableModelColumn
38 {
39 enum EnumType : int;
40 }
41 namespace BranchWatchTableModelUserRole
42 {
43 enum EnumType : int;
44 }
45
46 class BranchWatchDialog : public QDialog
47 {
48 Q_OBJECT
49
50 using Column = BranchWatchTableModelColumn::EnumType;
51 using UserRole = BranchWatchTableModelUserRole::EnumType;
52
53 public:
54 explicit BranchWatchDialog(Core::System& system, Core::BranchWatch& branch_watch,
55 PPCSymbolDB& ppc_symbol_db, CodeWidget* code_widget,
56 QWidget* parent = nullptr);
57 ~BranchWatchDialog() override;
58
59 BranchWatchDialog(const BranchWatchDialog&) = delete;
60 BranchWatchDialog(BranchWatchDialog&&) = delete;
61 BranchWatchDialog& operator=(const BranchWatchDialog&) = delete;
62 BranchWatchDialog& operator=(BranchWatchDialog&&) = delete;
63
64 protected:
65 void hideEvent(QHideEvent* event) override;
66 void showEvent(QShowEvent* event) override;
67
68 private:
69 void OnStartPause(bool checked) const;
70 void OnClearBranchWatch();
71 void OnSave();
72 void OnSaveAs();
73 void OnLoad();
74 void OnLoadFrom();
75 void OnCodePathWasTaken();
76 void OnCodePathNotTaken();
77 void OnBranchWasOverwritten();
78 void OnBranchNotOverwritten();
79 void OnWipeRecentHits() const;
80 void OnWipeInspection() const;
81 void OnTimeout() const;
82 void OnEmulationStateChanged(Core::State new_state) const;
83 void OnThemeChanged();
84 void OnHelp();
85 void OnToggleAutoSave(bool checked);
86 void OnHideShowControls(bool checked) const;
87 void OnToggleIgnoreApploader(bool checked) const;
88
89 void OnTableClicked(const QModelIndex& index) const;
90 void OnTableContextMenu(const QPoint& pos) const;
91 void OnTableHeaderContextMenu(const QPoint& pos) const;
92 void OnTableDelete() const;
93 void OnTableDeleteKeypress() const;
94 void OnTableSetBLR() const;
95 void OnTableSetNOP() const;
96 void OnTableInvertCondition() const;
97 void OnTableInvertDecrementCheck() const;
98 void OnTableMakeUnconditional() const;
99 void OnTableCopyAddress() const;
100 void OnTableSetBreakpointBreak() const;
101 void OnTableSetBreakpointLog() const;
102 void OnTableSetBreakpointBoth() const;
103
104 void ConnectSlots();
105 void DisconnectSlots();
106 void Show();
107 void Hide();
108 void LoadQSettings();
109 void SaveQSettings() const;
110
111 public:
112 // TODO: Step doesn't cause EmulationStateChanged to be emitted, so it has to call this manually.
113 void Update() const;
114
115 private:
116 void UpdateStatus() const;
117 void UpdateIcons();
118 void Save(const Core::CPUThreadGuard& guard, const std::string& filepath);
119 void Load(const Core::CPUThreadGuard& guard, const std::string& filepath);
120 void AutoSave(const Core::CPUThreadGuard& guard);
121 void SetStubPatches(u32 value) const;
122 void SetEditPatches(u32 (*transform)(u32)) const;
123 void SetBreakpoints(bool break_on_hit, bool log_on_hit) const;
124
125 void SetBreakpointMenuActionsIcons() const;
126 QMenu* GetTableContextMenu(const QModelIndex& index) const;
127 void RefreshVisibleContextMenuActions(bool core_initialized) const;
128 void RefreshContextMenuActions_Instruction(bool core_initialized) const;
129 void RefreshContextMenuActions_Condition(bool core_initialized) const;
130 void RefreshContextMenuActions_Origin(bool core_initialized) const;
131 void RefreshContextMenuActions_Destin(bool core_initialized) const;
132 void RefreshContextMenuActions_Symbol(bool core_initialized) const;
133
134 Core::System& m_system;
135 Core::BranchWatch& m_branch_watch;
136 CodeWidget* m_code_widget;
137
138 QPushButton *m_btn_start_pause, *m_btn_clear_watch, *m_btn_path_was_taken, *m_btn_path_not_taken,
139 *m_btn_was_overwritten, *m_btn_not_overwritten, *m_btn_wipe_recent_hits;
140 QAction* m_act_autosave;
141 QAction* m_act_invert_condition;
142 QAction* m_act_invert_decrement_check;
143 QAction* m_act_make_unconditional;
144 QAction* m_act_insert_nop;
145 QAction* m_act_insert_blr;
146 QAction* m_act_copy_address;
147 QMenu* m_mnu_set_breakpoint;
148 QAction* m_act_break_on_hit;
149 QAction* m_act_log_on_hit;
150 QAction* m_act_both_on_hit;
151 QMenu *m_mnu_table_context_instruction, *m_mnu_table_context_condition,
152 *m_mnu_table_context_origin, *m_mnu_table_context_destin, *m_mnu_table_context_symbol,
153 *m_mnu_table_context_other;
154 QMenu* m_mnu_column_visibility;
155
156 QToolBar* m_control_toolbar;
157 QAction *m_act_branch_type_filters, *m_act_origin_destin_filters, *m_act_condition_filters,
158 *m_act_misc_controls;
159 QTableView* m_table_view;
160 BranchWatchProxyModel* m_table_proxy;
161 BranchWatchTableModel* m_table_model;
162 QStatusBar* m_status_bar;
163 QTimer* m_timer;
164
165 QIcon m_icn_full, m_icn_partial;
166
167 mutable QModelIndexList m_index_list_temp;
168 std::optional<std::string> m_autosave_filepath;
169 };