openMSX
Debugger.hh
Go to the documentation of this file.
1#ifndef DEBUGGER_HH
2#define DEBUGGER_HH
3
4#include "Probe.hh"
5#include "RecordedCommand.hh"
6#include "WatchPoint.hh"
7
8#include "hash_map.hh"
9#include "outer.hh"
10#include "xxhash.hh"
11
12#include <string_view>
13#include <vector>
14#include <memory>
15
16namespace openmsx {
17
18class BreakPoint;
19class DebugCondition;
20class Debuggable;
21class MSXCPU;
22class MSXMotherBoard;
23class ProbeBase;
24class ProbeBreakPoint;
25class SymbolManager;
26
28{
29public:
30 explicit Debugger(MSXMotherBoard& motherBoard);
31 Debugger(const Debugger&) = delete;
32 Debugger(Debugger&&) = delete;
33 Debugger& operator=(const Debugger&) = delete;
35 ~Debugger();
36
37 void registerDebuggable (std::string name, Debuggable& debuggable);
38 void unregisterDebuggable (std::string_view name, Debuggable& debuggable);
39 [[nodiscard]] Debuggable* findDebuggable(std::string_view name);
40 [[nodiscard]] const auto& getDebuggables() const { return debuggables; }
41
42 void registerProbe (ProbeBase& probe);
43 void unregisterProbe(ProbeBase& probe);
44 [[nodiscard]] ProbeBase* findProbe(std::string_view name);
45
47 void setCPU(MSXCPU* cpu_) { cpu = cpu_; }
48
49 void transfer(Debugger& other);
50
51 [[nodiscard]] MSXMotherBoard& getMotherBoard() { return motherBoard; }
52 [[nodiscard]] Interpreter& getInterpreter();
53
54private:
55 [[nodiscard]] Debuggable& getDebuggable(std::string_view name);
56 [[nodiscard]] ProbeBase& getProbe(std::string_view name);
57
58 std::string insertProbeBreakPoint(
59 TclObject command, TclObject condition,
60 ProbeBase& probe, bool once, unsigned newId = -1);
61 void removeProbeBreakPoint(std::string_view name);
62
63 MSXMotherBoard& motherBoard;
64
65 class Cmd final : public RecordedCommand {
66 public:
67 Cmd(CommandController& commandController,
68 StateChangeDistributor& stateChangeDistributor,
69 Scheduler& scheduler);
70 [[nodiscard]] bool needRecord(std::span<const TclObject> tokens) const override;
71 void execute(std::span<const TclObject> tokens,
72 TclObject& result, EmuTime::param time) override;
73 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
74 void tabCompletion(std::vector<std::string>& tokens) const override;
75
76 private:
77 [[nodiscard]] Debugger& debugger() { return OUTER(Debugger, cmd); }
78 [[nodiscard]] const Debugger& debugger() const { return OUTER(Debugger, cmd); }
79 [[nodiscard]] SymbolManager& getSymbolManager();
80 void list(TclObject& result);
81 void desc(std::span<const TclObject> tokens, TclObject& result);
82 void size(std::span<const TclObject> tokens, TclObject& result);
83 void read(std::span<const TclObject> tokens, TclObject& result);
84 void readBlock(std::span<const TclObject> tokens, TclObject& result);
85 void write(std::span<const TclObject> tokens, TclObject& result);
86 void writeBlock(std::span<const TclObject> tokens, TclObject& result);
87 void disasm(std::span<const TclObject> tokens, TclObject& result, EmuTime::param time) const;
88 void disasmBlob(std::span<const TclObject> tokens, TclObject& result) const;
89 void breakPoint(std::span<const TclObject> tokens, TclObject& result);
90 void watchPoint(std::span<const TclObject> tokens, TclObject& result);
91 void condition (std::span<const TclObject> tokens, TclObject& result);
92 [[nodiscard]] BreakPoint* lookupBreakPoint(std::string_view str);
93 [[nodiscard]] std::shared_ptr<WatchPoint> lookupWatchPoint(std::string_view str);
94 [[nodiscard]] DebugCondition* lookupCondition(std::string_view str);
95 void breakPointList(std::span<const TclObject> tokens, TclObject& result);
96 void watchPointList(std::span<const TclObject> tokens, TclObject& result);
97 void conditionList (std::span<const TclObject> tokens, TclObject& result);
98 void parseCreateBreakPoint(BreakPoint& bp, std::span<const TclObject> tokens);
99 void parseCreateWatchPoint(WatchPoint& bp, std::span<const TclObject> tokens);
100 void parseCreateCondition (DebugCondition& bp, std::span<const TclObject> tokens);
101 void breakPointCreate(std::span<const TclObject> tokens, TclObject& result);
102 void watchPointCreate(std::span<const TclObject> tokens, TclObject& result);
103 void conditionCreate (std::span<const TclObject> tokens, TclObject& result);
104 void breakPointConfigure(std::span<const TclObject> tokens, TclObject& result);
105 void watchPointConfigure(std::span<const TclObject> tokens, TclObject& result);
106 void conditionConfigure (std::span<const TclObject> tokens, TclObject& result);
107 void breakPointRemove(std::span<const TclObject> tokens, TclObject& result);
108 void watchPointRemove(std::span<const TclObject> tokens, TclObject& result);
109 void conditionRemove (std::span<const TclObject> tokens, TclObject& result);
110 void setBreakPoint(std::span<const TclObject> tokens, TclObject& result);
111 void removeBreakPoint(std::span<const TclObject> tokens, TclObject& result);
112 void listBreakPoints(std::span<const TclObject> tokens, TclObject& result) const;
113 [[nodiscard]] std::vector<std::string> getBreakPointIds() const;
114 [[nodiscard]] std::vector<std::string> getWatchPointIds() const;
115 [[nodiscard]] std::vector<std::string> getConditionIds() const;
116 void setWatchPoint(std::span<const TclObject> tokens, TclObject& result);
117 void removeWatchPoint(std::span<const TclObject> tokens, TclObject& result);
118 void listWatchPoints(std::span<const TclObject> tokens, TclObject& result);
119 void setCondition(std::span<const TclObject> tokens, TclObject& result);
120 void removeCondition(std::span<const TclObject> tokens, TclObject& result);
121 void listConditions(std::span<const TclObject> tokens, TclObject& result) const;
122 void probe(std::span<const TclObject> tokens, TclObject& result);
123 void probeList(std::span<const TclObject> tokens, TclObject& result);
124 void probeDesc(std::span<const TclObject> tokens, TclObject& result);
125 void probeRead(std::span<const TclObject> tokens, TclObject& result);
126 void probeSetBreakPoint(std::span<const TclObject> tokens, TclObject& result);
127 void probeRemoveBreakPoint(std::span<const TclObject> tokens, TclObject& result);
128 void probeListBreakPoints(std::span<const TclObject> tokens, TclObject& result);
129 void symbols(std::span<const TclObject> tokens, TclObject& result);
130 void symbolsTypes(std::span<const TclObject> tokens, TclObject& result) const;
131 void symbolsLoad(std::span<const TclObject> tokens, TclObject& result);
132 void symbolsRemove(std::span<const TclObject> tokens, TclObject& result);
133 void symbolsFiles(std::span<const TclObject> tokens, TclObject& result);
134 void symbolsLookup(std::span<const TclObject> tokens, TclObject& result);
135 } cmd;
136
137 struct NameFromProbe {
138 [[nodiscard]] const std::string& operator()(const ProbeBase* p) const {
139 return p->getName();
140 }
141 };
142
145 std::vector<std::unique_ptr<ProbeBreakPoint>> probeBreakPoints; // unordered
146 MSXCPU* cpu = nullptr;
147};
148
149} // namespace openmsx
150
151#endif
Debugger(Debugger &&)=delete
void registerProbe(ProbeBase &probe)
Definition Debugger.cc:81
void setCPU(MSXCPU *cpu_)
Definition Debugger.hh:47
Debuggable * findDebuggable(std::string_view name)
Definition Debugger.cc:66
Debugger(const Debugger &)=delete
Debugger & operator=(Debugger &&)=delete
const auto & getDebuggables() const
Definition Debugger.hh:40
Interpreter & getInterpreter()
Definition Debugger.cc:182
void transfer(Debugger &other)
Definition Debugger.cc:157
void unregisterProbe(ProbeBase &probe)
Definition Debugger.cc:87
void unregisterDebuggable(std::string_view name, Debuggable &debuggable)
Definition Debugger.cc:59
ProbeBase * findProbe(std::string_view name)
Definition Debugger.cc:93
MSXMotherBoard & getMotherBoard()
Definition Debugger.hh:51
void removeProbeBreakPoint(ProbeBreakPoint &bp)
Definition Debugger.cc:149
void registerDebuggable(std::string name, Debuggable &debuggable)
Definition Debugger.cc:53
Debugger & operator=(const Debugger &)=delete
Commands that directly influence the MSX state should send and events so that they can be recorded by...
This file implemented 3 utility functions:
Definition Autofire.cc:11
size_t size(std::string_view utf8)
#define OUTER(type, member)
Definition outer.hh:42