From c00bc90b7c7ec991fdac39b46d843ecff481f32d Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Wed, 3 Feb 2021 19:25:02 +0000 Subject: [PATCH] Always output the wire trace with the injected error format The fuzzers will be updated to always expect this format. If the fuzzer doesn't do error injection, it will simply skip these bytes. Bug: dawn:629 Change-Id: I894e95ce9c1048eda81593219f7fc5d91e123392 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/40121 Commit-Queue: Austin Eng Reviewed-by: Stephen White --- src/utils/WireHelper.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/WireHelper.cpp b/src/utils/WireHelper.cpp index 2bdae6d580..846fcc7a7d 100644 --- a/src/utils/WireHelper.cpp +++ b/src/utils/WireHelper.cpp @@ -38,7 +38,7 @@ namespace utils { WireServerTraceLayer(const char* dir, dawn_wire::CommandHandler* handler) : dawn_wire::CommandHandler(), mDir(dir), mHandler(handler) { const char* sep = GetPathSeparator(); - if (mDir.back() != *sep) { + if (mDir.size() > 0 && mDir.back() != *sep) { mDir += sep; } } @@ -56,6 +56,12 @@ namespace utils { ASSERT(!mFile.is_open()); mFile.open(filename, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc); + + // Write the initial 8 bytes. This means the fuzzer should never inject an + // error. + const uint64_t injectedErrorIndex = 0xFFFF'FFFF'FFFF'FFFF; + mFile.write(reinterpret_cast(&injectedErrorIndex), + sizeof(injectedErrorIndex)); } const volatile char* HandleCommands(const volatile char* commands,