| 1 | #ifndef BREAKPOINTVIEWER_H |
| 2 | #define BREAKPOINTVIEWER_H |
| 3 | |
| 4 | #include "ui_BreakpointViewer.h" |
| 5 | #include "DebuggerData.h" |
| 6 | #include <QList> |
| 7 | #include <QTabWidget> |
| 8 | #include <optional> |
| 9 | #include <tuple> |
| 10 | |
| 11 | class QPaintEvent; |
| 12 | class Breakpoints; |
| 13 | class DebugSession; |
| 14 | |
| 15 | enum BreakpointType { BREAKPOINT, WATCHPOINT, CONDITION, ALL }; |
| 16 | |
| 17 | class BreakpointViewer : public QTabWidget, private Ui::BreakpointViewer |
| 18 | { |
| 19 | Q_OBJECT |
| 20 | public: |
| 21 | BreakpointViewer(DebugSession& session, QWidget* parent = nullptr); |
| 22 | void setBreakpoints(Breakpoints* bps); |
| 23 | |
| 24 | void onSymbolTableChanged(); |
| 25 | void on_btnAddBp_clicked(); |
| 26 | void on_btnRemoveBp_clicked(); |
| 27 | void on_btnAddWp_clicked(); |
| 28 | void on_btnRemoveWp_clicked(); |
| 29 | void on_btnAddCn_clicked(); |
| 30 | void on_btnRemoveCn_clicked(); |
| 31 | |
| 32 | void setRunState(); |
| 33 | void setBreakState(); |
| 34 | void refresh(); |
| 35 | |
| 36 | signals: |
| 37 | void contentsUpdated(); |
| 38 | |
| 39 | private: |
| 40 | void setTextField(BreakpointType type, int row, int column, const QString& value, const QString& tooltip = {}); |
| 41 | |
| 42 | std::optional<AddressRange> parseSymbolOrValue(const QString& field) const; |
| 43 | |
| 44 | QString findSymbolOrValue(uint16_t address) const; |
| 45 | |
| 46 | std::optional<AddressRange> parseLocationField(std::optional<int> bpIndex, |
| 47 | BreakpointType type, |
| 48 | const QString& field, |
| 49 | const QString& combo = {}); |
| 50 | Slot parseSlotField(std::optional<int> bpIndex, const QString& field); |
| 51 | std::optional<uint8_t> parseSegmentField(std::optional<int> bpIndex, const QString& field); |
| 52 | void changeTableItem(BreakpointType type, QTableWidgetItem* item); |
| 53 | void createComboBox(int row); |
| 54 | Breakpoint::Type readComboBox(int row); |
| 55 | int createTableRow(BreakpointType type, int row = -1); |
| 56 | void fillTableRowLocation(BreakpointType type, int row, const QString& location); |
| 57 | void fillTableRow(BreakpointType type, int row, int bpIndex); |
| 58 | std::optional<Breakpoint> parseTableRow(BreakpointType type, int row); |
| 59 | |
| 60 | std::optional<int> getTableIndexByRow(BreakpointType type, int row) const; |
| 61 | void createBreakpoint(BreakpointType type, int row); |
| 62 | void _handleSyncError(const QString& error); |
| 63 | void _handleKeyAlreadyExists(); |
| 64 | void _handleKeyNotFound(); |
| 65 | void _createBreakpoint(BreakpointType type, int row); |
| 66 | void _createCondition(int row); |
| 67 | |
| 68 | void replaceBreakpoint(BreakpointType type, int row); |
| 69 | void removeBreakpoint(BreakpointType type, int row, bool removeLocal = false); |
| 70 | void setBreakpointChecked(BreakpointType type, int row, Qt::CheckState state); |
| 71 | void onAddBtnClicked(BreakpointType type); |
| 72 | void onRemoveBtnClicked(BreakpointType type); |
| 73 | void stretchTable(BreakpointType type = BreakpointType::ALL); |
| 74 | |
| 75 | std::optional<int> findBreakpointIndex(BreakpointType type, int row) const; |
| 76 | std::optional<int> findBreakpointRow(BreakpointType type, const QString& id) const; |
| 77 | |
| 78 | void changeCurrentWpType(int row, int index); |
| 79 | void disableSorting(BreakpointType type = BreakpointType::ALL); |
| 80 | void changeBpTableItem(QTableWidgetItem* item); |
| 81 | void changeWpTableItem(QTableWidgetItem* item); |
| 82 | void changeCnTableItem(QTableWidgetItem* item); |
| 83 | void on_itemPressed(QTableWidgetItem* item); |
| 84 | void on_headerClicked(int index); |
| 85 | void refreshTableRow(int bpIndex, BreakpointType type, int row); |
| 86 | |
| 87 | private: |
| 88 | Ui::BreakpointViewer* ui; |
| 89 | DebugSession& debugSession; |
| 90 | |
| 91 | QTableWidget* tables[BreakpointType::ALL]; |
| 92 | |
| 93 | bool disableRefresh = false; |
| 94 | bool userMode = true; |
| 95 | bool runState; |
| 96 | bool conditionsMsg = false; |
| 97 | Breakpoints* breakpoints; |
| 98 | }; |
| 99 | |
| 100 | #endif // BREAKPOINTVIEWER_H |