pub fn dump_instr(buffer: &mut dyn Write, instr: &Instruction) -> Result<()>Expand description
Dump a VTIL Instruction to a String. This format is not stable
Examples found in repository?
examples/dot.rs (line 46)
28fn dump_routine(basic_blocks: Values<Vip, BasicBlock>) {
29 println!("digraph G {{");
30
31 for basic_block in basic_blocks {
32 let pc = basic_block.vip.0;
33
34 println!(
35 r#"vip_{0:x} [
36 shape="Mrecord"
37 fontname="Courier New"
38 label=<
39 <table border="0" cellborder="0" cellpadding="3">
40 <tr><td align="center" colspan="2" bgcolor="grey">{0:x}</td></tr>"#,
41 pc
42 );
43
44 for instr in &basic_block.instructions {
45 let mut buffer = Vec::<u8>::new();
46 dump_instr(&mut buffer, instr).unwrap();
47 println!(
48 r#" <tr><td align="left">{}</td></tr>"#,
49 escape(str::from_utf8(&buffer).unwrap().to_string())
50 );
51 }
52
53 println!(
54 r#" </table>
55 >
56];"#
57 );
58
59 let successors = &basic_block.next_vip;
60 if successors.len() == 2 {
61 println!(
62 r#"vip_{:x} -> vip_{:x} [color="green"];"#,
63 pc, successors[0].0
64 );
65 println!(
66 r#"vip_{:x} -> vip_{:x} [color="red"];"#,
67 pc, successors[1].0
68 );
69 } else {
70 for successor in successors {
71 println!(r#"vip_{:x} -> vip_{:x} [color="blue"];"#, pc, successor.0);
72 }
73 }
74 }
75
76 println!("}}");
77}