diff options
| author | Glenn Smith <glenn@vector35.com> | 2024-06-08 14:21:37 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2024-06-10 17:13:55 -0400 |
| commit | 3868101044631138291829168446412164679307 (patch) | |
| tree | f6d6e9a30211572aa2091904a74185f58a288b84 /rust/src/types.rs | |
| parent | 26afbd71f0b5bfd6584b58ae62093ac25afacdcb (diff) | |
Alternate fmt::Debug for Type with even more debug info
Diffstat (limited to 'rust/src/types.rs')
| -rw-r--r-- | rust/src/types.rs | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/rust/src/types.rs b/rust/src/types.rs index 29cdb2d3..b42c7039 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -31,6 +31,7 @@ use crate::{ }; use lazy_static::lazy_static; +use std::ptr::null_mut; use std::{ borrow::{Borrow, Cow}, collections::{HashMap, HashSet}, @@ -1224,17 +1225,33 @@ impl fmt::Debug for Type { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Ok(lock) = TYPE_DEBUG_BV.lock() { if let Some(bv) = &*lock { - let mut count: usize = 0; let container = unsafe { BNGetAnalysisTypeContainer(bv.handle) }; - let lines: *mut BNTypeDefinitionLine = unsafe { - BNGetTypeLines( + + let printer = if f.alternate() { + unsafe { BNGetTypePrinterByName(c"_DebugTypePrinter".as_ptr()) } + } else { + unsafe { BNGetTypePrinterByName(c"CoreTypePrinter".as_ptr()) } + }; + if printer.is_null() { + return Err(fmt::Error); + } + + let mut name = QualifiedName::from(""); + + let mut lines: *mut BNTypeDefinitionLine = null_mut(); + let mut count: usize = 0; + + unsafe { + BNGetTypePrinterTypeLines( + printer, self.handle, container, - "\x00".as_ptr() as *const c_char, + &mut name.0, 64, false, BNTokenEscapingType::NoTokenEscapingType, - &mut count as *mut usize, + &mut lines, + &mut count, ) }; unsafe { |
