summaryrefslogtreecommitdiff
path: root/plugins/warp/src/plugin/debug.rs
blob: fc4e5817a481f7c013bf226c97086c6cbe4a9c2a (plain)
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
use crate::cache::container::for_cached_containers;
use crate::{build_function, cache};
use binaryninja::binary_view::BinaryView;
use binaryninja::command::{Command, FunctionCommand};
use binaryninja::function::Function;
use binaryninja::ObjectDestructor;

pub struct DebugFunction;

impl FunctionCommand for DebugFunction {
    fn action(&self, _view: &BinaryView, func: &Function) {
        if let Ok(lifted_il) = func.lifted_il() {
            log::info!("{:#?}", build_function(func, &lifted_il));
        }
    }

    fn valid(&self, _view: &BinaryView, _func: &Function) -> bool {
        true
    }
}

pub struct DebugCache;

impl Command for DebugCache {
    fn action(&self, _view: &BinaryView) {
        for_cached_containers(|c| {
            log::info!("Container: {:#?}", c);
        });
    }

    fn valid(&self, _view: &BinaryView) -> bool {
        true
    }
}

pub struct DebugInvalidateCache;

impl Command for DebugInvalidateCache {
    fn action(&self, view: &BinaryView) {
        let destructor = cache::CacheDestructor {};
        destructor.destruct_view(view);
        log::info!("Invalidated all WARP caches...");
    }

    fn valid(&self, _view: &BinaryView) -> bool {
        true
    }
}