Skip to content

Commit 639cc50

Browse files
author
git apple-llvm automerger
committed
Merge commit 'd6ebd84862f5' from swift/release/5.3 into swift/master
2 parents 7bfb26d + d6ebd84 commit 639cc50

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

lldb/include/lldb/Symbol/Function.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "lldb/Utility/UserID.h"
1818
#include "llvm/ADT/ArrayRef.h"
1919

20+
#include <mutex>
21+
2022
namespace lldb_private {
2123

2224
class ExecutionContext;
@@ -644,6 +646,9 @@ class Function : public UserID, public SymbolContextScope {
644646
uint32_t
645647
m_prologue_byte_size; ///< Compute the prologue size once and cache it
646648

649+
std::mutex
650+
m_call_edges_lock; ///< Exclusive lock that controls read/write
651+
/// access to m_call_edges and m_call_edges_resolved.
647652
bool m_call_edges_resolved = false; ///< Whether call site info has been
648653
/// parsed.
649654
std::vector<std::unique_ptr<CallEdge>> m_call_edges; ///< Outgoing call edges.

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4118,6 +4118,11 @@ SymbolFileDWARF::CollectCallEdges(ModuleSP module, DWARFDIE function_die) {
41184118

41194119
std::vector<std::unique_ptr<lldb_private::CallEdge>>
41204120
SymbolFileDWARF::ParseCallEdgesInFunction(UserID func_id) {
4121+
// ParseCallEdgesInFunction must be called at the behest of an exclusively
4122+
// locked lldb::Function instance. Storage for parsed call edges is owned by
4123+
// the lldb::Function instance: locking at the SymbolFile level would be too
4124+
// late, because the act of storing results from ParseCallEdgesInFunction
4125+
// would be racy.
41214126
DWARFDIE func_die = GetDIE(func_id.GetID());
41224127
if (func_die.IsValid())
41234128
return CollectCallEdges(GetObjectFile()->GetModule(), func_die);

lldb/source/Symbol/Function.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ void Function::GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no) {
310310
}
311311

312312
llvm::ArrayRef<std::unique_ptr<CallEdge>> Function::GetCallEdges() {
313+
std::lock_guard<std::mutex> guard(m_call_edges_lock);
314+
313315
if (m_call_edges_resolved)
314316
return m_call_edges;
315317

0 commit comments

Comments
 (0)