[llvm] r308234 - [codeview] Fix YAML for LF_TYPESERVER2 by hoisting PDB_UniqueId
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 17 16:59:44 PDT 2017
Author: rnk
Date: Mon Jul 17 16:59:44 2017
New Revision: 308234
URL: http://llvm.org/viewvc/llvm-project?rev=308234&view=rev
Log:
[codeview] Fix YAML for LF_TYPESERVER2 by hoisting PDB_UniqueId
Summary:
We were treating the GUIDs in TypeServer2Record as strings, and the
non-ASCII bytes in the GUID would not round-trip through YAML.
We already had the PDB_UniqueId type portably represent a Windows GUID,
but we need to hoist that up to the DebugInfo/CodeView library so that
we can use it in the TypeServer2Record as well as in PDB parsing code.
Reviewers: inglorion, amccarth
Subscribers: llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D35495
Added:
llvm/trunk/include/llvm/DebugInfo/CodeView/GUID.h
llvm/trunk/test/ObjectYAML/CodeView/
llvm/trunk/test/ObjectYAML/CodeView/guid.yaml
Modified:
llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
llvm/trunk/include/llvm/DebugInfo/CodeView/Formatters.h
llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h
llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h
llvm/trunk/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h
llvm/trunk/include/llvm/DebugInfo/PDB/Native/Formatters.h
llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStream.h
llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h
llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h
llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
llvm/trunk/include/llvm/DebugInfo/PDB/Native/RawTypes.h
llvm/trunk/include/llvm/DebugInfo/PDB/PDBExtras.h
llvm/trunk/include/llvm/ObjectYAML/CodeViewYAMLTypes.h
llvm/trunk/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
llvm/trunk/lib/DebugInfo/CodeView/Formatters.cpp
llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp
llvm/trunk/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp
llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp
llvm/trunk/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp
llvm/trunk/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp
llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp
llvm/trunk/lib/DebugInfo/PDB/PDBExtras.cpp
llvm/trunk/lib/ObjectYAML/CodeViewYAMLTypes.cpp
llvm/trunk/tools/llvm-pdbutil/MinimalTypeDumper.cpp
llvm/trunk/tools/llvm-pdbutil/PdbYaml.cpp
llvm/trunk/tools/llvm-pdbutil/PdbYaml.h
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h Mon Jul 17 16:59:44 2017
@@ -84,7 +84,7 @@ public:
Error mapEncodedInteger(uint64_t &Value);
Error mapEncodedInteger(APSInt &Value);
Error mapStringZ(StringRef &Value);
- Error mapGuid(StringRef &Guid);
+ Error mapGuid(GUID &Guid);
Error mapStringZVectorZ(std::vector<StringRef> &Value);
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/Formatters.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/Formatters.h?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/Formatters.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/Formatters.h Mon Jul 17 16:59:44 2017
@@ -12,6 +12,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/DebugInfo/CodeView/GUID.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/FormatVariadic.h"
@@ -31,7 +32,7 @@ public:
explicit GuidAdapter(ArrayRef<uint8_t> Guid);
explicit GuidAdapter(StringRef Guid);
- void format(raw_ostream &Stream, StringRef Style) override ;
+ void format(raw_ostream &Stream, StringRef Style) override;
};
} // end namespace detail
@@ -60,6 +61,13 @@ public:
}
};
+template <> struct format_provider<codeview::GUID> {
+ static void format(const codeview::GUID &V, llvm::raw_ostream &Stream,
+ StringRef Style) {
+ Stream << V;
+ }
+};
+
} // end namespace llvm
#endif // LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H
Added: llvm/trunk/include/llvm/DebugInfo/CodeView/GUID.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/GUID.h?rev=308234&view=auto
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/GUID.h (added)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/GUID.h Mon Jul 17 16:59:44 2017
@@ -0,0 +1,35 @@
+//===- GUID.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_GUID_H
+#define LLVM_DEBUGINFO_CODEVIEW_GUID_H
+
+#include <cstdint>
+#include <cstring>
+
+namespace llvm {
+class raw_ostream;
+
+namespace codeview {
+
+/// This represents the 'GUID' type from windows.h.
+struct GUID {
+ uint8_t Guid[16];
+};
+
+inline bool operator==(const GUID &LHS, const GUID &RHS) {
+ return 0 == ::memcmp(LHS.Guid, RHS.Guid, sizeof(LHS.Guid));
+}
+
+raw_ostream &operator<<(raw_ostream &OS, const GUID &Guid);
+
+} // namespace codeview
+} // namespace llvm
+
+#endif
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h Mon Jul 17 16:59:44 2017
@@ -18,6 +18,7 @@
#include "llvm/ADT/iterator_range.h"
#include "llvm/DebugInfo/CodeView/CVRecord.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/GUID.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/Support/BinaryStreamArray.h"
#include "llvm/Support/Endian.h"
@@ -539,15 +540,17 @@ class TypeServer2Record : public TypeRec
public:
TypeServer2Record() = default;
explicit TypeServer2Record(TypeRecordKind Kind) : TypeRecord(Kind) {}
- TypeServer2Record(StringRef Guid, uint32_t Age, StringRef Name)
- : TypeRecord(TypeRecordKind::TypeServer2), Guid(Guid), Age(Age),
- Name(Name) {}
+ TypeServer2Record(StringRef GuidStr, uint32_t Age, StringRef Name)
+ : TypeRecord(TypeRecordKind::TypeServer2), Age(Age), Name(Name) {
+ assert(GuidStr.size() == 16 && "guid isn't 16 bytes");
+ ::memcpy(Guid.Guid, GuidStr.data(), 16);
+ }
- StringRef getGuid() const { return Guid; }
+ const GUID &getGuid() const { return Guid; }
uint32_t getAge() const { return Age; }
StringRef getName() const { return Name; }
- StringRef Guid;
+ GUID Guid;
uint32_t Age;
StringRef Name;
};
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/DIA/DIARawSymbol.h Mon Jul 17 16:59:44 2017
@@ -106,7 +106,7 @@ public:
getVirtualBaseTableType() const override;
PDB_DataKind getDataKind() const override;
PDB_SymType getSymTag() const override;
- PDB_UniqueId getGuid() const override;
+ codeview::GUID getGuid() const override;
int32_t getOffset() const override;
int32_t getThisAdjust() const override;
int32_t getVirtualBasePointerOffset() const override;
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/IPDBRawSymbol.h Mon Jul 17 16:59:44 2017
@@ -118,7 +118,7 @@ public:
virtual uint32_t getVirtualTableShapeId() const = 0;
virtual PDB_DataKind getDataKind() const = 0;
virtual PDB_SymType getSymTag() const = 0;
- virtual PDB_UniqueId getGuid() const = 0;
+ virtual codeview::GUID getGuid() const = 0;
virtual int32_t getOffset() const = 0;
virtual int32_t getThisAdjust() const = 0;
virtual int32_t getVirtualBasePointerOffset() const = 0;
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/Formatters.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/Formatters.h?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/Formatters.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/Formatters.h Mon Jul 17 16:59:44 2017
@@ -23,13 +23,6 @@
break;
namespace llvm {
-template <> struct format_provider<pdb::PDB_UniqueId> {
- static void format(const pdb::PDB_UniqueId &V, llvm::raw_ostream &Stream,
- StringRef Style) {
- codeview::fmt_guid(V.Guid).format(Stream, Style);
- }
-};
-
template <> struct format_provider<pdb::PdbRaw_ImplVer> {
static void format(const pdb::PdbRaw_ImplVer &V, llvm::raw_ostream &Stream,
StringRef Style) {
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStream.h?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStream.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStream.h Mon Jul 17 16:59:44 2017
@@ -12,6 +12,7 @@
#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/ADT/StringMap.h"
+#include "llvm/DebugInfo/CodeView/GUID.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/PDB/Native/NamedStreamMap.h"
#include "llvm/DebugInfo/PDB/Native/RawConstants.h"
@@ -39,7 +40,7 @@ public:
PdbRaw_ImplVer getVersion() const;
uint32_t getSignature() const;
uint32_t getAge() const;
- PDB_UniqueId getGuid() const;
+ codeview::GUID getGuid() const;
uint32_t getNamedStreamMapByteSize() const;
PdbRaw_Features getFeatures() const;
@@ -71,7 +72,7 @@ private:
// Due to the aforementioned limitations with `Signature`, this is a new
// signature present on VC70 and higher PDBs which is guaranteed to be
// universally unique.
- PDB_UniqueId Guid;
+ codeview::GUID Guid;
BinarySubstreamRef SubNamedStreams;
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h Mon Jul 17 16:59:44 2017
@@ -37,7 +37,7 @@ public:
void setVersion(PdbRaw_ImplVer V);
void setSignature(uint32_t S);
void setAge(uint32_t A);
- void setGuid(PDB_UniqueId G);
+ void setGuid(codeview::GUID G);
void addFeature(PdbRaw_FeatureSig Sig);
uint32_t finalize();
@@ -54,7 +54,7 @@ private:
PdbRaw_ImplVer Ver;
uint32_t Sig;
uint32_t Age;
- PDB_UniqueId Guid;
+ codeview::GUID Guid;
NamedStreamMap &NamedStreams;
};
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h Mon Jul 17 16:59:44 2017
@@ -27,7 +27,7 @@ public:
uint32_t getAge() const override;
std::string getSymbolsFileName() const override;
- PDB_UniqueId getGuid() const override;
+ codeview::GUID getGuid() const override;
bool hasCTypes() const override;
bool hasPrivateSymbols() const override;
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h Mon Jul 17 16:59:44 2017
@@ -111,7 +111,7 @@ public:
getVirtualBaseTableType() const override;
PDB_DataKind getDataKind() const override;
PDB_SymType getSymTag() const override;
- PDB_UniqueId getGuid() const override;
+ codeview::GUID getGuid() const override;
int32_t getOffset() const override;
int32_t getThisAdjust() const override;
int32_t getVirtualBasePointerOffset() const override;
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Native/RawTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Native/RawTypes.h?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Native/RawTypes.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Native/RawTypes.h Mon Jul 17 16:59:44 2017
@@ -10,6 +10,7 @@
#ifndef LLVM_DEBUGINFO_PDB_RAW_RAWTYPES_H
#define LLVM_DEBUGINFO_PDB_RAW_RAWTYPES_H
+#include "llvm/DebugInfo/CodeView/GUID.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/Support/Endian.h"
@@ -268,17 +269,6 @@ struct PublicsStreamHeader {
support::ulittle32_t NumSections;
};
-/// Defines a 128-bit unique identifier. This maps to a GUID on Windows, but
-/// is abstracted here for the purposes of non-Windows platforms that don't have
-/// the GUID structure defined.
-struct PDB_UniqueId {
- uint8_t Guid[16];
-};
-
-inline bool operator==(const PDB_UniqueId &LHS, const PDB_UniqueId &RHS) {
- return 0 == ::memcmp(LHS.Guid, RHS.Guid, sizeof(LHS.Guid));
-}
-
// The header preceeding the global TPI stream.
// This corresponds to `HDR` in PDB/dbi/tpi.h.
struct TpiStreamHeader {
@@ -312,7 +302,7 @@ struct InfoStreamHeader {
support::ulittle32_t Version;
support::ulittle32_t Signature;
support::ulittle32_t Age;
- PDB_UniqueId Guid;
+ codeview::GUID Guid;
};
/// The header preceeding the /names stream.
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/PDBExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/PDBExtras.h?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/PDBExtras.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/PDBExtras.h Mon Jul 17 16:59:44 2017
@@ -32,7 +32,6 @@ raw_ostream &operator<<(raw_ostream &OS,
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_Machine &Machine);
Modified: llvm/trunk/include/llvm/ObjectYAML/CodeViewYAMLTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ObjectYAML/CodeViewYAMLTypes.h?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ObjectYAML/CodeViewYAMLTypes.h (original)
+++ llvm/trunk/include/llvm/ObjectYAML/CodeViewYAMLTypes.h Mon Jul 17 16:59:44 2017
@@ -60,6 +60,8 @@ ArrayRef<uint8_t> toDebugT(ArrayRef<Leaf
} // end namespace llvm
+LLVM_YAML_DECLARE_SCALAR_TRAITS(codeview::GUID, true)
+
LLVM_YAML_DECLARE_MAPPING_TRAITS(CodeViewYAML::LeafRecord)
LLVM_YAML_DECLARE_MAPPING_TRAITS(CodeViewYAML::MemberRecord)
Modified: llvm/trunk/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp Mon Jul 17 16:59:44 2017
@@ -168,18 +168,19 @@ Error CodeViewRecordIO::mapStringZ(Strin
return Error::success();
}
-Error CodeViewRecordIO::mapGuid(StringRef &Guid) {
+Error CodeViewRecordIO::mapGuid(GUID &Guid) {
constexpr uint32_t GuidSize = 16;
if (maxFieldLength() < GuidSize)
return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
if (isWriting()) {
- assert(Guid.size() == 16 && "Invalid Guid Size!");
- if (auto EC = Writer->writeFixedString(Guid))
+ if (auto EC = Writer->writeBytes(Guid.Guid))
return EC;
} else {
- if (auto EC = Reader->readFixedString(Guid, 16))
+ ArrayRef<uint8_t> GuidBytes;
+ if (auto EC = Reader->readBytes(GuidBytes, GuidSize))
return EC;
+ memcpy(Guid.Guid, GuidBytes.data(), GuidSize);
}
return Error::success();
}
Modified: llvm/trunk/lib/DebugInfo/CodeView/Formatters.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/Formatters.cpp?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/Formatters.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/Formatters.cpp Mon Jul 17 16:59:44 2017
@@ -9,6 +9,7 @@
#include "llvm/DebugInfo/CodeView/Formatters.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/DebugInfo/CodeView/GUID.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
@@ -39,3 +40,9 @@ void GuidAdapter::format(raw_ostream &St
}
Stream << "}";
}
+
+raw_ostream &llvm::codeview::operator<<(raw_ostream &OS, const GUID &Guid) {
+ codeview::detail::GuidAdapter A(Guid.Guid);
+ A.format(OS, "");
+ return OS;
+}
Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp Mon Jul 17 16:59:44 2017
@@ -354,7 +354,7 @@ Error TypeDumpVisitor::visitKnownRecord(
}
Error TypeDumpVisitor::visitKnownRecord(CVType &CVR, TypeServer2Record &TS) {
- W->printString("Guid", formatv("{0}", fmt_guid(TS.getGuid())).str());
+ W->printString("Guid", formatv("{0}", TS.getGuid()).str());
W->printNumber("Age", TS.getAge());
W->printString("Name", TS.getName());
return Error::success();
Modified: llvm/trunk/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/DIA/DIARawSymbol.cpp Mon Jul 17 16:59:44 2017
@@ -125,16 +125,16 @@ PrivateGetDIAValue(IDiaSymbol *Symbol,
return Result8;
}
-PDB_UniqueId
+codeview::GUID
PrivateGetDIAValue(IDiaSymbol *Symbol,
HRESULT (__stdcall IDiaSymbol::*Method)(GUID *)) {
GUID Result;
if (S_OK != (Symbol->*Method)(&Result))
- return PDB_UniqueId();
+ return codeview::GUID();
- static_assert(sizeof(PDB_UniqueId) == sizeof(GUID),
- "PDB_UniqueId is the wrong size!");
- PDB_UniqueId IdResult;
+ static_assert(sizeof(codeview::GUID) == sizeof(GUID),
+ "GUID is the wrong size!");
+ codeview::GUID IdResult;
::memcpy(&IdResult, &Result, sizeof(GUID));
return IdResult;
}
@@ -746,7 +746,7 @@ PDB_SymType DIARawSymbol::getSymTag() co
&IDiaSymbol::get_symTag);
}
-PDB_UniqueId DIARawSymbol::getGuid() const {
+codeview::GUID DIARawSymbol::getGuid() const {
return PrivateGetDIAValue(Symbol, &IDiaSymbol::get_guid);
}
Modified: llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/InfoStream.cpp Mon Jul 17 16:59:44 2017
@@ -118,7 +118,7 @@ uint32_t InfoStream::getSignature() cons
uint32_t InfoStream::getAge() const { return Age; }
-PDB_UniqueId InfoStream::getGuid() const { return Guid; }
+GUID InfoStream::getGuid() const { return Guid; }
uint32_t InfoStream::getNamedStreamMapByteSize() const {
return NamedStreamMapByteSize;
Modified: llvm/trunk/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/InfoStreamBuilder.cpp Mon Jul 17 16:59:44 2017
@@ -34,7 +34,7 @@ void InfoStreamBuilder::setSignature(uin
void InfoStreamBuilder::setAge(uint32_t A) { Age = A; }
-void InfoStreamBuilder::setGuid(PDB_UniqueId G) { Guid = G; }
+void InfoStreamBuilder::setGuid(GUID G) { Guid = G; }
void InfoStreamBuilder::addFeature(PdbRaw_FeatureSig Sig) {
Features.push_back(Sig);
Modified: llvm/trunk/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp Mon Jul 17 16:59:44 2017
@@ -56,12 +56,12 @@ std::string NativeExeSymbol::getSymbolsF
return File.getFilePath();
}
-PDB_UniqueId NativeExeSymbol::getGuid() const {
+codeview::GUID NativeExeSymbol::getGuid() const {
auto IS = File.getPDBInfoStream();
if (IS)
return IS->getGuid();
consumeError(IS.takeError());
- return PDB_UniqueId{{0}};
+ return codeview::GUID{{0}};
}
bool NativeExeSymbol::hasCTypes() const {
Modified: llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp Mon Jul 17 16:59:44 2017
@@ -323,9 +323,7 @@ PDB_SymType NativeRawSymbol::getSymTag()
return PDB_SymType::None;
}
-PDB_UniqueId NativeRawSymbol::getGuid() const {
- return PDB_UniqueId{{0}};
-}
+codeview::GUID NativeRawSymbol::getGuid() const { return codeview::GUID{{0}}; }
int32_t NativeRawSymbol::getOffset() const {
return 0;
Modified: llvm/trunk/lib/DebugInfo/PDB/PDBExtras.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/PDBExtras.cpp?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/PDBExtras.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/PDBExtras.cpp Mon Jul 17 16:59:44 2017
@@ -260,12 +260,6 @@ raw_ostream &llvm::pdb::operator<<(raw_o
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)
Modified: llvm/trunk/lib/ObjectYAML/CodeViewYAMLTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/CodeViewYAMLTypes.cpp?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/lib/ObjectYAML/CodeViewYAMLTypes.cpp (original)
+++ llvm/trunk/lib/ObjectYAML/CodeViewYAMLTypes.cpp Mon Jul 17 16:59:44 2017
@@ -141,6 +141,33 @@ template <typename T> struct MemberRecor
} // end namespace CodeViewYAML
} // end namespace llvm
+void ScalarTraits<GUID>::output(const GUID &G, void *, llvm::raw_ostream &OS) {
+ OS << G;
+}
+
+StringRef ScalarTraits<GUID>::input(StringRef Scalar, void *Ctx, GUID &S) {
+ if (Scalar.size() != 38)
+ return "GUID strings are 38 characters long";
+ if (Scalar[0] != '{' || Scalar[37] != '}')
+ return "GUID is not enclosed in {}";
+ if (Scalar[9] != '-' || Scalar[14] != '-' || Scalar[19] != '-' ||
+ Scalar[24] != '-')
+ return "GUID sections are not properly delineated with dashes";
+
+ uint8_t *OutBuffer = S.Guid;
+ for (auto Iter = Scalar.begin(); Iter != Scalar.end();) {
+ if (*Iter == '-' || *Iter == '{' || *Iter == '}') {
+ ++Iter;
+ continue;
+ }
+ uint8_t Value = (llvm::hexDigitValue(*Iter++) << 4);
+ Value |= llvm::hexDigitValue(*Iter++);
+ *OutBuffer++ = Value;
+ }
+
+ return "";
+}
+
void ScalarTraits<TypeIndex>::output(const TypeIndex &S, void *,
raw_ostream &OS) {
OS << S.getIndex();
Added: llvm/trunk/test/ObjectYAML/CodeView/guid.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ObjectYAML/CodeView/guid.yaml?rev=308234&view=auto
==============================================================================
--- llvm/trunk/test/ObjectYAML/CodeView/guid.yaml (added)
+++ llvm/trunk/test/ObjectYAML/CodeView/guid.yaml Mon Jul 17 16:59:44 2017
@@ -0,0 +1,59 @@
+# RUN: yaml2obj %s | obj2yaml | FileCheck %s
+
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_AMD64
+ Characteristics: [ ]
+sections:
+ - Name: '.debug$T'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
+ Alignment: 1
+ Types:
+ - Kind: LF_TYPESERVER2
+ TypeServer2:
+ Guid: '{01DF191B-22BF-6B42-96CE-5258B8329FE5}'
+ Age: 24
+ Name: 'C:\src\llvm-project\build\vc140.pdb'
+symbols:
+ - Name: '.debug$T'
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 64
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 0
+...
+
+# CHECK: --- !COFF
+# CHECK: header:
+# CHECK: Machine: IMAGE_FILE_MACHINE_AMD64
+# CHECK: Characteristics: [ ]
+# CHECK: sections:
+# CHECK: - Name: '.debug$T'
+# CHECK: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
+# CHECK: Alignment: 1
+# CHECK: Types:
+# CHECK: - Kind: LF_TYPESERVER2
+# CHECK: TypeServer2:
+# CHECK: Guid: '{01DF191B-22BF-6B42-96CE-5258B8329FE5}'
+# CHECK: Age: 24
+# CHECK: Name: 'C:\src\llvm-project\build\vc140.pdb'
+# CHECK: symbols:
+# CHECK: - Name: '.debug$T'
+# CHECK: Value: 0
+# CHECK: SectionNumber: 1
+# CHECK: SimpleType: IMAGE_SYM_TYPE_NULL
+# CHECK: ComplexType: IMAGE_SYM_DTYPE_NULL
+# CHECK: StorageClass: IMAGE_SYM_CLASS_STATIC
+# CHECK: SectionDefinition:
+# CHECK: Length: 64
+# CHECK: NumberOfRelocations: 0
+# CHECK: NumberOfLinenumbers: 0
+# CHECK: CheckSum: 0
+# CHECK: Number: 0
+# CHECK: ...
Modified: llvm/trunk/tools/llvm-pdbutil/MinimalTypeDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/MinimalTypeDumper.cpp?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/MinimalTypeDumper.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/MinimalTypeDumper.cpp Mon Jul 17 16:59:44 2017
@@ -395,8 +395,7 @@ Error MinimalTypeDumpVisitor::visitKnown
Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR,
TypeServer2Record &TS) {
- P.formatLine("name = {0}, age = {1}, guid = {2}", TS.Name, TS.Age,
- fmt_guid(TS.Guid));
+ P.formatLine("name = {0}, age = {1}, guid = {2}", TS.Name, TS.Age, TS.Guid);
return Error::success();
}
Modified: llvm/trunk/tools/llvm-pdbutil/PdbYaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/PdbYaml.cpp?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/PdbYaml.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/PdbYaml.cpp Mon Jul 17 16:59:44 2017
@@ -38,41 +38,6 @@ LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(llvm::
namespace llvm {
namespace yaml {
-template <> struct ScalarTraits<llvm::pdb::PDB_UniqueId> {
- static void output(const llvm::pdb::PDB_UniqueId &S, void *,
- llvm::raw_ostream &OS) {
- OS << S;
- }
-
- static StringRef input(StringRef Scalar, void *Ctx,
- llvm::pdb::PDB_UniqueId &S) {
- if (Scalar.size() != 38)
- return "GUID strings are 38 characters long";
- if (Scalar[0] != '{' || Scalar[37] != '}')
- return "GUID is not enclosed in {}";
- if (Scalar[9] != '-' || Scalar[14] != '-' || Scalar[19] != '-' ||
- Scalar[24] != '-')
- return "GUID sections are not properly delineated with dashes";
-
- uint8_t *OutBuffer = S.Guid;
- for (auto Iter = Scalar.begin(); Iter != Scalar.end();) {
- if (*Iter == '-' || *Iter == '{' || *Iter == '}') {
- ++Iter;
- continue;
- }
- uint8_t Value = (llvm::hexDigitValue(*Iter) << 4);
- ++Iter;
- Value |= llvm::hexDigitValue(*Iter);
- ++Iter;
- *OutBuffer++ = Value;
- }
-
- return "";
- }
-
- static bool mustQuote(StringRef Scalar) { return needsQuotes(Scalar); }
-};
-
template <> struct ScalarEnumerationTraits<llvm::pdb::PDB_Machine> {
static void enumeration(IO &io, llvm::pdb::PDB_Machine &Value) {
io.enumCase(Value, "Invalid", PDB_Machine::Invalid);
Modified: llvm/trunk/tools/llvm-pdbutil/PdbYaml.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/PdbYaml.h?rev=308234&r1=308233&r2=308234&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/PdbYaml.h (original)
+++ llvm/trunk/tools/llvm-pdbutil/PdbYaml.h Mon Jul 17 16:59:44 2017
@@ -57,7 +57,7 @@ struct PdbInfoStream {
PdbRaw_ImplVer Version = PdbImplVC70;
uint32_t Signature = 0;
uint32_t Age = 1;
- PDB_UniqueId Guid;
+ codeview::GUID Guid;
std::vector<PdbRaw_FeatureSig> Features;
std::vector<NamedStreamMapping> NamedStreams;
};
More information about the llvm-commits
mailing list