aconfig: add 'verbose' dump format
Add a new --format=verbose dump output format. This is identical to the
default 'text' format but includes the source files from which the flag
declaration and values were read, and is intended to help debug why a
flag isn't set to some expected value.
Bug: 283910447
Test: atest aconfig.test
Test: printflags --format=verbose # manually inspect output
Change-Id: I03a1c8d940e7a0c6f91e986c5bafa4aa6cd1125a
diff --git a/tools/aconfig/src/commands.rs b/tools/aconfig/src/commands.rs
index 5ca53a7..4f0a706 100644
--- a/tools/aconfig/src/commands.rs
+++ b/tools/aconfig/src/commands.rs
@@ -213,6 +213,7 @@
#[derive(Copy, Clone, Debug, PartialEq, Eq, ValueEnum)]
pub enum DumpFormat {
Text,
+ Verbose,
Protobuf,
Textproto,
}
@@ -237,6 +238,21 @@
output.extend_from_slice(line.as_bytes());
}
}
+ DumpFormat::Verbose => {
+ for parsed_flag in parsed_flags.parsed_flag.into_iter() {
+ let sources: Vec<_> =
+ parsed_flag.trace.iter().map(|tracepoint| tracepoint.source()).collect();
+ let line = format!(
+ "{}/{}: {:?} + {:?} ({})\n",
+ parsed_flag.package(),
+ parsed_flag.name(),
+ parsed_flag.permission(),
+ parsed_flag.state(),
+ sources.join(", ")
+ );
+ output.extend_from_slice(line.as_bytes());
+ }
+ }
DumpFormat::Protobuf => {
parsed_flags.write_to_vec(&mut output)?;
}