vitalybuka created this revision. vitalybuka requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
Test leaks if we run tools/lldb/unittests/Host/HostTests without --gtest_filter Also if we call HostInfoLinux::Initialize twice some llvm::call_once will prevent initialization of some fields. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D104091 Files: lldb/source/Host/linux/HostInfoLinux.cpp lldb/unittests/Host/HostInfoTest.cpp Index: lldb/unittests/Host/HostInfoTest.cpp =================================================================== --- lldb/unittests/Host/HostInfoTest.cpp +++ lldb/unittests/Host/HostInfoTest.cpp @@ -60,3 +60,16 @@ EXPECT_TRUE(HostInfo::GetXcodeSDKPath(XcodeSDK("CeciNestPasUnOS.sdk")).empty()); } #endif + +TEST(HostInfoTest2, InitTwice) { + llvm::VersionTuple Version; + { + SubsystemRAII<FileSystem, HostInfo> subsystems; + Version = HostInfo::GetOSVersion(); + } + + { + SubsystemRAII<FileSystem, HostInfo> subsystems; + EXPECT_EQ(Version, HostInfo::GetOSVersion()); + } +} Index: lldb/source/Host/linux/HostInfoLinux.cpp =================================================================== --- lldb/source/Host/linux/HostInfoLinux.cpp +++ lldb/source/Host/linux/HostInfoLinux.cpp @@ -35,8 +35,8 @@ void HostInfoLinux::Initialize(SharedLibraryDirectoryHelper *helper) { HostInfoPosix::Initialize(helper); - - g_fields = new HostInfoLinuxFields(); + if (!g_fields) + g_fields = new HostInfoLinuxFields(); } llvm::VersionTuple HostInfoLinux::GetOSVersion() {
Index: lldb/unittests/Host/HostInfoTest.cpp =================================================================== --- lldb/unittests/Host/HostInfoTest.cpp +++ lldb/unittests/Host/HostInfoTest.cpp @@ -60,3 +60,16 @@ EXPECT_TRUE(HostInfo::GetXcodeSDKPath(XcodeSDK("CeciNestPasUnOS.sdk")).empty()); } #endif + +TEST(HostInfoTest2, InitTwice) { + llvm::VersionTuple Version; + { + SubsystemRAII<FileSystem, HostInfo> subsystems; + Version = HostInfo::GetOSVersion(); + } + + { + SubsystemRAII<FileSystem, HostInfo> subsystems; + EXPECT_EQ(Version, HostInfo::GetOSVersion()); + } +} Index: lldb/source/Host/linux/HostInfoLinux.cpp =================================================================== --- lldb/source/Host/linux/HostInfoLinux.cpp +++ lldb/source/Host/linux/HostInfoLinux.cpp @@ -35,8 +35,8 @@ void HostInfoLinux::Initialize(SharedLibraryDirectoryHelper *helper) { HostInfoPosix::Initialize(helper); - - g_fields = new HostInfoLinuxFields(); + if (!g_fields) + g_fields = new HostInfoLinuxFields(); } llvm::VersionTuple HostInfoLinux::GetOSVersion() {
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits