mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
[lld] Fixed CodeView GuidAdapter::format to handle GUID bytes in the right order.
This fixes https://bugs.llvm.org/show_bug.cgi?id=41712 bug. Reviewed By: aganea Differential Revision: https://reviews.llvm.org/D99978
This commit is contained in:
parent
c70b8c71ee
commit
a8234cdb0e
@ -24,20 +24,21 @@ GuidAdapter::GuidAdapter(ArrayRef<uint8_t> Guid)
|
||||
: FormatAdapter(std::move(Guid)) {}
|
||||
|
||||
void GuidAdapter::format(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 << "}";
|
||||
struct MSGuid {
|
||||
support::ulittle32_t Data1;
|
||||
support::ulittle16_t Data2;
|
||||
support::ulittle16_t Data3;
|
||||
support::ubig64_t Data4;
|
||||
};
|
||||
const MSGuid *G = reinterpret_cast<const MSGuid *>(Item.data());
|
||||
Stream
|
||||
<< '{' << format_hex_no_prefix(G->Data1, sizeof(G->Data1), /*Upper=*/true)
|
||||
<< '-' << format_hex_no_prefix(G->Data2, sizeof(G->Data2), /*Upper=*/true)
|
||||
<< '-' << format_hex_no_prefix(G->Data3, sizeof(G->Data3), /*Upper=*/true)
|
||||
<< '-' << format_hex_no_prefix(G->Data4 >> 48, 2, /*Upper=*/true) << '-'
|
||||
<< format_hex_no_prefix(G->Data4 & ((1ULL << 48) - 1), 6, /*Upper=*/true)
|
||||
<< '}';
|
||||
}
|
||||
|
||||
raw_ostream &llvm::codeview::operator<<(raw_ostream &OS, const GUID &Guid) {
|
||||
|
@ -148,23 +148,28 @@ void ScalarTraits<GUID>::output(const GUID &G, void *, llvm::raw_ostream &OS) {
|
||||
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] != '}')
|
||||
if (Scalar.front() != '{' || Scalar.back() != '}')
|
||||
return "GUID is not enclosed in {}";
|
||||
if (Scalar[9] != '-' || Scalar[14] != '-' || Scalar[19] != '-' ||
|
||||
Scalar[24] != '-')
|
||||
Scalar = Scalar.substr(1, Scalar.size() - 2);
|
||||
SmallVector<StringRef, 6> A;
|
||||
Scalar.split(A, '-', 5);
|
||||
if (A.size() != 5 || Scalar[8] != '-' || Scalar[13] != '-' ||
|
||||
Scalar[18] != '-' || Scalar[23] != '-')
|
||||
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;
|
||||
}
|
||||
|
||||
struct MSGuid {
|
||||
support::ulittle32_t Data1;
|
||||
support::ulittle16_t Data2;
|
||||
support::ulittle16_t Data3;
|
||||
support::ubig64_t Data4;
|
||||
};
|
||||
MSGuid G = {};
|
||||
uint64_t D41{}, D42{};
|
||||
if (!to_integer(A[0], G.Data1, 16) || !to_integer(A[1], G.Data2, 16) ||
|
||||
!to_integer(A[2], G.Data3, 16) || !to_integer(A[3], D41, 16) ||
|
||||
!to_integer(A[4], D42, 16))
|
||||
return "GUID contains non hex digits";
|
||||
G.Data4 = (D41 << 48) | D42;
|
||||
::memcpy(&S, &G, sizeof(GUID));
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
; Check that neither symbols nor compilands are dumped when neither argument specified.
|
||||
; NO_ARGS: empty.pdb
|
||||
; NO_ARGS: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0}
|
||||
; NO_ARGS: Guid: {4156350B-A086-49A2-896F-9988FAE52FF0}
|
||||
; NO_ARGS: Attributes: HasPrivateSymbols
|
||||
; NO_ARGS-NOT: ---TYPES---
|
||||
; NO_ARGS-NOT: ---COMPILANDS---
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
; Check that only types are dumped when only -types is specified.
|
||||
; TYPES: empty.pdb
|
||||
; TYPES: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0}
|
||||
; TYPES: Guid: {4156350B-A086-49A2-896F-9988FAE52FF0}
|
||||
; TYPES: Attributes: HasPrivateSymbols
|
||||
; TYPES: ---TYPES---
|
||||
; TYPES-NOT: ---COMPILANDS---
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
; Check that only compilands are dumped when only -compilands is specified.
|
||||
; COMPILANDS: empty.pdb
|
||||
; COMPILANDS: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0}
|
||||
; COMPILANDS: Guid: {4156350B-A086-49A2-896F-9988FAE52FF0}
|
||||
; COMPILANDS: Attributes: HasPrivateSymbols
|
||||
; COMPILANDS: ---COMPILANDS---
|
||||
; COMPILANDS-NOT: ---TYPES---
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
; Check that types and compilands are dumped when both arguments are specified.
|
||||
; MULTIPLE: empty.pdb
|
||||
; MULTIPLE: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0}
|
||||
; MULTIPLE: Guid: {4156350B-A086-49A2-896F-9988FAE52FF0}
|
||||
; MULTIPLE: Attributes: HasPrivateSymbols
|
||||
; MULTIPLE: ---COMPILANDS---
|
||||
; MULTIPLE: ---TYPES---
|
||||
|
@ -6,6 +6,6 @@
|
||||
; `-native` option produces identical output.
|
||||
|
||||
; EMPTY: Size: 102400 bytes
|
||||
; EMPTY: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0}
|
||||
; EMPTY: Guid: {4156350B-A086-49A2-896F-9988FAE52FF0}
|
||||
; EMPTY: Age: 1
|
||||
; EMPTY: Attributes: HasPrivateSymbols
|
||||
|
@ -12,7 +12,7 @@ ALL-NEXT: Number of blocks: 25
|
||||
ALL-NEXT: Number of streams: 17
|
||||
ALL-NEXT: Signature: 1424295906
|
||||
ALL-NEXT: Age: 1
|
||||
ALL-NEXT: GUID: {0B355641-86A0-A249-896F-9988FAE52FF0}
|
||||
ALL-NEXT: GUID: {4156350B-A086-49A2-896F-9988FAE52FF0}
|
||||
ALL-NEXT: Features: 0x1
|
||||
ALL-NEXT: Has Debug Info: true
|
||||
ALL-NEXT: Has Types: true
|
||||
@ -601,7 +601,7 @@ BIG-NEXT: Number of blocks: 99
|
||||
BIG-NEXT: Number of streams: 64
|
||||
BIG-NEXT: Signature: 1461714535
|
||||
BIG-NEXT: Age: 1
|
||||
BIG-NEXT: GUID: {880ECC89-DF81-0B4F-839C-58CBD052E937}
|
||||
BIG-NEXT: GUID: {89CC0E88-81DF-4F0B-839C-58CBD052E937}
|
||||
BIG-NEXT: Features: 0x1
|
||||
BIG-NEXT: Has Debug Info: true
|
||||
BIG-NEXT: Has Types: true
|
||||
|
@ -14,7 +14,7 @@ CHECK-NEXT: Number of blocks:
|
||||
CHECK-NEXT: Number of streams:
|
||||
CHECK-NEXT: Signature: 1424295906
|
||||
CHECK-NEXT: Age: 1
|
||||
CHECK-NEXT: GUID: {0B355641-86A0-A249-896F-9988FAE52FF0}
|
||||
CHECK-NEXT: GUID: {4156350B-A086-49A2-896F-9988FAE52FF0}
|
||||
CHECK-NEXT: Features: 0x1
|
||||
CHECK-NEXT: Has Debug Info: true
|
||||
CHECK-NEXT: Has Types: true
|
||||
|
@ -42,7 +42,7 @@
|
||||
; YAML-NEXT: - '$T0 $ebp = $eip $T0 4 + ^ = $ebp $T0 ^ = $esp $T0 8 + = '
|
||||
; YAML-NEXT: PdbStream:
|
||||
; YAML-NEXT: Age: 1
|
||||
; YAML-NEXT: Guid: '{0B355641-86A0-A249-896F-9988FAE52FF0}'
|
||||
; YAML-NEXT: Guid: '{4156350B-A086-49A2-896F-9988FAE52FF0}'
|
||||
; YAML-NEXT: Signature: 1424295906
|
||||
; YAML-NEXT: Features: [ VC110 ]
|
||||
; YAML-NEXT: Version: VC70
|
||||
|
@ -13,7 +13,7 @@ sections:
|
||||
Types:
|
||||
- Kind: LF_TYPESERVER2
|
||||
TypeServer2:
|
||||
Guid: '{01DF191B-22BF-6B42-96CE-5258B8329FE5}'
|
||||
Guid: '{1B19DF01-BF22-426B-96CE-5258B8329FE5}'
|
||||
Age: 24
|
||||
Name: 'C:\src\llvm-project\build\vc140.pdb'
|
||||
- Name: '.debug$H'
|
||||
@ -66,7 +66,7 @@ symbols:
|
||||
# CHECK: Types:
|
||||
# CHECK: - Kind: LF_TYPESERVER2
|
||||
# CHECK: TypeServer2:
|
||||
# CHECK: Guid: '{01DF191B-22BF-6B42-96CE-5258B8329FE5}'
|
||||
# CHECK: Guid: '{1B19DF01-BF22-426B-96CE-5258B8329FE5}'
|
||||
# CHECK: Age: 24
|
||||
# CHECK: Name: 'C:\src\llvm-project\build\vc140.pdb'
|
||||
# CHECK: - Name: '.debug$H'
|
||||
|
@ -39,7 +39,7 @@ CHECK-NEXT: Address is at offset 12/202 of Stream 1 (PDB Stream).
|
||||
CHECK-NEXT: Within the PDB stream:
|
||||
CHECK-NEXT: address is at offset 12/28 of the PDB Stream Header.
|
||||
CHECK-NEXT: which contains the guid of the PDB.
|
||||
CHECK-NEXT: The current value is {826BE46E-02ED-7043-9C27-20CCC07E92A7}.
|
||||
CHECK-NEXT: The current value is {6EE46B82-ED02-4370-9C27-20CCC07E92A7}.
|
||||
|
||||
CHECK: Block:Offset = 11:001C.
|
||||
CHECK-NEXT: Address is in block 17 (allocated).
|
||||
|
@ -8,7 +8,7 @@
|
||||
; CHECK-NEXT: Number of streams: 12
|
||||
; CHECK-NEXT: Signature: 1541179274
|
||||
; CHECK-NEXT: Age: 2
|
||||
; CHECK-NEXT: GUID: {FF4F9B62-D99A-4647-97A7-22C702B1E053}
|
||||
; CHECK-NEXT: GUID: {629B4FFF-9AD9-4746-97A7-22C702B1E053}
|
||||
; CHECK-NEXT: Features: 0x1
|
||||
; CHECK-NEXT: Has Debug Info: true
|
||||
; CHECK-NEXT: Has Types: true
|
||||
|
Loading…
Reference in New Issue
Block a user