[Lldb-commits] [PATCH] D131081: [lldb] Prevent race condition when fetching /proc/cpuinfo
Pavel Labath via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 4 05:52:52 PDT 2022
labath added a comment.
It's not clear to me why you're insisting on `call_once`, when c++ guarantees that the function-local statics will only be initialized once (atomically). And with the new version, we don't even need the lambda..
================
Comment at: lldb/source/Plugins/Process/Linux/Procfs.cpp:12
#include "lldb/Host/linux/Support.h"
+
#include "llvm/Support/MemoryBuffer.h"
----------------
btw, llvm does not generally put blank lines between include headers. omitting those lets clang format reorder everything according to the [[ https://llvm.org/docs/CodingStandards.html#include-style | official style ]].
================
Comment at: lldb/source/Plugins/Process/Linux/Procfs.cpp:22-26
+ static Optional<ErrorOr<std::unique_ptr<MemoryBuffer>>> cpu_info_or_err;
+ static llvm::once_flag g_once_flag;
+
+ llvm::call_once(g_once_flag,
+ [] { cpu_info_or_err = getProcFile("cpuinfo"); });
----------------
And why not this?
================
Comment at: lldb/source/Plugins/Process/Linux/Procfs.cpp:30
+
+ MemoryBuffer &buffer = ***cpu_info_or_err;
+ return ArrayRef<uint8_t>(
----------------
lol
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131081/new/
https://reviews.llvm.org/D131081
More information about the lldb-commits
mailing list