xref: /src/contrib/llvm-project/lldb/source/Symbol/Function.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1cfca06d7SDimitry Andric //===-- Function.cpp ------------------------------------------------------===//
2f034231aSEd Maste //
35f29bb8aSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45f29bb8aSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
55f29bb8aSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6f034231aSEd Maste //
7f034231aSEd Maste //===----------------------------------------------------------------------===//
8f034231aSEd Maste 
9f034231aSEd Maste #include "lldb/Symbol/Function.h"
10145449b1SDimitry Andric #include "lldb/Core/Debugger.h"
11866dcdacSEd Maste #include "lldb/Core/Disassembler.h"
12f034231aSEd Maste #include "lldb/Core/Module.h"
1394994d37SDimitry Andric #include "lldb/Core/ModuleList.h"
14f034231aSEd Maste #include "lldb/Core/Section.h"
15f034231aSEd Maste #include "lldb/Host/Host.h"
16f034231aSEd Maste #include "lldb/Symbol/CompileUnit.h"
1714f1b3e8SDimitry Andric #include "lldb/Symbol/CompilerType.h"
18f034231aSEd Maste #include "lldb/Symbol/LineTable.h"
19f034231aSEd Maste #include "lldb/Symbol/SymbolFile.h"
20e81d9d49SDimitry Andric #include "lldb/Target/Language.h"
21706b4fc4SDimitry Andric #include "lldb/Target/Target.h"
22145449b1SDimitry Andric #include "lldb/Utility/LLDBLog.h"
2394994d37SDimitry Andric #include "lldb/Utility/Log.h"
24f034231aSEd Maste #include "llvm/Support/Casting.h"
25f034231aSEd Maste 
26f034231aSEd Maste using namespace lldb;
27f034231aSEd Maste using namespace lldb_private;
28f034231aSEd Maste 
29f73363f1SDimitry Andric // Basic function information is contained in the FunctionInfo class. It is
30f73363f1SDimitry Andric // designed to contain the name, linkage name, and declaration location.
FunctionInfo(const char * name,const Declaration * decl_ptr)3114f1b3e8SDimitry Andric FunctionInfo::FunctionInfo(const char *name, const Declaration *decl_ptr)
3214f1b3e8SDimitry Andric     : m_name(name), m_declaration(decl_ptr) {}
33f034231aSEd Maste 
FunctionInfo(ConstString name,const Declaration * decl_ptr)345f29bb8aSDimitry Andric FunctionInfo::FunctionInfo(ConstString name, const Declaration *decl_ptr)
3514f1b3e8SDimitry Andric     : m_name(name), m_declaration(decl_ptr) {}
36f034231aSEd Maste 
37344a3780SDimitry Andric FunctionInfo::~FunctionInfo() = default;
38f034231aSEd Maste 
Dump(Stream * s,bool show_fullpaths) const3914f1b3e8SDimitry Andric void FunctionInfo::Dump(Stream *s, bool show_fullpaths) const {
40f034231aSEd Maste   if (m_name)
41f034231aSEd Maste     *s << ", name = \"" << m_name << "\"";
42f034231aSEd Maste   m_declaration.Dump(s, show_fullpaths);
43f034231aSEd Maste }
44f034231aSEd Maste 
Compare(const FunctionInfo & a,const FunctionInfo & b)4514f1b3e8SDimitry Andric int FunctionInfo::Compare(const FunctionInfo &a, const FunctionInfo &b) {
46f034231aSEd Maste   int result = ConstString::Compare(a.GetName(), b.GetName());
47f034231aSEd Maste   if (result)
48f034231aSEd Maste     return result;
49f034231aSEd Maste 
50f034231aSEd Maste   return Declaration::Compare(a.m_declaration, b.m_declaration);
51f034231aSEd Maste }
52f034231aSEd Maste 
GetDeclaration()5314f1b3e8SDimitry Andric Declaration &FunctionInfo::GetDeclaration() { return m_declaration; }
54f034231aSEd Maste 
GetDeclaration() const5514f1b3e8SDimitry Andric const Declaration &FunctionInfo::GetDeclaration() const {
56f034231aSEd Maste   return m_declaration;
57f034231aSEd Maste }
58f034231aSEd Maste 
GetName() const5914f1b3e8SDimitry Andric ConstString FunctionInfo::GetName() const { return m_name; }
60f034231aSEd Maste 
MemorySize() const6114f1b3e8SDimitry Andric size_t FunctionInfo::MemorySize() const {
62f034231aSEd Maste   return m_name.MemorySize() + m_declaration.MemorySize();
63f034231aSEd Maste }
64f034231aSEd Maste 
InlineFunctionInfo(const char * name,llvm::StringRef mangled,const Declaration * decl_ptr,const Declaration * call_decl_ptr)65ead24645SDimitry Andric InlineFunctionInfo::InlineFunctionInfo(const char *name,
66ead24645SDimitry Andric                                        llvm::StringRef mangled,
67f034231aSEd Maste                                        const Declaration *decl_ptr,
6814f1b3e8SDimitry Andric                                        const Declaration *call_decl_ptr)
69ead24645SDimitry Andric     : FunctionInfo(name, decl_ptr), m_mangled(mangled),
7014f1b3e8SDimitry Andric       m_call_decl(call_decl_ptr) {}
71f034231aSEd Maste 
InlineFunctionInfo(ConstString name,const Mangled & mangled,const Declaration * decl_ptr,const Declaration * call_decl_ptr)725f29bb8aSDimitry Andric InlineFunctionInfo::InlineFunctionInfo(ConstString name,
73f034231aSEd Maste                                        const Mangled &mangled,
74f034231aSEd Maste                                        const Declaration *decl_ptr,
7514f1b3e8SDimitry Andric                                        const Declaration *call_decl_ptr)
7614f1b3e8SDimitry Andric     : FunctionInfo(name, decl_ptr), m_mangled(mangled),
7714f1b3e8SDimitry Andric       m_call_decl(call_decl_ptr) {}
78f034231aSEd Maste 
79344a3780SDimitry Andric InlineFunctionInfo::~InlineFunctionInfo() = default;
80f034231aSEd Maste 
Dump(Stream * s,bool show_fullpaths) const8114f1b3e8SDimitry Andric void InlineFunctionInfo::Dump(Stream *s, bool show_fullpaths) const {
82f034231aSEd Maste   FunctionInfo::Dump(s, show_fullpaths);
83f034231aSEd Maste   if (m_mangled)
84f034231aSEd Maste     m_mangled.Dump(s);
85f034231aSEd Maste }
86f034231aSEd Maste 
DumpStopContext(Stream * s) const87cfca06d7SDimitry Andric void InlineFunctionInfo::DumpStopContext(Stream *s) const {
88f034231aSEd Maste   //    s->Indent("[inlined] ");
89f034231aSEd Maste   s->Indent();
90f034231aSEd Maste   if (m_mangled)
91cfca06d7SDimitry Andric     s->PutCString(m_mangled.GetName().AsCString());
92f034231aSEd Maste   else
93f034231aSEd Maste     s->PutCString(m_name.AsCString());
94f034231aSEd Maste }
95f034231aSEd Maste 
GetName() const96cfca06d7SDimitry Andric ConstString InlineFunctionInfo::GetName() const {
97f034231aSEd Maste   if (m_mangled)
98cfca06d7SDimitry Andric     return m_mangled.GetName();
99f034231aSEd Maste   return m_name;
100f034231aSEd Maste }
101f034231aSEd Maste 
GetDisplayName() const102cfca06d7SDimitry Andric ConstString InlineFunctionInfo::GetDisplayName() const {
103027f1c96SDimitry Andric   if (m_mangled)
104cfca06d7SDimitry Andric     return m_mangled.GetDisplayDemangledName();
105027f1c96SDimitry Andric   return m_name;
106027f1c96SDimitry Andric }
107f034231aSEd Maste 
GetCallSite()10814f1b3e8SDimitry Andric Declaration &InlineFunctionInfo::GetCallSite() { return m_call_decl; }
10914f1b3e8SDimitry Andric 
GetCallSite() const11014f1b3e8SDimitry Andric const Declaration &InlineFunctionInfo::GetCallSite() const {
111f034231aSEd Maste   return m_call_decl;
112f034231aSEd Maste }
113f034231aSEd Maste 
GetMangled()11414f1b3e8SDimitry Andric Mangled &InlineFunctionInfo::GetMangled() { return m_mangled; }
115f034231aSEd Maste 
GetMangled() const11614f1b3e8SDimitry Andric const Mangled &InlineFunctionInfo::GetMangled() const { return m_mangled; }
117f034231aSEd Maste 
MemorySize() const11814f1b3e8SDimitry Andric size_t InlineFunctionInfo::MemorySize() const {
119f034231aSEd Maste   return FunctionInfo::MemorySize() + m_mangled.MemorySize();
120f034231aSEd Maste }
121f034231aSEd Maste 
122706b4fc4SDimitry Andric /// @name Call site related structures
123706b4fc4SDimitry Andric /// @{
124706b4fc4SDimitry Andric 
125b1c73532SDimitry Andric CallEdge::~CallEdge() = default;
126b1c73532SDimitry Andric 
CallEdge(AddrType caller_address_type,lldb::addr_t caller_address,bool is_tail_call,CallSiteParameterArray && parameters)127b1c73532SDimitry Andric CallEdge::CallEdge(AddrType caller_address_type, lldb::addr_t caller_address,
128b1c73532SDimitry Andric                    bool is_tail_call, CallSiteParameterArray &&parameters)
129b1c73532SDimitry Andric     : caller_address(caller_address), caller_address_type(caller_address_type),
130b1c73532SDimitry Andric       is_tail_call(is_tail_call), parameters(std::move(parameters)) {}
131b1c73532SDimitry Andric 
GetLoadAddress(lldb::addr_t unresolved_pc,Function & caller,Target & target)132cfca06d7SDimitry Andric lldb::addr_t CallEdge::GetLoadAddress(lldb::addr_t unresolved_pc,
133cfca06d7SDimitry Andric                                       Function &caller, Target &target) {
134145449b1SDimitry Andric   Log *log = GetLog(LLDBLog::Step);
135cfca06d7SDimitry Andric 
136cfca06d7SDimitry Andric   const Address &caller_start_addr = caller.GetAddressRange().GetBaseAddress();
137cfca06d7SDimitry Andric 
138cfca06d7SDimitry Andric   ModuleSP caller_module_sp = caller_start_addr.GetModule();
139cfca06d7SDimitry Andric   if (!caller_module_sp) {
140cfca06d7SDimitry Andric     LLDB_LOG(log, "GetLoadAddress: cannot get Module for caller");
141cfca06d7SDimitry Andric     return LLDB_INVALID_ADDRESS;
142cfca06d7SDimitry Andric   }
143cfca06d7SDimitry Andric 
144cfca06d7SDimitry Andric   SectionList *section_list = caller_module_sp->GetSectionList();
145cfca06d7SDimitry Andric   if (!section_list) {
146cfca06d7SDimitry Andric     LLDB_LOG(log, "GetLoadAddress: cannot get SectionList for Module");
147cfca06d7SDimitry Andric     return LLDB_INVALID_ADDRESS;
148cfca06d7SDimitry Andric   }
149cfca06d7SDimitry Andric 
150cfca06d7SDimitry Andric   Address the_addr = Address(unresolved_pc, section_list);
151cfca06d7SDimitry Andric   lldb::addr_t load_addr = the_addr.GetLoadAddress(&target);
152cfca06d7SDimitry Andric   return load_addr;
153cfca06d7SDimitry Andric }
154cfca06d7SDimitry Andric 
GetReturnPCAddress(Function & caller,Target & target) const155706b4fc4SDimitry Andric lldb::addr_t CallEdge::GetReturnPCAddress(Function &caller,
156706b4fc4SDimitry Andric                                           Target &target) const {
157cfca06d7SDimitry Andric   return GetLoadAddress(GetUnresolvedReturnPCAddress(), caller, target);
15894994d37SDimitry Andric }
15994994d37SDimitry Andric 
ParseSymbolFileAndResolve(ModuleList & images)160706b4fc4SDimitry Andric void DirectCallEdge::ParseSymbolFileAndResolve(ModuleList &images) {
16194994d37SDimitry Andric   if (resolved)
16294994d37SDimitry Andric     return;
16394994d37SDimitry Andric 
164145449b1SDimitry Andric   Log *log = GetLog(LLDBLog::Step);
165706b4fc4SDimitry Andric   LLDB_LOG(log, "DirectCallEdge: Lazily parsing the call graph for {0}",
16694994d37SDimitry Andric            lazy_callee.symbol_name);
16794994d37SDimitry Andric 
16894994d37SDimitry Andric   auto resolve_lazy_callee = [&]() -> Function * {
16994994d37SDimitry Andric     ConstString callee_name{lazy_callee.symbol_name};
17094994d37SDimitry Andric     SymbolContextList sc_list;
17194994d37SDimitry Andric     images.FindFunctionSymbols(callee_name, eFunctionNameTypeAuto, sc_list);
172ead24645SDimitry Andric     size_t num_matches = sc_list.GetSize();
17394994d37SDimitry Andric     if (num_matches == 0 || !sc_list[0].symbol) {
174706b4fc4SDimitry Andric       LLDB_LOG(log,
175706b4fc4SDimitry Andric                "DirectCallEdge: Found no symbols for {0}, cannot resolve it",
17694994d37SDimitry Andric                callee_name);
17794994d37SDimitry Andric       return nullptr;
17894994d37SDimitry Andric     }
17994994d37SDimitry Andric     Address callee_addr = sc_list[0].symbol->GetAddress();
18094994d37SDimitry Andric     if (!callee_addr.IsValid()) {
181706b4fc4SDimitry Andric       LLDB_LOG(log, "DirectCallEdge: Invalid symbol address");
18294994d37SDimitry Andric       return nullptr;
18394994d37SDimitry Andric     }
18494994d37SDimitry Andric     Function *f = callee_addr.CalculateSymbolContextFunction();
18594994d37SDimitry Andric     if (!f) {
186706b4fc4SDimitry Andric       LLDB_LOG(log, "DirectCallEdge: Could not find complete function");
18794994d37SDimitry Andric       return nullptr;
18894994d37SDimitry Andric     }
18994994d37SDimitry Andric     return f;
19094994d37SDimitry Andric   };
19194994d37SDimitry Andric   lazy_callee.def = resolve_lazy_callee();
19294994d37SDimitry Andric   resolved = true;
19394994d37SDimitry Andric }
19494994d37SDimitry Andric 
DirectCallEdge(const char * symbol_name,AddrType caller_address_type,lldb::addr_t caller_address,bool is_tail_call,CallSiteParameterArray && parameters)195b1c73532SDimitry Andric DirectCallEdge::DirectCallEdge(const char *symbol_name,
196b1c73532SDimitry Andric                                AddrType caller_address_type,
197b1c73532SDimitry Andric                                lldb::addr_t caller_address, bool is_tail_call,
198b1c73532SDimitry Andric                                CallSiteParameterArray &&parameters)
199b1c73532SDimitry Andric     : CallEdge(caller_address_type, caller_address, is_tail_call,
200b1c73532SDimitry Andric                std::move(parameters)) {
201b1c73532SDimitry Andric   lazy_callee.symbol_name = symbol_name;
202b1c73532SDimitry Andric }
203b1c73532SDimitry Andric 
GetCallee(ModuleList & images,ExecutionContext &)204706b4fc4SDimitry Andric Function *DirectCallEdge::GetCallee(ModuleList &images, ExecutionContext &) {
20594994d37SDimitry Andric   ParseSymbolFileAndResolve(images);
206ead24645SDimitry Andric   assert(resolved && "Did not resolve lazy callee");
20794994d37SDimitry Andric   return lazy_callee.def;
20894994d37SDimitry Andric }
20994994d37SDimitry Andric 
IndirectCallEdge(DWARFExpressionList call_target,AddrType caller_address_type,lldb::addr_t caller_address,bool is_tail_call,CallSiteParameterArray && parameters)210b1c73532SDimitry Andric IndirectCallEdge::IndirectCallEdge(DWARFExpressionList call_target,
211b1c73532SDimitry Andric                                    AddrType caller_address_type,
212b1c73532SDimitry Andric                                    lldb::addr_t caller_address,
213b1c73532SDimitry Andric                                    bool is_tail_call,
214b1c73532SDimitry Andric                                    CallSiteParameterArray &&parameters)
215b1c73532SDimitry Andric     : CallEdge(caller_address_type, caller_address, is_tail_call,
216b1c73532SDimitry Andric                std::move(parameters)),
217b1c73532SDimitry Andric       call_target(std::move(call_target)) {}
218b1c73532SDimitry Andric 
GetCallee(ModuleList & images,ExecutionContext & exe_ctx)219706b4fc4SDimitry Andric Function *IndirectCallEdge::GetCallee(ModuleList &images,
220706b4fc4SDimitry Andric                                       ExecutionContext &exe_ctx) {
221145449b1SDimitry Andric   Log *log = GetLog(LLDBLog::Step);
222706b4fc4SDimitry Andric   Status error;
223ac9a064cSDimitry Andric   llvm::Expected<Value> callee_addr_val = call_target.Evaluate(
2241f917f69SDimitry Andric       &exe_ctx, exe_ctx.GetRegisterContext(), LLDB_INVALID_ADDRESS,
225706b4fc4SDimitry Andric       /*initial_value_ptr=*/nullptr,
226ac9a064cSDimitry Andric       /*object_address_ptr=*/nullptr);
227ac9a064cSDimitry Andric   if (!callee_addr_val) {
228ac9a064cSDimitry Andric     LLDB_LOG_ERROR(log, callee_addr_val.takeError(),
229ac9a064cSDimitry Andric                    "IndirectCallEdge: Could not evaluate expression: {0}");
230706b4fc4SDimitry Andric     return nullptr;
23194994d37SDimitry Andric   }
23294994d37SDimitry Andric 
233ac9a064cSDimitry Andric   addr_t raw_addr =
234ac9a064cSDimitry Andric       callee_addr_val->GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
235706b4fc4SDimitry Andric   if (raw_addr == LLDB_INVALID_ADDRESS) {
236706b4fc4SDimitry Andric     LLDB_LOG(log, "IndirectCallEdge: Could not extract address from scalar");
237706b4fc4SDimitry Andric     return nullptr;
238706b4fc4SDimitry Andric   }
239706b4fc4SDimitry Andric 
240706b4fc4SDimitry Andric   Address callee_addr;
241706b4fc4SDimitry Andric   if (!exe_ctx.GetTargetPtr()->ResolveLoadAddress(raw_addr, callee_addr)) {
242706b4fc4SDimitry Andric     LLDB_LOG(log, "IndirectCallEdge: Could not resolve callee's load address");
243706b4fc4SDimitry Andric     return nullptr;
244706b4fc4SDimitry Andric   }
245706b4fc4SDimitry Andric 
246706b4fc4SDimitry Andric   Function *f = callee_addr.CalculateSymbolContextFunction();
247706b4fc4SDimitry Andric   if (!f) {
248706b4fc4SDimitry Andric     LLDB_LOG(log, "IndirectCallEdge: Could not find complete function");
249706b4fc4SDimitry Andric     return nullptr;
250706b4fc4SDimitry Andric   }
251706b4fc4SDimitry Andric 
252706b4fc4SDimitry Andric   return f;
253706b4fc4SDimitry Andric }
254706b4fc4SDimitry Andric 
255706b4fc4SDimitry Andric /// @}
256706b4fc4SDimitry Andric 
25794994d37SDimitry Andric //
Function(CompileUnit * comp_unit,lldb::user_id_t func_uid,lldb::user_id_t type_uid,const Mangled & mangled,Type * type,const AddressRange & range)25814f1b3e8SDimitry Andric Function::Function(CompileUnit *comp_unit, lldb::user_id_t func_uid,
25914f1b3e8SDimitry Andric                    lldb::user_id_t type_uid, const Mangled &mangled, Type *type,
26014f1b3e8SDimitry Andric                    const AddressRange &range)
26114f1b3e8SDimitry Andric     : UserID(func_uid), m_comp_unit(comp_unit), m_type_uid(type_uid),
26214f1b3e8SDimitry Andric       m_type(type), m_mangled(mangled), m_block(func_uid), m_range(range),
2635f29bb8aSDimitry Andric       m_frame_base(), m_flags(), m_prologue_byte_size(0) {
264f034231aSEd Maste   m_block.SetParentScope(this);
2650cac4ca3SEd Maste   assert(comp_unit != nullptr);
266f034231aSEd Maste }
267f034231aSEd Maste 
268344a3780SDimitry Andric Function::~Function() = default;
269f034231aSEd Maste 
GetStartLineSourceInfo(FileSpec & source_file,uint32_t & line_no)27014f1b3e8SDimitry Andric void Function::GetStartLineSourceInfo(FileSpec &source_file,
27114f1b3e8SDimitry Andric                                       uint32_t &line_no) {
272f034231aSEd Maste   line_no = 0;
273f034231aSEd Maste   source_file.Clear();
274f034231aSEd Maste 
2750cac4ca3SEd Maste   if (m_comp_unit == nullptr)
276f034231aSEd Maste     return;
277f034231aSEd Maste 
27814f1b3e8SDimitry Andric   // Initialize m_type if it hasn't been initialized already
27914f1b3e8SDimitry Andric   GetType();
28014f1b3e8SDimitry Andric 
28114f1b3e8SDimitry Andric   if (m_type != nullptr && m_type->GetDeclaration().GetLine() != 0) {
282f034231aSEd Maste     source_file = m_type->GetDeclaration().GetFile();
283f034231aSEd Maste     line_no = m_type->GetDeclaration().GetLine();
28414f1b3e8SDimitry Andric   } else {
285f034231aSEd Maste     LineTable *line_table = m_comp_unit->GetLineTable();
2860cac4ca3SEd Maste     if (line_table == nullptr)
287f034231aSEd Maste       return;
288f034231aSEd Maste 
289f034231aSEd Maste     LineEntry line_entry;
29014f1b3e8SDimitry Andric     if (line_table->FindLineEntryByAddress(GetAddressRange().GetBaseAddress(),
29114f1b3e8SDimitry Andric                                            line_entry, nullptr)) {
292f034231aSEd Maste       line_no = line_entry.line;
293ac9a064cSDimitry Andric       source_file = line_entry.GetFile();
294f034231aSEd Maste     }
295f034231aSEd Maste   }
296f034231aSEd Maste }
297f034231aSEd Maste 
GetEndLineSourceInfo(FileSpec & source_file,uint32_t & line_no)29814f1b3e8SDimitry Andric void Function::GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no) {
299f034231aSEd Maste   line_no = 0;
300f034231aSEd Maste   source_file.Clear();
301f034231aSEd Maste 
30214f1b3e8SDimitry Andric   // The -1 is kind of cheesy, but I want to get the last line entry for the
303f73363f1SDimitry Andric   // given function, not the first entry of the next.
304f034231aSEd Maste   Address scratch_addr(GetAddressRange().GetBaseAddress());
30514f1b3e8SDimitry Andric   scratch_addr.SetOffset(scratch_addr.GetOffset() +
30614f1b3e8SDimitry Andric                          GetAddressRange().GetByteSize() - 1);
307f034231aSEd Maste 
308f034231aSEd Maste   LineTable *line_table = m_comp_unit->GetLineTable();
3090cac4ca3SEd Maste   if (line_table == nullptr)
310f034231aSEd Maste     return;
311f034231aSEd Maste 
312f034231aSEd Maste   LineEntry line_entry;
31314f1b3e8SDimitry Andric   if (line_table->FindLineEntryByAddress(scratch_addr, line_entry, nullptr)) {
314f034231aSEd Maste     line_no = line_entry.line;
315ac9a064cSDimitry Andric     source_file = line_entry.GetFile();
316f034231aSEd Maste   }
317f034231aSEd Maste }
318f034231aSEd Maste 
GetCallEdges()319706b4fc4SDimitry Andric llvm::ArrayRef<std::unique_ptr<CallEdge>> Function::GetCallEdges() {
320cfca06d7SDimitry Andric   std::lock_guard<std::mutex> guard(m_call_edges_lock);
321cfca06d7SDimitry Andric 
32294994d37SDimitry Andric   if (m_call_edges_resolved)
32394994d37SDimitry Andric     return m_call_edges;
32494994d37SDimitry Andric 
325145449b1SDimitry Andric   Log *log = GetLog(LLDBLog::Step);
32694994d37SDimitry Andric   LLDB_LOG(log, "GetCallEdges: Attempting to parse call site info for {0}",
32794994d37SDimitry Andric            GetDisplayName());
32894994d37SDimitry Andric 
32994994d37SDimitry Andric   m_call_edges_resolved = true;
33094994d37SDimitry Andric 
33194994d37SDimitry Andric   // Find the SymbolFile which provided this function's definition.
33294994d37SDimitry Andric   Block &block = GetBlock(/*can_create*/true);
33394994d37SDimitry Andric   SymbolFile *sym_file = block.GetSymbolFile();
33494994d37SDimitry Andric   if (!sym_file)
335e3b55780SDimitry Andric     return std::nullopt;
33694994d37SDimitry Andric 
33794994d37SDimitry Andric   // Lazily read call site information from the SymbolFile.
33894994d37SDimitry Andric   m_call_edges = sym_file->ParseCallEdgesInFunction(GetID());
33994994d37SDimitry Andric 
34094994d37SDimitry Andric   // Sort the call edges to speed up return_pc lookups.
341cfca06d7SDimitry Andric   llvm::sort(m_call_edges, [](const std::unique_ptr<CallEdge> &LHS,
342706b4fc4SDimitry Andric                               const std::unique_ptr<CallEdge> &RHS) {
343cfca06d7SDimitry Andric     return LHS->GetSortKey() < RHS->GetSortKey();
34494994d37SDimitry Andric   });
34594994d37SDimitry Andric 
34694994d37SDimitry Andric   return m_call_edges;
34794994d37SDimitry Andric }
34894994d37SDimitry Andric 
GetTailCallingEdges()349706b4fc4SDimitry Andric llvm::ArrayRef<std::unique_ptr<CallEdge>> Function::GetTailCallingEdges() {
350cfca06d7SDimitry Andric   // Tail calling edges are sorted at the end of the list. Find them by dropping
351cfca06d7SDimitry Andric   // all non-tail-calls.
352cfca06d7SDimitry Andric   return GetCallEdges().drop_until(
353cfca06d7SDimitry Andric       [](const std::unique_ptr<CallEdge> &edge) { return edge->IsTailCall(); });
35494994d37SDimitry Andric }
35594994d37SDimitry Andric 
GetCallEdgeForReturnAddress(addr_t return_pc,Target & target)356ead24645SDimitry Andric CallEdge *Function::GetCallEdgeForReturnAddress(addr_t return_pc,
357ead24645SDimitry Andric                                                 Target &target) {
358ead24645SDimitry Andric   auto edges = GetCallEdges();
359ead24645SDimitry Andric   auto edge_it =
360cfca06d7SDimitry Andric       llvm::partition_point(edges, [&](const std::unique_ptr<CallEdge> &edge) {
361cfca06d7SDimitry Andric         return std::make_pair(edge->IsTailCall(),
362cfca06d7SDimitry Andric                               edge->GetReturnPCAddress(*this, target)) <
363cfca06d7SDimitry Andric                std::make_pair(false, return_pc);
364ead24645SDimitry Andric       });
365ead24645SDimitry Andric   if (edge_it == edges.end() ||
366706b4fc4SDimitry Andric       edge_it->get()->GetReturnPCAddress(*this, target) != return_pc)
367ead24645SDimitry Andric     return nullptr;
368cfca06d7SDimitry Andric   return edge_it->get();
369ead24645SDimitry Andric }
370ead24645SDimitry Andric 
GetBlock(bool can_create)37114f1b3e8SDimitry Andric Block &Function::GetBlock(bool can_create) {
37214f1b3e8SDimitry Andric   if (!m_block.BlockInfoHasBeenParsed() && can_create) {
37394994d37SDimitry Andric     ModuleSP module_sp = CalculateSymbolContextModule();
37494994d37SDimitry Andric     if (module_sp) {
375ead24645SDimitry Andric       module_sp->GetSymbolFile()->ParseBlocksRecursive(*this);
37614f1b3e8SDimitry Andric     } else {
377145449b1SDimitry Andric       Debugger::ReportError(llvm::formatv(
378145449b1SDimitry Andric           "unable to find module shared pointer for function '{0}' in {1}",
379145449b1SDimitry Andric           GetName().GetCString(), m_comp_unit->GetPrimaryFile().GetPath()));
380f034231aSEd Maste     }
381f034231aSEd Maste     m_block.SetBlockInfoHasBeenParsed(true, true);
382f034231aSEd Maste   }
383f034231aSEd Maste   return m_block;
384f034231aSEd Maste }
385f034231aSEd Maste 
GetCompileUnit()38614f1b3e8SDimitry Andric CompileUnit *Function::GetCompileUnit() { return m_comp_unit; }
387f034231aSEd Maste 
GetCompileUnit() const38814f1b3e8SDimitry Andric const CompileUnit *Function::GetCompileUnit() const { return m_comp_unit; }
389f034231aSEd Maste 
GetDescription(Stream * s,lldb::DescriptionLevel level,Target * target)39014f1b3e8SDimitry Andric void Function::GetDescription(Stream *s, lldb::DescriptionLevel level,
39114f1b3e8SDimitry Andric                               Target *target) {
39274a628f7SDimitry Andric   ConstString name = GetName();
39374a628f7SDimitry Andric   ConstString mangled = m_mangled.GetMangledName();
394f034231aSEd Maste 
39574a628f7SDimitry Andric   *s << "id = " << (const UserID &)*this;
39674a628f7SDimitry Andric   if (name)
397cfca06d7SDimitry Andric     s->AsRawOstream() << ", name = \"" << name << '"';
39874a628f7SDimitry Andric   if (mangled)
399cfca06d7SDimitry Andric     s->AsRawOstream() << ", mangled = \"" << mangled << '"';
400b1c73532SDimitry Andric   if (level == eDescriptionLevelVerbose) {
401b1c73532SDimitry Andric     *s << ", decl_context = {";
402b1c73532SDimitry Andric     auto decl_context = GetCompilerContext();
403b1c73532SDimitry Andric     // Drop the function itself from the context chain.
404b1c73532SDimitry Andric     if (decl_context.size())
405b1c73532SDimitry Andric       decl_context.pop_back();
406b1c73532SDimitry Andric     llvm::interleaveComma(decl_context, *s, [&](auto &ctx) { ctx.Dump(*s); });
407b1c73532SDimitry Andric     *s << "}";
408b1c73532SDimitry Andric   }
40974a628f7SDimitry Andric   *s << ", range = ";
410f034231aSEd Maste   Address::DumpStyle fallback_style;
411f034231aSEd Maste   if (level == eDescriptionLevelVerbose)
412f034231aSEd Maste     fallback_style = Address::DumpStyleModuleWithFileAddress;
413f034231aSEd Maste   else
414f034231aSEd Maste     fallback_style = Address::DumpStyleFileAddress;
41514f1b3e8SDimitry Andric   GetAddressRange().Dump(s, target, Address::DumpStyleLoadAddress,
41614f1b3e8SDimitry Andric                          fallback_style);
417f034231aSEd Maste }
418f034231aSEd Maste 
Dump(Stream * s,bool show_context) const41914f1b3e8SDimitry Andric void Function::Dump(Stream *s, bool show_context) const {
4200cac4ca3SEd Maste   s->Printf("%p: ", static_cast<const void *>(this));
421f034231aSEd Maste   s->Indent();
4220cac4ca3SEd Maste   *s << "Function" << static_cast<const UserID &>(*this);
423f034231aSEd Maste 
424f034231aSEd Maste   m_mangled.Dump(s);
425f034231aSEd Maste 
426f034231aSEd Maste   if (m_type)
4270cac4ca3SEd Maste     s->Printf(", type = %p", static_cast<void *>(m_type));
428f034231aSEd Maste   else if (m_type_uid != LLDB_INVALID_UID)
429f034231aSEd Maste     s->Printf(", type_uid = 0x%8.8" PRIx64, m_type_uid);
430f034231aSEd Maste 
431f034231aSEd Maste   s->EOL();
432f034231aSEd Maste   // Dump the root object
433f034231aSEd Maste   if (m_block.BlockInfoHasBeenParsed())
43414f1b3e8SDimitry Andric     m_block.Dump(s, m_range.GetBaseAddress().GetFileAddress(), INT_MAX,
43514f1b3e8SDimitry Andric                  show_context);
436f034231aSEd Maste }
437f034231aSEd Maste 
CalculateSymbolContext(SymbolContext * sc)43814f1b3e8SDimitry Andric void Function::CalculateSymbolContext(SymbolContext *sc) {
439f034231aSEd Maste   sc->function = this;
440f034231aSEd Maste   m_comp_unit->CalculateSymbolContext(sc);
441f034231aSEd Maste }
442f034231aSEd Maste 
CalculateSymbolContextModule()44314f1b3e8SDimitry Andric ModuleSP Function::CalculateSymbolContextModule() {
444f034231aSEd Maste   SectionSP section_sp(m_range.GetBaseAddress().GetSection());
445f034231aSEd Maste   if (section_sp)
446f034231aSEd Maste     return section_sp->GetModule();
447f034231aSEd Maste 
448f034231aSEd Maste   return this->GetCompileUnit()->GetModule();
449f034231aSEd Maste }
450f034231aSEd Maste 
CalculateSymbolContextCompileUnit()45114f1b3e8SDimitry Andric CompileUnit *Function::CalculateSymbolContextCompileUnit() {
452f034231aSEd Maste   return this->GetCompileUnit();
453f034231aSEd Maste }
454f034231aSEd Maste 
CalculateSymbolContextFunction()45514f1b3e8SDimitry Andric Function *Function::CalculateSymbolContextFunction() { return this; }
456f034231aSEd Maste 
GetInstructions(const ExecutionContext & exe_ctx,const char * flavor,bool prefer_file_cache)45714f1b3e8SDimitry Andric lldb::DisassemblerSP Function::GetInstructions(const ExecutionContext &exe_ctx,
458866dcdacSEd Maste                                                const char *flavor,
45914f1b3e8SDimitry Andric                                                bool prefer_file_cache) {
460866dcdacSEd Maste   ModuleSP module_sp(GetAddressRange().GetBaseAddress().GetModule());
461cfca06d7SDimitry Andric   if (module_sp && exe_ctx.HasTargetScope()) {
46214f1b3e8SDimitry Andric     return Disassembler::DisassembleRange(module_sp->GetArchitecture(), nullptr,
463cfca06d7SDimitry Andric                                           flavor, exe_ctx.GetTargetRef(),
464344a3780SDimitry Andric                                           GetAddressRange(), !prefer_file_cache);
465866dcdacSEd Maste   }
466866dcdacSEd Maste   return lldb::DisassemblerSP();
467866dcdacSEd Maste }
468866dcdacSEd Maste 
GetDisassembly(const ExecutionContext & exe_ctx,const char * flavor,Stream & strm,bool prefer_file_cache)46914f1b3e8SDimitry Andric bool Function::GetDisassembly(const ExecutionContext &exe_ctx,
470344a3780SDimitry Andric                               const char *flavor, Stream &strm,
471344a3780SDimitry Andric                               bool prefer_file_cache) {
47214f1b3e8SDimitry Andric   lldb::DisassemblerSP disassembler_sp =
47314f1b3e8SDimitry Andric       GetInstructions(exe_ctx, flavor, prefer_file_cache);
47414f1b3e8SDimitry Andric   if (disassembler_sp) {
475866dcdacSEd Maste     const bool show_address = true;
476866dcdacSEd Maste     const bool show_bytes = false;
4771f917f69SDimitry Andric     const bool show_control_flow_kind = false;
4781f917f69SDimitry Andric     disassembler_sp->GetInstructionList().Dump(
4791f917f69SDimitry Andric         &strm, show_address, show_bytes, show_control_flow_kind, &exe_ctx);
480866dcdacSEd Maste     return true;
481866dcdacSEd Maste   }
482866dcdacSEd Maste   return false;
483866dcdacSEd Maste }
484866dcdacSEd Maste 
485f034231aSEd Maste // Symbol *
486f034231aSEd Maste // Function::CalculateSymbolContextSymbol ()
487f034231aSEd Maste //{
488f034231aSEd Maste //    return // TODO: find the symbol for the function???
489f034231aSEd Maste //}
490f034231aSEd Maste 
DumpSymbolContext(Stream * s)49114f1b3e8SDimitry Andric void Function::DumpSymbolContext(Stream *s) {
492f034231aSEd Maste   m_comp_unit->DumpSymbolContext(s);
493f034231aSEd Maste   s->Printf(", Function{0x%8.8" PRIx64 "}", GetID());
494f034231aSEd Maste }
495f034231aSEd Maste 
MemorySize() const49614f1b3e8SDimitry Andric size_t Function::MemorySize() const {
497f034231aSEd Maste   size_t mem_size = sizeof(Function) + m_block.MemorySize();
498f034231aSEd Maste   return mem_size;
499f034231aSEd Maste }
500f034231aSEd Maste 
GetIsOptimized()50114f1b3e8SDimitry Andric bool Function::GetIsOptimized() {
502e81d9d49SDimitry Andric   bool result = false;
503e81d9d49SDimitry Andric 
504f73363f1SDimitry Andric   // Currently optimization is only indicted by the vendor extension
505f73363f1SDimitry Andric   // DW_AT_APPLE_optimized which is set on a compile unit level.
50614f1b3e8SDimitry Andric   if (m_comp_unit) {
507e81d9d49SDimitry Andric     result = m_comp_unit->GetIsOptimized();
508e81d9d49SDimitry Andric   }
509e81d9d49SDimitry Andric   return result;
510e81d9d49SDimitry Andric }
511e81d9d49SDimitry Andric 
IsTopLevelFunction()51214f1b3e8SDimitry Andric bool Function::IsTopLevelFunction() {
513e81d9d49SDimitry Andric   bool result = false;
514e81d9d49SDimitry Andric 
515e81d9d49SDimitry Andric   if (Language *language = Language::FindPlugin(GetLanguage()))
516e81d9d49SDimitry Andric     result = language->IsTopLevelFunction(*this);
517e81d9d49SDimitry Andric 
518e81d9d49SDimitry Andric   return result;
519e81d9d49SDimitry Andric }
520e81d9d49SDimitry Andric 
GetDisplayName() const52114f1b3e8SDimitry Andric ConstString Function::GetDisplayName() const {
522cfca06d7SDimitry Andric   return m_mangled.GetDisplayDemangledName();
523027f1c96SDimitry Andric }
524027f1c96SDimitry Andric 
GetDeclContext()52514f1b3e8SDimitry Andric CompilerDeclContext Function::GetDeclContext() {
526b1c73532SDimitry Andric   if (ModuleSP module_sp = CalculateSymbolContextModule())
527ead24645SDimitry Andric     if (SymbolFile *sym_file = module_sp->GetSymbolFile())
528e81d9d49SDimitry Andric       return sym_file->GetDeclContextForUID(GetID());
529b1c73532SDimitry Andric   return {};
530e81d9d49SDimitry Andric }
531b1c73532SDimitry Andric 
GetCompilerContext()532b1c73532SDimitry Andric std::vector<CompilerContext> Function::GetCompilerContext() {
533b1c73532SDimitry Andric   if (ModuleSP module_sp = CalculateSymbolContextModule())
534b1c73532SDimitry Andric     if (SymbolFile *sym_file = module_sp->GetSymbolFile())
535b1c73532SDimitry Andric       return sym_file->GetCompilerContextForUID(GetID());
536b1c73532SDimitry Andric   return {};
537f034231aSEd Maste }
538f034231aSEd Maste 
GetType()53914f1b3e8SDimitry Andric Type *Function::GetType() {
54014f1b3e8SDimitry Andric   if (m_type == nullptr) {
541f034231aSEd Maste     SymbolContext sc;
542f034231aSEd Maste 
543f034231aSEd Maste     CalculateSymbolContext(&sc);
544f034231aSEd Maste 
545f034231aSEd Maste     if (!sc.module_sp)
5460cac4ca3SEd Maste       return nullptr;
547f034231aSEd Maste 
548ead24645SDimitry Andric     SymbolFile *sym_file = sc.module_sp->GetSymbolFile();
549f034231aSEd Maste 
5500cac4ca3SEd Maste     if (sym_file == nullptr)
5510cac4ca3SEd Maste       return nullptr;
552f034231aSEd Maste 
553f034231aSEd Maste     m_type = sym_file->ResolveTypeUID(m_type_uid);
554f034231aSEd Maste   }
555f034231aSEd Maste   return m_type;
556f034231aSEd Maste }
557f034231aSEd Maste 
GetType() const55814f1b3e8SDimitry Andric const Type *Function::GetType() const { return m_type; }
559f034231aSEd Maste 
GetCompilerType()56014f1b3e8SDimitry Andric CompilerType Function::GetCompilerType() {
561f034231aSEd Maste   Type *function_type = GetType();
562f034231aSEd Maste   if (function_type)
563e81d9d49SDimitry Andric     return function_type->GetFullCompilerType();
564e81d9d49SDimitry Andric   return CompilerType();
565f034231aSEd Maste }
566f034231aSEd Maste 
GetPrologueByteSize()56714f1b3e8SDimitry Andric uint32_t Function::GetPrologueByteSize() {
56814f1b3e8SDimitry Andric   if (m_prologue_byte_size == 0 &&
56914f1b3e8SDimitry Andric       m_flags.IsClear(flagsCalculatedPrologueSize)) {
570f034231aSEd Maste     m_flags.Set(flagsCalculatedPrologueSize);
571f034231aSEd Maste     LineTable *line_table = m_comp_unit->GetLineTable();
572f3fbd1c0SDimitry Andric     uint32_t prologue_end_line_idx = 0;
573f3fbd1c0SDimitry Andric 
57414f1b3e8SDimitry Andric     if (line_table) {
575f034231aSEd Maste       LineEntry first_line_entry;
576f034231aSEd Maste       uint32_t first_line_entry_idx = UINT32_MAX;
57714f1b3e8SDimitry Andric       if (line_table->FindLineEntryByAddress(GetAddressRange().GetBaseAddress(),
57814f1b3e8SDimitry Andric                                              first_line_entry,
57914f1b3e8SDimitry Andric                                              &first_line_entry_idx)) {
580f034231aSEd Maste         // Make sure the first line entry isn't already the end of the prologue
581f034231aSEd Maste         addr_t prologue_end_file_addr = LLDB_INVALID_ADDRESS;
582f3fbd1c0SDimitry Andric         addr_t line_zero_end_file_addr = LLDB_INVALID_ADDRESS;
583f3fbd1c0SDimitry Andric 
58414f1b3e8SDimitry Andric         if (first_line_entry.is_prologue_end) {
58514f1b3e8SDimitry Andric           prologue_end_file_addr =
58614f1b3e8SDimitry Andric               first_line_entry.range.GetBaseAddress().GetFileAddress();
587f3fbd1c0SDimitry Andric           prologue_end_line_idx = first_line_entry_idx;
58814f1b3e8SDimitry Andric         } else {
589f034231aSEd Maste           // Check the first few instructions and look for one that has
590f034231aSEd Maste           // is_prologue_end set to true.
591f034231aSEd Maste           const uint32_t last_line_entry_idx = first_line_entry_idx + 6;
59214f1b3e8SDimitry Andric           for (uint32_t idx = first_line_entry_idx + 1;
59314f1b3e8SDimitry Andric                idx < last_line_entry_idx; ++idx) {
594f034231aSEd Maste             LineEntry line_entry;
59514f1b3e8SDimitry Andric             if (line_table->GetLineEntryAtIndex(idx, line_entry)) {
59614f1b3e8SDimitry Andric               if (line_entry.is_prologue_end) {
59714f1b3e8SDimitry Andric                 prologue_end_file_addr =
59814f1b3e8SDimitry Andric                     line_entry.range.GetBaseAddress().GetFileAddress();
599f3fbd1c0SDimitry Andric                 prologue_end_line_idx = idx;
600f034231aSEd Maste                 break;
601f034231aSEd Maste               }
602f034231aSEd Maste             }
603f034231aSEd Maste           }
604f034231aSEd Maste         }
605f034231aSEd Maste 
606f73363f1SDimitry Andric         // If we didn't find the end of the prologue in the line tables, then
607f73363f1SDimitry Andric         // just use the end address of the first line table entry
60814f1b3e8SDimitry Andric         if (prologue_end_file_addr == LLDB_INVALID_ADDRESS) {
609f73363f1SDimitry Andric           // Check the first few instructions and look for one that has a line
610f73363f1SDimitry Andric           // number that's different than the first entry.
611f3fbd1c0SDimitry Andric           uint32_t last_line_entry_idx = first_line_entry_idx + 6;
61214f1b3e8SDimitry Andric           for (uint32_t idx = first_line_entry_idx + 1;
61314f1b3e8SDimitry Andric                idx < last_line_entry_idx; ++idx) {
614f034231aSEd Maste             LineEntry line_entry;
61514f1b3e8SDimitry Andric             if (line_table->GetLineEntryAtIndex(idx, line_entry)) {
61614f1b3e8SDimitry Andric               if (line_entry.line != first_line_entry.line) {
61714f1b3e8SDimitry Andric                 prologue_end_file_addr =
61814f1b3e8SDimitry Andric                     line_entry.range.GetBaseAddress().GetFileAddress();
619f3fbd1c0SDimitry Andric                 prologue_end_line_idx = idx;
620f034231aSEd Maste                 break;
621f034231aSEd Maste               }
622f034231aSEd Maste             }
623f034231aSEd Maste           }
624f034231aSEd Maste 
62514f1b3e8SDimitry Andric           if (prologue_end_file_addr == LLDB_INVALID_ADDRESS) {
62614f1b3e8SDimitry Andric             prologue_end_file_addr =
62714f1b3e8SDimitry Andric                 first_line_entry.range.GetBaseAddress().GetFileAddress() +
62814f1b3e8SDimitry Andric                 first_line_entry.range.GetByteSize();
629f3fbd1c0SDimitry Andric             prologue_end_line_idx = first_line_entry_idx;
630f034231aSEd Maste           }
631f034231aSEd Maste         }
632f3fbd1c0SDimitry Andric 
63314f1b3e8SDimitry Andric         const addr_t func_start_file_addr =
63414f1b3e8SDimitry Andric             m_range.GetBaseAddress().GetFileAddress();
63514f1b3e8SDimitry Andric         const addr_t func_end_file_addr =
63614f1b3e8SDimitry Andric             func_start_file_addr + m_range.GetByteSize();
637f034231aSEd Maste 
638f3fbd1c0SDimitry Andric         // Now calculate the offset to pass the subsequent line 0 entries.
639f3fbd1c0SDimitry Andric         uint32_t first_non_zero_line = prologue_end_line_idx;
6405f29bb8aSDimitry Andric         while (true) {
641f3fbd1c0SDimitry Andric           LineEntry line_entry;
64214f1b3e8SDimitry Andric           if (line_table->GetLineEntryAtIndex(first_non_zero_line,
64314f1b3e8SDimitry Andric                                               line_entry)) {
644f3fbd1c0SDimitry Andric             if (line_entry.line != 0)
645f3fbd1c0SDimitry Andric               break;
646f3fbd1c0SDimitry Andric           }
64714f1b3e8SDimitry Andric           if (line_entry.range.GetBaseAddress().GetFileAddress() >=
64814f1b3e8SDimitry Andric               func_end_file_addr)
649f3fbd1c0SDimitry Andric             break;
650f3fbd1c0SDimitry Andric 
651f3fbd1c0SDimitry Andric           first_non_zero_line++;
652f3fbd1c0SDimitry Andric         }
653f3fbd1c0SDimitry Andric 
65414f1b3e8SDimitry Andric         if (first_non_zero_line > prologue_end_line_idx) {
655f3fbd1c0SDimitry Andric           LineEntry first_non_zero_entry;
65614f1b3e8SDimitry Andric           if (line_table->GetLineEntryAtIndex(first_non_zero_line,
65714f1b3e8SDimitry Andric                                               first_non_zero_entry)) {
65814f1b3e8SDimitry Andric             line_zero_end_file_addr =
65914f1b3e8SDimitry Andric                 first_non_zero_entry.range.GetBaseAddress().GetFileAddress();
660f3fbd1c0SDimitry Andric           }
661f3fbd1c0SDimitry Andric         }
662f3fbd1c0SDimitry Andric 
663f73363f1SDimitry Andric         // Verify that this prologue end file address in the function's address
664f73363f1SDimitry Andric         // range just to be sure
66514f1b3e8SDimitry Andric         if (func_start_file_addr < prologue_end_file_addr &&
66614f1b3e8SDimitry Andric             prologue_end_file_addr < func_end_file_addr) {
667f034231aSEd Maste           m_prologue_byte_size = prologue_end_file_addr - func_start_file_addr;
668f034231aSEd Maste         }
669f3fbd1c0SDimitry Andric 
67014f1b3e8SDimitry Andric         if (prologue_end_file_addr < line_zero_end_file_addr &&
67114f1b3e8SDimitry Andric             line_zero_end_file_addr < func_end_file_addr) {
67214f1b3e8SDimitry Andric           m_prologue_byte_size +=
67314f1b3e8SDimitry Andric               line_zero_end_file_addr - prologue_end_file_addr;
674f034231aSEd Maste         }
675f034231aSEd Maste       }
676f034231aSEd Maste     }
677f3fbd1c0SDimitry Andric   }
678f3fbd1c0SDimitry Andric 
679f034231aSEd Maste   return m_prologue_byte_size;
680f034231aSEd Maste }
681f034231aSEd Maste 
GetLanguage() const68214f1b3e8SDimitry Andric lldb::LanguageType Function::GetLanguage() const {
6835f29bb8aSDimitry Andric   lldb::LanguageType lang = m_mangled.GuessLanguage();
6845f29bb8aSDimitry Andric   if (lang != lldb::eLanguageTypeUnknown)
6855f29bb8aSDimitry Andric     return lang;
6865f29bb8aSDimitry Andric 
687027f1c96SDimitry Andric   if (m_comp_unit)
688027f1c96SDimitry Andric     return m_comp_unit->GetLanguage();
6895f29bb8aSDimitry Andric 
690027f1c96SDimitry Andric   return lldb::eLanguageTypeUnknown;
691027f1c96SDimitry Andric }
692027f1c96SDimitry Andric 
GetName() const69314f1b3e8SDimitry Andric ConstString Function::GetName() const {
694cfca06d7SDimitry Andric   return m_mangled.GetName();
695027f1c96SDimitry Andric }
696027f1c96SDimitry Andric 
GetNameNoArguments() const69714f1b3e8SDimitry Andric ConstString Function::GetNameNoArguments() const {
698cfca06d7SDimitry Andric   return m_mangled.GetName(Mangled::ePreferDemangledWithoutArguments);
699027f1c96SDimitry Andric }
700