[Lldb-commits] [PATCH] D57195: Add UUID::SetFromOptionalStringRef, use it in DynamicLoaderDarwin
Jim Ingham via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Jan 24 14:44:10 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB352122: Add UUID::SetFromOptionalStringRef, use it in DynamicLoaderDarwin (authored by jingham, committed by ).
Repository:
rLLDB LLDB
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57195/new/
https://reviews.llvm.org/D57195
Files:
include/lldb/Utility/UUID.h
source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
source/Utility/UUID.cpp
unittests/Utility/UUIDTest.cpp
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) {
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: 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: 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57195.183407.patch
Type: text/x-patch
Size: 2720 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190124/2153f2c5/attachment.bin>
More information about the lldb-commits
mailing list