[Lldb-commits] [PATCH] D83359: [SymbolFileDWARF] Lock the module when parsing call site info
Vedant Kumar via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 7 17:38:01 PDT 2020
vsk updated this revision to Diff 276280.
vsk added a comment.
Move locking up into lldb::Function, and leave a comment in SymbolFileDWARF explaining why.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83359/new/
https://reviews.llvm.org/D83359
Files:
lldb/include/lldb/Symbol/Function.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Symbol/Function.cpp
Index: lldb/source/Symbol/Function.cpp
===================================================================
--- lldb/source/Symbol/Function.cpp
+++ lldb/source/Symbol/Function.cpp
@@ -290,6 +290,8 @@
}
llvm::ArrayRef<std::unique_ptr<CallEdge>> Function::GetCallEdges() {
+ std::lock_guard<std::mutex> guard(m_call_edges_lock);
+
if (m_call_edges_resolved)
return m_call_edges;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3844,6 +3844,11 @@
std::vector<std::unique_ptr<lldb_private::CallEdge>>
SymbolFileDWARF::ParseCallEdgesInFunction(UserID func_id) {
+ // ParseCallEdgesInFunction must be called at the behest of an exclusively
+ // locked lldb::Function instance. Storage for parsed call edges is owned by
+ // the lldb::Function instance: locking at the SymbolFile level would be too
+ // late, because the act of storing results from ParseCallEdgesInFunction
+ // would be racy.
DWARFDIE func_die = GetDIE(func_id.GetID());
if (func_die.IsValid())
return CollectCallEdges(GetObjectFile()->GetModule(), func_die);
Index: lldb/include/lldb/Symbol/Function.h
===================================================================
--- lldb/include/lldb/Symbol/Function.h
+++ lldb/include/lldb/Symbol/Function.h
@@ -17,6 +17,8 @@
#include "lldb/Utility/UserID.h"
#include "llvm/ADT/ArrayRef.h"
+#include <mutex>
+
namespace lldb_private {
class ExecutionContext;
@@ -655,6 +657,9 @@
uint32_t
m_prologue_byte_size; ///< Compute the prologue size once and cache it
+ std::mutex
+ m_call_edges_lock; ///< Exclusive lock that controls read/write
+ /// access to m_call_edges and m_call_edges_resolved.
bool m_call_edges_resolved = false; ///< Whether call site info has been
/// parsed.
std::vector<std::unique_ptr<CallEdge>> m_call_edges; ///< Outgoing call edges.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83359.276280.patch
Type: text/x-patch
Size: 2104 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200708/a3695b75/attachment.bin>
More information about the lldb-commits
mailing list