--- nono/debugger/branchhistory.h 2026/04/29 17:04:43 1.1 +++ nono/debugger/branchhistory.h 2026/04/29 17:05:09 1.1.1.3 @@ -4,11 +4,14 @@ // Licensed under nono-license.txt // +// // ブランチ履歴 +// #pragma once #include "object.h" +#include "monitor.h" // MPU に依存しないブランチ履歴。 // @@ -23,6 +26,8 @@ class BranchHistory : public Object { + using inherited = Object; + protected: struct BranchEntry { uint32 count; // 連続通過回数 @@ -32,12 +37,15 @@ class BranchHistory : public Object } __packed; public: + // コンストラクタで指定する種別 (bool に名前を付けたいだけ) + static const bool BrHist = false; // ブランチ履歴 (例外も含む) + static const bool ExHistOnly = true; // 例外履歴(のみ) + // 表示系フラグ - static const uint64 ExHist = (1ULL << 63); // ヘッダを例外履歴に - static const uint64 BottomToTop = (1ULL << 62); // 新しい方を下に + static const uint64 BottomToTop = (1ULL << 63); // 新しい方を下に public: - BranchHistory(); + BranchHistory(bool is_exhist_); virtual ~BranchHistory() override; // 初期化 @@ -63,8 +71,6 @@ class BranchHistory : public Object return *e; } - void MonitorUpdate(TextScreen&) override; - // 使用中のエントリ数を取得する int GetUsed() const; @@ -73,8 +79,16 @@ class BranchHistory : public Object // 直近に使用した位置 uint8 top {}; + // モニター (デバッガから直接参照する) + Monitor monitor { this }; + protected: virtual std::string FormatEntry(const BranchEntry& e) = 0; + + DECLARE_MONITOR_CALLBACK(MonitorUpdate); + + // 例外履歴かどうか。ヘッダ行が違う。 + bool is_exhist {}; }; // @@ -85,7 +99,7 @@ class BranchHistory_m680x0 : public Bran { using inherited = BranchHistory; public: - BranchHistory_m680x0(); + BranchHistory_m680x0(bool mode); virtual ~BranchHistory_m680x0() override; std::string FormatEntry(const BranchEntry& e) override; @@ -99,7 +113,7 @@ class BranchHistory_m88xx0 : public Bran { using inherited = BranchHistory; public: - BranchHistory_m88xx0(); + BranchHistory_m88xx0(bool mode); virtual ~BranchHistory_m88xx0() override; std::string FormatEntry(const BranchEntry& e) override;