@@ -2342,8 +2342,11 @@ size_t DWARFASTParserClang::ParseChildEnumerators(
2342
2342
return enumerators_added;
2343
2343
}
2344
2344
2345
- Function *DWARFASTParserClang::ParseFunctionFromDWARF (CompileUnit &comp_unit,
2346
- const DWARFDIE &die) {
2345
+ Function *
2346
+ DWARFASTParserClang::ParseFunctionFromDWARF (CompileUnit &comp_unit,
2347
+ const DWARFDIE &die,
2348
+ const AddressRange &func_range) {
2349
+ assert (func_range.GetBaseAddress ().IsValid ());
2347
2350
DWARFRangeList func_ranges;
2348
2351
const char *name = nullptr ;
2349
2352
const char *mangled = nullptr ;
@@ -2363,94 +2366,75 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
2363
2366
if (die.GetDIENamesAndRanges (name, mangled, func_ranges, decl_file, decl_line,
2364
2367
decl_column, call_file, call_line, call_column,
2365
2368
&frame_base)) {
2369
+ Mangled func_name;
2370
+ if (mangled)
2371
+ func_name.SetValue (ConstString (mangled), true );
2372
+ else if ((die.GetParent ().Tag () == DW_TAG_compile_unit ||
2373
+ die.GetParent ().Tag () == DW_TAG_partial_unit) &&
2374
+ Language::LanguageIsCPlusPlus (
2375
+ SymbolFileDWARF::GetLanguage (*die.GetCU ())) &&
2376
+ !Language::LanguageIsObjC (
2377
+ SymbolFileDWARF::GetLanguage (*die.GetCU ())) &&
2378
+ name && strcmp (name, " main" ) != 0 ) {
2379
+ // If the mangled name is not present in the DWARF, generate the
2380
+ // demangled name using the decl context. We skip if the function is
2381
+ // "main" as its name is never mangled.
2382
+ bool is_static = false ;
2383
+ bool is_variadic = false ;
2384
+ bool has_template_params = false ;
2385
+ unsigned type_quals = 0 ;
2386
+ std::vector<CompilerType> param_types;
2387
+ std::vector<clang::ParmVarDecl *> param_decls;
2388
+ StreamString sstr;
2389
+
2390
+ DWARFDeclContext decl_ctx = SymbolFileDWARF::GetDWARFDeclContext (die);
2391
+ sstr << decl_ctx.GetQualifiedName ();
2366
2392
2367
- // Union of all ranges in the function DIE (if the function is
2368
- // discontiguous)
2369
- AddressRange func_range;
2370
- lldb::addr_t lowest_func_addr = func_ranges.GetMinRangeBase (0 );
2371
- lldb::addr_t highest_func_addr = func_ranges.GetMaxRangeEnd (0 );
2372
- if (lowest_func_addr != LLDB_INVALID_ADDRESS &&
2373
- lowest_func_addr <= highest_func_addr) {
2374
- ModuleSP module_sp (die.GetModule ());
2375
- func_range.GetBaseAddress ().ResolveAddressUsingFileSections (
2376
- lowest_func_addr, module_sp->GetSectionList ());
2377
- if (func_range.GetBaseAddress ().IsValid ())
2378
- func_range.SetByteSize (highest_func_addr - lowest_func_addr);
2379
- }
2380
-
2381
- if (func_range.GetBaseAddress ().IsValid ()) {
2382
- Mangled func_name;
2383
- if (mangled)
2384
- func_name.SetValue (ConstString (mangled), true );
2385
- else if ((die.GetParent ().Tag () == DW_TAG_compile_unit ||
2386
- die.GetParent ().Tag () == DW_TAG_partial_unit) &&
2387
- Language::LanguageIsCPlusPlus (
2388
- SymbolFileDWARF::GetLanguage (*die.GetCU ())) &&
2389
- !Language::LanguageIsObjC (
2390
- SymbolFileDWARF::GetLanguage (*die.GetCU ())) &&
2391
- name && strcmp (name, " main" ) != 0 ) {
2392
- // If the mangled name is not present in the DWARF, generate the
2393
- // demangled name using the decl context. We skip if the function is
2394
- // "main" as its name is never mangled.
2395
- bool is_static = false ;
2396
- bool is_variadic = false ;
2397
- bool has_template_params = false ;
2398
- unsigned type_quals = 0 ;
2399
- std::vector<CompilerType> param_types;
2400
- std::vector<clang::ParmVarDecl *> param_decls;
2401
- StreamString sstr;
2402
-
2403
- DWARFDeclContext decl_ctx = SymbolFileDWARF::GetDWARFDeclContext (die);
2404
- sstr << decl_ctx.GetQualifiedName ();
2405
-
2406
- clang::DeclContext *containing_decl_ctx =
2407
- GetClangDeclContextContainingDIE (die, nullptr );
2408
- ParseChildParameters (containing_decl_ctx, die, true , is_static,
2409
- is_variadic, has_template_params, param_types,
2410
- param_decls, type_quals);
2411
- sstr << " (" ;
2412
- for (size_t i = 0 ; i < param_types.size (); i++) {
2413
- if (i > 0 )
2414
- sstr << " , " ;
2415
- sstr << param_types[i].GetTypeName ();
2416
- }
2417
- if (is_variadic)
2418
- sstr << " , ..." ;
2419
- sstr << " )" ;
2420
- if (type_quals & clang::Qualifiers::Const)
2421
- sstr << " const" ;
2422
-
2423
- func_name.SetValue (ConstString (sstr.GetString ()), false );
2424
- } else
2425
- func_name.SetValue (ConstString (name), false );
2426
-
2427
- FunctionSP func_sp;
2428
- std::unique_ptr<Declaration> decl_up;
2429
- if (decl_file != 0 || decl_line != 0 || decl_column != 0 )
2430
- decl_up = std::make_unique<Declaration>(die.GetCU ()->GetFile (decl_file),
2431
- decl_line, decl_column);
2432
-
2433
- SymbolFileDWARF *dwarf = die.GetDWARF ();
2434
- // Supply the type _only_ if it has already been parsed
2435
- Type *func_type = dwarf->GetDIEToType ().lookup (die.GetDIE ());
2436
-
2437
- assert (func_type == nullptr || func_type != DIE_IS_BEING_PARSED);
2438
-
2439
- if (dwarf->FixupAddress (func_range.GetBaseAddress ())) {
2440
- const user_id_t func_user_id = die.GetID ();
2441
- func_sp =
2442
- std::make_shared<Function>(&comp_unit,
2393
+ clang::DeclContext *containing_decl_ctx =
2394
+ GetClangDeclContextContainingDIE (die, nullptr );
2395
+ ParseChildParameters (containing_decl_ctx, die, true , is_static,
2396
+ is_variadic, has_template_params, param_types,
2397
+ param_decls, type_quals);
2398
+ sstr << " (" ;
2399
+ for (size_t i = 0 ; i < param_types.size (); i++) {
2400
+ if (i > 0 )
2401
+ sstr << " , " ;
2402
+ sstr << param_types[i].GetTypeName ();
2403
+ }
2404
+ if (is_variadic)
2405
+ sstr << " , ..." ;
2406
+ sstr << " )" ;
2407
+ if (type_quals & clang::Qualifiers::Const)
2408
+ sstr << " const" ;
2409
+
2410
+ func_name.SetValue (ConstString (sstr.GetString ()), false );
2411
+ } else
2412
+ func_name.SetValue (ConstString (name), false );
2413
+
2414
+ FunctionSP func_sp;
2415
+ std::unique_ptr<Declaration> decl_up;
2416
+ if (decl_file != 0 || decl_line != 0 || decl_column != 0 )
2417
+ decl_up = std::make_unique<Declaration>(die.GetCU ()->GetFile (decl_file),
2418
+ decl_line, decl_column);
2419
+
2420
+ SymbolFileDWARF *dwarf = die.GetDWARF ();
2421
+ // Supply the type _only_ if it has already been parsed
2422
+ Type *func_type = dwarf->GetDIEToType ().lookup (die.GetDIE ());
2423
+
2424
+ assert (func_type == nullptr || func_type != DIE_IS_BEING_PARSED);
2425
+
2426
+ const user_id_t func_user_id = die.GetID ();
2427
+ func_sp =
2428
+ std::make_shared<Function>(&comp_unit,
2443
2429
func_user_id, // UserID is the DIE offset
2444
2430
func_user_id, func_name, func_type,
2445
- func_range); // first address range
2431
+ func_range); // first address range
2446
2432
2447
- if (func_sp.get () != nullptr ) {
2448
- if (frame_base.IsValid ())
2449
- func_sp->GetFrameBaseExpression () = frame_base;
2450
- comp_unit.AddFunction (func_sp);
2451
- return func_sp.get ();
2452
- }
2453
- }
2433
+ if (func_sp.get () != nullptr ) {
2434
+ if (frame_base.IsValid ())
2435
+ func_sp->GetFrameBaseExpression () = frame_base;
2436
+ comp_unit.AddFunction (func_sp);
2437
+ return func_sp.get ();
2454
2438
}
2455
2439
}
2456
2440
return nullptr ;
0 commit comments