summaryrefslogtreecommitdiff
path: root/plugins/warp/src/plugin/debug.rs
blob: 4198ea303fe39fa4d743bbaf6419f05443dad517 (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
49
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::object_destructor::ObjectDestructor;

pub struct DebugFunction;

impl FunctionCommand for DebugFunction {
    fn action(&self, _view: &BinaryView, func: &Function) {
        tracing::info!(
            "{:#?}",
            build_function(func, || func.lifted_il().ok(), false)
        );
    }

    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| {
            tracing::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);
        tracing::info!("Invalidated all WARP caches...");
    }

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