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