MCPcopy Create free account
hub / github.com/FuzzAnything/PromptFuzz / dump_to_file

Method dump_to_file

src/analysis/callgraph.rs:121–148  ·  view source on GitHub ↗

Dump this cfg to a Graphviz format file and translate it to PNG.

(&self, deopt: &Deopt)

Source from the content-addressed store, hash-verified

119
120 /// Dump this cfg to a Graphviz format file and translate it to PNG.
121 pub fn dump_to_file(&self, deopt: &Deopt) -> eyre::Result<()> {
122 let config = vec![petgraph::dot::Config::EdgeNoLabel];
123 let raw_str = format!(
124 "{:?}",
125 petgraph::dot::Dot::with_config(&self.graph, &config)
126 );
127 let file: PathBuf = [deopt.get_library_misc_dir()?, "callgraph".into()]
128 .iter()
129 .collect();
130
131 let mut dot_path = file.clone();
132 dot_path.set_extension("dot");
133 std::fs::write(&dot_path, raw_str)?;
134 let mut cfg_path = file.clone();
135 cfg_path.set_extension("pdf");
136 let output = std::process::Command::new("dot")
137 .arg("-Tpdf")
138 .arg(&dot_path)
139 .arg("-o")
140 .arg(cfg_path)
141 .output()?;
142 if !output.status.success() {
143 let err_msg = String::from_utf8_lossy(&output.stderr).to_string();
144 eyre::bail!("{err_msg}");
145 }
146 std::fs::remove_file(dot_path)?;
147 Ok(())
148 }
149}
150
151pub fn get_lib_call_graph() -> &'static CallGraph {

Callers 1

test_parse_call_graphFunction · 0.45

Calls 1

get_library_misc_dirMethod · 0.80

Tested by 1

test_parse_call_graphFunction · 0.36