--- nono/debugger/debugger_m88xx0.h 2026/04/29 17:04:30 1.1.1.1 +++ nono/debugger/debugger_m88xx0.h 2026/04/29 17:05:09 1.1.1.7 @@ -1,60 +1,89 @@ // // nono -// Copyright (C) 2020 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt +// + +// +// デバッガ (M88xx0 依存部分) // #pragma once #include "debugger_private.h" +#include "mpu88xx0.h" #include "m88100.h" #include "m88100disasm.h" class DebuggerMD_m88xx0 : public DebuggerMD { - typedef DebuggerMD inherited; + using inherited = DebuggerMD; public: - DebuggerMD_m88xx0(Debugger *parg, m88kcpu *carg) - : inherited(parg) - { - cpu = carg; - } - virtual ~DebuggerMD_m88xx0() { } + DebuggerMD_m88xx0(Debugger *parent_, m88kcpu *cpu_); + ~DebuggerMD_m88xx0() override; - void ReqSet(uint32 flag) { cpu->atomic_reqflag |= flag; } - void ReqClr(uint32 flag) { cpu->atomic_reqflag &= ~flag; } + void ReqSet(uint32 flag) override { cpu->atomic_reqflag |= flag; } + void ReqClr(uint32 flag) override { cpu->atomic_reqflag &= ~flag; } - bool IsSuper() const { return false; } - bool MMUEnabled() const { return false; } - uint64 TranslateAddr(saddr_t laddr) { return 0; } + bool IsSuper() const override { return (cpu->psr & m88100reg::PSR_SUPER); } + bool MMUEnabled() const override; + uint64 TranslateAddr(saddr_t laddr, bool lookup) const override; // XXX ? - uint32 GetPC() const { return cpu->Getxip(); } + uint32 GetPC() const override { return cpu->GetXIP(); } - void SetStepOut() {} - bool IsStepOut() const { return false; } - uint64 GetRegAddr(const char *name) const; - void BackupRegs(); - void ShowRegMain(Console *cons); - void ShowRegCtrl(Console *cons); - void ShowRegFPU(Console *cons); - void ShowRegMMU(Console *cons); - void ShowRegATC(Console *cons) {} - void ShowRegOther(Console *cons); + void SetStepOut() override; + bool IsStepOut() const override; + bool IsOpStepIn(DebuggerMemoryStream& mem) override; + uint64 GetRegAddr(const char *name) const override; + void BackupRegs() override; + bool ShowRegister(FILE *, const std::vector& args) override; + const HelpMessages& GetHelpListReg() const override; + const HelpMessages& GetHelpReg() const override; - bool CheckLEA(uint32 laddr) { + BranchHistory& GetBrHist() const override { return cpu->brhist; } + BranchHistory& GetExHist() const override { return cpu->exhist; } + + bool CheckLEA(uint32 laddr) override { bool rv = cpu->lastaddr == laddr; cpu->lastaddr = 0; // XXX: ていうかここでクリアはおかしい return rv; } - bool Disassemble(saddr_t laddr, - std::string& mnemonic, std::vector& bin); + bool Disassemble(DebuggerMemoryStream& mem, + std::string& mnemonic, std::vector& bin) override; std::string FormatDisasm(const std::string& mnemonic, - const std::vector& bin); + const std::vector& bin) override; std::string FormatDisasmLive(const std::string& mnemonic, - const std::vector& bin); + const std::vector& bin) override; private: - m88kcpu *cpu = NULL; // CPU コア - m88100reg prev {}; + m88kcpu *cpu {}; // CPU コア + m88100reg prev {}; // 前回のレジスタセットのコピー + + static bool IsBB0(uint32 op); + static bool IsTB0(uint32 op); + static bool IsBBTB0(uint32 op); + static bool IsBB1(uint32 op); + static bool IsTB1(uint32 op); + static bool IsBBTB1(uint32 op); + const char *CondStr(uint32 op); + + static const HelpMessages HelpListReg; + static const HelpMessages HelpReg; + bool MatchCMMUCmd(const std::string& cmdname, const char *name, int *); + void ShowRegMain(); + bool ShowRegCache(FILE *, const std::vector& args, int id); + void ShowRegCacheOverview(m88200 *cmmu); + void ShowRegCacheSet(m88200 *cmmu, int setidx); + void ShowRegCtrl(); + void ShowRegFPU(); + void ShowRegOther(); + + // cmp 命令後の分岐命令で結果レジスタを表示するため、 + // cmp 命令のデスティネーションレジスタを覚えておく。 + // -1 なら該当しないの意。 + int cmp_rd {}; + + uint32 so_r1 {}; // ステップアウト判定用 };