--- nono/debugger/debugger_m680x0.h 2026/04/29 17:04:30 1.1 +++ nono/debugger/debugger_m680x0.h 2026/04/29 17:05:58 1.1.1.12 @@ -1,63 +1,89 @@ // // nono -// Copyright (C) 2020 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt +// + +// +// デバッガ (M680x0 依存部分) // #pragma once #include "debugger_private.h" -#include "m68030.h" -#include "m68030disasm.h" +#include "mpu680x0.h" +#include "m680x0disasm.h" + +class StackData; class DebuggerMD_m680x0 : public DebuggerMD { - typedef DebuggerMD inherited; + using inherited = DebuggerMD; public: - DebuggerMD_m680x0(Debugger *parg, m68kcpu *carg) - : inherited(parg) - { - cpu = carg; + explicit DebuggerMD_m680x0(Debugger *parent); + ~DebuggerMD_m680x0() override; + + CPUState GetCPUState() const override { return (CPUState)cpu->GetState(); } + bool IsSuper() const override { return cpu->IsSuper(); } + bool MMUEnabled() const override { return cpu->mmu_enable; } + busaddr TranslateAddr(busaddr laddr) const override; + + uint32 GetPC() const override { return cpu->reg.pc; } + int32 GetAndResetLastVector() override { + return cpu->GetAndResetLastVector(); } - virtual ~DebuggerMD_m680x0() { } - void ReqSet(uint32 flag) { cpu->atomic_reqflag |= flag; } - void ReqClr(uint32 flag) { cpu->atomic_reqflag &= ~flag; } + void SetStepOut() override; + bool IsStepOut() const override; + bool IsOpStepIn(DebuggerMemoryStream& mem) override; + uint64 GetRegAddr(const char *name) const override; + void BackupRegs() override { prev = cpu->reg; } + bool ShowRegister(FILE *, const std::vector& args) override; + const HelpMessages& GetHelpListReg() const override; + const HelpMessages& GetHelpReg() const override; + + bool CheckLEA(uint32 laddr) override { return false; } + + std::string Disassemble(DebuggerMemoryStream& mem) override; + std::string ParseInst(const std::string&) const override; + + void PrintExceptionFrame(FILE *, busaddr) override; - bool IsSuper() const { return cpu->reg.s; } - bool MMUEnabled() const { return cpu->mmu_enable; } - uint64 TranslateAddr(saddr_t laddr); - - uint32 GetPC() const { return RegPC; } - - void SetStepOut(); - bool IsStepOut() const; - uint64 GetRegAddr(const char *name) const; - void BackupRegs() { prev = cpu->reg; } - void ShowRegMain(Console *cons); - void ShowRegCtrl(Console *cons) {} - void ShowRegFPU(Console *cons); - void ShowRegMMU(Console *cons); - void ShowRegATC(Console *cons); - void ShowRegOther(Console *cons); - - bool CheckLEA(uint32 laddr) { return false; } - - bool Disassemble(saddr_t laddr, - std::string& mnemonic, std::vector& bin); - std::string FormatDisasm(const std::string& mnemonic, - const std::vector& bin); - std::string FormatDisasmLive(const std::string& mnemonic, - const std::vector& bin); + // 浮動小数点ステートフレームを表示する。 + void PrintFPStateFrame(FILE *, busaddr); private: - m68kcpu *cpu = NULL; // CPU コア - m68kreg prev {}; // 前回のレジスタセットのコピー + MPU680x0Device *cpu {}; // MPU デバイス + m68kreg prev {}; // 前回のレジスタセットのコピー - const char *CondStr(const std::vector& ir); - bool IsOPcc(uint16 op); - bool IsDBcc(uint16 op); - bool IsCond(uint16 op); + static bool IsOPcc(uint16 op); + static bool IsDBcc(uint16 op); + static int IsFXcc(const std::vector& ir); + bool IsCond(uint16 op) const; + const char *CondStr(const std::vector& ir) const; + + static const HelpMessages HelpListReg; + static const HelpMessages HelpReg; + void ShowRegMain(FILE *); + void ShowRegFPU(FILE *); + void ShowRegMMU30(FILE *); + void ShowRegMMU40(FILE *); + void ShowRegATC(); + void ShowRegOther(); + + bool PrintExceptionFrameCommon(FILE *, const StackData&, bool); + void PrintExceptionFrame0(FILE *, StackData&); + void PrintExceptionFrame2(FILE *, StackData&); + void PrintExceptionFrame3(FILE *, StackData&); + void PrintExceptionFrame4(FILE *, StackData&); + void PrintExceptionFrame7(FILE *, StackData&); + void PrintExceptionFrameB(FILE *, StackData&); + + void PrintFPFrame6888xIdle(FILE *, StackData&, uint32 len); + void PrintFPFrame6888xBusy(FILE *, StackData&, uint32 len); + void PrintFPFrame68040Unimpl(FILE *, StackData&, uint base); + void PrintFPFrame68040Busy(FILE *, StackData&); - uint32 so_a7 = 0; // ステップアウト判定用 - uint16 so_sr = 0; + uint32 so_a7 {}; // ステップアウト判定用 + uint16 so_sr {}; };