openMSX
ImGuiDebugger.cc
Go to the documentation of this file.
1#include "ImGuiDebugger.hh"
2
4#include "ImGuiBreakPoints.hh"
5#include "ImGuiCharacter.hh"
6#include "ImGuiCpp.hh"
7#include "ImGuiManager.hh"
8#include "ImGuiPalette.hh"
10#include "ImGuiSymbols.hh"
11#include "ImGuiUtils.hh"
12#include "ImGuiVdpRegs.hh"
13#include "ImGuiWatchExpr.hh"
14
15#include "CPURegs.hh"
16#include "Dasm.hh"
17#include "Debuggable.hh"
18#include "Debugger.hh"
19#include "MSXCPU.hh"
20#include "MSXCPUInterface.hh"
22#include "MSXMotherBoard.hh"
23#include "RomPlain.hh"
24#include "RomInfo.hh"
25#include "SymbolManager.hh"
26
27#include "narrow.hh"
28#include "join.hh"
29#include "ranges.hh"
30#include "stl.hh"
31#include "strCat.hh"
32#include "StringOp.hh"
33#include "view.hh"
34
35#include <imgui.h>
36#include <imgui_stdlib.h>
37
38#include <cstdint>
39#include <vector>
40
41using namespace std::literals;
42
43namespace openmsx {
44
46 : ImGuiPart(manager_)
47 , symbolManager(manager.getReactor().getSymbolManager())
48{
49}
50
52
53// TODO quick and dirty, doesn't look right yet
54// Created from a .ttf file via:
55// binary_to_compressed_c openmsx-debugger-icons.ttf myIcons > myfont.cpp
56// https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp
57static const char icons_compressed_base85[1815+1] =
58 "7])#######;9u/('/###W),##.f1$#Q6>##%[n42)[KU%G5)=-<NE/1aNV=BZrPSb]->>#ICi9.o`(*HGsO2(b6O3L+lQS%,5LsCC,H3AnAMeNA*&#Gb';9Cs3BMNvSN`sr1dD4Eo3R/"
59 "w/)8eXHkG2V3dW.;h^`I@cj`W)a4&>ZW%q/o6Q<Bou@GMQuuoJH`;-*0iR/Go%fr6jMWVRReK?-qmnUCC'Hv'<J]p]`;`Y5@C=GH?o6O+j#)*Mp]G&#70lQ#;0xfLQ7wj#O?DX-@1>F%"
60 "5[)<#8JFgL6SgV-xew@'uB5X7If]8QR3O%b'kS`a)%vW-iXx6*BfW>-'lB#$1fs-$R'Mk+(lB#$ckf&,peu.:J/PQ'-MYY#jFs9)*lXJgaDe8Qw(Y:v47Y&#*r[w'WQ1x'1/V:m^U4+3"
61 "7GJcM604,NJ:-##O]-x-e:k(NX@$##]jP]4ACh^X0(^fLHl/o#g]L7#N'+&#L)Qv$t@0+*I5^+4]77<.aQ9k0$g`,3$+h,3Pqji06rs-$=uG=3tq$>MOAQY>@'.`&K8P>#g>AvL9q*<#"
62 ")EEjLr^PA#m.Us-KRb'4g)Cb4%IuD#GKRL2KkRP/N7R20t3wK#-8/$jJA5U;0viS&[5AC>uIVS%3^oh24GbM(hIL>#xP%U#WE323lpd].B[A30GK_+,sX/D=dn5q&0####GBO&#.1d7$"
63 "3g1$#prgo.-<Tv->;gF4LZ>x#<)]L(/p^I*^nr?#&Y@C#cF&@'wvPJ(?nU^#pRpQ0gF*j0EPtdVN'+9%k*l)*0qi<%>=+dVKrdx0Iu(kLgk4DWX?/YGZv9dMb/q8/+fMO#W+WBOM>#`Q"
64 "xR--3bO1F*.D,G4rFuG-hwhH-AI7q.3B3I):[(cJ[pl6&]3KI%)B1se0fv]M6T3kuGSoBJNCZY#q+er?Y,8v,5cNY5*`$s$#]YV-[@i?#=@[s$G+TC4P#l8./=]s$1Pev6jlje3&-Xf-"
65 "e](jr145d3?;Rv$ZUvC%h5%fqxC$Y@8^CY$O,@H),W'Z-W-Rh27<C[Krsf;$.wg<L9br,4%.6v,>=+dVIIx:/@JJH)Z:Nu.iUkJ2tpPm:t0(Q$@OEp%Upn;%j&5QCa)iS0%5YY#IX$_]"
66 "2^x^]Zrju5Fhf-*i+YV-6'PA#(cK+*mtq;/qwkj1?f6<.0MbI),VW/23>%&4m$ie3%&AA4l'eq7+jkA#dlfj-&$+&^S8VTd.^AN-,CeM0l,'hoodPir`IofLX=$##5C.%T=UYF%^Yk*$"
67 "/)m<-]'LS-&%.20'>uu#OYU7#euQ['GPSw8P`&:)AF14+&YF&#WW`>$Mbk-$I&l-$Bp0.$eo4wLW(I3#Ys%(#U-4&#MXN1#EIc>#ik*$M0xSfLRq)$#@>[A-$Mg;-'Spr-gN<;Ni;-##"
68 "Jer=--`/,Mv_d##tg`=-5X`=-8sG<-*fG<-+C`T.3f1$#mrG<-8X`=-/#XN0Ht*A#e5>##_RFgLX%1kLF=`T.3xL$#)6xU.R,_'#RA`T.T5$C#<rG<-M2(@-xrG<-DKx>-#EfT%8nT`3"
69 "]kU.G-i@+H=DpTCuAo6D<B?hD-rI+HXhdxFL7-AFY'auGt$EJ1m,(@'un@VHdt6L#s[DYGB0-gD.X`'/4+auGpkn+H5-xF-^%/(#B_=?-kQU@-QRt7/uJ6(#Cm[*b[^es/c:@bHdN4/#"
70 "d>?L-NNei.Fn@-#afh]%mxtLF//5UCvs.>B,(rE-i<cM:^0[eF/1u'#.mk.#[5C/#-)IqLR`4rL;wXrLX.lrL1x.qLf.K-#J#`5/%$S-#c7]nLNM-X.Q####F/LMTxS&=u<7L8#";
71
72static constexpr ImWchar DEBUGGER_ICON_MIN = 0xead1;
73static constexpr ImWchar DEBUGGER_ICON_MAX = 0xeb8f;
74static constexpr ImWchar DEBUGGER_ICON_RUN = 0xead3;
75static constexpr ImWchar DEBUGGER_ICON_BREAK = 0xead1;
76static constexpr ImWchar DEBUGGER_ICON_STEP_IN = 0xead4;
77static constexpr ImWchar DEBUGGER_ICON_STEP_OUT = 0xead5;
78static constexpr ImWchar DEBUGGER_ICON_STEP_OVER = 0xead6;
79static constexpr ImWchar DEBUGGER_ICON_STEP_BACK = 0xeb8f;
80
82{
83 auto& io = ImGui::GetIO();
84 ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true;
85 static constexpr std::array<ImWchar, 3> ranges = {DEBUGGER_ICON_MIN, DEBUGGER_ICON_MAX, 0};
86 io.Fonts->AddFontFromMemoryCompressedBase85TTF(icons_compressed_base85, 20.0f, &icons_config, ranges.data());
87}
88
90{
91 syncDisassemblyWithPC = true;
92}
93
94void ImGuiDebugger::save(ImGuiTextBuffer& buf)
95{
96 savePersistent(buf, *this, persistentElements);
97
98 // TODO in the future use c++23 std::chunk_by
99 auto it = hexEditors.begin();
100 auto et = hexEditors.end();
101 while (it != et) {
102 int count = 0;
103 auto name = std::string((*it)->getDebuggableName());
104 do {
105 ++it;
106 ++count;
107 } while (it != et && (*it)->getDebuggableName() == name);
108 buf.appendf("hexEditor.%s=%d\n", name.c_str(), count);
109 }
110
111}
112
114{
115 hexEditors.clear();
116}
117
118void ImGuiDebugger::loadLine(std::string_view name, zstring_view value)
119{
120 static constexpr std::string_view prefix = "hexEditor.";
121
122 if (loadOnePersistent(name, value, *this, persistentElements)) {
123 // already handled
124 } else if (name.starts_with(prefix)) {
125 if (auto r = StringOp::stringTo<unsigned>(value)) {
126 auto debuggableName = std::string(name.substr(prefix.size()));
127 auto [b, e] = ranges::equal_range(hexEditors, debuggableName, {}, &DebuggableEditor::getDebuggableName);
128 auto index = std::distance(b, e); // expected to be 0, but be robust against imgui.ini changes
129 for (auto i : xrange(*r)) {
130 e = hexEditors.insert(e, std::make_unique<DebuggableEditor>(manager, debuggableName, index + i));
131 ++e;
132 }
133 }
134 }
135}
136
138{
139 setDisassemblyScrollY = disassemblyScrollY;
140}
141
143{
144 auto createHexEditor = [&](const std::string& name) {
145 // prefer to reuse a previously closed editor
146 auto [b, e] = ranges::equal_range(hexEditors, name, {}, &DebuggableEditor::getDebuggableName);
147 for (auto it = b; it != e; ++it) {
148 if (!(*it)->open) {
149 (*it)->open = true;
150 return;
151 }
152 }
153 // or create a new one
154 auto index = std::distance(b, e);
155 auto it = hexEditors.insert(e, std::make_unique<DebuggableEditor>(manager, name, index));
156 (*it)->open = true;
157 };
158
159 im::Menu("Debugger", motherBoard != nullptr, [&]{
160 ImGui::MenuItem("Tool bar", nullptr, &showControl);
161 ImGui::MenuItem("Disassembly", nullptr, &showDisassembly);
162 ImGui::MenuItem("CPU registers", nullptr, &showRegisters);
163 ImGui::MenuItem("CPU flags", nullptr, &showFlags);
164 ImGui::MenuItem("Slots", nullptr, &showSlots);
165 ImGui::MenuItem("Stack", nullptr, &showStack);
166 auto it = ranges::lower_bound(hexEditors, "memory", {}, &DebuggableEditor::getDebuggableName);
167 bool memoryOpen = (it != hexEditors.end()) && (*it)->open;
168 if (ImGui::MenuItem("Memory", nullptr, &memoryOpen)) {
169 if (memoryOpen) {
170 createHexEditor("memory");
171 } else {
172 assert(it != hexEditors.end());
173 (*it)->open = false;
174 }
175 }
176 ImGui::Separator();
177 ImGui::MenuItem("Breakpoints", nullptr, &manager.breakPoints->show);
178 ImGui::MenuItem("Symbol manager", nullptr, &manager.symbols->show);
179 ImGui::MenuItem("Watch expression", nullptr, &manager.watchExpr->show);
180 ImGui::Separator();
181 ImGui::MenuItem("VDP bitmap viewer", nullptr, &manager.bitmap->showBitmapViewer);
182 ImGui::MenuItem("VDP tile viewer", nullptr, &manager.character->show);
183 ImGui::MenuItem("VDP sprite viewer", nullptr, &manager.sprite->show);
184 ImGui::MenuItem("VDP register viewer", nullptr, &manager.vdpRegs->show);
185 ImGui::MenuItem("Palette editor", nullptr, &manager.palette->window.open);
186 ImGui::Separator();
187 im::Menu("Add hex editor", [&]{
188 const auto& debugger = motherBoard->getDebugger();
189 auto debuggables = to_vector<std::pair<std::string, Debuggable*>>(debugger.getDebuggables());
190 ranges::sort(debuggables, StringOp::caseless{}, [](const auto& p) { return p.first; }); // sort on name
191 for (const auto& [name, debuggable] : debuggables) {
192 if (ImGui::Selectable(strCat(name, " ...").c_str())) {
193 createHexEditor(name);
194 }
195 }
196 });
197 });
198}
199
200void ImGuiDebugger::setGotoTarget(uint16_t target)
201{
202 gotoTarget = target;
203 showDisassembly = true;
204 setDisassemblyScrollY.reset(); // don't restore initial scroll position
205}
206
208{
209 if (!motherBoard) return;
210
211 auto& regs = motherBoard->getCPU().getRegisters();
212 auto& cpuInterface = motherBoard->getCPUInterface();
213 auto& debugger = motherBoard->getDebugger();
214 auto time = motherBoard->getCurrentTime();
215 drawControl(cpuInterface);
216 drawDisassembly(regs, cpuInterface, debugger, time);
217 drawSlots(cpuInterface, debugger);
218 drawStack(regs, cpuInterface, time);
219 drawRegisters(regs);
220 drawFlags(regs);
221}
222
223void ImGuiDebugger::actionBreakContinue(MSXCPUInterface& cpuInterface)
224{
226 cpuInterface.doContinue();
227 } else {
228 cpuInterface.doBreak();
229 }
230}
231void ImGuiDebugger::actionStepIn(MSXCPUInterface& cpuInterface)
232{
233 cpuInterface.doStep();
234}
235void ImGuiDebugger::actionStepOver()
236{
237 manager.executeDelayed(TclObject("step_over"));
238}
239void ImGuiDebugger::actionStepOut()
240{
241 manager.executeDelayed(TclObject("step_out"));
242}
243void ImGuiDebugger::actionStepBack()
244{
245 manager.executeDelayed(TclObject("step_back"),
246 [&](const TclObject&) { syncDisassemblyWithPC = true; });
247}
248
249void ImGuiDebugger::checkShortcuts(MSXCPUInterface& cpuInterface)
250{
251 using enum Shortcuts::ID;
252 const auto& shortcuts = manager.getShortcuts();
253
254 if (shortcuts.checkShortcut(DEBUGGER_BREAK_CONTINUE)) {
255 actionBreakContinue(cpuInterface);
256 }
257 if (shortcuts.checkShortcut(DEBUGGER_STEP_IN)) {
258 actionStepIn(cpuInterface);
259 }
260 if (shortcuts.checkShortcut(DEBUGGER_STEP_OVER)) {
261 actionStepOver();
262 }
263 if (shortcuts.checkShortcut(DEBUGGER_STEP_OUT)) {
264 actionStepOut();
265 }
266 if (shortcuts.checkShortcut(DEBUGGER_STEP_BACK)) {
267 actionStepBack();
268 }
269}
270
271void ImGuiDebugger::drawControl(MSXCPUInterface& cpuInterface)
272{
273 if (!showControl) return;
274 im::Window("Debugger tool bar", &showControl, [&]{
275 checkShortcuts(cpuInterface);
276
277 auto ButtonGlyph = [&](const char* id, ImWchar c, Shortcuts::ID sid) {
278 const auto* font = ImGui::GetFont();
279 auto texId = font->ContainerAtlas->TexID;
280 const auto* g = font->FindGlyph(c);
281 bool result = ImGui::ImageButton(id, texId, {g->X1 - g->X0, g->Y1 - g->Y0}, {g->U0, g->V0}, {g->U1, g->V1});
282 simpleToolTip([&]() -> std::string {
283 const auto& shortcuts = manager.getShortcuts();
284 const auto& shortcut = shortcuts.getShortcut(sid);
285 if (shortcut.keyChord == ImGuiKey_None) return id;
286 return strCat(id, " (", getKeyChordName(shortcut.keyChord), ')');
287 });
288 return result;
289 };
290
291 bool breaked = MSXCPUInterface::isBreaked();
292 using enum Shortcuts::ID;
293 if (auto breakContinueIcon = breaked ? DEBUGGER_ICON_RUN : DEBUGGER_ICON_BREAK;
294 ButtonGlyph("run", breakContinueIcon, DEBUGGER_BREAK_CONTINUE)) {
295 actionBreakContinue(cpuInterface);
296 }
297 ImGui::SameLine();
298 ImGui::SetCursorPosX(50.0f);
299
300 im::Disabled(!breaked, [&]{
301 if (ButtonGlyph("step-in", DEBUGGER_ICON_STEP_IN, DEBUGGER_STEP_IN)) {
302 actionStepIn(cpuInterface);
303 }
304 ImGui::SameLine();
305
306 if (ButtonGlyph("step-over", DEBUGGER_ICON_STEP_OVER, DEBUGGER_STEP_OVER)) {
307 actionStepOver();
308 }
309 ImGui::SameLine();
310
311 if (ButtonGlyph("step-out", DEBUGGER_ICON_STEP_OUT, DEBUGGER_STEP_OUT)) {
312 actionStepOut();
313 }
314 ImGui::SameLine();
315
316 if (ButtonGlyph("step-back", DEBUGGER_ICON_STEP_BACK, DEBUGGER_STEP_BACK)) {
317 actionStepBack();
318 }
319 });
320 });
321}
322
323[[nodiscard]] static std::pair<const MSXRom*, Debuggable*> getRomBlocks(Debugger& debugger, const MSXDevice* device)
324{
325 Debuggable* debuggable = nullptr;
326 const auto* rom = dynamic_cast<const MSXRom*>(device);
327 if (rom && !dynamic_cast<const RomPlain*>(rom)) {
328 debuggable = debugger.findDebuggable(rom->getName() + " romblocks");
329 }
330 return {rom, debuggable};
331}
332
334 int ps;
335 std::optional<int> ss;
336 std::optional<int> seg;
337};
338[[nodiscard]] static CurrentSlot getCurrentSlot(
339 MSXCPUInterface& cpuInterface, Debugger& debugger,
340 uint16_t addr, bool wantSs = true, bool wantSeg = true)
341{
342 CurrentSlot result;
343 int page = addr / 0x4000;
344 result.ps = cpuInterface.getPrimarySlot(page);
345
346 if (wantSs && cpuInterface.isExpanded(result.ps)) {
347 result.ss = cpuInterface.getSecondarySlot(page);
348 }
349 if (wantSeg) {
350 const auto* device = cpuInterface.getVisibleMSXDevice(page);
351 if (const auto* mapper = dynamic_cast<const MSXMemoryMapperBase*>(device)) {
352 result.seg = mapper->getSelectedSegment(narrow<uint8_t>(page));
353 } else if (auto [_, romBlocks] = getRomBlocks(debugger, device); romBlocks) {
354 result.seg = romBlocks->read(addr);
355 }
356 }
357 return result;
358}
359
360[[nodiscard]] static TclObject toTclExpression(const CurrentSlot& slot)
361{
362 std::string result = strCat("[pc_in_slot ", slot.ps);
363 if (slot.ss) {
364 strAppend(result, ' ', *slot.ss);
365 } else {
366 if (slot.seg) strAppend(result, " X");
367 }
368 if (slot.seg) strAppend(result, ' ', *slot.seg);
369 strAppend(result, ']');
370 return TclObject(result);
371}
372
373[[nodiscard]] static bool addrInSlot(
374 const ParsedSlotCond& slot, MSXCPUInterface& cpuInterface, Debugger& debugger, uint16_t addr)
375{
376 if (!slot.hasPs) return true; // no ps specified -> always ok
377
378 auto current = getCurrentSlot(cpuInterface, debugger, addr, slot.hasSs, slot.hasSeg);
379 if (slot.ps != current.ps) return false;
380 if (slot.hasSs && current.ss && (slot.ss != current.ss)) return false;
381 if (slot.hasSeg && current.seg && (slot.seg != current.seg)) return false;
382 return true;
383}
384
385struct BpLine {
386 int count = 0;
387 int idx = -1; // only valid when count=1
388 bool anyEnabled = false;
389 bool anyDisabled = false;
390 bool anyInSlot = false;
391 bool anyComplex = false;
392};
393static BpLine examineBpLine(uint16_t addr, std::span<const ImGuiBreakPoints::GuiItem> bps, MSXCPUInterface& cpuInterface, Debugger& debugger)
394{
395 BpLine result;
396 for (auto [i, bp] : enumerate(bps)) {
397 if (!bp.addr || *bp.addr != addr) continue;
398 ++result.count;
399 result.idx = int(i);
400
401 bool enabled = (bp.id > 0) && bp.wantEnable;
402 result.anyEnabled |= enabled;
403 result.anyDisabled |= !enabled;
404
405 ParsedSlotCond bpSlot("pc_in_slot", bp.cond.getString());
406 result.anyInSlot |= addrInSlot(bpSlot, cpuInterface, debugger, addr);
407
408 result.anyComplex |= !bpSlot.rest.empty() || (bp.cmd.getString() != "debug break");
409 }
410 return result;
411}
412
413void ImGuiDebugger::drawDisassembly(CPURegs& regs, MSXCPUInterface& cpuInterface, Debugger& debugger, EmuTime::param time)
414{
415 if (!showDisassembly) return;
416 ImGui::SetNextWindowSize({340, 540}, ImGuiCond_FirstUseEver);
417 im::Window("Disassembly", &showDisassembly, [&]{
418 checkShortcuts(cpuInterface);
419
420 std::optional<BreakPoint> addBp;
421 std::optional<unsigned> removeBpId;
422
423 auto pc = regs.getPC();
424 if (followPC && !MSXCPUInterface::isBreaked()) {
425 gotoTarget = pc;
426 }
427
428 auto widthOpcode = ImGui::CalcTextSize("12 34 56 78"sv).x;
429 int flags = ImGuiTableFlags_RowBg |
430 ImGuiTableFlags_BordersV |
431 ImGuiTableFlags_BordersOuterV |
432 ImGuiTableFlags_Resizable |
433 ImGuiTableFlags_Hideable |
434 ImGuiTableFlags_Reorderable |
435 ImGuiTableFlags_ScrollY |
436 ImGuiTableFlags_ScrollX;
437 im::Table("table", 4, flags, [&]{
438 ImGui::TableSetupScrollFreeze(0, 1); // Make top row always visible
439 ImGui::TableSetupColumn("bp", ImGuiTableColumnFlags_WidthFixed);
440 ImGui::TableSetupColumn("address", ImGuiTableColumnFlags_NoHide);
441 ImGui::TableSetupColumn("opcode", ImGuiTableColumnFlags_WidthFixed, widthOpcode);
442 ImGui::TableSetupColumn("mnemonic", ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_NoHide);
443 ImGui::TableHeadersRow();
444
445 auto& guiBps = manager.breakPoints->getBps();
446 auto textSize = ImGui::GetTextLineHeight();
447
448 std::string mnemonic;
449 std::string opcodesStr;
450 std::vector<std::string_view> candidates;
451 std::array<uint8_t, 4> opcodes;
452 ImGuiListClipper clipper; // only draw the actually visible rows
453 clipper.Begin(0x10000);
454 if (gotoTarget) {
455 clipper.IncludeItemsByIndex(*gotoTarget, *gotoTarget + 4);
456 }
457 std::optional<unsigned> nextGotoTarget;
458 while (clipper.Step()) {
459 auto addr16 = instructionBoundary(cpuInterface, narrow<uint16_t>(clipper.DisplayStart), time);
460 for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; ++row) {
461 unsigned addr = addr16;
462 ImGui::TableNextRow();
463 if (addr >= 0x10000) continue;
464 im::ID(narrow<int>(addr), [&]{
465 if (gotoTarget && addr >= *gotoTarget) {
466 gotoTarget = {};
467 ImGui::SetScrollHereY(0.25f);
468 }
469
470 if (bool rowAtPc = !syncDisassemblyWithPC && (addr == pc);
471 rowAtPc) {
472 ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1, getColor(imColor::YELLOW_BG));
473 }
474 bool bpRightClick = false;
475 if (ImGui::TableNextColumn()) { // bp
476 auto bpLine = examineBpLine(addr16, guiBps, cpuInterface, debugger);
477 bool hasBp = bpLine.count != 0;
478 bool multi = bpLine.count > 1;
479 if (hasBp) {
480 auto calcColor = [](bool enabled, bool inSlot) {
481 auto [r,g,b] = enabled ? std::tuple{0xE0, 0x00, 0x00}
482 : std::tuple{0x70, 0x70, 0x70};
483 auto a = inSlot ? 0xFF : 0x60;
484 return IM_COL32(r, g, b, a);
485 };
486 auto colIn = calcColor(bpLine.anyEnabled, bpLine.anyInSlot);
487 auto colOut = ImGui::GetColorU32(ImGuiCol_WindowBg);
488
489 auto* drawList = ImGui::GetWindowDrawList();
490 gl::vec2 scrn = ImGui::GetCursorScreenPos();
491 auto center = scrn + textSize * gl::vec2(multi ? 0.3f : 0.5f, 0.5f);
492 auto radiusIn = 0.4f * textSize;
493 auto radiusOut = 0.5f * textSize;
494
495 if (multi) {
496 auto center2 = center + textSize * gl::vec2(0.4f, 0.0f);
497 drawList->AddCircleFilled(center2, radiusOut, colOut);
498 auto colIn2 = calcColor(!bpLine.anyDisabled, bpLine.anyInSlot);
499 drawList->AddCircleFilled(center2, radiusIn, colIn2);
500 }
501 drawList->AddCircleFilled(center, radiusOut, colOut);
502 drawList->AddCircleFilled(center, radiusIn, colIn);
503 if (bpLine.anyComplex) {
504 auto d = 0.3f * textSize;
505 auto c = IM_COL32(0, 0, 0, 192);
506 auto t = 0.2f * textSize;
507 drawList->AddLine(center - gl::vec2(d, 0.0f), center + gl::vec2(d, 0.0f), c, t);
508 drawList->AddLine(center - gl::vec2(0.0f, d), center + gl::vec2(0.0f, d), c, t);
509 }
510 }
511 if (ImGui::InvisibleButton("##bp-button", {-FLT_MIN, textSize})) {
512 if (hasBp) {
513 // only allow to remove single breakpoints,
514 // others can be edited via the breakpoint viewer
515 if (!multi) {
516 auto& bp = guiBps[bpLine.idx];
517 if (bp.id > 0) {
518 removeBpId = bp.id; // schedule removal
519 } else {
520 guiBps.erase(guiBps.begin() + bpLine.idx);
521 }
522 }
523 } else {
524 // schedule creation of new bp
525 auto slot = getCurrentSlot(cpuInterface, debugger, addr16);
526 addBp.emplace(addr, TclObject("debug break"), toTclExpression(slot), false);
527 }
528 } else {
529 bpRightClick = hasBp && ImGui::IsItemClicked(ImGuiMouseButton_Right);
530 if (bpRightClick) ImGui::OpenPopup("bp-context");
531 im::Popup("bp-context", [&]{
532 manager.breakPoints->paintBpTab(cpuInterface, debugger, addr16);
533 });
534 }
535 }
536
537 mnemonic.clear();
538 std::optional<uint16_t> mnemonicAddr;
539 std::span<const Symbol* const> mnemonicLabels;
540 auto len = dasm(cpuInterface, addr16, opcodes, mnemonic, time,
541 [&](std::string& output, uint16_t a) {
542 mnemonicAddr = a;
543 mnemonicLabels = symbolManager.lookupValue(a);
544 if (!mnemonicLabels.empty()) {
545 strAppend(output, mnemonicLabels[cycleLabelsCounter % mnemonicLabels.size()]->name);
546 } else {
547 appendAddrAsHex(output, a);
548 }
549 });
550 assert(len >= 1);
551 if ((addr < pc) && (pc < (addr + len))) {
552 // pc is strictly inside current instruction,
553 // replace the just disassembled instruction with "db #..."
554 mnemonicAddr.reset();
555 mnemonicLabels = {};
556 len = pc - addr;
557 assert((1 <= len) && (len <= 3));
558 mnemonic = strCat("db ", join(
560 [&](unsigned i) { return strCat('#', hex_string<2>(opcodes[i])); }),
561 ','));
562 }
563
564 if (ImGui::TableNextColumn()) { // addr
565 bool focusScrollToAddress = false;
566 bool focusRunToAddress = false;
567
568 // do the full-row-selectable stuff in a column that cannot be hidden
569 auto pos = ImGui::GetCursorPos();
570 ImGui::Selectable("##row", false,
571 ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap);
573 ImGui::OpenPopup("disassembly-context");
574 focusScrollToAddress = true;
575 }
577 ImGui::OpenPopup("disassembly-context");
578 focusRunToAddress = true;
579 }
580 if (!bpRightClick && ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
581 ImGui::OpenPopup("disassembly-context");
582 }
583
584 auto addrStr = tmpStrCat(hex_string<4>(addr));
585 im::Popup("disassembly-context", [&]{
586 auto addrToolTip = [&](const std::string& str) {
587 simpleToolTip([&]{
588 if (auto a = symbolManager.parseSymbolOrValue(str)) {
589 return strCat("0x", hex_string<4>(*a));
590 }
591 return std::string{};
592 });
593 };
594
595 if (ImGui::MenuItem("Scroll to PC")) {
596 nextGotoTarget = pc;
597 }
598
599 im::Indent([&]{
600 ImGui::Checkbox("Follow PC while running", &followPC);
601 });
602
603 ImGui::AlignTextToFramePadding();
604 ImGui::TextUnformatted("Scroll to address:"sv);
605 ImGui::SameLine();
606 if (focusScrollToAddress) ImGui::SetKeyboardFocusHere();
607 if (ImGui::InputText("##goto", &gotoAddr, ImGuiInputTextFlags_EnterReturnsTrue)) {
608 if (auto a = symbolManager.parseSymbolOrValue(gotoAddr)) {
609 nextGotoTarget = *a;
610 }
611 }
612 addrToolTip(gotoAddr);
613
614 ImGui::Separator();
615
616 auto runTo = strCat("Run to here (address 0x", addrStr, ')');
617 if (ImGui::MenuItem(runTo.c_str())) {
618 manager.executeDelayed(makeTclList("run_to", addr));
619 }
620
621 ImGui::AlignTextToFramePadding();
622 ImGui::TextUnformatted("Run to address:"sv);
623 ImGui::SameLine();
624 if (focusRunToAddress) ImGui::SetKeyboardFocusHere();
625 if (ImGui::InputText("##run", &runToAddr, ImGuiInputTextFlags_EnterReturnsTrue)) {
626 if (auto a = symbolManager.parseSymbolOrValue(runToAddr)) {
627 manager.executeDelayed(makeTclList("run_to", *a));
628 }
629 }
630 addrToolTip(runToAddr);
631
632 ImGui::Separator();
633
634 auto setPc = strCat("Set PC to 0x", addrStr);
635 if (ImGui::MenuItem(setPc.c_str())) {
636 regs.setPC(addr16);
637 }
638 });
639
640 enum Priority {
641 MISSING_BOTH = 0, // from lowest to highest
642 MISSING_ONE,
643 SLOT_AND_SEGMENT
644 };
645 Priority currentPriority = Priority::MISSING_BOTH;
646 candidates.clear();
647 auto add = [&](const Symbol* sym, Priority newPriority) {
648 if (newPriority < currentPriority) return; // we already have a better candidate
649 if (newPriority > currentPriority) candidates.clear(); // drop previous candidates, we found a better one
650 currentPriority = newPriority;
651 candidates.push_back(sym->name); // cycle symbols in the same priority level
652 };
653
654 auto slot = getCurrentSlot(cpuInterface, debugger, addr16);
655 auto psss = (slot.ss.value_or(0) << 2) + slot.ps;
656 auto addrLabels = symbolManager.lookupValue(addr16);
657 for (const Symbol* symbol: addrLabels) {
658 // skip symbols with any mismatch
659 if (symbol->slot && *symbol->slot != psss) continue;
660 if (symbol->segment && *symbol->segment != slot.seg) continue;
661 // the info that's present does match
662 if (symbol->slot && symbol->segment == slot.seg) {
663 add(symbol, Priority::SLOT_AND_SEGMENT);
664 } else if (!symbol->slot && !symbol->segment) {
665 add(symbol, Priority::MISSING_BOTH);
666 } else {
667 add(symbol, Priority::MISSING_ONE);
668 }
669 }
670 ImGui::SetCursorPos(pos);
672 ImGui::TextUnformatted(candidates.empty() ? addrStr : candidates[cycleLabelsCounter % candidates.size()]);
673 });
674 if (!addrLabels.empty()) {
675 simpleToolTip([&]{
676 std::string tip(addrStr);
677 if (addrLabels.size() > 1) {
678 strAppend(tip, "\nmultiple possibilities (click to cycle):\n",
679 join(view::transform(addrLabels, &Symbol::name), ' '));
680 }
681 return tip;
682 });
683 ImGui::SetCursorPos(pos);
684 if (ImGui::InvisibleButton("##addrButton", {-FLT_MIN, textSize})) {
685 ++cycleLabelsCounter;
686 }
687 }
688 }
689
690 if (ImGui::TableNextColumn()) { // opcode
691 opcodesStr.clear();
692 for (auto i : xrange(len)) {
693 strAppend(opcodesStr, hex_string<2>(opcodes[i]), ' ');
694 }
696 ImGui::TextUnformatted(opcodesStr.data(), opcodesStr.data() + 3 * len - 1);
697 });
698 }
699
700 if (ImGui::TableNextColumn()) { // mnemonic
701 auto pos = ImGui::GetCursorPos();
703 ImGui::TextUnformatted(mnemonic);
704 });
705 if (mnemonicAddr) {
706 ImGui::SetCursorPos(pos);
707 if (ImGui::InvisibleButton("##mnemonicButton", {-FLT_MIN, textSize})) {
708 if (!mnemonicLabels.empty()) {
709 ++cycleLabelsCounter;
710 }
711 }
712 if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
713 nextGotoTarget = *mnemonicAddr;
714 }
715 if (!mnemonicLabels.empty()) {
716 simpleToolTip([&]{
717 auto tip = strCat('#', hex_string<4>(*mnemonicAddr));
718 if (mnemonicLabels.size() > 1) {
719 strAppend(tip, "\nmultiple possibilities (click to cycle):\n",
720 join(view::transform(mnemonicLabels, &Symbol::name), ' '));
721 }
722 return tip;
723 });
724 }
725 }
726 }
727 addr16 += len;
728 });
729 }
730 }
731 gotoTarget = nextGotoTarget;
732 if (syncDisassemblyWithPC) {
733 syncDisassemblyWithPC = false; // only once
734
735 auto itemHeight = ImGui::GetTextLineHeightWithSpacing();
736 auto winHeight = ImGui::GetWindowHeight();
737 auto lines = std::max(1, int(winHeight / itemHeight) - 1); // approx
738
739 auto topAddr = nInstructionsBefore(cpuInterface, pc, time, narrow<int>(lines / 4) + 1);
740
741 ImGui::SetScrollY(topAddr * itemHeight);
742 } else if (setDisassemblyScrollY) {
743 ImGui::SetScrollY(*setDisassemblyScrollY);
744 setDisassemblyScrollY.reset();
745 }
746 disassemblyScrollY = ImGui::GetScrollY();
747 });
748 // only add/remove bp's after drawing (can't change list of bp's while iterating over it)
749 if (addBp) {
750 cpuInterface.insertBreakPoint(std::move(*addBp));
751 }
752 if (removeBpId) {
753 cpuInterface.removeBreakPoint(*removeBpId);
754 }
755 });
756}
757
758void ImGuiDebugger::drawSlots(MSXCPUInterface& cpuInterface, Debugger& debugger)
759{
760 if (!showSlots) return;
761 im::Window("Slots", &showSlots, [&]{
762 int flags = ImGuiTableFlags_BordersInnerV |
763 ImGuiTableFlags_Resizable |
764 ImGuiTableFlags_Reorderable |
765 ImGuiTableFlags_Hideable |
766 ImGuiTableFlags_ContextMenuInBody;
767 im::Table("table", 4, flags, [&]{
768 ImGui::TableSetupColumn("Page");
769 ImGui::TableSetupColumn("Address", ImGuiTableColumnFlags_DefaultHide);
770 ImGui::TableSetupColumn("Slot");
771 ImGui::TableSetupColumn("Segment");
772 ImGui::TableHeadersRow();
773
774 for (auto page : xrange(uint8_t(4))) {
775 auto addr = 0x4000 * page;
776 if (ImGui::TableNextColumn()) { // page
777 ImGui::StrCat(page);
778 }
779 if (ImGui::TableNextColumn()) { // address
780 ImGui::StrCat("0x", hex_string<4>(addr));
781 }
782 if (ImGui::TableNextColumn()) { // slot
783 int ps = cpuInterface.getPrimarySlot(page);
784 if (cpuInterface.isExpanded(ps)) {
785 int ss = cpuInterface.getSecondarySlot(page);
786 ImGui::StrCat(ps, '-', ss);
787 } else {
788 ImGui::StrCat(' ', ps);
789 }
790 }
791 if (ImGui::TableNextColumn()) { // segment
792 const auto* device = cpuInterface.getVisibleMSXDevice(page);
793 if (const auto* mapper = dynamic_cast<const MSXMemoryMapperBase*>(device)) {
794 ImGui::StrCat(mapper->getSelectedSegment(page));
795 } else if (auto [rom, romBlocks] = getRomBlocks(debugger, device); romBlocks) {
796 if (unsigned blockSize = RomInfo::getBlockSize(rom->getRomType())) {
797 std::string text;
798 char separator = 'R';
799 for (int offset = 0; offset < 0x4000; offset += blockSize) {
800 strAppend(text, separator, romBlocks->read(addr + offset));
801 separator = '/';
802 }
804 } else {
806 }
807 } else {
809 }
810 }
811 }
812 });
813 });
814}
815
816void ImGuiDebugger::drawStack(const CPURegs& regs, const MSXCPUInterface& cpuInterface, EmuTime::param time)
817{
818 if (!showStack) return;
819
820 auto line = ImGui::GetTextLineHeightWithSpacing();
821 ImGui::SetNextWindowSize(ImVec2(0.0f, 12 * line), ImGuiCond_FirstUseEver);
822 im::Window("stack", &showStack, [&]{
823 auto sp = regs.getSP();
824
825 int flags = ImGuiTableFlags_ScrollY |
826 ImGuiTableFlags_BordersInnerV |
827 ImGuiTableFlags_Resizable |
828 ImGuiTableFlags_Reorderable |
829 ImGuiTableFlags_Hideable |
830 ImGuiTableFlags_ContextMenuInBody;
831 im::Table("table", 3, flags, [&]{
832 ImGui::TableSetupScrollFreeze(0, 1); // Make top row always visible
833 ImGui::TableSetupColumn("Address");
834 ImGui::TableSetupColumn("Offset", ImGuiTableColumnFlags_DefaultHide);
835 ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_NoHide);
836 ImGui::TableHeadersRow();
837
839 im::ListClipper(std::min(128, (0x10000 - sp) / 2), [&](int row) {
840 auto offset = 2 * row;
841 auto addr = sp + offset;
842 if (ImGui::TableNextColumn()) { // address
843 ImGui::StrCat(hex_string<4>(addr));
844 }
845 if (ImGui::TableNextColumn()) { // offset
846 ImGui::Text("SP+%X", offset);
847 }
848 if (ImGui::TableNextColumn()) { // value
849 auto l = cpuInterface.peekMem(narrow_cast<uint16_t>(addr + 0), time);
850 auto h = cpuInterface.peekMem(narrow_cast<uint16_t>(addr + 1), time);
851 auto value = narrow<uint16_t>(256 * h + l);
852 ImGui::StrCat(hex_string<4>(value));
853 }
854 });
855 });
856 });
857}
858
859void ImGuiDebugger::drawRegisters(CPURegs& regs)
860{
861 if (!showRegisters) return;
862 im::Window("CPU registers", &showRegisters, [&]{
864
865 const auto& style = ImGui::GetStyle();
866 auto padding = 2 * style.FramePadding.x;
867 auto width16 = ImGui::CalcTextSize("FFFF"sv).x + padding;
868 auto edit16 = [&](std::string_view label, std::string_view high, std::string_view low, auto getter, auto setter) {
869 uint16_t value = getter();
870 im::Group([&]{
871 ImGui::AlignTextToFramePadding();
873 ImGui::SameLine();
874 ImGui::SetNextItemWidth(width16);
875 if (ImGui::InputScalar(tmpStrCat("##", label).c_str(), ImGuiDataType_U16, &value, nullptr, nullptr, "%04X")) {
876 setter(value);
877 }
878 });
879 simpleToolTip([&]{
880 return strCat(
881 "Bin: ", bin_string<4>(value >> 12), ' ', bin_string<4>(value >> 8), ' ',
882 bin_string<4>(value >> 4), ' ', bin_string<4>(value >> 0), "\n"
883 "Dec: ", dec_string<5>(value), '\n',
884 high, ": ", dec_string<3>(value >> 8), " ", low, ": ", dec_string<3>(value & 0xff));
885 });
886 };
887 auto edit8 = [&](std::string_view label, auto getter, auto setter) {
888 uint8_t value = getter();
889 im::Group([&]{
890 ImGui::AlignTextToFramePadding();
892 ImGui::SameLine();
893 ImGui::SetNextItemWidth(width16);
894 if (ImGui::InputScalar(tmpStrCat("##", label).c_str(), ImGuiDataType_U8, &value, nullptr, nullptr, "%02X")) {
895 setter(value);
896 }
897 });
898 simpleToolTip([&]{
899 return strCat(
900 "Bin: ", bin_string<4>(value >> 4), ' ', bin_string<4>(value >> 0), "\n"
901 "Dec: ", dec_string<3>(value), '\n');
902 });
903 };
904
905 edit16("AF", "A", "F", [&]{ return regs.getAF(); }, [&](uint16_t value) { regs.setAF(value); });
906 ImGui::SameLine(0.0f, 20.0f);
907 edit16("AF'", "A'", "F'", [&]{ return regs.getAF2(); }, [&](uint16_t value) { regs.setAF2(value); });
908
909 edit16("BC", "B", "C", [&]{ return regs.getBC(); }, [&](uint16_t value) { regs.setBC(value); });
910 ImGui::SameLine(0.0f, 20.0f);
911 edit16("BC'", "B'", "C'", [&]{ return regs.getBC2(); }, [&](uint16_t value) { regs.setBC2(value); });
912
913 edit16("DE", "D", "E", [&]{ return regs.getDE(); }, [&](uint16_t value) { regs.setDE(value); });
914 ImGui::SameLine(0.0f, 20.0f);
915 edit16("DE'", "D'", "E'", [&]{ return regs.getDE2(); }, [&](uint16_t value) { regs.setDE2(value); });
916
917 edit16("HL", "H", "L", [&]{ return regs.getHL(); }, [&](uint16_t value) { regs.setHL(value); });
918 ImGui::SameLine(0.0f, 20.0f);
919 edit16("HL'", "H'", "L'", [&]{ return regs.getHL2(); }, [&](uint16_t value) { regs.setHL2(value); });
920
921 edit16("IX", "IXh", "IXl", [&]{ return regs.getIX(); }, [&](uint16_t value) { regs.setIX(value); });
922 ImGui::SameLine(0.0f, 20.0f);
923 edit16("IY ", "IYh", "IYl", [&]{ return regs.getIY(); }, [&](uint16_t value) { regs.setIY(value); });
924
925 edit16("PC", "PCh", "PCl", [&]{ return regs.getPC(); }, [&](uint16_t value) { regs.setPC(value); });
926 ImGui::SameLine(0.0f, 20.0f);
927 edit16("SP ", "SPh", "SPl", [&]{ return regs.getSP(); }, [&](uint16_t value) { regs.setSP(value); });
928
929 edit8("I ", [&]{ return regs.getI(); }, [&](uint8_t value) { regs.setI(value); });
930 ImGui::SameLine(0.0f, 20.0f);
931 edit8("R ", [&]{ return regs.getR(); }, [&](uint8_t value) { regs.setR(value); });
932
933 ImGui::AlignTextToFramePadding();
935 ImGui::SameLine();
936 ImGui::SetNextItemWidth(width16);
937 if (uint8_t im = regs.getIM();
938 ImGui::InputScalar("##IM", ImGuiDataType_U8, &im, nullptr, nullptr, "%d")) {
939 if (im <= 2) regs.setIM(im);
940 }
941
942 ImGui::SameLine(0.0f, 20.0f);
943 ImGui::AlignTextToFramePadding();
944 if (bool ei = regs.getIFF1();
945 ImGui::Selectable(ei ? "EI" : "DI", false, ImGuiSelectableFlags_AllowDoubleClick)) {
946 if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
947 regs.setIFF1(!ei);
948 regs.setIFF2(!ei);
949 }
950 }
951 simpleToolTip("double-click to toggle");
952 });
953}
954
955void ImGuiDebugger::drawFlags(CPURegs& regs)
956{
957 if (!showFlags) return;
958 im::Window("CPU flags", &showFlags, [&]{
959 auto [sizeH1_, sizeH2_, sizeV_] = [&]{
961 return std::tuple{
962 ImGui::CalcTextSize("NC"sv),
963 ImGui::CalcTextSize("X:0"sv),
964 ImGui::CalcTextSize("C 0 (NC)"sv)
965 };
966 }();
967 // clang workaround
968 auto sizeH1 = sizeH1_; auto sizeH2 = sizeH2_; auto sizeV = sizeV_;
969
970 auto f = regs.getF();
971
972 auto draw = [&](const char* name, uint8_t bit, const char* val0 = nullptr, const char* val1 = nullptr) {
973 std::string s;
974 ImVec2 sz;
975 if (flagsLayout == 0) {
976 // horizontal
977 if (val0) {
978 s = (f & bit) ? val1 : val0;
979 sz = sizeH1;
980 } else {
981 s = strCat(name, ':', (f & bit) ? '1' : '0');
982 sz = sizeH2;
983 }
984 } else {
985 // vertical
986 s = strCat(name, ' ', (f & bit) ? '1' : '0');
987 if (val0) {
988 strAppend(s, " (", (f & bit) ? val1 : val0, ')');
989 }
990 sz = sizeV;
991 }
993 if (ImGui::Selectable(s.c_str(), false, ImGuiSelectableFlags_AllowDoubleClick, sz)) {
994 if (ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) {
995 regs.setF(f ^ bit);
996 }
997 }
998 });
999 simpleToolTip("double-click to toggle, right-click to configure");
1000 if (flagsLayout == 0) {
1001 // horizontal
1002 ImGui::SameLine(0.0f, sizeH1.x);
1003 }
1004 };
1005
1006 draw("S", 0x80, " P", " M");
1007 draw("Z", 0x40, "NZ", " Z");
1008 if (showXYFlags) draw("Y", 0x20);
1009 draw("H", 0x10);
1010 if (showXYFlags) draw("X", 0x08);
1011 draw("P", 0x04, "PO", "PE");
1012 draw("N", 0x02);
1013 draw("C", 0x01, "NC", " C");
1014
1016 ImGui::TextUnformatted("Layout"sv);
1017 ImGui::RadioButton("horizontal", &flagsLayout, 0);
1018 ImGui::RadioButton("vertical", &flagsLayout, 1);
1019 ImGui::Separator();
1020 ImGui::Checkbox("show undocumented", &showXYFlags);
1021 });
1022 });
1023}
1024
1025} // namespace openmsx
uintptr_t id
int g
TclObject t
std::string_view getDebuggableName() const
void loadEnd() override
void loadStart() override
void showMenu(MSXMotherBoard *motherBoard) override
ImGuiDebugger(ImGuiManager &manager)
void loadLine(std::string_view name, zstring_view value) override
void setGotoTarget(uint16_t target)
void paint(MSXMotherBoard *motherBoard) override
void save(ImGuiTextBuffer &buf) override
std::unique_ptr< ImGuiBreakPoints > breakPoints
std::unique_ptr< ImGuiVdpRegs > vdpRegs
std::unique_ptr< ImGuiWatchExpr > watchExpr
std::unique_ptr< ImGuiPalette > palette
std::unique_ptr< ImGuiSpriteViewer > sprite
Shortcuts & getShortcuts()
std::unique_ptr< ImGuiBitmapViewer > bitmap
std::unique_ptr< ImGuiCharacter > character
void executeDelayed(std::function< void()> action)
std::unique_ptr< ImGuiSymbols > symbols
ImGuiManager & manager
Definition ImGuiPart.hh:30
auto getPrimarySlot(int page) const
MSXDevice * getVisibleMSXDevice(int page)
bool isExpanded(int ps) const
auto getSecondarySlot(int page) const
CPURegs & getRegisters()
Definition MSXCPU.cc:339
EmuTime::param getCurrentTime() const
Convenience method: This is the same as getScheduler().getCurrentTime().
MSXCPUInterface & getCPUInterface()
static unsigned getBlockSize(RomType type)
Definition RomInfo.cc:201
bool checkShortcut(const ShortcutWithRepeat &shortcut) const
Definition Shortcuts.cc:134
const Shortcut & getShortcut(ID id) const
Definition Shortcuts.cc:90
std::span< Symbol const *const > lookupValue(uint16_t value)
std::optional< uint16_t > parseSymbolOrValue(std::string_view s) const
Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.
constexpr auto enumerate(Iterable &&iterable)
Heavily inspired by Nathan Reed's blog post: Python-Like enumerate() In C++17 http://reedbeta....
Definition enumerate.hh:28
detail::Joiner< Collection, Separator > join(Collection &&col, Separator &&sep)
Definition join.hh:60
void StrCat(Ts &&...ts)
Definition ImGuiUtils.hh:43
auto CalcTextSize(std::string_view str)
Definition ImGuiUtils.hh:37
void TextUnformatted(const std::string &str)
Definition ImGuiUtils.hh:24
vecN< 2, float > vec2
Definition gl_vec.hh:178
Definition ImGuiCpp.hh:60
void Table(const char *str_id, int column, ImGuiTableFlags flags, const ImVec2 &outer_size, float inner_width, std::invocable<> auto next)
Definition ImGuiCpp.hh:455
void Window(const char *name, bool *p_open, ImGuiWindowFlags flags, std::invocable<> auto next)
Definition ImGuiCpp.hh:63
void ID(const char *str_id, std::invocable<> auto next)
Definition ImGuiCpp.hh:244
void PopupContextWindow(const char *str_id, ImGuiPopupFlags popup_flags, std::invocable<> auto next)
Definition ImGuiCpp.hh:438
bool Menu(const char *label, bool enabled, std::invocable<> auto next)
Definition ImGuiCpp.hh:359
void Disabled(bool b, std::invocable<> auto next)
Definition ImGuiCpp.hh:506
void Group(std::invocable<> auto next)
Definition ImGuiCpp.hh:236
void Font(ImFont *font, std::invocable<> auto next)
Definition ImGuiCpp.hh:131
void Indent(float indent_w, std::invocable<> auto next)
Definition ImGuiCpp.hh:224
void ListClipper(size_t count, int forceIndex, float lineHeight, std::invocable< int > auto next)
Definition ImGuiCpp.hh:538
void Popup(const char *str_id, ImGuiWindowFlags flags, std::invocable<> auto next)
Definition ImGuiCpp.hh:391
This file implemented 3 utility functions:
Definition Autofire.cc:11
bool loadOnePersistent(std::string_view name, zstring_view value, C &c, const std::tuple< Elements... > &tup)
void simpleToolTip(std::string_view desc)
Definition ImGuiUtils.hh:77
void savePersistent(ImGuiTextBuffer &buf, C &c, const std::tuple< Elements... > &tup)
unsigned dasm(const MSXCPUInterface &interface, uint16_t pc, std::span< uint8_t, 4 > buf, std::string &dest, EmuTime::param time, function_ref< void(std::string &, uint16_t)> appendAddr)
Disassemble.
Definition Dasm.cc:26
ImU32 getColor(imColor col)
std::string getKeyChordName(ImGuiKeyChord keyChord)
uint16_t instructionBoundary(const MSXCPUInterface &interface, uint16_t addr, EmuTime::param time)
This is only an heuristic to display instructions in a debugger disassembly view.
Definition Dasm.cc:175
uint16_t nInstructionsBefore(const MSXCPUInterface &interface, uint16_t addr, EmuTime::param time, int n)
Get the start address of the 'n'th instruction before the instruction containing the byte at the give...
Definition Dasm.cc:182
TclObject makeTclList(Args &&... args)
Definition TclObject.hh:293
auto equal_range(ForwardRange &&range, const T &value, Compare comp={})
Definition ranges.hh:135
constexpr void sort(RandomAccessRange &&range)
Definition ranges.hh:51
auto lower_bound(ForwardRange &&range, const T &value, Compare comp={}, Proj proj={})
Definition ranges.hh:117
constexpr auto transform(Range &&range, UnaryOp op)
Definition view.hh:520
std::string strCat()
Definition strCat.hh:703
TemporaryString tmpStrCat(Ts &&... ts)
Definition strCat.hh:742
void strAppend(std::string &result, Ts &&...ts)
Definition strCat.hh:752
std::optional< int > seg
std::optional< int > ss
std::string name
constexpr auto xrange(T e)
Definition xrange.hh:132