From 4ec5535f77966370827e0d43bd4252cefbc49e87 Mon Sep 17 00:00:00 2001 From: Kamal Tufekcic Date: Mon, 27 Jul 2026 11:22:21 +0300 Subject: [PATCH] add additional logging --- src/produce.rs | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/produce.rs b/src/produce.rs index 51e4109..f0656fb 100644 --- a/src/produce.rs +++ b/src/produce.rs @@ -1205,25 +1205,36 @@ pub(crate) fn launch_bots_server( logpath.display() ); } - if let Ok(live) = live::LiveProcess::attach(pid) - && let Some(base) = live.base(lib) - { - let insts = live.find_instances(ready_vt.slot0 + base, 64); - let ready = match pawn_health { - Some(health) => insts - .into_iter() - .any(|o| live.read_i32(o + health).unwrap_or(0) > 0), - None => !insts.is_empty(), - }; - if ready { - return Ok(OwnedServer { child, pid }); // ready — detach the poll handle, hand off the child - } - } + // Each failure mode records WHY. Reporting only "not ready" conflates three very different causes — + // memory unreadable, the library never mapped, and the instance simply not spawned yet — and leaves + // the operator guessing at which. + let why = match live::LiveProcess::attach(pid) { + Err(e) => format!("cannot read pid {pid}'s memory: {e:#}"), + Ok(live) => match live.base(lib) { + None => format!("{lib} is not mapped in pid {pid}"), + Some(base) => { + let insts = live.find_instances(ready_vt.slot0 + base, 64); + let ready = match pawn_health { + Some(health) => insts + .iter() + .any(|&o| live.read_i32(o + health).unwrap_or(0) > 0), + None => !insts.is_empty(), + }; + if ready { + return Ok(OwnedServer { child, pid }); // ready — hand off the child + } + match pawn_health { + Some(_) => format!("{} instance(s) found, none alive", insts.len()), + None => "no instance found".to_string(), + } + } + }, + }; if std::time::Instant::now() >= deadline { let _ = child.kill(); let _ = child.wait(); anyhow::bail!( - "not ready within {wait}s — check {} (server up? map/bots loaded?)", + "not ready within {wait}s ({why}) — check {} (server up? map/bots loaded?)", logpath.display() ); }