openMSX
ImGuiBreakPoints.hh
Go to the documentation of this file.
1#ifndef IMGUI_BREAKPOINT_HH
2#define IMGUI_BREAKPOINT_HH
3
4#include "ImGuiPart.hh"
5
6#include "TclObject.hh"
7
8#include <optional>
9#include <vector>
10
11namespace openmsx {
12
13class BreakPoint;
14class DebugCondition;
15class Debugger;
16class MSXCPUInterface;
17class SymbolManager;
18class WatchPoint;
19
21 ParsedSlotCond(std::string_view checkCmd, std::string_view cond);
22 [[nodiscard]] std::string toTclExpression(std::string_view checkCmd) const;
23 [[nodiscard]] std::string toDisplayString() const;
24
25 std::string rest;
26
27 int ps = 0;
28 int ss = 0;
29 uint8_t seg = 0;
30 bool hasPs = false; // if false then the whole slot-substructure is invalid
31 bool hasSs = false;
32 bool hasSeg = false;
33};
34
35class ImGuiBreakPoints final : public ImGuiPart
36{
37public:
38 struct GuiItem {
39 int id; // id > 0: exists also on the openMSX side
40 // id < 0: only exists on the GUI side
41 bool wantEnable; // only really enabled if it's also valid
42 int wpType; // only used for Watchpoint
43 std::optional<uint16_t> addr; // not used for DebugCondition
44 std::optional<uint16_t> endAddr; // (inclusive) only used for WatchPoint
49 };
50
51public:
53
54 [[nodiscard]] zstring_view iniName() const override { return "breakpoints"; }
55 void save(ImGuiTextBuffer& buf) override;
56 void loadStart() override;
57 void loadLine(std::string_view name, zstring_view value) override;
58 void loadEnd() override;
59 void paint(MSXMotherBoard* motherBoard) override;
60
61 void refreshSymbols();
62
63 [[nodiscard]] std::vector<GuiItem>& getBps(MSXCPUInterface& cpuInterface);
64 void paintBpTab(MSXCPUInterface& cpuInterface, Debugger& debugger, uint16_t addr);
65
66private:
67 template<typename Item> void loadItem(zstring_view value);
68 template<typename Item> void paintTab(MSXCPUInterface& cpuInterface, Debugger& debugger, std::optional<uint16_t> addr = {});
69 template<typename Item> void syncFromOpenMsx(std::vector<GuiItem>& items, MSXCPUInterface& cpuInterface);
70 void checkSort(std::vector<GuiItem>& items);
71 std::optional<uint16_t> parseAddress(const TclObject& o);
72 template<typename Item> void syncToOpenMsx(
73 MSXCPUInterface& cpuInterface, Debugger& debugger,
74 Interpreter& interp, GuiItem& item);
75 template<typename Item> void drawRow(MSXCPUInterface& cpuInterface, Debugger& debugger, int row, GuiItem& item);
76 bool editRange(std::string& begin, std::string& end);
77 bool editCondition(ParsedSlotCond& slot);
78
79 [[nodiscard]] auto& getItems(BreakPoint*) { return guiBps; }
80 [[nodiscard]] auto& getItems(WatchPoint*) { return guiWps; }
81 [[nodiscard]] auto& getItems(DebugCondition*) { return guiConditions; }
82
83 void clear(BreakPoint*, MSXCPUInterface& cpuInterface);
84 void clear(WatchPoint*, MSXCPUInterface& cpuInterface);
85 void clear(DebugCondition*, MSXCPUInterface& cpuInterface);
86
87 template<typename Item> void refresh(std::vector<GuiItem>& items);
88
89public:
90 bool show = false;
91
92private:
93 SymbolManager& symbolManager;
94
95 static inline int idCounter = 0;
96 std::vector<GuiItem> guiBps;
97 std::vector<GuiItem> guiWps;
98 std::vector<GuiItem> guiConditions;
99 int selectedRow = -1;
100
101 static constexpr auto persistentElements = std::tuple{
103 };
104};
105
106} // namespace openmsx
107
108#endif
void paintBpTab(MSXCPUInterface &cpuInterface, Debugger &debugger, uint16_t addr)
std::vector< GuiItem > & getBps(MSXCPUInterface &cpuInterface)
void save(ImGuiTextBuffer &buf) override
void loadLine(std::string_view name, zstring_view value) override
void paint(MSXMotherBoard *motherBoard) override
zstring_view iniName() const override
ImGuiManager & manager
Definition ImGuiPart.hh:30
Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.
This file implemented 3 utility functions:
Definition Autofire.cc:9
std::optional< uint16_t > endAddr
std::string toDisplayString() const
std::string toTclExpression(std::string_view checkCmd) const
constexpr auto begin(const zstring_view &x)
constexpr auto end(const zstring_view &x)