Skip to content

Commit

Permalink
Revert "[llvm-pdbutil] Add options to only dump symbol record at spec…
Browse files Browse the repository at this point in the history
…ified offset and its parents or children with spcified depth."

This reverts commit a3b7cb0.

symbol-offset.test fails under MSAN:

[  1] ; RUN: llvm-pdbutil yaml2pdb %p/Inputs/symbol-offset.yaml --pdb=%t.pdb [FAIL]
llvm-pdbutil yaml2pdb <REDACTED>/llvm/test/tools/llvm-pdbutil/Inputs/symbol-offset.yaml --pdb=<REDACTED>/tmp/symbol-offset.test/symbol-offset.test.tmp.pdb
==9283==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x55f975e5eb91 in __libcpp_tls_set <REDACTED>/include/c++/v1/__threading_support:428:12
    #1 0x55f975e5eb91 in set_pointer <REDACTED>/include/c++/v1/thread:196:5
    #2 0x55f975e5eb91 in void* std::__msan::__thread_proxy<std::__msan::tuple<std::__msan::unique_ptr<std::__msan::__thread_struct, std::__msan::default_delete<std::__msan::__thread_struct> >, llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()::operator()() const::'lambda'()> >(void*) <REDACTED>/include/c++/v1/thread:285:27
    #3 0x7f74a1e55b54 in start_thread (<REDACTED>/libpthread.so.0+0xbb54) (BuildId: 64752de50ebd1a108f4b3f8d0d7e1a13)
    #4 0x7f74a1dc9f7e in clone (<REDACTED>/libc.so.6+0x13cf7e) (BuildId: 7cfed7708e5ab7fcb286b373de21ee76)
  • Loading branch information
MForster committed Apr 28, 2022
1 parent dcb2ddd commit cfb4e78
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 516 deletions.
8 changes: 0 additions & 8 deletions llvm/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,12 @@ class SymbolVisitorCallbacks;

