[PATCH] D102713: [PDB] Improve error handling when writes fail
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 18 13:20:33 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac2226b0f573: [PDB] Improve error handling when writes fail (authored by rnk).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102713/new/
https://reviews.llvm.org/D102713
Files:
lld/COFF/PDB.cpp
llvm/include/llvm/DebugInfo/MSF/MSFError.h
llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
llvm/lib/DebugInfo/MSF/MSFError.cpp
Index: llvm/lib/DebugInfo/MSF/MSFError.cpp
===================================================================
--- llvm/lib/DebugInfo/MSF/MSFError.cpp
+++ llvm/lib/DebugInfo/MSF/MSFError.cpp
@@ -27,6 +27,8 @@
case msf_error_code::insufficient_buffer:
return "The buffer is not large enough to read the requested number of "
"bytes.";
+ case msf_error_code::size_overflow:
+ return "Output data is larger than 4 GiB.";
case msf_error_code::not_writable:
return "The specified stream is not writable.";
case msf_error_code::no_stream:
Index: llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
===================================================================
--- llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
+++ llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
@@ -15,6 +15,7 @@
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FormatVariadic.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
@@ -348,8 +349,9 @@
// block-based and as long as each stream is small enough, PDBs larger than
// 4 GiB might work. Check if tools can handle these large PDBs, and if so
// add support for writing them.
- return make_error<MSFError>(msf_error_code::invalid_format,
- "Output larger than 4 GiB");
+ return make_error<MSFError>(
+ msf_error_code::size_overflow,
+ formatv("File size would have been {0,1:N}", FileSize));
}
auto OutFileOrError = FileOutputBuffer::create(Path, FileSize);
Index: llvm/include/llvm/DebugInfo/MSF/MSFError.h
===================================================================
--- llvm/include/llvm/DebugInfo/MSF/MSFError.h
+++ llvm/include/llvm/DebugInfo/MSF/MSFError.h
@@ -18,6 +18,7 @@
enum class msf_error_code {
unspecified = 1,
insufficient_buffer,
+ size_overflow,
not_writable,
no_stream,
invalid_format,
Index: lld/COFF/PDB.cpp
===================================================================
--- lld/COFF/PDB.cpp
+++ lld/COFF/PDB.cpp
@@ -1648,9 +1648,13 @@
}
void PDBLinker::commit(codeview::GUID *guid) {
- ExitOnError exitOnErr((config->pdbPath + ": ").str());
- // Write to a file.
- exitOnErr(builder.commit(config->pdbPath, guid));
+ // Print an error and continue if PDB writing fails. This is done mainly so
+ // the user can see the output of /time and /summary, which is very helpful
+ // when trying to figure out why a PDB file is too large.
+ if (Error e = builder.commit(config->pdbPath, guid)) {
+ checkError(std::move(e));
+ error("failed to write PDB file " + Twine(config->pdbPath));
+ }
}
static uint32_t getSecrelReloc() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102713.346257.patch
Type: text/x-patch
Size: 2709 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210518/e458a57f/attachment.bin>
More information about the llvm-commits
mailing list