1 //===-- Function.cpp ------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/Symbol/Function.h"
10 #include "lldb/Core/Disassembler.h"
11 #include "lldb/Core/Module.h"
12 #include "lldb/Core/ModuleList.h"
13 #include "lldb/Core/Section.h"
14 #include "lldb/Host/Host.h"
15 #include "lldb/Symbol/CompileUnit.h"
16 #include "lldb/Symbol/CompilerType.h"
17 #include "lldb/Symbol/LineTable.h"
18 #include "lldb/Symbol/SymbolFile.h"
19 #include "lldb/Target/Language.h"
20 #include "lldb/Target/Target.h"
21 #include "lldb/Utility/Log.h"
22 #include "llvm/Support/Casting.h"
23 
24 using namespace lldb;
25 using namespace lldb_private;
26 
27 // Basic function information is contained in the FunctionInfo class. It is
28 // designed to contain the name, linkage name, and declaration location.
29 FunctionInfo::FunctionInfo(const char *name, const Declaration *decl_ptr)
30     : m_name(name), m_declaration(decl_ptr) {}
31 
32 FunctionInfo::FunctionInfo(ConstString name, const Declaration *decl_ptr)
33     : m_name(name), m_declaration(decl_ptr) {}
34 
35 FunctionInfo::~FunctionInfo() {}
36 
37 void FunctionInfo::Dump(Stream *s, bool show_fullpaths) const {
38   if (m_name)
39     *s << ", name = \"" << m_name << "\"";
40   m_declaration.Dump(s, show_fullpaths);
41 }
42 
43 int FunctionInfo::Compare(const FunctionInfo &a, const FunctionInfo &b) {
44   int result = ConstString::Compare(a.GetName(), b.GetName());
45   if (result)
46     return result;
47 
48   return Declaration::Compare(a.m_declaration, b.m_declaration);
49 }
50 
51 Declaration &FunctionInfo::GetDeclaration() { return m_declaration; }
52 
53 const Declaration &FunctionInfo::GetDeclaration() const {
54   return m_declaration;
55 }
56 
57 ConstString FunctionInfo::GetName() const { return m_name; }
58 
59 size_t FunctionInfo::MemorySize() const {
60   return m_name.MemorySize() + m_declaration.MemorySize();
61 }
62 
63 InlineFunctionInfo::InlineFunctionInfo(const char *name,
64                                        llvm::StringRef mangled,
65                                        const Declaration *decl_ptr,
66                                        const Declaration *call_decl_ptr)
67     : FunctionInfo(name, decl_ptr), m_mangled(mangled),
68       m_call_decl(call_decl_ptr) {}
69 
70 InlineFunctionInfo::InlineFunctionInfo(ConstString name,
71                                        const Mangled &mangled,
72                                        const Declaration *decl_ptr,
73                                        const Declaration *call_decl_ptr)
74     : FunctionInfo(name, decl_ptr), m_mangled(mangled),
75       m_call_decl(call_decl_ptr) {}
76 
77 InlineFunctionInfo::~InlineFunctionInfo() {}
78 
79 void InlineFunctionInfo::Dump(Stream *s, bool show_fullpaths) const {
80   FunctionInfo::Dump(s, show_fullpaths);
81   if (m_mangled)
82     m_mangled.Dump(s);
83 }
84 
85 void InlineFunctionInfo::DumpStopContext(Stream *s) const {
86   //    s->Indent("[inlined] ");
87   s->Indent();
88   if (m_mangled)
89     s->PutCString(m_mangled.GetName().AsCString());
90   else
91     s->PutCString(m_name.AsCString());
92 }
93 
94 ConstString InlineFunctionInfo::GetName() const {
95   if (m_mangled)
96     return m_mangled.GetName();
97   return m_name;
98 }
99 
100 ConstString InlineFunctionInfo::GetDisplayName() const {
101   if (m_mangled)
102     return m_mangled.GetDisplayDemangledName();
103   return m_name;
104 }
105 
106 Declaration &InlineFunctionInfo::GetCallSite() { return m_call_decl; }
107 
108 const Declaration &InlineFunctionInfo::GetCallSite() const {
109   return m_call_decl;
110 }
111 
112 Mangled &InlineFunctionInfo::GetMangled() { return m_mangled; }
113 
114 const Mangled &InlineFunctionInfo::GetMangled() const { return m_mangled; }
115 
116 size_t InlineFunctionInfo::MemorySize() const {
117   return FunctionInfo::MemorySize() + m_mangled.MemorySize();
118 }
119 
120 /// @name Call site related structures
121 /// @{
122 
123 lldb::addr_t CallEdge::GetReturnPCAddress(Function &caller,
124                                           Target &target) const {
125   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
126 
127   const Address &caller_start_addr = caller.GetAddressRange().GetBaseAddress();
128 
129   ModuleSP caller_module_sp = caller_start_addr.GetModule();
130   if (!caller_module_sp) {
131     LLDB_LOG(log, "GetReturnPCAddress: cannot get Module for caller");
132     return LLDB_INVALID_ADDRESS;
133   }
134 
135   SectionList *section_list = caller_module_sp->GetSectionList();
136   if (!section_list) {
137     LLDB_LOG(log, "GetReturnPCAddress: cannot get SectionList for Module");
138     return LLDB_INVALID_ADDRESS;
139   }
140 
141   Address return_pc_addr = Address(return_pc, section_list);
142   lldb::addr_t ret_addr = return_pc_addr.GetLoadAddress(&target);
143   return ret_addr;
144 }
145 
146 void DirectCallEdge::ParseSymbolFileAndResolve(ModuleList &images) {
147   if (resolved)
148     return;
149 
150   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
151   LLDB_LOG(log, "DirectCallEdge: Lazily parsing the call graph for {0}",
152            lazy_callee.symbol_name);
153 
154   auto resolve_lazy_callee = [&]() -> Function * {
155     ConstString callee_name{lazy_callee.symbol_name};
156     SymbolContextList sc_list;
157     images.FindFunctionSymbols(callee_name, eFunctionNameTypeAuto, sc_list);
158     size_t num_matches = sc_list.GetSize();
159     if (num_matches == 0 || !sc_list[0].symbol) {
160       LLDB_LOG(log,
161                "DirectCallEdge: Found no symbols for {0}, cannot resolve it",
162                callee_name);
163       return nullptr;
164     }
165     Address callee_addr = sc_list[0].symbol->GetAddress();
166     if (!callee_addr.IsValid()) {
167       LLDB_LOG(log, "DirectCallEdge: Invalid symbol address");
168       return nullptr;
169     }
170     Function *f = callee_addr.CalculateSymbolContextFunction();
171     if (!f) {
172       LLDB_LOG(log, "DirectCallEdge: Could not find complete function");
173       return nullptr;
174     }
175     return f;
176   };
177   lazy_callee.def = resolve_lazy_callee();
178   resolved = true;
179 }
180 
181 Function *DirectCallEdge::GetCallee(ModuleList &images, ExecutionContext &) {
182   ParseSymbolFileAndResolve(images);
183   assert(resolved && "Did not resolve lazy callee");
184   return lazy_callee.def;
185 }
186 
187 Function *IndirectCallEdge::GetCallee(ModuleList &images,
188                                       ExecutionContext &exe_ctx) {
189   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
190   Status error;
191   Value callee_addr_val;
192   if (!call_target.Evaluate(&exe_ctx, exe_ctx.GetRegisterContext(),
193                             /*loclist_base_addr=*/LLDB_INVALID_ADDRESS,
194                             /*initial_value_ptr=*/nullptr,
195                             /*object_address_ptr=*/nullptr, callee_addr_val,
196                             &error)) {
197     LLDB_LOGF(log, "IndirectCallEdge: Could not evaluate expression: %s",
198               error.AsCString());
199     return nullptr;
200   }
201 
202   addr_t raw_addr = callee_addr_val.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
203   if (raw_addr == LLDB_INVALID_ADDRESS) {
204     LLDB_LOG(log, "IndirectCallEdge: Could not extract address from scalar");
205     return nullptr;
206   }
207 
208   Address callee_addr;
209   if (!exe_ctx.GetTargetPtr()->ResolveLoadAddress(raw_addr, callee_addr)) {
210     LLDB_LOG(log, "IndirectCallEdge: Could not resolve callee's load address");
211     return nullptr;
212   }
213 
214   Function *f = callee_addr.CalculateSymbolContextFunction();
215   if (!f) {
216     LLDB_LOG(log, "IndirectCallEdge: Could not find complete function");
217     return nullptr;
218   }
219 
220   return f;
221 }
222 
223 /// @}
224 
225 //
226 Function::Function(CompileUnit *comp_unit, lldb::user_id_t func_uid,
227                    lldb::user_id_t type_uid, const Mangled &mangled, Type *type,
228                    const AddressRange &range)
229     : UserID(func_uid), m_comp_unit(comp_unit), m_type_uid(type_uid),
230       m_type(type), m_mangled(mangled), m_block(func_uid), m_range(range),
231       m_frame_base(), m_flags(), m_prologue_byte_size(0) {
232   m_block.SetParentScope(this);
233   assert(comp_unit != nullptr);
234 }
235 
236 Function::~Function() {}
237 
238 void Function::GetStartLineSourceInfo(FileSpec &source_file,
239                                       uint32_t &line_no) {
240   line_no = 0;
241   source_file.Clear();
242 
243   if (m_comp_unit == nullptr)
244     return;
245 
246   // Initialize m_type if it hasn't been initialized already
247   GetType();
248 
249   if (m_type != nullptr && m_type->GetDeclaration().GetLine() != 0) {
250     source_file = m_type->GetDeclaration().GetFile();
251     line_no = m_type->GetDeclaration().GetLine();
252   } else {
253     LineTable *line_table = m_comp_unit->GetLineTable();
254     if (line_table == nullptr)
255       return;
256 
257     LineEntry line_entry;
258     if (line_table->FindLineEntryByAddress(GetAddressRange().GetBaseAddress(),
259                                            line_entry, nullptr)) {
260       line_no = line_entry.line;
261       source_file = line_entry.file;
262     }
263   }
264 }
265 
266 void Function::GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no) {
267   line_no = 0;
268   source_file.Clear();
269 
270   // The -1 is kind of cheesy, but I want to get the last line entry for the
271   // given function, not the first entry of the next.
272   Address scratch_addr(GetAddressRange().GetBaseAddress());
273   scratch_addr.SetOffset(scratch_addr.GetOffset() +
274                          GetAddressRange().GetByteSize() - 1);
275 
276   LineTable *line_table = m_comp_unit->GetLineTable();
277   if (line_table == nullptr)
278     return;
279 
280   LineEntry line_entry;
281   if (line_table->FindLineEntryByAddress(scratch_addr, line_entry, nullptr)) {
282     line_no = line_entry.line;
283     source_file = line_entry.file;
284   }
285 }
286 
287 llvm::ArrayRef<std::unique_ptr<CallEdge>> Function::GetCallEdges() {
288   if (m_call_edges_resolved)
289     return m_call_edges;
290 
291   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
292   LLDB_LOG(log, "GetCallEdges: Attempting to parse call site info for {0}",
293            GetDisplayName());
294 
295   m_call_edges_resolved = true;
296 
297   // Find the SymbolFile which provided this function's definition.
298   Block &block = GetBlock(/*can_create*/true);
299   SymbolFile *sym_file = block.GetSymbolFile();
300   if (!sym_file)
301     return llvm::None;
302 
303   // Lazily read call site information from the SymbolFile.
304   m_call_edges = sym_file->ParseCallEdgesInFunction(GetID());
305 
306   // Sort the call edges to speed up return_pc lookups.
307   llvm::sort(m_call_edges.begin(), m_call_edges.end(),
308              [](const std::unique_ptr<CallEdge> &LHS,
309                 const std::unique_ptr<CallEdge> &RHS) {
310                return LHS->GetUnresolvedReturnPCAddress() <
311                       RHS->GetUnresolvedReturnPCAddress();
312              });
313 
314   return m_call_edges;
315 }
316 
317 llvm::ArrayRef<std::unique_ptr<CallEdge>> Function::GetTailCallingEdges() {
318   // Call edges are sorted by return PC, and tail calling edges have invalid
319   // return PCs. Find them at the end of the list.
320   return GetCallEdges().drop_until([](const std::unique_ptr<CallEdge> &edge) {
321     return edge->GetUnresolvedReturnPCAddress() == LLDB_INVALID_ADDRESS;
322   });
323 }
324 
325 CallEdge *Function::GetCallEdgeForReturnAddress(addr_t return_pc,
326                                                 Target &target) {
327   auto edges = GetCallEdges();
328   auto edge_it =
329       std::lower_bound(edges.begin(), edges.end(), return_pc,
330                        [&](const std::unique_ptr<CallEdge> &edge, addr_t pc) {
331                          return edge->GetReturnPCAddress(*this, target) < pc;
332                        });
333   if (edge_it == edges.end() ||
334       edge_it->get()->GetReturnPCAddress(*this, target) != return_pc)
335     return nullptr;
336   return &const_cast<CallEdge &>(*edge_it->get());
337 }
338 
339 Block &Function::GetBlock(bool can_create) {
340   if (!m_block.BlockInfoHasBeenParsed() && can_create) {
341     ModuleSP module_sp = CalculateSymbolContextModule();
342     if (module_sp) {
343       module_sp->GetSymbolFile()->ParseBlocksRecursive(*this);
344     } else {
345       Host::SystemLog(Host::eSystemLogError,
346                       "error: unable to find module "
347                       "shared pointer for function '%s' "
348                       "in %s\n",
349                       GetName().GetCString(),
350                       m_comp_unit->GetPrimaryFile().GetPath().c_str());
351     }
352     m_block.SetBlockInfoHasBeenParsed(true, true);
353   }
354   return m_block;
355 }
356 
357 CompileUnit *Function::GetCompileUnit() { return m_comp_unit; }
358 
359 const CompileUnit *Function::GetCompileUnit() const { return m_comp_unit; }
360 
361 void Function::GetDescription(Stream *s, lldb::DescriptionLevel level,
362                               Target *target) {
363   ConstString name = GetName();
364   ConstString mangled = m_mangled.GetMangledName();
365 
366   *s << "id = " << (const UserID &)*this;
367   if (name)
368     *s << ", name = \"" << name.GetCString() << '"';
369   if (mangled)
370     *s << ", mangled = \"" << mangled.GetCString() << '"';
371   *s << ", range = ";
372   Address::DumpStyle fallback_style;
373   if (level == eDescriptionLevelVerbose)
374     fallback_style = Address::DumpStyleModuleWithFileAddress;
375   else
376     fallback_style = Address::DumpStyleFileAddress;
377   GetAddressRange().Dump(s, target, Address::DumpStyleLoadAddress,
378                          fallback_style);
379 }
380 
381 void Function::Dump(Stream *s, bool show_context) const {
382   s->Printf("%p: ", static_cast<const void *>(this));
383   s->Indent();
384   *s << "Function" << static_cast<const UserID &>(*this);
385 
386   m_mangled.Dump(s);
387 
388   if (m_type)
389     s->Printf(", type = %p", static_cast<void *>(m_type));
390   else if (m_type_uid != LLDB_INVALID_UID)
391     s->Printf(", type_uid = 0x%8.8" PRIx64, m_type_uid);
392 
393   s->EOL();
394   // Dump the root object
395   if (m_block.BlockInfoHasBeenParsed())
396     m_block.Dump(s, m_range.GetBaseAddress().GetFileAddress(), INT_MAX,
397                  show_context);
398 }
399 
400 void Function::CalculateSymbolContext(SymbolContext *sc) {
401   sc->function = this;
402   m_comp_unit->CalculateSymbolContext(sc);
403 }
404 
405 ModuleSP Function::CalculateSymbolContextModule() {
406   SectionSP section_sp(m_range.GetBaseAddress().GetSection());
407   if (section_sp)
408     return section_sp->GetModule();
409 
410   return this->GetCompileUnit()->GetModule();
411 }
412 
413 CompileUnit *Function::CalculateSymbolContextCompileUnit() {
414   return this->GetCompileUnit();
415 }
416 
417 Function *Function::CalculateSymbolContextFunction() { return this; }
418 
419 lldb::DisassemblerSP Function::GetInstructions(const ExecutionContext &exe_ctx,
420                                                const char *flavor,
421                                                bool prefer_file_cache) {
422   ModuleSP module_sp(GetAddressRange().GetBaseAddress().GetModule());
423   if (module_sp) {
424     const bool prefer_file_cache = false;
425     return Disassembler::DisassembleRange(module_sp->GetArchitecture(), nullptr,
426                                           flavor, exe_ctx, GetAddressRange(),
427                                           prefer_file_cache);
428   }
429   return lldb::DisassemblerSP();
430 }
431 
432 bool Function::GetDisassembly(const ExecutionContext &exe_ctx,
433                               const char *flavor, bool prefer_file_cache,
434                               Stream &strm) {
435   lldb::DisassemblerSP disassembler_sp =
436       GetInstructions(exe_ctx, flavor, prefer_file_cache);
437   if (disassembler_sp) {
438     const bool show_address = true;
439     const bool show_bytes = false;
440     disassembler_sp->GetInstructionList().Dump(&strm, show_address, show_bytes,
441                                                &exe_ctx);
442     return true;
443   }
444   return false;
445 }
446 
447 // Symbol *
448 // Function::CalculateSymbolContextSymbol ()
449 //{
450 //    return // TODO: find the symbol for the function???
451 //}
452 
453 void Function::DumpSymbolContext(Stream *s) {
454   m_comp_unit->DumpSymbolContext(s);
455   s->Printf(", Function{0x%8.8" PRIx64 "}", GetID());
456 }
457 
458 size_t Function::MemorySize() const {
459   size_t mem_size = sizeof(Function) + m_block.MemorySize();
460   return mem_size;
461 }
462 
463 bool Function::GetIsOptimized() {
464   bool result = false;
465 
466   // Currently optimization is only indicted by the vendor extension
467   // DW_AT_APPLE_optimized which is set on a compile unit level.
468   if (m_comp_unit) {
469     result = m_comp_unit->GetIsOptimized();
470   }
471   return result;
472 }
473 
474 bool Function::IsTopLevelFunction() {
475   bool result = false;
476 
477   if (Language *language = Language::FindPlugin(GetLanguage()))
478     result = language->IsTopLevelFunction(*this);
479 
480   return result;
481 }
482 
483 ConstString Function::GetDisplayName() const {
484   return m_mangled.GetDisplayDemangledName();
485 }
486 
487 CompilerDeclContext Function::GetDeclContext() {
488   ModuleSP module_sp = CalculateSymbolContextModule();
489 
490   if (module_sp) {
491     if (SymbolFile *sym_file = module_sp->GetSymbolFile())
492       return sym_file->GetDeclContextForUID(GetID());
493   }
494   return CompilerDeclContext();
495 }
496 
497 Type *Function::GetType() {
498   if (m_type == nullptr) {
499     SymbolContext sc;
500 
501     CalculateSymbolContext(&sc);
502 
503     if (!sc.module_sp)
504       return nullptr;
505 
506     SymbolFile *sym_file = sc.module_sp->GetSymbolFile();
507 
508     if (sym_file == nullptr)
509       return nullptr;
510 
511     m_type = sym_file->ResolveTypeUID(m_type_uid);
512   }
513   return m_type;
514 }
515 
516 const Type *Function::GetType() const { return m_type; }
517 
518 CompilerType Function::GetCompilerType() {
519   Type *function_type = GetType();
520   if (function_type)
521     return function_type->GetFullCompilerType();
522   return CompilerType();
523 }
524 
525 uint32_t Function::GetPrologueByteSize() {
526   if (m_prologue_byte_size == 0 &&
527       m_flags.IsClear(flagsCalculatedPrologueSize)) {
528     m_flags.Set(flagsCalculatedPrologueSize);
529     LineTable *line_table = m_comp_unit->GetLineTable();
530     uint32_t prologue_end_line_idx = 0;
531 
532     if (line_table) {
533       LineEntry first_line_entry;
534       uint32_t first_line_entry_idx = UINT32_MAX;
535       if (line_table->FindLineEntryByAddress(GetAddressRange().GetBaseAddress(),
536                                              first_line_entry,
537                                              &first_line_entry_idx)) {
538         // Make sure the first line entry isn't already the end of the prologue
539         addr_t prologue_end_file_addr = LLDB_INVALID_ADDRESS;
540         addr_t line_zero_end_file_addr = LLDB_INVALID_ADDRESS;
541 
542         if (first_line_entry.is_prologue_end) {
543           prologue_end_file_addr =
544               first_line_entry.range.GetBaseAddress().GetFileAddress();
545           prologue_end_line_idx = first_line_entry_idx;
546         } else {
547           // Check the first few instructions and look for one that has
548           // is_prologue_end set to true.
549           const uint32_t last_line_entry_idx = first_line_entry_idx + 6;
550           for (uint32_t idx = first_line_entry_idx + 1;
551                idx < last_line_entry_idx; ++idx) {
552             LineEntry line_entry;
553             if (line_table->GetLineEntryAtIndex(idx, line_entry)) {
554               if (line_entry.is_prologue_end) {
555                 prologue_end_file_addr =
556                     line_entry.range.GetBaseAddress().GetFileAddress();
557                 prologue_end_line_idx = idx;
558                 break;
559               }
560             }
561           }
562         }
563 
564         // If we didn't find the end of the prologue in the line tables, then
565         // just use the end address of the first line table entry
566         if (prologue_end_file_addr == LLDB_INVALID_ADDRESS) {
567           // Check the first few instructions and look for one that has a line
568           // number that's different than the first entry.
569           uint32_t last_line_entry_idx = first_line_entry_idx + 6;
570           for (uint32_t idx = first_line_entry_idx + 1;
571                idx < last_line_entry_idx; ++idx) {
572             LineEntry line_entry;
573             if (line_table->GetLineEntryAtIndex(idx, line_entry)) {
574               if (line_entry.line != first_line_entry.line) {
575                 prologue_end_file_addr =
576                     line_entry.range.GetBaseAddress().GetFileAddress();
577                 prologue_end_line_idx = idx;
578                 break;
579               }
580             }
581           }
582 
583           if (prologue_end_file_addr == LLDB_INVALID_ADDRESS) {
584             prologue_end_file_addr =
585                 first_line_entry.range.GetBaseAddress().GetFileAddress() +
586                 first_line_entry.range.GetByteSize();
587             prologue_end_line_idx = first_line_entry_idx;
588           }
589         }
590 
591         const addr_t func_start_file_addr =
592             m_range.GetBaseAddress().GetFileAddress();
593         const addr_t func_end_file_addr =
594             func_start_file_addr + m_range.GetByteSize();
595 
596         // Now calculate the offset to pass the subsequent line 0 entries.
597         uint32_t first_non_zero_line = prologue_end_line_idx;
598         while (true) {
599           LineEntry line_entry;
600           if (line_table->GetLineEntryAtIndex(first_non_zero_line,
601                                               line_entry)) {
602             if (line_entry.line != 0)
603               break;
604           }
605           if (line_entry.range.GetBaseAddress().GetFileAddress() >=
606               func_end_file_addr)
607             break;
608 
609           first_non_zero_line++;
610         }
611 
612         if (first_non_zero_line > prologue_end_line_idx) {
613           LineEntry first_non_zero_entry;
614           if (line_table->GetLineEntryAtIndex(first_non_zero_line,
615                                               first_non_zero_entry)) {
616             line_zero_end_file_addr =
617                 first_non_zero_entry.range.GetBaseAddress().GetFileAddress();
618           }
619         }
620 
621         // Verify that this prologue end file address in the function's address
622         // range just to be sure
623         if (func_start_file_addr < prologue_end_file_addr &&
624             prologue_end_file_addr < func_end_file_addr) {
625           m_prologue_byte_size = prologue_end_file_addr - func_start_file_addr;
626         }
627 
628         if (prologue_end_file_addr < line_zero_end_file_addr &&
629             line_zero_end_file_addr < func_end_file_addr) {
630           m_prologue_byte_size +=
631               line_zero_end_file_addr - prologue_end_file_addr;
632         }
633       }
634     }
635   }
636 
637   return m_prologue_byte_size;
638 }
639 
640 lldb::LanguageType Function::GetLanguage() const {
641   lldb::LanguageType lang = m_mangled.GuessLanguage();
642   if (lang != lldb::eLanguageTypeUnknown)
643     return lang;
644 
645   if (m_comp_unit)
646     return m_comp_unit->GetLanguage();
647 
648   return lldb::eLanguageTypeUnknown;
649 }
650 
651 ConstString Function::GetName() const {
652   return m_mangled.GetName();
653 }
654 
655 ConstString Function::GetNameNoArguments() const {
656   return m_mangled.GetName(Mangled::ePreferDemangledWithoutArguments);
657 }
658