--- nono/debugger/debugger.cpp 2026/04/29 17:05:28 1.1.1.16 +++ nono/debugger/debugger.cpp 2026/04/29 17:05:45 1.1.1.19 @@ -63,9 +63,9 @@ Debugger::Debugger() pVectorTable.reset(new VectorTable(gMainApp.GetVMType())); // ブレークポイントモニタ - bpoint_monitor.func = ToMonitorCallback(&Debugger::MonitorUpdateBpoint); - bpoint_monitor.SetSize(60, 9); - bpoint_monitor.Regist(ID_MONITOR_BREAKPOINT); + bpoint_monitor = gMonitorManager->Regist(ID_MONITOR_BREAKPOINT, this); + bpoint_monitor->func = ToMonitorCallback(&Debugger::MonitorUpdateBpoint); + bpoint_monitor->SetSize(60, 9); // メモリダンプモニタ for (int i = 0, end = memdump_monitor.size(); i < end; i++) { @@ -92,7 +92,7 @@ Debugger::~Debugger() Close(); if ((bool)hostcom) { - hostcom->SetRxCallback(NULL); + hostcom->ResetRxCallback(); hostcom->SetAcceptCallback(NULL); } @@ -103,12 +103,15 @@ bool Debugger::Create() { // ホストドライバを作成 - hostcom.reset(new HostCOMDevice(this, "Debugger")); + try { + hostcom.reset(new HostCOMDevice(this, -1, "Debugger")); + } catch (...) { } if ((bool)hostcom == false) { + warnx("Failed to initialize HostCOMDevice at %s", __method__); return false; } - hostcom->SetRxCallback(ToDeviceCallback(&Debugger::RxCallback)); + hostcom->SetRxCallback(ToDeviceCallback(&Debugger::RxCallback), 0); hostcom->SetAcceptCallback(ToDeviceCallback(&Debugger::AcceptCallback)); return true; @@ -136,14 +139,28 @@ Debugger::Init() syncer = GetSyncer(); - if (gMainApp.Has(VMCap::M88K)) { - md_mpu.reset(new DebuggerMD_m88xx0(this)); - } else { - md_mpu.reset(new DebuggerMD_m680x0(this)); + try { + if (gMainApp.Has(VMCap::M88K)) { + md_mpu.reset(new DebuggerMD_m88xx0(this)); + } else { + md_mpu.reset(new DebuggerMD_m680x0(this)); + } + } catch (...) { } + if ((bool)md_mpu == false) { + warnx("Failed to initialize md_mpu at %s", __method__); + return false; } + if (gMainApp.Has(VMCap::LUNA)) { - md_xp.reset(new DebuggerMD_hd64180(this)); + try { + md_xp.reset(new DebuggerMD_hd64180(this)); + } catch (...) { } + if ((bool)md_xp == false) { + warnx("Failed to initialize md_xp at %s", __method__); + return false; + } } + // とりあえずメインプロセッサに固定 curmd = md_mpu.get(); @@ -202,7 +219,14 @@ Debugger::Init() } // を取り出す - if (!ParseVerbHex(addrstr.c_str(), &bp.addr)) { + if (ParseVerbHex(addrstr.c_str(), &bp.addr)) { + bp.type = BreakpointType::Address; + } else if (addrstr[0] == 'v' + && ParseVector( + ParseCPU(cpustr), &(addrstr.c_str()[1]), (uint32 *)&bp.vec1)) { + bp.type = BreakpointType::Exception; + bp.vec2 = bp.vec1; + } else { warnx("\"%s\": Invalid breakpoint address", str.c_str()); return false; } @@ -211,7 +235,6 @@ Debugger::Init() bp.skip = atoi(skipstr.c_str()); } // 登録 - bp.type = BreakpointType::Address; AddBreakpoint(bp, cpustr); } @@ -398,7 +421,7 @@ Debugger::WriteFunc(const char *buf, int // ホストからの1文字受信通知 (HostCOM スレッドから呼ばれる) void -Debugger::RxCallback() +Debugger::RxCallback(uint32 arg) { // デバッガスレッドに通知 std::unique_lock lock(mtx); @@ -408,7 +431,7 @@ Debugger::RxCallback() // ホストからの着信通知 (HostCOM スレッドから呼ばれる) void -Debugger::AcceptCallback() +Debugger::AcceptCallback(uint32 dummy) { // デバッガスレッドに通知 std::unique_lock lock(mtx); @@ -2013,10 +2036,9 @@ Debugger::cmd_hist_common(BranchHistory& int lines = std::min(used, maxlines) + 1; // MonitorUpdate() は TextScreen 高さに合わせて出力してくれる。 - auto& histmon = hist.monitor; - auto size = histmon.GetSize(); + auto *histmon = hist.monitor; TextScreen screen; - screen.Init(size.width, lines); + screen.Init(histmon->GetCol(), lines); // コンソールでは下が新しいの順のほうがいい if (bottom_to_top) { @@ -2645,7 +2667,7 @@ Debugger::cmd_show() fprintf(cons, "unknown monitor name: \"%s\"\n", name.c_str()); } else if (candidates.size() == 1) { // 確定した - Monitor& mon = *(candidates[0]); + Monitor *mon = candidates[0]; ShowMonitor(mon); } else { // 候補が複数あった @@ -2663,12 +2685,12 @@ Debugger::cmd_show() // モニタを更新して表示。 void -Debugger::ShowMonitor(Monitor& monitor) +Debugger::ShowMonitor(Monitor *monitor) { // モニタを更新 TextScreen ts; - auto size = monitor.GetSize(); + auto size = monitor->GetSize(); ts.Init(size.width, size.height); MONITOR_UPDATE(monitor, ts); @@ -2861,11 +2883,6 @@ Debugger::ParseAddr(const char *arg, uin uint64 r; r = curmd->GetRegAddr(arg + 1); if ((int64)r < 0) { -#if 0 // not yet - fprintf(cons, "valid register name are: %s%s\n", - "%d0-%d7,%a0-%a7,%sp,%usp,%isp,%pc", - ",%msp,%vbr,%srp,%crp"); -#endif fprintf(cons, "invalid register name\n"); return false; }