[Lldb-commits] [lldb] 632cbca - [lldb] Move once_flags in HostInfoLinux so the internal state struct
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Thu Jun 10 23:53:58 PDT 2021
Author: Raphael Isemann
Date: 2021-06-11T08:53:38+02:00
New Revision: 632cbcac79065a62a306dbda7b3a6e1f315e3260
URL: https://github.com/llvm/llvm-project/commit/632cbcac79065a62a306dbda7b3a6e1f315e3260
DIFF: https://github.com/llvm/llvm-project/commit/632cbcac79065a62a306dbda7b3a6e1f315e3260.diff
LOG: [lldb] Move once_flags in HostInfoLinux so the internal state struct
The HostInfoLinuxFields struct is supposed to be set up/torn down on
Initialize/Terminate and should contain all the state of the plugin.
`once_flags` are part of this state and should also be reset on `Terminate` so
we can re-initialize these lazy values after the next `Initialize` call.
This itself is NFC as the HostInfoLinux was broken before this patch and is
still broken afterwards. D104091 will be the proper fix.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D104093
Added:
Modified:
lldb/source/Host/linux/HostInfoLinux.cpp
Removed:
################################################################################
diff --git a/lldb/source/Host/linux/HostInfoLinux.cpp b/lldb/source/Host/linux/HostInfoLinux.cpp
index 5f314cc7b50d9..36ac0ec6c3c37 100644
--- a/lldb/source/Host/linux/HostInfoLinux.cpp
+++ b/lldb/source/Host/linux/HostInfoLinux.cpp
@@ -26,7 +26,9 @@ using namespace lldb_private;
namespace {
struct HostInfoLinuxFields {
+ llvm::once_flag m_distribution_once_flag;
std::string m_distribution_id;
+ llvm::once_flag m_os_version_once_flag;
llvm::VersionTuple m_os_version;
};
@@ -40,8 +42,8 @@ void HostInfoLinux::Initialize(SharedLibraryDirectoryHelper *helper) {
}
llvm::VersionTuple HostInfoLinux::GetOSVersion() {
- static llvm::once_flag g_once_flag;
- llvm::call_once(g_once_flag, []() {
+ assert(g_fields && "Missing call to Initialize?");
+ llvm::call_once(g_fields->m_os_version_once_flag, []() {
struct utsname un;
if (uname(&un) != 0)
return;
@@ -82,10 +84,10 @@ bool HostInfoLinux::GetOSKernelDescription(std::string &s) {
}
llvm::StringRef HostInfoLinux::GetDistributionId() {
+ assert(g_fields && "Missing call to Initialize?");
// Try to run 'lbs_release -i', and use that response for the distribution
// id.
- static llvm::once_flag g_once_flag;
- llvm::call_once(g_once_flag, []() {
+ llvm::call_once(g_fields->m_distribution_once_flag, []() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST));
LLDB_LOGF(log, "attempting to determine Linux distribution...");
More information about the lldb-commits
mailing list