[llvm] [llvm-readobj] Consistent PDBGUID Formatting (PR #94256)
Miguel A. Arroyo via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 3 09:53:39 PDT 2024
https://github.com/mayanez created https://github.com/llvm/llvm-project/pull/94256
## Consistent PDB GUID in `llvm-readobj`
Currently, the PDB GUID is shown as a byte array:
`PDBGUID: (D8 4C 88 D9 26 15 1F 11 4C 4C 44 20 50 44 42 2E)`
This is inconsistent with `llvm-pdbutil` (e.g. `llvm-pdbutil dump --summary`) which shows it as a hexadecimal string.
Additionally, `llvm-yaml2obj` uses the same hexadecimal string format.
In general, the hexadecimal string is the common representation for PDB GUIDs on Windows.
This PR changes it to be consistent as shown below:
`PDBGUID: {D9884CD8-1526-111F-4C4C-44205044422E}`
>From 3b1f907d92cec2b1687742d20a879f3409ef18f3 Mon Sep 17 00:00:00 2001
From: Miguel Arroyo <miguel.arroyo at rockstargames.com>
Date: Fri, 31 May 2024 09:32:42 -0700
Subject: [PATCH] Consistent PDBGUID Formatting
---
llvm/test/tools/llvm-readobj/COFF/debug-directory.test | 2 +-
llvm/tools/llvm-readobj/COFFDumper.cpp | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/llvm/test/tools/llvm-readobj/COFF/debug-directory.test b/llvm/test/tools/llvm-readobj/COFF/debug-directory.test
index f67eb70d82095..88295679a290a 100644
--- a/llvm/test/tools/llvm-readobj/COFF/debug-directory.test
+++ b/llvm/test/tools/llvm-readobj/COFF/debug-directory.test
@@ -12,7 +12,7 @@ CHECK: AddressOfRawData: 0x5B068
CHECK: PointerToRawData: 0x5A268
CHECK: PDBInfo {
CHECK: PDBSignature: 0x53445352
-CHECK: PDBGUID: (96 83 40 42 81 07 9D 40 90 1B 4A 3C 0D 4F 56 32)
+CHECK: PDBGUID: {42408396-0781-409D-901B-4A3C0D4F5632}
CHECK: PDBAge: 3
CHECK: PDBFileName: D:\src\llvm\build\has_pdb.pdb
CHECK: }
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp
index 32b1d6a2089ca..b2939f7826393 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -27,6 +27,7 @@
#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
+#include "llvm/DebugInfo/CodeView/Formatters.h"
#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
#include "llvm/DebugInfo/CodeView/Line.h"
#include "llvm/DebugInfo/CodeView/MergingTypeTableBuilder.h"
@@ -793,7 +794,10 @@ void COFFDumper::printCOFFDebugDirectory() {
DictScope PDBScope(W, "PDBInfo");
W.printHex("PDBSignature", DebugInfo->Signature.CVSignature);
if (DebugInfo->Signature.CVSignature == OMF::Signature::PDB70) {
- W.printBinary("PDBGUID", ArrayRef(DebugInfo->PDB70.Signature));
+ SmallString<38> FormattedGUIDStr;
+ raw_svector_ostream OS(FormattedGUIDStr);
+ fmt_guid(DebugInfo->PDB70.Signature).format(OS, "" /*Style=unused*/);
+ W.printString("PDBGUID", FormattedGUIDStr);
W.printNumber("PDBAge", DebugInfo->PDB70.Age);
W.printString("PDBFileName", PDBFileName);
}
More information about the llvm-commits
mailing list