--- nono/debugger/branchhistory.cpp 2026/04/29 17:05:41 1.1.1.11 +++ nono/debugger/branchhistory.cpp 2026/04/29 17:05:58 1.1.1.13 @@ -48,7 +48,7 @@ BranchHistory::BranchHistory(uint objid_ vectortable = GetVectorTable(); monitor = gMonitorManager->Regist(monitor_id, this); - monitor->func = ToMonitorCallback(&BranchHistory::MonitorUpdate); + monitor->SetCallback(&BranchHistory::MonitorScreen); monitor->SetSize(55, 1 + 32); // ヘッダ1行とエントリ数 monitor->SetMaxHeight(1 + 256); @@ -92,7 +92,7 @@ BranchHistory::GetUsed() const // モニタ更新 void -BranchHistory::MonitorUpdate(Monitor *, TextScreen& screen) +BranchHistory::MonitorScreen(Monitor *, TextScreen& screen) { uint8 t; int y; @@ -190,18 +190,26 @@ BranchHistory::FormatHeader() const // |1 1| 0 | 0 | Vector No. | // +-+-+-----------+---------------+---------------+---------------+ // -// 3. 例外発生 (IOCS/DOS コールの場合): +// 3. 例外発生 (各種サービスコールの場合): // from, to は同じ。 // info は上位2ビットが %10 (ServiceCall)。 -// IOCS コールなら、b8 が %0 で b7-b0 に IOCS コール番号。 -// DOS コールなら、b8 が %1 で b7-b0 に DOS コール番号。 -// -// +-+-+-----------+---------------+---------------+---------------+ -// |1 0| 0 | 0 |0| IOCS Call No. | -// +-+-+-----------+---------------+---------------+---------------+ -// +-+-+-----------+---------------+---------------+---------------+ -// |1 0| 0 | - |1| DOS Call No. | -// +-+-+-----------+---------------+---------------+---------------+ +// info の上位ワードが OS 種別。 +// $0 なら Human68k +// $1 なら NetBSD/m68k +// Human68k なら下位ワードは +// IOCS コールなら、b8 が %0 で b7-b0 に IOCS コール番号。 +// DOS コールなら、b8 が %1 で b7-b0 に DOS コール番号。 +// NetBSD/m68k なら下位ワードはシステムコール番号。 +// +// +-+-+-----------+-------------+-+---------------+---------------+ +// |1 0| $0| 0 |0| IOCS Call No. | +// +-+-+-----------+-------------+-+---------------+---------------+ +// +-+-+-----------+-------------+-+---------------+---------------+ +// |1 0| $0| - |1| DOS Call No. | +// +-+-+-----------+-------------+-+---------------+---------------+ +// +-+-+-----------+-------------+-+---------------+---------------+ +// |1 0| $1| System Call No. | +// +-+-+-----------+-------------+-+---------------+---------------+ // // 4. 例外ベクタによる分岐 (例外処理の最後に起きる): // from はベクタアドレス、 @@ -228,7 +236,7 @@ std::string BranchHistory_m680x0::FormatEntry(const BranchEntry& e) { // m68k では from の最下位1ビットを S/U として使う - std::string desc = string_format("%c:%08x", + std::string desc = string_format("%c.%08x", (e.from & 1) ? 'S' : 'U', (e.from & ~1)); switch (e.info >> 30) { @@ -274,23 +282,32 @@ BranchHistory_m680x0::FormatEntry(const case 2: // 例外発生 (IOCS/DOS コール) { - const char *call; - const char *name; uint vector; - uint num = e.info & 0xff; - if ((e.info & 0x0100) == 0) { - call = "IOCS"; - name = m680x0disasm::GetIOCSName(num); - vector = M68K::EXCEP_TRAP15; - } else { - call = "DOS"; - name = m680x0disasm::GetDOSName(num); - vector = M68K::EXCEP_FLINE; - } - if (name != NULL) { - desc += string_format("<%3u> %s %s", vector, call, name); + if (((e.info >> 16) & 0x01) == 0) { + // Human68k、IOCS/DOS コール + const char *call; + const char *name; + uint num = e.info & 0xff; + if ((e.info & 0x0100) == 0) { + call = "IOCS"; + name = m680x0disasm::GetIOCSName(num); + vector = M68K::EXCEP_TRAP15; + } else { + call = "DOS"; + name = m680x0disasm::GetDOSName(num); + vector = M68K::EXCEP_FLINE; + } + if (name != NULL) { + desc += string_format("<%3u> %s %s", vector, call, name); + } else { + desc += string_format("<%3u> %s $%02x", vector, call, num); + } } else { - desc += string_format("<%3u> %s $%02x", vector, call, num); + // NetBSD/m68k システムコール + vector = M68K::EXCEP_TRAP0; + const char *name = vectortable->GetExceptionName(vector); + uint num = e.info & 0xffff; + desc += string_format("<%3u> %s (syscall %u)", vector, name, num); } break; } @@ -325,7 +342,7 @@ BranchHistory_m680x0::FormatEntry(const // // 例外発生: // from は上位30ビットが例外発生時の XIP、最下位ビットが S/U、 -// to は 0。 +// to は不問。 // info は、9 ビットのベクタ番号と、ベクタが OpenBSD/m88k システムコール // の場合はシステムコール番号を含む。 // 3 2 1 0 @@ -351,10 +368,10 @@ std::string BranchHistory_m88xx0::FormatEntry(const BranchEntry& e) { // m88k では from の最下位1ビットを S/U として使う - std::string desc = string_format("%c:%08x", + std::string desc = string_format("%c.%08x", (e.from & 1) ? 'S' : 'U', (e.from & ~1)); - if (e.info >= 0xfc000000 && e.to == 0) { + if (e.info >= 0xfc000000) { // 例外発生記録 // 発生アドレスとベクタを表示 uint32 vector = e.info & 0x1ff;