--- nono/debugger/branchhistory.h 2026/04/29 17:05:28 1.1.1.7 +++ nono/debugger/branchhistory.h 2026/04/29 17:05:41 1.1.1.9 @@ -11,7 +11,6 @@ #pragma once #include "object.h" -#include "monitor.h" class VectorTable; @@ -35,7 +34,7 @@ class BranchHistory : public Object uint32 count; // 連続通過回数 uint32 from; // ジャンプ元アドレス(VA) uint32 to; // ジャンプ先アドレス(VA) - uint32 inst; // ジャンプ元命令や例外情報など (機種による↓) + uint32 info; // ジャンプ元命令や例外情報など (機種による) } __packed; public: @@ -51,7 +50,7 @@ class BranchHistory : public Object // エントリを追加。 // エントリを返す。 - const BranchEntry& AddEntry(uint32 from, uint32 to, uint32 inst) { + const BranchEntry& AddEntry(uint32 from, uint32 to, uint32 info) { BranchEntry *e = &entry[top]; if (e->from == from && e->to == to) { @@ -64,7 +63,7 @@ class BranchHistory : public Object e->count = 1; e->from = from; e->to = to; - e->inst = inst; + e->info = info; } return *e; } @@ -78,7 +77,7 @@ class BranchHistory : public Object uint8 top {}; // モニタ (デバッガから直接参照する) - Monitor monitor { this }; + Monitor *monitor {}; protected: virtual std::string FormatHeader() const; @@ -102,16 +101,33 @@ class BranchHistory : public Object class BranchHistory_m680x0 : public BranchHistory { using inherited = BranchHistory; - public: - // inst の分岐種別 - static const uint32 Normal = 0x00000000; // 通常分岐 - static const uint32 VectorJump = 0x40000000; // ベクタによる分岐 - static const uint32 IOCSCall = 0x80000000; // IOCS コール - static const uint32 Exception = 0xc0000000; // 例外発生 + + // info の分岐種別 + static constexpr uint32 NORMAL = 0x00000000; // 通常分岐 + static constexpr uint32 VECTORJUMP = 0x40000000; // ベクタによる分岐 + static constexpr uint32 SERVICECALL = 0x80000000; // IOCS/DOS コール + static constexpr uint32 EXCEPTION = 0xc0000000; // 例外発生 + public: explicit BranchHistory_m680x0(uint objid_); ~BranchHistory_m680x0() override; + static constexpr uint32 InfoNormal(uint16 inst) { + return NORMAL | inst; + } + static constexpr uint32 InfoVectorJump() { + return VECTORJUMP; + } + static constexpr uint32 InfoException(uint8 vector) { + return EXCEPTION | vector; + } + static constexpr uint32 InfoIOCSCall(uint8 num) { + return SERVICECALL | num; + } + static constexpr uint32 InfoDOSCall(uint16 ir) { + return SERVICECALL | ir; + } + std::string FormatEntry(const BranchEntry& e) override; };