From 89d7f060ddc5287e9acbd6c61abeb2bdb9de3447 Mon Sep 17 00:00:00 2001 From: bmc-msft <41130664+bmc-msft@users.noreply.github.com> Date: Wed, 17 Feb 2021 11:34:09 -0500 Subject: [PATCH] make missing symbols for coverage tasks more explicit (#554) This moves from: ``` "Error: coverage extraction from C:\users\bcaswell\projects\bugs\andrew-coverage-fail\setup\oft-setup-5c77cfe1b181520ab0b33a16286a690a\fuzz.exe failed when processing file "11f6ad8ec52a2984abaafd7c3b516503785c2072". target appears to be missing sancov instrumentation", ``` To even more explicit: ``` Error: Target appears to be missing sancov instrumentation. This error can happen due to missing coverage symbols. target_exe: C:\users\bcaswell\projects\bugs\andrew-coverage-fail\setup\oft-setup-5c77cfe1b181520ab0b33a16286a690a\fuzz.exe input: "11f6ad8ec52a2984abaafd7c3b516503785c2072" debugger stdout: ... [+] disabling sympath [+] processing fuzz.exe [+] no tables fuzz.exe [+] processing C:\WINDOWS\SYSTEM32\kernel.appcore.dll [+] no tables C:\WINDOWS\SYSTEM32\kernel.appcore.dll [+] processing C:\WINDOWS\System32\KERNELBASE.dll [+] no tables C:\WINDOWS\System32\KERNELBASE.dll [+] processing C:\WINDOWS\System32\RPCRT4.dll [+] no tables C:\WINDOWS\System32\RPCRT4.dll [+] processing C:\WINDOWS\System32\msvcrt.dll [+] no tables C:\WINDOWS\System32\msvcrt.dll [+] processing C:\WINDOWS\System32\KERNEL32.DLL [+] no tables C:\WINDOWS\System32\KERNEL32.DLL [+] processing ntdll.dll [+] no tables ntdll.dll Error: unable to find sancov counter symbols [at DumpCounters (line 114 col 9)] ... ``` --- .../src/tasks/coverage/recorder.rs | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/agent/onefuzz-agent/src/tasks/coverage/recorder.rs b/src/agent/onefuzz-agent/src/tasks/coverage/recorder.rs index 9ea5fbee39..5ce7fc8686 100644 --- a/src/agent/onefuzz-agent/src/tasks/coverage/recorder.rs +++ b/src/agent/onefuzz-agent/src/tasks/coverage/recorder.rs @@ -25,6 +25,8 @@ pub struct CoverageRecorder { script_dir: OwnedDir, } +const SYMBOL_EXTRACT_ERROR: &str = "Target appears to be missing sancov instrumentation. This error can also happen if symbols for the target are not available."; + impl CoverageRecorder { pub fn new(config: Arc) -> Self { let script_dir = @@ -57,28 +59,19 @@ impl CoverageRecorder { let script = self.invoke_debugger_script(test_input, &coverage_path)?; let output = script.wait_with_output().await?; + let stdout = String::from_utf8_lossy(&output.stdout); + let stderr = String::from_utf8_lossy(&output.stderr); + if !output.status.success() { let err = format_err!("coverage recording failed: {}", output.status); error!("{}", err); - error!( - "recording stderr: {}", - String::from_utf8_lossy(&output.stderr) - ); - error!( - "recording stdout: {}", - String::from_utf8_lossy(&output.stdout) - ); + error!("recording stderr: {}", stderr); + error!("recording stdout: {}", stdout); return Err(err); } else { - debug!( - "recording stderr: {}", - String::from_utf8_lossy(&output.stderr) - ); - debug!( - "recording stdout: {}", - String::from_utf8_lossy(&output.stdout) - ); + debug!("recording stderr: {}", stderr); + debug!("recording stdout: {}", stdout); } if !has_files(&coverage_path).await? { @@ -96,9 +89,12 @@ impl CoverageRecorder { .ok_or_else(|| format_err!("unable to identify coverage input filename"))?; bail!( - "coverage extraction from {} failed when processing file {:?}. target appears to be missing sancov instrumentation", + "{}\ntarget_exe: {}\ninput: {:?}\ndebugger stdout: {}\ndebugger stderr: {}", + SYMBOL_EXTRACT_ERROR, self.config.target_exe.display(), - filename + filename, + stdout, + stderr ); }