mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
fa9d44b037
We have llvm-readobj for dumping CodeView from object files, and llvm-pdbutil has always been more focused on PDB. However, llvm-pdbutil has a lot of useful options for summarizing debug information in aggregate and presenting high level statistical views. Furthermore, it's arguably better as a testing tool since we don't have to write tests to conform to a state-machine like structure where you match multiple lines in succession, each depending on a previous match. llvm-pdbutil dumps much more concisely, so it's possible to use single-line matches in many cases where as with readobj tests you have to use multi-line matches with an implicit state machine. Because of this, I'm adding object file support to llvm-pdbutil. In fact, this mirrors the cvdump tool from Microsoft, which also supports both object files and pdb files. In the future we could perhaps rename this tool llvm-cvutil. In the meantime, this allows us to deep dive into object files the same way we already can with PDB files. llvm-svn: 312358
104 lines
2.3 KiB
C++
104 lines
2.3 KiB
C++
//===- DumpOutputStyle.h -------------------------------------- *- C++ --*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
|
|
#define LLVM_TOOLS_LLVMPDBDUMP_DUMPOUTPUTSTYLE_H
|
|
|
|
#include "LinePrinter.h"
|
|
#include "OutputStyle.h"
|
|
#include "StreamUtil.h"
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
#include "llvm/ADT/Optional.h"
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
|
|
|
|
#include <string>
|
|
|
|
namespace llvm {
|
|
class BitVector;
|
|
|
|
namespace codeview {
|
|
class LazyRandomTypeCollection;
|
|
}
|
|
|
|
namespace object {
|
|
class COFFObjectFile;
|
|
}
|
|
|
|
namespace pdb {
|
|
class GSIHashTable;
|
|
class InputFile;
|
|
|
|
struct StatCollection {
|
|
struct Stat {
|
|
Stat() {}
|
|
Stat(uint32_t Count, uint32_t Size) : Count(Count), Size(Size) {}
|
|
uint32_t Count = 0;
|
|
uint32_t Size = 0;
|
|
|
|
void update(uint32_t RecordSize) {
|
|
++Count;
|
|
Size += RecordSize;
|
|
}
|
|
};
|
|
|
|
void update(uint32_t Kind, uint32_t RecordSize) {
|
|
Totals.update(RecordSize);
|
|
auto Iter = Individual.try_emplace(Kind, 1, RecordSize);
|
|
if (!Iter.second)
|
|
Iter.first->second.update(RecordSize);
|
|
}
|
|
Stat Totals;
|
|
DenseMap<uint32_t, Stat> Individual;
|
|
};
|
|
|
|
class DumpOutputStyle : public OutputStyle {
|
|
|
|
public:
|
|
DumpOutputStyle(InputFile &File);
|
|
|
|
Error dump() override;
|
|
|
|
private:
|
|
PDBFile &getPdb();
|
|
object::COFFObjectFile &getObj();
|
|
|
|
Error dumpFileSummary();
|
|
Error dumpStreamSummary();
|
|
Error dumpSymbolStats();
|
|
Error dumpUdtStats();
|
|
Error dumpStringTable();
|
|
Error dumpLines();
|
|
Error dumpInlineeLines();
|
|
Error dumpXmi();
|
|
Error dumpXme();
|
|
Error dumpTpiStream(uint32_t StreamIdx);
|
|
Error dumpModules();
|
|
Error dumpModuleFiles();
|
|
Error dumpModuleSymsForPdb();
|
|
Error dumpModuleSymsForObj();
|
|
Error dumpGlobals();
|
|
Error dumpPublics();
|
|
Error dumpSymbolsFromGSI(const GSIHashTable &Table, bool HashExtras);
|
|
Error dumpSectionHeaders();
|
|
Error dumpSectionContribs();
|
|
Error dumpSectionMap();
|
|
|
|
void dumpSectionHeaders(StringRef Label, DbgHeaderType Type);
|
|
|
|
InputFile &File;
|
|
LinePrinter P;
|
|
SmallVector<StreamInfo, 32> StreamPurposes;
|
|
};
|
|
} // namespace pdb
|
|
} // namespace llvm
|
|
|
|
#endif
|