--- nono/debugger/branchhistory.h 2026/04/29 17:04:43 1.1 +++ nono/debugger/branchhistory.h 2026/04/29 17:05:28 1.1.1.7 @@ -4,11 +4,16 @@ // Licensed under nono-license.txt // +// // ブランチ履歴 +// #pragma once #include "object.h" +#include "monitor.h" + +class VectorTable; // MPU に依存しないブランチ履歴。 // @@ -23,6 +28,8 @@ class BranchHistory : public Object { + using inherited = Object; + protected: struct BranchEntry { uint32 count; // 連続通過回数 @@ -33,12 +40,11 @@ class BranchHistory : public Object public: // 表示系フラグ - static const uint64 ExHist = (1ULL << 63); // ヘッダを例外履歴に - static const uint64 BottomToTop = (1ULL << 62); // 新しい方を下に + static const uint64 BottomToTop = (1ULL << 63); // 新しい方を下に public: - BranchHistory(); - virtual ~BranchHistory() override; + explicit BranchHistory(uint objid_); + ~BranchHistory() override; // 初期化 void Clear(); @@ -63,8 +69,6 @@ class BranchHistory : public Object return *e; } - void MonitorUpdate(TextScreen&) override; - // 使用中のエントリ数を取得する int GetUsed() const; @@ -73,8 +77,22 @@ class BranchHistory : public Object // 直近に使用した位置 uint8 top {}; + // モニタ (デバッガから直接参照する) + Monitor monitor { this }; + protected: + virtual std::string FormatHeader() const; virtual std::string FormatEntry(const BranchEntry& e) = 0; + + DECLARE_MONITOR_CALLBACK(MonitorUpdate); + + // 例外履歴かどうか。ヘッダ行が違う。 + bool is_exhist {}; + + // カウンタの表示開始座標 (HD64180 だけ違うため) + int x_count {}; + + VectorTable *vectortable {}; }; // @@ -85,8 +103,14 @@ class BranchHistory_m680x0 : public Bran { using inherited = BranchHistory; public: - BranchHistory_m680x0(); - virtual ~BranchHistory_m680x0() override; + // inst の分岐種別 + static const uint32 Normal = 0x00000000; // 通常分岐 + static const uint32 VectorJump = 0x40000000; // ベクタによる分岐 + static const uint32 IOCSCall = 0x80000000; // IOCS コール + static const uint32 Exception = 0xc0000000; // 例外発生 + public: + explicit BranchHistory_m680x0(uint objid_); + ~BranchHistory_m680x0() override; std::string FormatEntry(const BranchEntry& e) override; }; @@ -99,8 +123,25 @@ class BranchHistory_m88xx0 : public Bran { using inherited = BranchHistory; public: - BranchHistory_m88xx0(); - virtual ~BranchHistory_m88xx0() override; + explicit BranchHistory_m88xx0(uint objid_); + ~BranchHistory_m88xx0() override; std::string FormatEntry(const BranchEntry& e) override; }; + +// +// HD64180 ブランチ履歴 +// +class BranchHistory_hd64180 : public BranchHistory +{ + using inherited = BranchHistory; + public: + explicit BranchHistory_hd64180(uint objid_); + ~BranchHistory_hd64180() override; + + std::string FormatHeader() const override; + std::string FormatEntry(const BranchEntry& e) override; + + private: + static std::string fstr(int); +};