llvm.org GIT mirror llvm / b8e48a6
Debug Info: In DIBuilder, the context field of subprogram is updated to use DIScopeRef. A paired commit at clang is required due to changes to DIBuilder. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192378 91177308-0d34-0410-b5e6-96231b3b80d8 Manman Ren 5 years ago
8 changed file(s) with 56 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
561561 MDNode *TParam = 0,
562562 MDNode *Decl = 0);
563563
564 /// FIXME: this is added for dragonegg. Once we update dragonegg
565 /// to call resolve function, this will be removed.
566 DISubprogram createFunction(DIScopeRef Scope, StringRef Name,
567 StringRef LinkageName,
568 DIFile File, unsigned LineNo,
569 DICompositeType Ty, bool isLocalToUnit,
570 bool isDefinition,
571 unsigned ScopeLine,
572 unsigned Flags = 0,
573 bool isOptimized = false,
574 Function *Fn = 0,
575 MDNode *TParam = 0,
576 MDNode *Decl = 0);
577
564578 /// createMethod - Create a new descriptor for the specified C++ method.
565579 /// See comments in DISubprogram for descriptions of these fields.
566580 /// @param Scope Function scope.
433433 public:
434434 explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
435435
436 DIScope getContext() const { return getFieldAs>(2); }
436 DIScopeRef getContext() const { return getFieldAs>(2); }
437437 StringRef getName() const { return getStringField(3); }
438438 StringRef getDisplayName() const { return getStringField(4); }
439439 StringRef getLinkageName() const { return getStringField(5); }
12991299 // Construct the context before querying for the existence of the DIE in case
13001300 // such construction creates the DIE (as is the case for member function
13011301 // declarations).
1302 DIE *ContextDIE = getOrCreateContextDIE(SP.getContext());
1302 DIE *ContextDIE = getOrCreateContextDIE(resolve(SP.getContext()));
13031303 if (!ContextDIE)
13041304 ContextDIE = CUDie.get();
13051305
392392 // function then gdb prefers the definition at top level and but does not
393393 // expect specification DIE in parent function. So avoid creating
394394 // specification DIE for a function defined inside a function.
395 if (SP.isDefinition() && !SP.getContext().isCompileUnit() &&
396 !SP.getContext().isFile() &&
397 !isSubprogramContext(SP.getContext())) {
395 DIScope SPContext = resolve(SP.getContext());
396 if (SP.isDefinition() && !SPContext.isCompileUnit() &&
397 !SPContext.isFile() &&
398 !isSubprogramContext(SPContext)) {
398399 SPCU->addFlag(SPDie, dwarf::DW_AT_declaration);
399400
400401 // Add arguments.
10401040 }
10411041
10421042 /// createFunction - Create a new descriptor for the specified function.
1043 /// FIXME: this is added for dragonegg. Once we update dragonegg
1044 /// to call resolve function, this will be removed.
1045 DISubprogram DIBuilder::createFunction(DIScopeRef Context,
1046 StringRef Name,
1047 StringRef LinkageName,
1048 DIFile File, unsigned LineNo,
1049 DICompositeType Ty,
1050 bool isLocalToUnit, bool isDefinition,
1051 unsigned ScopeLine,
1052 unsigned Flags, bool isOptimized,
1053 Function *Fn,
1054 MDNode *TParams,
1055 MDNode *Decl) {
1056 // dragonegg does not generate identifier for types, so using an empty map
1057 // to resolve the context should be fine.
1058 DITypeIdentifierMap EmptyMap;
1059 return createFunction(Context.resolve(EmptyMap), Name, LinkageName, File,
1060 LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine,
1061 Flags, isOptimized, Fn, TParams, Decl);
1062 }
1063
1064 /// createFunction - Create a new descriptor for the specified function.
10431065 DISubprogram DIBuilder::createFunction(DIDescriptor Context,
10441066 StringRef Name,
10451067 StringRef LinkageName,
10571079 Value *Elts[] = {
10581080 GetTagConstant(VMContext, dwarf::DW_TAG_subprogram),
10591081 File.getFileNode(),
1060 getNonCompileUnitScope(Context),
1082 DIScope(getNonCompileUnitScope(Context)).getRef(),
10611083 MDString::get(VMContext, Name),
10621084 MDString::get(VMContext, Name),
10631085 MDString::get(VMContext, LinkageName),
11061128 Value *Elts[] = {
11071129 GetTagConstant(VMContext, dwarf::DW_TAG_subprogram),
11081130 F.getFileNode(),
1109 getNonCompileUnitScope(Context),
1131 DIScope(getNonCompileUnitScope(Context)).getRef(),
11101132 MDString::get(VMContext, Name),
11111133 MDString::get(VMContext, Name),
11121134 MDString::get(VMContext, LinkageName),
510510 if (!isSubprogram())
511511 return false;
512512
513 // Make sure context @ field 2 and type @ field 7 are MDNodes.
514 if (!fieldIsMDNode(DbgNode, 2))
513 // Make sure context @ field 2 is a ScopeRef and type @ field 7 is a MDNode.
514 if (!fieldIsScopeRef(DbgNode, 2))
515515 return false;
516516 if (!fieldIsMDNode(DbgNode, 7))
517517 return false;
10701070 void DebugInfoFinder::processSubprogram(DISubprogram SP) {
10711071 if (!addSubprogram(SP))
10721072 return;
1073 processScope(SP.getContext());
1073 processScope(SP.getContext().resolve(TypeIdentifierMap));
10741074 processType(SP.getType());
10751075 DIArray TParams = SP.getTemplateParams();
10761076 for (unsigned I = 0, E = TParams.getNumElements(); I != E; ++I) {
55 ; Make sure we correctly handle containing type of a struct being a type identifier.
66 ; CHECK-NEXT: DW_AT_containing_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]})
77 ; CHECK-NEXT: DW_AT_name [DW_FORM_strp] {{.*}}= "C")
8
9 ; Make sure we correctly handle context of a subprogram being a type identifier.
810 ; CHECK: [[SP:.*]]: DW_TAG_subprogram
11 ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "foo")
912 ; Make sure we correctly handle containing type of a subprogram being a type identifier.
1013 ; CHECK: DW_AT_containing_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]})
14 ; CHECK: DW_TAG_formal_parameter
15 ; CHECK: NULL
16 ; CHECK: NULL
17
1118 ; CHECK: [[TYPE2:.*]]: DW_TAG_structure_type
1219 ; CHECK: DW_TAG_structure_type
1320 ; CHECK: DW_AT_name [DW_FORM_strp] {{.*}}= "D")
127134 !10 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !11, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
128135 !11 = metadata !{metadata !12}
129136 !12 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
130 !13 = metadata !{i32 786478, metadata !1, metadata !4, metadata !"foo", metadata !"foo", metadata !"_ZN1C3fooEv", i32 2, metadata !14, i1 false, i1 false, i32 1, i32 0, metadata !"_ZTS1C", i32 256, i1 false, null, null, i32 0, metadata !17, i32 2} ; [ DW_TAG_subprogram ] [line 2] [foo]
137 !13 = metadata !{i32 786478, metadata !1, metadata !"_ZTS1C", metadata !"foo", metadata !"foo", metadata !"_ZN1C3fooEv", i32 2, metadata !14, i1 false, i1 false, i32 1, i32 0, metadata !"_ZTS1C", i32 256, i1 false, null, null, i32 0, metadata !17, i32 2} ; [ DW_TAG_subprogram ] [line 2] [foo]
131138 !14 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !15, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
132139 !15 = metadata !{null, metadata !16}
133140 !16 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !"_ZTS1C"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1C]
403403 "A MDNode in llvm.dbg.sp should be null or a DISubprogram.");
404404 if (!SP)
405405 continue;
406 getContextName(SP.getContext(), Name);
406 getContextName(SP.getContext().resolve(TypeIdentifierMap), Name);
407407 Name = Name + SP.getDisplayName().str();
408408 if (!Name.empty() && Processed.insert(Name)) {
409409 Out << Name << "\n";