This adds column numbers if they are present, and otherwise
sets the column number to be zero.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This looks right, but I'd like to see a test.
llvm-pdbutil is used in a DIA test for line numbers (llvm\test\DebugInfo\PDB\DIA\pdbdump-linenumbers.test), so perhaps that could be the model for a native one that also checks the column numbers. That would require a tweak to llvm-pdbutil to make essentially the same change as you have here, to include column numbers in the output when they're present.
llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp | ||
---|---|---|
476 | As I understand it, the line numbers and column numbers are in parallel arrays (streams). So, for each line number you take the next column number (if there are column numbers at all). Assuming that's right: I don't see a need to change the for loop to use the line number iterators. Yeah, it creates some source code symmetry with the column number iterators, but I'm not sure that makes that more understandable here. I won't block on it, but I'd prefer the original for (const LineNumberEntry &LN : Group.LineNumbers). | |
481 | It seems that if there is no column info, then ColIt would always equal ColsEnd, so perhaps that first part of the condition is not necessary. Perhaps, just before the loop, you could assert that either Lines.hasColumnInfo() or that ColIt is ColsEnd and then simplify the condition here. The assertion would be a nice place to add a comment like // If there are column numbers, then they are in a parallel stream to the line numbers. |
thanks for the comments! I added another llvm-symbolizer test with a pdb that contains column numbers.
It looks like llvm-pdbutil does already output column info, but I guess PDBs don't normally contain column info.
Very close now. It looks like the change I requested led to a bug. Once that's corrected, this'll look great.
Thanks for adding the test. Perhaps you could generate PDBs both with and without column info and then the test could check that it works either way (which should have caught the new bug). If there's already an existing test that catches the bug (skipping the line numbers whether there are no column numbers), that's sufficient.
Feel free to ping me if I've not been clear.
llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp | ||
---|---|---|
470 | Sorry, I wasn't clear enough before because it looks like I confused you. This if statement is unnecessary and, in fact, wrong. You still want to go through the line numbers in this group even if there's no column information. When I said assert, I literally meant an assert like this: llvm_assert(Lines.hasColumnInfo() || ColIt == ColsEnd); Note that it's ||, not &&. If we have column info, great. If we don't, then ensure that the iterator alone makes that clear in order to use the simpler test in the loop. |
llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp | ||
---|---|---|
470 | Makes sense. I was avoiding using asserts in case some section happened to be messed up, in which case we would just skip it instead of asserting. (Although I don't know if this is actually something that could happen.) I think my if statement is just the inverse of your suggested assert? It continues if it claims there is column info and the column info is empty. The original test case in llvm/test/tools/llvm-symbolizer/pdb/pdb-native.test doesn't have column info and passes. |
The test-columns.pdb file added here is 6MB large. Is it possible to reduce its size while preserving the spirit of the test?
I think it can be built without the system headers, which would reduce the PDB size by a lot. I can make a patch for that.
Sorry, I wasn't clear enough before because it looks like I confused you. This if statement is unnecessary and, in fact, wrong. You still want to go through the line numbers in this group even if there's no column information.
When I said assert, I literally meant an assert like this:
Note that it's ||, not &&. If we have column info, great. If we don't, then ensure that the iterator alone makes that clear in order to use the simpler test in the loop.