Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lldb/include/lldb/Symbol/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "lldb/Utility/UserID.h"
#include "llvm/ADT/ArrayRef.h"

#include <mutex>

namespace lldb_private {

class ExecutionContext;
Expand Down Expand Up @@ -636,6 +638,9 @@ class Function : public UserID, public SymbolContextScope {
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.
Expand Down
5 changes: 5 additions & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4030,6 +4030,11 @@ SymbolFileDWARF::CollectCallEdges(ModuleSP module, DWARFDIE function_die) {

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);
Expand Down
2 changes: 2 additions & 0 deletions lldb/source/Symbol/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ void Function::GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no) {
}

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;

Expand Down