feat(diagnostics): preserve Registry and resource fault context for PLN-0176 step 28
This commit is contained in:
@@ -2,10 +2,11 @@ use base64::{Engine as _, engine::general_purpose::STANDARD};
|
||||
use prometeu_bytecode::Value as VmValue;
|
||||
use prometeu_hal::InputSignals;
|
||||
use prometeu_system::CrashReport;
|
||||
use prometeu_vm::VmInitError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
use std::io;
|
||||
#[cfg(test)]
|
||||
mod fault_tests;
|
||||
|
||||
use crate::{CapturedFrame, HostError, HostExecutionStatus, HostState};
|
||||
|
||||
@@ -282,24 +283,13 @@ pub(super) fn fault(report: &CrashReport) -> Value {
|
||||
match report {
|
||||
CrashReport::VmTrap { trap } => {
|
||||
result["trap"] = json!({"code":trap.code,"opcode":trap.opcode,
|
||||
"message":trap.message,"pc":trap.pc,"span":trap.span});
|
||||
"message":trap.message,"pc":trap.pc,"span":trap.span,"resource":trap.resource});
|
||||
}
|
||||
CrashReport::VmPanic { message, .. } => {
|
||||
result["message"] = json!(message);
|
||||
}
|
||||
CrashReport::VmInit { error } => {
|
||||
let code = match error {
|
||||
VmInitError::RegistryLoadFailed(_) => "registry_load_failed",
|
||||
VmInitError::RuntimeResourceLimit(_) => "runtime_resource_limit",
|
||||
VmInitError::InvalidFormat => "invalid_format",
|
||||
VmInitError::UnsupportedFormat => "unsupported_format",
|
||||
VmInitError::ImageLoadFailed(_) => "image_load_failed",
|
||||
VmInitError::LoaderPatchFailed(_) => "loader_patch_failed",
|
||||
VmInitError::EntrypointNotFound => "entrypoint_not_found",
|
||||
VmInitError::EntrypointArgumentsInvalid { .. } => "entrypoint_arguments_invalid",
|
||||
VmInitError::VerificationFailed(_) => "verification_failed",
|
||||
};
|
||||
result["initError"] = json!({"code":code,"message":format!("{error:?}")});
|
||||
CrashReport::VmInit { .. } => {
|
||||
result["initError"] = report.init_diagnostic().expect("initialization report");
|
||||
}
|
||||
}
|
||||
result
|
||||
|
||||
Reference in New Issue
Block a user