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

Function parse_call_stack_from_err_msg

src/program/libfuzzer.rs:841–875  ·  view source on GitHub ↗
(fuzz_entry: &Path)

Source from the content-addressed store, hash-verified

839 }
840
841 fn parse_call_stack_from_err_msg(fuzz_entry: &Path) -> Result<Vec<(String, String)>> {
842 let fuzz_log: PathBuf = [PathBuf::from(fuzz_entry), "fuzz.log".into()]
843 .iter()
844 .collect();
845 if !fuzz_log.exists() {
846 eyre::bail!("Fuzz log doesn't exist: {fuzz_log:?}")
847 }
848 let err_msg = std::fs::read_to_string(fuzz_log)?;
849 let mut de = Deserializer::from_input(&err_msg);
850 // the start of err msg
851 de.eat_token_until("==")?;
852 de.eat_token_until("#0")?;
853
854 let mut call_stacks = Vec::new();
855 let err_msg = de.remain();
856 for line in err_msg.lines() {
857 let line = line.trim();
858 if !line.contains(" in ") {
859 continue;
860 }
861 if !line.starts_with('#') {
862 break;
863 }
864 let (trap_call, trap_loc) =
865 parse_call_stack_line(line).context(format!("error when parse line: {line}"))?;
866 if !trap_loc.contains(&crate::deopt::Deopt::get_crate_build_dir()?.to_string_lossy().to_string()) {
867 continue;
868 }
869 if trap_call.contains("LLVMFuzzerTestOneInput") {
870 break;
871 }
872 call_stacks.push((trap_call, trap_loc));
873 }
874 Ok(call_stacks)
875 }
876
877 fn call_stack_to_hash(call_stack: Vec<(String, String)>) -> String {
878 let mut hash = String::new();

Callers 1

Calls 4

parse_call_stack_lineFunction · 0.85
eat_token_untilMethod · 0.80
remainMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected