MCPcopy Create free account
hub / github.com/diem/move / process

Method process

language/move-prover/bytecode/src/debug_instrumentation.rs:31–106  ·  view source on GitHub ↗
(
        &self,
        _targets: &mut FunctionTargetsHolder,
        fun_env: &FunctionEnv<'_>,
        data: FunctionData,
    )

Source from the content-addressed store, hash-verified

29
30impl FunctionTargetProcessor for DebugInstrumenter {
31 fn process(
32 &self,
33 _targets: &mut FunctionTargetsHolder,
34 fun_env: &FunctionEnv<'_>,
35 data: FunctionData,
36 ) -> FunctionData {
37 use Bytecode::*;
38
39 if fun_env.is_native() {
40 // Nothing to do
41 return data;
42 }
43
44 let mut builder = FunctionDataBuilder::new(fun_env, data);
45 let code = std::mem::take(&mut builder.data.code);
46
47 // Emit trace instructions for parameters at entry.
48 builder.set_loc(builder.fun_env.get_loc().at_start());
49 for i in 0..builder.fun_env.get_parameter_count() {
50 builder.emit_with(|id| Call(id, vec![], Operation::TraceLocal(i), vec![i], None));
51 }
52
53 for bc in code {
54 match &bc {
55 Ret(id, locals) => {
56 // Emit trace instructions for return values.
57 builder.set_loc_from_attr(*id);
58 for (i, l) in locals.iter().enumerate() {
59 builder.emit_with(|id| {
60 Call(id, vec![], Operation::TraceReturn(i), vec![*l], None)
61 });
62 }
63 builder.emit(bc);
64 }
65 Abort(id, l) => {
66 builder.set_loc_from_attr(*id);
67 builder.emit_with(|id| Call(id, vec![], Operation::TraceAbort, vec![*l], None));
68 builder.emit(bc);
69 }
70 Call(_, _, Operation::WriteRef, srcs, _) if srcs[0] < fun_env.get_local_count() => {
71 builder.set_loc_from_attr(bc.get_attr_id());
72 builder.emit(bc.clone());
73 builder.emit_with(|id| {
74 Call(
75 id,
76 vec![],
77 Operation::TraceLocal(srcs[0]),
78 vec![srcs[0]],
79 None,
80 )
81 });
82 }
83 _ => {
84 builder.set_loc_from_attr(bc.get_attr_id());
85 builder.emit(bc.clone());
86 // Emit trace instructions for modified values.
87 let (val_targets, mut_targets) = bc.modifies(&builder.get_target());
88 let affected_variables: BTreeSet<_> = val_targets

Callers

nothing calls this directly

Calls 15

set_locMethod · 0.80
at_startMethod · 0.80
emit_withMethod · 0.80
set_loc_from_attrMethod · 0.80
get_attr_idMethod · 0.80
modifiesMethod · 0.80
is_nativeMethod · 0.45
get_locMethod · 0.45
get_parameter_countMethod · 0.45
iterMethod · 0.45
emitMethod · 0.45
get_local_countMethod · 0.45

Tested by

no test coverage detected