1mod debuginfo;
2
3use clap::{Subcommand, ValueEnum};
4use miden_mast_package::PackageDebugInfoError;
5
6#[derive(Debug, Subcommand)]
8#[command(name = "debuginfo", rename_all = "kebab-case")]
9pub enum Dump {
10 DebugInfo(debuginfo::Config),
12}
13
14#[derive(Debug, Clone, Copy, ValueEnum)]
16pub enum Section {
17 Strings,
19 Types,
21 Files,
23 Functions,
25 Variables,
27 Locations,
29}
30
31#[derive(Debug, thiserror::Error)]
32pub enum DumpError {
33 #[error("failed to read file: {0}")]
34 Io(#[from] std::io::Error),
35 #[error("failed to parse package: {0}")]
36 Parse(String),
37 #[error("no debug_info section found in package")]
38 NoDebugInfo,
39 #[error(transparent)]
40 InvalidDebugInfo(#[from] PackageDebugInfoError),
41}
42
43impl From<miden_core::serde::DeserializationError> for DumpError {
44 #[inline]
45 fn from(err: miden_core::serde::DeserializationError) -> Self {
46 Self::Parse(err.to_string())
47 }
48}
49
50pub fn run(command: &Dump) -> Result<(), DumpError> {
51 match command {
52 Dump::DebugInfo(config) => debuginfo::dump(config),
53 }
54}