1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
extern crate gimli; #[macro_use] extern crate log; extern crate memmap; extern crate object; extern crate pdb as crate_pdb; mod file; mod function; mod namespace; mod print; mod range; mod source; mod types; mod variable; mod unit; use std::borrow::Borrow; use std::borrow::Cow; use std::error; use std::fmt; use std::io; use std::result; use std::rc::Rc; use namespace::Namespace; pub use file::File; #[derive(Debug)] pub struct Error(pub Cow<'static, str>); impl error::Error for Error { fn description(&self) -> &str { self.0.borrow() } } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.0) } } impl From<&'static str> for Error { fn from(s: &'static str) -> Error { Error(Cow::Borrowed(s)) } } impl From<String> for Error { fn from(s: String) -> Error { Error(Cow::Owned(s)) } } impl From<io::Error> for Error { fn from(e: io::Error) -> Error { Error(Cow::Owned(format!("IO error: {}", e))) } } impl From<gimli::Error> for Error { fn from(e: gimli::Error) -> Error { Error(Cow::Owned(format!("DWARF error: {}", e))) } } impl From<crate_pdb::Error> for Error { fn from(e: crate_pdb::Error) -> Error { Error(Cow::Owned(format!("PDB error: {}", e))) } } pub type Result<T> = result::Result<T, Error>; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Sort { None, Name, Size, } impl Default for Sort { fn default() -> Self { Sort::None } } #[derive(Debug, Default, Clone)] pub struct Options<'a> { pub print_source: bool, pub print_file_address: bool, pub print_unit_address: bool, pub print_function_calls: bool, pub print_function_variables: bool, pub inline_depth: usize, pub category_file: bool, pub category_unit: bool, pub category_type: bool, pub category_function: bool, pub category_variable: bool, pub filter_function_inline: Option<bool>, pub filter_name: Option<&'a str>, pub filter_namespace: Vec<&'a str>, pub filter_unit: Option<&'a str>, pub sort: Sort, pub ignore_added: bool, pub ignore_deleted: bool, pub ignore_function_address: bool, pub ignore_function_size: bool, pub ignore_function_inline: bool, pub ignore_function_symbol_name: bool, pub ignore_variable_address: bool, pub ignore_variable_symbol_name: bool, pub prefix_map: Vec<(&'a str, &'a str)>, } impl<'a> Options<'a> { pub fn unit(&mut self, unit: &'a str) -> &mut Self { self.filter_unit = Some(unit); self } pub fn name(&mut self, name: &'a str) -> &mut Self { self.filter_name = Some(name); self } fn filter_function_inline(&self, inline: bool) -> bool { self.filter_function_inline.is_none() || self.filter_function_inline == Some(inline) } fn filter_name(&self, name: Option<&[u8]>) -> bool { self.filter_name.is_none() || self.filter_name.map(str::as_bytes) == name } fn filter_namespace(&self, namespace: &Option<Rc<Namespace>>) -> bool { self.filter_namespace.is_empty() || { match *namespace { Some(ref namespace) => namespace.filter(&self.filter_namespace), None => false, } } } }