--- nono/debugger/branchhistory.cpp 2026/04/29 17:04:51 1.1.1.3 +++ nono/debugger/branchhistory.cpp 2026/04/29 17:05:09 1.1.1.5 @@ -4,16 +4,31 @@ // Licensed under nono-license.txt // +// // ブランチ履歴 +// #include "branchhistory.h" #include "m68030core.h" #include "m88100.h" +#include "vectortable.h" // コンストラクタ -BranchHistory::BranchHistory() +BranchHistory::BranchHistory(bool is_exhist_) + : inherited(is_exhist_ ? "(ExceptionHistory)" : "(BranchHistory)") { - monitor_size = nnSize(55, 33); + is_exhist = is_exhist_; + + // ログは不要 + ClearAlias(); + + monitor.func = ToMonitorCallback(&BranchHistory::MonitorUpdate); + monitor.SetSize(55, 33); + if (is_exhist) { + monitor.Regist(ID_SUBWIN_EXHIST); + } else { + monitor.Regist(ID_SUBWIN_BRHIST); + } } // デストラクタ @@ -52,7 +67,7 @@ BranchHistory::GetUsed() const // モニタ更新 void -BranchHistory::MonitorUpdate(TextScreen& monitor) +BranchHistory::MonitorUpdate(Monitor *, TextScreen& screen) { uint8 t; int y; @@ -61,13 +76,10 @@ BranchHistory::MonitorUpdate(TextScreen& // userdata は表示開始位置と各種フラグ。 // 下位 32bit が表示開始位置で、0 なら先頭のエントリから、1 なら先頭の - // 一つ次のエントリから、…を表す (表示行数は monitor の高さ分)。 - // ExHist が %1 なら例外履歴、%0 ならブランチ履歴。これによって - // ヘッダを変えたい。 + // 一つ次のエントリから、…を表す (表示行数は screen の高さ分)。 // BottomToTop が %1 なら並び順を下から上に変える (コンソール用)。 - bool is_exhist = (monitor.userdata & ExHist); - bool bottom_to_top = (monitor.userdata & BottomToTop); - int pos = (int)monitor.userdata; + bool bottom_to_top = (screen.userdata & BottomToTop); + int pos = (int)screen.userdata; // 0 1 2 3 4 5 6 // 0123456789012345678901234567890123456789012345678901234567890123456789 @@ -78,16 +90,16 @@ BranchHistory::MonitorUpdate(TextScreen& // 002 S:01234567< 69> MFP Timer-C // 01234567890123456789012 - monitor.Clear(); - row = monitor.GetRow(); + screen.Clear(); + row = screen.GetRow(); // 最初の1行は常にヘッダ if (is_exhist) { - monitor.Print(0, 0, "No. FromAddr Vec. Exception"); - monitor.Print(45, 0, "Iteration"); + screen.Print(0, 0, "No. FromAddr Vec. Exception"); + screen.Print(45, 0, "Iteration"); } else { - monitor.Print(0, 0, "No. FromAddr Instruction"); - monitor.Print(35, 0, "ToAddr Iteration"); + screen.Print(0, 0, "No. FromAddr Instruction"); + screen.Print(35, 0, "ToAddr Iteration"); } // pos は最新を 0 とした通し番号。(スクロールしてたら開始が 0 とは限らない) @@ -108,9 +120,9 @@ BranchHistory::MonitorUpdate(TextScreen& continue; } std::string str = FormatEntry(e); - monitor.Print(0, y, "%3d %s", pos, str.c_str()); + screen.Print(0, y, "%3d %s", pos, str.c_str()); if (e.count > 1) { - monitor.Print(45, y, "x%9u", e.count); + screen.Print(45, y, "x%9u", e.count); } } } @@ -146,7 +158,8 @@ BranchHistory::MonitorUpdate(TextScreen& // inst が $00008000 と一致することで区別する (ビットが立っているではない)。 // コンストラクタ -BranchHistory_m680x0::BranchHistory_m680x0() +BranchHistory_m680x0::BranchHistory_m680x0(bool mode_) + : inherited(mode_) { } @@ -172,8 +185,8 @@ BranchHistory_m680x0::FormatEntry(const vector = 0; } // とりあえず - desc += string_format("<%3d> %s", vector, - m68030_get_exception_name(vector)); + const char *name = gVectorTable->GetExceptionName(vector); + desc += string_format("<%3d> %s", vector, name ?: ""); // XXX TODO 割り込みレベル } else { // 例外ベクタフェッチしてジャンプ @@ -236,7 +249,8 @@ BranchHistory_m680x0::FormatEntry(const // 命令ワードとは衝突しない (instruction.txt 参照)。 // コンストラクタ -BranchHistory_m88xx0::BranchHistory_m88xx0() +BranchHistory_m88xx0::BranchHistory_m88xx0(bool mode_) + : inherited(mode_) { } @@ -257,7 +271,7 @@ BranchHistory_m88xx0::FormatEntry(const // 例外発生記録 // 発生アドレスとベクタを表示 uint32 vector = e.inst & 0x1ff; - const char *name = m88kcpu::GetExceptionName(vector); + const char *name = gVectorTable->GetExceptionName(vector); desc += string_format("<%3d> %s", vector, name ?: ""); if (vector == 450) { // OpenBSD のシステムコール番号