mirror of
https://codeberg.org/unspeaker/vestal.git
synced 2025-12-06 08:36:41 +01:00
list output call sites
This commit is contained in:
parent
8f7faca54a
commit
8726b94122
2 changed files with 9 additions and 2 deletions
|
|
@ -60,7 +60,7 @@ impl Module {
|
|||
fn call_site (self: &Arc<Self>, position: usize, opcodes: &[u8]) -> Usually<Arc<CallSite>> {
|
||||
let group = false;
|
||||
let offset = (position + self.code_start) as u32;
|
||||
let source = self.pe.offset_to_rva(Offset((position + self.code_start) as u32))?.0;
|
||||
let source = self.pe.offset_to_rva(Offset(offset))?.0;
|
||||
let target = CallSite::target(source, opcodes).unwrap_or(0);
|
||||
let import = self.imports.read().unwrap().get(&target).cloned();
|
||||
let call_site = Arc::new(CallSite {
|
||||
|
|
@ -85,6 +85,8 @@ impl Module {
|
|||
targets.insert(call_site.target, vec![]);
|
||||
}
|
||||
targets.get_mut(&call_site.target).unwrap().push(call_site.clone());
|
||||
let mut call_sites = self.call_sites.write().unwrap();
|
||||
call_sites.insert(call_site.source, call_site.clone());
|
||||
}
|
||||
/// Follow the call site and resolve the next call site found in the dependency.
|
||||
fn load_call_site_recurse (self: &Arc<Self>, call_site: &Arc<CallSite>, depth: usize) -> Usually<()> {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ pub struct Module {
|
|||
/// Addresses of exported methods by name
|
||||
pub exports: RwLock<BTreeMap<Arc<str>, ThunkData>>,
|
||||
/// Locations in `.text` section that need to be patched
|
||||
pub call_sites: BTreeMap<u32, Arc<CallSite>>,
|
||||
pub call_sites: RwLock<BTreeMap<u32, Arc<CallSite>>>,
|
||||
/// More detailed output.
|
||||
pub verbose: bool,
|
||||
}
|
||||
|
|
@ -169,6 +169,11 @@ impl Module {
|
|||
module.name);
|
||||
layout.insert(index, self.clone());
|
||||
index += module.code_size.div_ceil(page) * page;
|
||||
for (addr, call) in module.call_sites.read().unwrap().iter() {
|
||||
println!(" {} {:?}::{:?}", fmt_num(*addr as usize),
|
||||
call.module.as_ref().map(|m|m.name.clone()),
|
||||
call.method);
|
||||
}
|
||||
};
|
||||
append(&self);
|
||||
for module in self.namespace.read().unwrap().values() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue