Index: include/lldb/Utility/UUID.h =================================================================== --- include/lldb/Utility/UUID.h +++ include/lldb/Utility/UUID.h @@ -67,6 +67,11 @@ std::string GetAsString(llvm::StringRef separator = "-") const; size_t SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes = 16); + + // Same as SetFromStringRef, but if the resultant UUID is all 0 bytes, set the + // UUID to invalid. + size_t SetFromOptionalStringRef(llvm::StringRef str, + uint32_t num_uuid_bytes = 16); // Decode as many UUID bytes (up to 16) as possible from the C string "cstr" // This is used for auto completion where a partial UUID might have been Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -476,7 +476,7 @@ image_infos[i].segments.push_back(segment); } - image_infos[i].uuid.SetFromStringRef( + image_infos[i].uuid.SetFromOptionalStringRef( image->GetValueForKey("uuid")->GetAsString()->GetValue()); // All sections listed in the dyld image info structure will all either be Index: source/Utility/UUID.cpp =================================================================== --- source/Utility/UUID.cpp +++ source/Utility/UUID.cpp @@ -109,3 +109,15 @@ // Else return zero to indicate we were not able to parse a UUID value return 0; } + +size_t UUID::SetFromOptionalStringRef(llvm::StringRef str, + uint32_t num_uuid_bytes) { + size_t num_chars_consumed = SetFromStringRef(str, num_uuid_bytes); + if (num_chars_consumed) { + if (llvm::all_of(m_bytes, [](uint8_t b) { return b == 0; })) + Clear(); + } + + return num_chars_consumed; +} + Index: unittests/Utility/UUIDTest.cpp =================================================================== --- unittests/Utility/UUIDTest.cpp +++ unittests/Utility/UUIDTest.cpp @@ -41,11 +41,18 @@ UUID a20 = UUID::fromData(zeroes.data(), 20); UUID a16_0 = UUID::fromOptionalData(zeroes.data(), 16); UUID a20_0 = UUID::fromOptionalData(zeroes.data(), 20); + UUID from_str; + from_str.SetFromStringRef("00000000-0000-0000-0000-000000000000"); + UUID opt_from_str; + opt_from_str.SetFromOptionalStringRef("00000000-0000-0000-0000-000000000000"); + EXPECT_FALSE(empty); EXPECT_TRUE(a16); EXPECT_TRUE(a20); + EXPECT_TRUE(from_str); EXPECT_FALSE(a16_0); EXPECT_FALSE(a20_0); + EXPECT_FALSE(opt_from_str); } TEST(UUIDTest, SetFromStringRef) {