diff --git a/lldb/source/Plugins/Process/Linux/Procfs.cpp b/lldb/source/Plugins/Process/Linux/Procfs.cpp index 7c0c55a4f208..f59883d1caff 100644 --- a/lldb/source/Plugins/Process/Linux/Procfs.cpp +++ b/lldb/source/Plugins/Process/Linux/Procfs.cpp @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include "Procfs.h" - #include "lldb/Host/linux/Support.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/Threading.h" using namespace lldb; using namespace lldb_private; @@ -17,17 +17,14 @@ using namespace process_linux; using namespace llvm; Expected> lldb_private::process_linux::GetProcfsCpuInfo() { - static Optional> cpu_info; - if (!cpu_info) { - auto buffer_or_error = errorOrToExpected(getProcFile("cpuinfo")); - if (!buffer_or_error) - return buffer_or_error.takeError(); - MemoryBuffer &buffer = **buffer_or_error; - cpu_info = std::vector( - reinterpret_cast(buffer.getBufferStart()), - reinterpret_cast(buffer.getBufferEnd())); - } - return *cpu_info; + static ErrorOr> cpu_info_or_err = + getProcFile("cpuinfo"); + + if (!*cpu_info_or_err) + cpu_info_or_err.getError(); + + MemoryBuffer &buffer = **cpu_info_or_err; + return arrayRefFromStringRef(buffer.getBuffer()); } Expected>