[PATCH] D159471: [DWARFVerifier] Allow ObjectiveC names in dwarf_debug tables
Felipe de Azevedo Piovezan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 7 11:27:37 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGab0eb59f1cda: [DWARFVerifier] Allow ObjectiveC names in dwarf_debug tables (authored by fdeazeve).
Changed prior to commit:
https://reviews.llvm.org/D159471?vs=556074&id=556188#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D159471/new/
https://reviews.llvm.org/D159471
Files:
llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
llvm/test/tools/dsymutil/X86/objc.test
Index: llvm/test/tools/dsymutil/X86/objc.test
===================================================================
--- llvm/test/tools/dsymutil/X86/objc.test
+++ llvm/test/tools/dsymutil/X86/objc.test
@@ -1,6 +1,17 @@
RUN: dsymutil --verify-dwarf=output -f -oso-prepend-path=%p/.. %p/../Inputs/objc.macho.x86_64 -o %t.d4
RUN: llvm-dwarfdump -apple-types -apple-objc %t.d4 | FileCheck %s
+; Test DWARF 5 tables
+RUN: dsymutil --verify-dwarf=output --accelerator='Dwarf' -f -oso-prepend-path=%p/.. %p/../Inputs/objc.macho.x86_64 -o %t.d5
+RUN: llvm-dwarfdump -debug-names %t.d5 | FileCheck %s --check-prefix=D5
+
+D5: String: {{.*}} "method1:"
+D5: String: {{.*}} "method2:"
+D5: String: {{.*}} "A"
+D5: String: {{.*}} "-[A(Category) method2:]"
+D5: String: {{.*}} "-[A method1:]"
+D5: String: {{.*}} "-[Amethod2:]"
+
CHECK: .apple_types contents:
CHECK: String: 0x00000066 "A"
CHECK-NEXT: Data 0 [
Index: llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -1351,16 +1351,32 @@
return NumErrors;
}
-static SmallVector<StringRef, 3> getNames(const DWARFDie &DIE,
- bool IncludeStrippedTemplateNames,
- bool IncludeLinkageName = true) {
- SmallVector<StringRef, 3> Result;
+static SmallVector<std::string, 3> getNames(const DWARFDie &DIE,
+ bool IncludeStrippedTemplateNames,
+ bool IncludeObjCNames = true,
+ bool IncludeLinkageName = true) {
+ SmallVector<std::string, 3> Result;
if (const char *Str = DIE.getShortName()) {
- Result.emplace_back(Str);
+ StringRef Name(Str);
+ Result.emplace_back(Name);
if (IncludeStrippedTemplateNames) {
if (std::optional<StringRef> StrippedName =
StripTemplateParameters(Result.back()))
- Result.push_back(*StrippedName);
+ // Convert to std::string and push; emplacing the StringRef may trigger
+ // a vector resize which may destroy the StringRef memory.
+ Result.push_back(StrippedName->str());
+ }
+
+ if (IncludeObjCNames) {
+ if (std::optional<ObjCSelectorNames> ObjCNames =
+ getObjCNamesIfSelector(Name)) {
+ Result.emplace_back(ObjCNames->ClassName);
+ Result.emplace_back(ObjCNames->Selector);
+ if (ObjCNames->ClassNameNoCategory)
+ Result.emplace_back(*ObjCNames->ClassNameNoCategory);
+ if (ObjCNames->MethodNameNoCategory)
+ Result.push_back(std::move(*ObjCNames->MethodNameNoCategory));
+ }
}
} else if (DIE.getTag() == dwarf::DW_TAG_namespace)
Result.emplace_back("(anonymous namespace)");
@@ -1507,11 +1523,12 @@
// the linkage name."
auto IncludeLinkageName = Die.getTag() == DW_TAG_subprogram ||
Die.getTag() == DW_TAG_inlined_subroutine;
- // We *allow* stripped template names as an extra entry into the template,
- // but we don't *require* them to pass the completeness test.
+ // We *allow* stripped template names / ObjectiveC names as extra entries into
+ // the table, but we don't *require* them to pass the completeness test.
auto IncludeStrippedTemplateNames = false;
- auto EntryNames =
- getNames(Die, IncludeStrippedTemplateNames, IncludeLinkageName);
+ auto IncludeObjCNames = false;
+ auto EntryNames = getNames(Die, IncludeStrippedTemplateNames,
+ IncludeObjCNames, IncludeLinkageName);
if (EntryNames.empty())
return 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159471.556188.patch
Type: text/x-patch
Size: 3717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230907/21765231/attachment.bin>
More information about the llvm-commits
mailing list