mirror of
https://github.com/RPCS3/llvm.git
synced 2025-04-11 18:42:01 +00:00
Properly parse the TypeServer2 record.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294046 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
482cfedce1
commit
e1a6c0f419
36
include/llvm/DebugInfo/CodeView/Formatters.h
Normal file
36
include/llvm/DebugInfo/CodeView/Formatters.h
Normal file
@ -0,0 +1,36 @@
|
||||
//===- Formatters.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_DEBUGINFO_CODEVIEW_FORMATTERS_H
|
||||
#define LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/FormatAdapters.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace codeview {
|
||||
namespace detail {
|
||||
class GuidAdapter final : public llvm::FormatAdapter<ArrayRef<uint8_t>> {
|
||||
ArrayRef<uint8_t> Guid;
|
||||
|
||||
public:
|
||||
explicit GuidAdapter(ArrayRef<uint8_t> Guid);
|
||||
explicit GuidAdapter(StringRef Guid);
|
||||
void format(llvm::raw_ostream &Stream, StringRef Style);
|
||||
};
|
||||
}
|
||||
|
||||
inline detail::GuidAdapter fmt_guid(StringRef Item) {
|
||||
return detail::GuidAdapter(Item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -30,8 +30,8 @@ raw_ostream &operator<<(raw_ostream &OS, const PDB_Checksum &Checksum);
|
||||
raw_ostream &operator<<(raw_ostream &OS, const PDB_Lang &Lang);
|
||||
raw_ostream &operator<<(raw_ostream &OS, const PDB_SymType &Tag);
|
||||
raw_ostream &operator<<(raw_ostream &OS, const PDB_MemberAccess &Access);
|
||||
raw_ostream &operator<<(raw_ostream &OS, const PDB_UniqueId &Guid);
|
||||
raw_ostream &operator<<(raw_ostream &OS, const PDB_UdtType &Type);
|
||||
raw_ostream &operator<<(raw_ostream &OS, const PDB_UniqueId &Id);
|
||||
raw_ostream &operator<<(raw_ostream &OS, const PDB_Machine &Machine);
|
||||
|
||||
raw_ostream &operator<<(raw_ostream &OS, const Variant &Value);
|
||||
|
@ -22,9 +22,6 @@ protected:
|
||||
explicit FormatAdapter(T &&Item) : Item(Item) {}
|
||||
|
||||
T Item;
|
||||
|
||||
static_assert(!detail::uses_missing_provider<T>::value,
|
||||
"Item does not have a format provider!");
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
@ -5,6 +5,7 @@ add_llvm_library(LLVMDebugInfoCodeView
|
||||
CVTypeDumper.cpp
|
||||
CVTypeVisitor.cpp
|
||||
EnumTables.cpp
|
||||
Formatters.cpp
|
||||
Line.cpp
|
||||
ModuleSubstream.cpp
|
||||
ModuleSubstreamVisitor.cpp
|
||||
|
37
lib/DebugInfo/CodeView/Formatters.cpp
Normal file
37
lib/DebugInfo/CodeView/Formatters.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
//===- Formatters.cpp -------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/DebugInfo/CodeView/Formatters.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::codeview;
|
||||
using namespace llvm::codeview::detail;
|
||||
|
||||
GuidAdapter::GuidAdapter(StringRef Guid)
|
||||
: FormatAdapter(makeArrayRef(Guid.bytes_begin(), Guid.bytes_end())) {}
|
||||
|
||||
GuidAdapter::GuidAdapter(ArrayRef<uint8_t> Guid)
|
||||
: FormatAdapter(std::move(Guid)) {}
|
||||
|
||||
void GuidAdapter::format(llvm::raw_ostream &Stream, StringRef Style) {
|
||||
static const char *Lookup = "0123456789ABCDEF";
|
||||
|
||||
assert(Item.size() == 16 && "Expected 16-byte GUID");
|
||||
Stream << "{";
|
||||
for (int i = 0; i < 16;) {
|
||||
uint8_t Byte = Item[i];
|
||||
uint8_t HighNibble = (Byte >> 4) & 0xF;
|
||||
uint8_t LowNibble = Byte & 0xF;
|
||||
Stream << Lookup[HighNibble] << Lookup[LowNibble];
|
||||
++i;
|
||||
if (i >= 4 && i <= 10 && i % 2 == 0)
|
||||
Stream << "-";
|
||||
}
|
||||
Stream << "}";
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
//===-- TypeDumpVisitor.cpp - CodeView type info dumper -----------*- C++
|
||||
//-*-===//
|
||||
//===-- TypeDumpVisitor.cpp - CodeView type info dumper ----------*- C++-*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -13,6 +12,7 @@
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
|
||||
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
|
||||
#include "llvm/DebugInfo/CodeView/Formatters.h"
|
||||
#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
|
||||
#include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"
|
||||
#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
|
||||
@ -20,6 +20,7 @@
|
||||
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
|
||||
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
|
||||
#include "llvm/DebugInfo/MSF/ByteStream.h"
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
#include "llvm/Support/ScopedPrinter.h"
|
||||
|
||||
using namespace llvm;
|
||||
@ -336,7 +337,7 @@ Error TypeDumpVisitor::visitKnownRecord(CVType &CVR, FuncIdRecord &Func) {
|
||||
}
|
||||
|
||||
Error TypeDumpVisitor::visitKnownRecord(CVType &CVR, TypeServer2Record &TS) {
|
||||
W->printBinary("Signature", TS.getGuid());
|
||||
W->printString("Guid", formatv("{0}", fmt_guid(TS.getGuid())).str());
|
||||
W->printNumber("Age", TS.getAge());
|
||||
W->printString("Name", TS.getName());
|
||||
return Error::success();
|
||||
|
@ -368,6 +368,9 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR,
|
||||
|
||||
Error TypeRecordMapping::visitKnownRecord(CVType &CVR,
|
||||
TypeServer2Record &Record) {
|
||||
error(IO.mapGuid(Record.Guid));
|
||||
error(IO.mapInteger(Record.Age));
|
||||
error(IO.mapStringZ(Record.Name));
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "llvm/DebugInfo/PDB/DIA/DIARawSymbol.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/DebugInfo/CodeView/Formatters.h"
|
||||
#include "llvm/DebugInfo/PDB/DIA/DIAEnumSymbols.h"
|
||||
#include "llvm/DebugInfo/PDB/DIA/DIASession.h"
|
||||
#include "llvm/DebugInfo/PDB/PDBExtras.h"
|
||||
@ -178,9 +179,10 @@ void DumpDIAValue(llvm::raw_ostream &OS, int Indent, StringRef Name,
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
raw_ostream &operator<<(raw_ostream &OS, const GUID &Guid) {
|
||||
const PDB_UniqueId *Id = reinterpret_cast<const PDB_UniqueId *>(&Guid);
|
||||
OS << *Id;
|
||||
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const GUID &G) {
|
||||
StringRef GuidBytes(reinterpret_cast<const char *>(&G), sizeof(G));
|
||||
codeview::detail::GuidAdapter A(GuidBytes);
|
||||
A.format(OS, "");
|
||||
return OS;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "llvm/DebugInfo/PDB/PDBExtras.h"
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/DebugInfo/CodeView/Formatters.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::pdb;
|
||||
@ -259,6 +260,12 @@ raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
|
||||
return OS;
|
||||
}
|
||||
|
||||
raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_UniqueId &Guid) {
|
||||
codeview::detail::GuidAdapter A(Guid.Guid);
|
||||
A.format(OS, "");
|
||||
return OS;
|
||||
}
|
||||
|
||||
raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_UdtType &Type) {
|
||||
switch (Type) {
|
||||
CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Class, "class", OS)
|
||||
@ -269,25 +276,6 @@ raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_UdtType &Type) {
|
||||
return OS;
|
||||
}
|
||||
|
||||
raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_UniqueId &Id) {
|
||||
static const char *Lookup = "0123456789ABCDEF";
|
||||
|
||||
static_assert(sizeof(PDB_UniqueId) == 16, "Expected 16-byte GUID");
|
||||
ArrayRef<uint8_t> GuidBytes(reinterpret_cast<const uint8_t*>(&Id), 16);
|
||||
OS << "{";
|
||||
for (int i=0; i < 16;) {
|
||||
uint8_t Byte = GuidBytes[i];
|
||||
uint8_t HighNibble = (Byte >> 4) & 0xF;
|
||||
uint8_t LowNibble = Byte & 0xF;
|
||||
OS << Lookup[HighNibble] << Lookup[LowNibble];
|
||||
++i;
|
||||
if (i>=4 && i<=10 && i%2==0)
|
||||
OS << "-";
|
||||
}
|
||||
OS << "}";
|
||||
return OS;
|
||||
}
|
||||
|
||||
raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
|
||||
const PDB_Machine &Machine) {
|
||||
switch (Machine) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user