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