mod debuginfo;
use clap::{Subcommand, ValueEnum};
use miden_mast_package::PackageDebugInfoError;
#[derive(Debug, Subcommand)]
#[command(name = "debuginfo", rename_all = "kebab-case")]
pub enum Dump {
DebugInfo(debuginfo::Config),
}
#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum Section {
Strings,
Types,
Files,
Functions,
Variables,
Locations,
}
#[derive(Debug, thiserror::Error)]
pub enum DumpError {
#[error("failed to read file: {0}")]
Io(#[from] std::io::Error),
#[error("failed to parse package: {0}")]
Parse(String),
#[error("no debug_info section found in package")]
NoDebugInfo,
#[error(transparent)]
InvalidDebugInfo(#[from] PackageDebugInfoError),
}
impl From<miden_core::serde::DeserializationError> for DumpError {
#[inline]
fn from(err: miden_core::serde::DeserializationError) -> Self {
Self::Parse(err.to_string())
}
}
pub fn run(command: &Dump) -> Result<(), DumpError> {
match command {
Dump::DebugInfo(config) => debuginfo::dump(config),
}
}