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