[lldb][NFC] Refactor getUUID functionality
Differential Revision: https://reviews.llvm.org/D90325
This commit is contained in:
@@ -43,45 +43,16 @@ using namespace lldb_private;
|
||||
|
||||
LLDB_PLUGIN_DEFINE(ObjectFilePECOFF)
|
||||
|
||||
struct CVInfoPdb70 {
|
||||
// 16-byte GUID
|
||||
struct _Guid {
|
||||
llvm::support::ulittle32_t Data1;
|
||||
llvm::support::ulittle16_t Data2;
|
||||
llvm::support::ulittle16_t Data3;
|
||||
uint8_t Data4[8];
|
||||
} Guid;
|
||||
|
||||
llvm::support::ulittle32_t Age;
|
||||
};
|
||||
|
||||
static UUID GetCoffUUID(llvm::object::COFFObjectFile &coff_obj) {
|
||||
const llvm::codeview::DebugInfo *pdb_info = nullptr;
|
||||
llvm::StringRef pdb_file;
|
||||
|
||||
// This part is similar with what has done in minidump parser.
|
||||
if (!coff_obj.getDebugPDBInfo(pdb_info, pdb_file) && pdb_info) {
|
||||
if (pdb_info->PDB70.CVSignature == llvm::OMF::Signature::PDB70) {
|
||||
using llvm::support::endian::read16be;
|
||||
using llvm::support::endian::read32be;
|
||||
|
||||
const uint8_t *sig = pdb_info->PDB70.Signature;
|
||||
struct CVInfoPdb70 info;
|
||||
info.Guid.Data1 = read32be(sig);
|
||||
sig += 4;
|
||||
info.Guid.Data2 = read16be(sig);
|
||||
sig += 2;
|
||||
info.Guid.Data3 = read16be(sig);
|
||||
sig += 2;
|
||||
memcpy(info.Guid.Data4, sig, 8);
|
||||
|
||||
// Return 20-byte UUID if the Age is not zero
|
||||
if (pdb_info->PDB70.Age) {
|
||||
info.Age = read32be(&pdb_info->PDB70.Age);
|
||||
return UUID::fromOptionalData(&info, sizeof(info));
|
||||
}
|
||||
// Otherwise return 16-byte GUID
|
||||
return UUID::fromOptionalData(&info.Guid, sizeof(info.Guid));
|
||||
UUID::CvRecordPdb70 info;
|
||||
memcpy(&info.Uuid, pdb_info->PDB70.Signature, sizeof(info.Uuid));
|
||||
info.Age = pdb_info->PDB70.Age;
|
||||
return UUID::fromCvRecord(info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user