Previously, there is no way to create a stream other than
pre-defined special stream such as DBI or IPI. This patch
adds a new method, addStream, to add a stream of arbitrary
bytes to a PDB file. The new function takes a byte array
and returns the index of the new stream.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
- rename PDBFileBuilder::addStream to addDbgStream
- make addDbgStream to set the directory entry for a new debug stream.
include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h | ||
---|---|---|
99–100 ↗ | (On Diff #73990) | I believe these should be initialized to kInvalidStreamIndex. |
99–101 ↗ | (On Diff #73990) | I wonder if this could just be a llvm::SmallVector<ArrayRef<uint8_t>, DbgHeaderType::Max>. This way you don't need one array which indexes into another array, but rather you just have one array altogether that contains all the data. |
lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp | ||
246–249 ↗ | (On Diff #73990) | Here you will need to loop through the various optional debug streams and call setStreamSize() on each one. |
295–296 ↗ | (On Diff #73990) | Here you should check if Idx == kInvalidStreamIndex, and continue if so. |
297 ↗ | (On Diff #73990) | Can you use a different variable name here? This Writer shadows the previous Writer, which could be confusing. Maybe calling it DbgStreamWriter. |
include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h | ||
---|---|---|
99–101 ↗ | (On Diff #73990) | We need to distinguish an empty stream from nonexistent stream, so we need to store the stream number somewhere. I defined a new class for that purpose. |
lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp | ||
246–249 ↗ | (On Diff #73990) | I don't think so. We create a new stream like this auto ExpectedIndex = Msf.addStream(Data.size()); and because the size will never change, we don't need to adjust the size afterwards. |
lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp | ||
---|---|---|
49 ↗ | (On Diff #74155) | I think we shouldn't call addStream here. Suppose someone called addDbgStream more than once for the same value of Type. Then you would end up with unreferenced streams in the file. Maybe instead we can just store the ArrayRef, overwriting any previous value of the ArrayRef that was there before. Then in finalizeMsfLayout we can add all the streams. This way everything is semantically "atomic". No modification to the underlying file happens until you call finalize(), so you can do whatever you want until then without risk of messing anything up. |
246–249 ↗ | (On Diff #73990) | Ahh, I didn't see that before. I will go back and comment up there. |
lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp | ||
---|---|---|
49 ↗ | (On Diff #74155) | How about this? I think this is atomic because we check everything that can fail before calling addStream in this function. |