class CVSymbolVisitor {
public:
struct FilterOptions {
llvm::Optional<uint32_t> SymbolOffset;
llvm::Optional<uint32_t> ParentRecursiveDepth;
llvm::Optional<uint32_t> ChildRecursiveDepth;
};

CVSymbolVisitor(SymbolVisitorCallbacks &Callbacks);

Error visitSymbolRecord(CVSymbol &Record);
Error visitSymbolRecord(CVSymbol &Record, uint32_t Offset);
Error visitSymbolStream(const CVSymbolArray &Symbols);
Error visitSymbolStream(const CVSymbolArray &Symbols, uint32_t InitialOffset);
Error visitSymbolStreamFiltered(const CVSymbolArray &Symbols,
const FilterOptions &Filter);

private:
SymbolVisitorCallbacks &Callbacks;
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/DebugInfo/PDB/Native/InputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ Error iterateSymbolGroups(InputFile &Input, const PrintScope &HeaderScope,
AutoIndent Indent(HeaderScope);

FilterOptions Filters = HeaderScope.P.getFilters();
if (Filters.DumpModi) {
uint32_t Modi = Filters.DumpModi.getValue();
if (Filters.NumOccurrences) {
uint32_t Modi = Filters.DumpModi;
SymbolGroup SG(&Input, Modi);
return iterateOneModule(Input, withLabelWidth(HeaderScope, NumDigits(Modi)),
SG, Modi, Callback);
Expand Down
6 changes: 2 additions & 4 deletions llvm/include/llvm/DebugInfo/PDB/Native/LinePrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ struct FilterOptions {
std::list<std::string> IncludeCompilands;
uint32_t PaddingThreshold;
uint32_t SizeThreshold;
llvm::Optional<uint32_t> DumpModi;
llvm::Optional<uint32_t> ParentRecurseDepth;
llvm::Optional<uint32_t> ChildrenRecurseDepth;
llvm::Optional<uint32_t> SymbolOffset;
uint32_t DumpModi;
uint32_t NumOccurrences;
bool JustMyCode;
};

Expand Down
2 changes: 0 additions & 2 deletions llvm/include/llvm/Support/BinaryStreamArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ class VarStreamArray {

bool valid() const { return Stream.valid(); }

bool isOffsetValid(uint32_t Offset) const { return at(Offset) != end(); }

uint32_t skew() const { return Skew; }
Iterator end() const { return Iterator(E); }

Expand Down
72 changes: 0 additions & 72 deletions llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h"
#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
#include "llvm/Support/BinaryStreamArray.h"
#include "llvm/Support/ErrorHandling.h"
Expand Down Expand Up @@ -84,74 +83,3 @@ Error CVSymbolVisitor::visitSymbolStream(const CVSymbolArray &Symbols,
}
return Error::success();
}

Error CVSymbolVisitor::visitSymbolStreamFiltered(const CVSymbolArray &Symbols,
const FilterOptions &Filter) {
if (!Filter.SymbolOffset)
return visitSymbolStream(Symbols);
uint32_t SymbolOffset = *Filter.SymbolOffset;
uint32_t ParentRecurseDepth =
Filter.ParentRecursiveDepth ? *Filter.ParentRecursiveDepth : 0;
uint32_t ChildrenRecurseDepth =
Filter.ChildRecursiveDepth ? *Filter.ChildRecursiveDepth : 0;
if (!Symbols.isOffsetValid(SymbolOffset))
return createStringError(inconvertibleErrorCode(), "Invalid symbol offset");
CVSymbol Sym = *Symbols.at(SymbolOffset);
uint32_t SymEndOffset =
symbolOpensScope(Sym.kind()) ? getScopeEndOffset(Sym) : 0;

std::vector<uint32_t> ParentOffsets;
std::vector<uint32_t> ParentEndOffsets;
uint32_t ChildrenDepth = 0;
for (auto Begin = Symbols.begin(), End = Symbols.end(); Begin != End;
++Begin) {
uint32_t BeginOffset = Begin.offset();
CVSymbol BeginSym = *Begin;
if (BeginOffset < SymbolOffset) {
if (symbolOpensScope(Begin->kind())) {
uint32_t EndOffset = getScopeEndOffset(BeginSym);
if (SymbolOffset < EndOffset) {
ParentOffsets.push_back(BeginOffset);
ParentEndOffsets.push_back(EndOffset);
}
}
} else if (BeginOffset == SymbolOffset) {
// Found symbol at offset. Visit its parent up to ParentRecurseDepth.
if (ParentRecurseDepth >= ParentOffsets.size())
ParentRecurseDepth = ParentOffsets.size();
uint32_t StartIndex = ParentOffsets.size() - ParentRecurseDepth;
while (StartIndex < ParentOffsets.size()) {
if (!Symbols.isOffsetValid(ParentOffsets[StartIndex]))
break;
CVSymbol Parent = *Symbols.at(ParentOffsets[StartIndex]);
if (auto EC = visitSymbolRecord(Parent, ParentOffsets[StartIndex]))
return EC;
++StartIndex;
}
if (auto EC = visitSymbolRecord(Sym, SymbolOffset))
return EC;
} else if (BeginOffset <= SymEndOffset) {
if (ChildrenRecurseDepth) {
// Visit children.
if (symbolEndsScope(Begin->kind()))
--ChildrenDepth;
if (ChildrenDepth < ChildrenRecurseDepth ||
BeginOffset == SymEndOffset) {
if (auto EC = visitSymbolRecord(BeginSym, BeginOffset))
return EC;
}
if (symbolOpensScope(Begin->kind()))
++ChildrenDepth;
}
} else {
// Visit parents' ends.
if (ParentRecurseDepth && BeginOffset == ParentEndOffsets.back()) {
if (auto EC = visitSymbolRecord(BeginSym, BeginOffset))
return EC;
ParentEndOffsets.pop_back();
--ParentRecurseDepth;
}
}
}
return Error::success();
}
2 changes: 1 addition & 1 deletion llvm/lib/DebugInfo/PDB/Native/InputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ bool llvm::pdb::shouldDumpSymbolGroup(uint32_t Idx, const SymbolGroup &Group,
return false;

// If the arg was not specified on the command line, always dump all modules.
if (!Filters.DumpModi)
if (Filters.NumOccurrences == 0)
return true;

// Otherwise, only dump if this is the same module specified.
Expand Down
204 changes: 0 additions & 204 deletions llvm/test/tools/llvm-pdbutil/Inputs/symbol-offset.yaml

This file was deleted.

Loading

0 comments on commit cfb4e78

Please sign in to comment.