Skip to main content

miden_objtool/
dump.rs

1mod debuginfo;
2
3use clap::{Subcommand, ValueEnum};
4
5/// Dump useful information from assembled Miden packages
6#[derive(Debug, Subcommand)]
7#[command(name = "debuginfo", rename_all = "kebab-case")]
8pub enum Dump {
9    /// Dump debug information encoded in a .masp file
10    DebugInfo(debuginfo::Config),
11}
12
13/// The set of known sections that we've added dump support for
14#[derive(Debug, Clone, Copy, ValueEnum)]
15pub enum Section {
16    /// Show string table
17    Strings,
18    /// Show type information
19    Types,
20    /// Show source file information
21    Files,
22    /// Show function debug information
23    Functions,
24    /// Show variable information within functions
25    Variables,
26    /// Show variable location decorators from MAST (similar to DWARF .debug_loc)
27    Locations,
28}
29
30#[derive(Debug, thiserror::Error)]
31pub enum DumpError {
32    #[error("failed to read file: {0}")]
33    Io(#[from] std::io::Error),
34    #[error("failed to parse package: {0}")]
35    Parse(String),
36    #[error("no debug_info section found in package")]
37    NoDebugInfo,
38}
39
40impl From<miden_core::serde::DeserializationError> for DumpError {
41    #[inline]
42    fn from(err: miden_core::serde::DeserializationError) -> Self {
43        Self::Parse(err.to_string())
44    }
45}
46
47pub fn run(command: &Dump) -> Result<(), DumpError> {
48    match command {
49        Dump::DebugInfo(config) => debuginfo::dump(config),
50    }
51}