feat(usym): Add in a formatter for UsymSourceRecords that makes them user-readable
There're a few fields on the struct that don't normally print
out very nicely (ie string byte slices), so this customizes
the formatter to make them human-readable during
debugging.
@@ -214,6 +214,34 @@ pub enum UsymSourceRecord<'a> {
Mapped(MappedRecord<'a>),
}
+impl<'data> std::fmt::Debug for UsymSourceRecord<'data> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let mut formatter = f.debug_struct("UsymSourceRecord");
+ match &self {
+ UsymSourceRecord::Unmapped(record) => formatter
+ .field("address", &record.address)
+ .field(
+ "symbol",
+ &String::from_utf8_lossy(record.native_symbol_bytes),
+ )
+ .field("file", &record.native_file_info.path_str())
+ .field("line", &record.native_line),
+ UsymSourceRecord::Mapped(record) => formatter
+ .field("address", &record.address)
+ .field(
+ "native_symbol",
+ &String::from_utf8_lossy(record.native_symbol_bytes),
+ )
+ .field("native_file", &record.native_file_info.path_str())
+ .field("native_line", &record.native_line)
+ .field("managed_symbol", &record.managed_symbol)
+ .field("managed_file", &record.managed_file_info.path_str())
+ .field("managed_line", &record.managed_line),
+ };
+ formatter.finish()
+ }
+}
+
/// A usym file containing data on how to map native code generated by Unity's IL2CPP back to their
/// C# (i.e. managed) equivalents.
pub struct UsymSymbols<'a> {
