-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lldb simplified template names rebuild without clang ast #90008
Draft
dwblaikie
wants to merge
3
commits into
llvm:main
Choose a base branch
from
dwblaikie:lldb_simplified_template_names_rebuild_without_clang_ast
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
lldb simplified template names rebuild without clang ast #90008
dwblaikie
wants to merge
3
commits into
llvm:main
from
dwblaikie:lldb_simplified_template_names_rebuild_without_clang_ast
+844
−716
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Collaborator
dwblaikie
commented
Apr 25, 2024
- DO NOT SUBMIT: lldb DWARF-Clang AST parsing tracing
- Fix scope operator ordering
- DO NOT SUBMIT: Really dodgy demonstration of DWARFTypePrinter reuse in lldb
…n lldb The hacks necessary to make lldb's DWARFDIE APIs sufficiently compatible with LLVM's DWARFDie API aren't shippable, but maybe somewhere to start the conversation. With all these changes, an internal example that would crash expanding too many types (computing the fully qualified name for 414671 types before crashing due to running out of stack) - but with these patches applied, it comes down to 856 expansions (compared to 848 for non-simplified template names inputs)
You can test this locally with the following command:git-clang-format --diff 396cdabe47f3596464b289d0937c0066f50a0ac6 9a654b056d9c05c0aa4856db161c1f1b08b9dfe9 -- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp llvm/include/llvm-c/Error.h llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h llvm/lib/DebugInfo/DWARF/DWARFDie.cpp llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp View the diff from clang-format here.diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 962844af28..1232f29e36 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
+#include <algorithm>
#include <cstdlib>
#include <iostream>
-#include <algorithm>
#include "DWARFASTParser.h"
#include "DWARFASTParserClang.h"
@@ -1569,7 +1569,8 @@ DWARFASTParserClang::GetCPlusPlusQualifiedName(const DWARFDIE &die) {
if (!name)
return "";
static int indent = 0;
- std::cerr << std::string(indent, ' ') << "starting qualified name for: " << name << '\n';
+ std::cerr << std::string(indent, ' ')
+ << "starting qualified name for: " << name << '\n';
auto &FS = die.GetCU()->GetSymbolFileDWARF().GetObjectFile()->GetFileSpec();
std::string Directory = FS.GetDirectory().AsCString("");
std::cerr << std::string(indent, ' ')
@@ -1623,7 +1624,8 @@ DWARFASTParserClang::GetCPlusPlusQualifiedName(const DWARFDIE &die) {
qualified_name.append(GetDIEClassTemplateParams(die).AsCString(""));
--indent;
- std::cerr << std::string(indent, ' ') << "computed qualified name: " << qualified_name << '\n';
+ std::cerr << std::string(indent, ' ')
+ << "computed qualified name: " << qualified_name << '\n';
return qualified_name;
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
index 6a5ef1f83a..10c946a292 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
@@ -87,9 +87,7 @@ public:
// Accessing information about a DIE
dw_tag_t Tag() const;
- dw_tag_t getTag() const {
- return Tag();
- }
+ dw_tag_t getTag() const { return Tag(); }
using DWARFFormValue = dwarf::DWARFFormValue;
const char *GetTagAsCString() const;
@@ -103,9 +101,7 @@ public:
lldb::user_id_t GetID() const;
const char *GetName() const;
- const char *getShortName() const {
- return GetName();
- }
+ const char *getShortName() const { return GetName(); }
lldb::ModuleSP GetModule() const;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index 064c510eea..eb8147e01c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -532,9 +532,7 @@ llvm::iterator_range<DWARFDIE::child_iterator> DWARFDIE::children() const {
DWARFDIE::child_iterator DWARFDIE::begin() const {
return child_iterator(*this);
}
-DWARFDIE::child_iterator DWARFDIE::end() const {
- return child_iterator();
-}
+DWARFDIE::child_iterator DWARFDIE::end() const { return child_iterator(); }
std::optional<DWARFFormValue> DWARFDIE::find(const dw_attr_t attr) const {
DWARFFormValue form_value;
if (m_die->GetAttributeValue(m_cu, attr, form_value, nullptr, false))
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
index 42a9b9e8e7..c4e2db2407 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
@@ -118,15 +118,16 @@ protected:
ValueType m_value; // Contains all data for the form
};
-inline const char* toString(DWARFFormValue Value, const char* Default) {
- if (const char* R = Value.AsCString())
+inline const char *toString(DWARFFormValue Value, const char *Default) {
+ if (const char *R = Value.AsCString())
return R;
return Default;
}
-inline const char* toString(std::optional<DWARFFormValue> Value, const char* Default) {
+inline const char *toString(std::optional<DWARFFormValue> Value,
+ const char *Default) {
if (!Value)
return Default;
- if (const char* R = Value->AsCString())
+ if (const char *R = Value->AsCString())
return R;
return Default;
}
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
index abc0ab8e27..cadc47caf1 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
@@ -82,11 +82,14 @@ void DWARFTypePrinter<DieType>::appendArrayType(const DieType &D) {
std::optional<uint64_t> Count;
std::optional<uint64_t> UB;
std::optional<unsigned> DefaultLB;
- if (std::optional<typename DieType::DWARFFormValue> L = C.find(dwarf::DW_AT_lower_bound))
+ if (std::optional<typename DieType::DWARFFormValue> L =
+ C.find(dwarf::DW_AT_lower_bound))
LB = L->getAsUnsignedConstant();
- if (std::optional<typename DieType::DWARFFormValue> CountV = C.find(dwarf::DW_AT_count))
+ if (std::optional<typename DieType::DWARFFormValue> CountV =
+ C.find(dwarf::DW_AT_count))
Count = CountV->getAsUnsignedConstant();
- if (std::optional<typename DieType::DWARFFormValue> UpperV = C.find(dwarf::DW_AT_upper_bound))
+ if (std::optional<typename DieType::DWARFFormValue> UpperV =
+ C.find(dwarf::DW_AT_upper_bound))
UB = UpperV->getAsUnsignedConstant();
/*
if (std::optional<typename DieType::DWARFFormValue> LV =
@@ -124,10 +127,11 @@ void DWARFTypePrinter<DieType>::appendArrayType(const DieType &D) {
}
namespace detail {
-template<typename DieType>
+template <typename DieType>
DieType resolveReferencedType(DieType D,
- dwarf::Attribute Attr = dwarf::DW_AT_type) {
- return D.getAttributeValueAsReferencedDie(Attr); // .resolveTypeUnitReference();
+ dwarf::Attribute Attr = dwarf::DW_AT_type) {
+ return D.getAttributeValueAsReferencedDie(
+ Attr); // .resolveTypeUnitReference();
}
template <typename DieType>
DieType resolveReferencedType(DieType D, typename DieType::DWARFFormValue F) {
@@ -204,7 +208,8 @@ DieType DWARFTypePrinter<DieType>::appendUnqualifiedNameBefore(
OS << '(';
else if (Word)
OS << ' ';
- if (DieType Cont = detail::resolveReferencedType(D, dwarf::DW_AT_containing_type)) {
+ if (DieType Cont =
+ detail::resolveReferencedType(D, dwarf::DW_AT_containing_type)) {
appendQualifiedName(Cont);
EndedWithTemplate = false;
OS << "::";
@@ -275,7 +280,8 @@ DieType DWARFTypePrinter<DieType>::appendUnqualifiedNameBefore(
}
template <typename DieType>
-void DWARFTypePrinter<DieType>::appendAndTerminateTemplateParameters(DieType D) {
+void DWARFTypePrinter<DieType>::appendAndTerminateTemplateParameters(
+ DieType D) {
if (!appendTemplateParameters(D))
return;
@@ -354,8 +360,11 @@ void DWARFTypePrinter<DieType>::appendUnqualifiedNameAfter(
llvm::raw_string_ostream PtrauthStream(PtrauthString);
PtrauthStream
<< "__ptrauth(" << getValOrNull(dwarf::DW_AT_LLVM_ptrauth_key) << ", "
- << getValOrNull(dwarf::DW_AT_LLVM_ptrauth_address_discriminated) << ", 0x0"
- << utohexstr(getValOrNull(dwarf::DW_AT_LLVM_ptrauth_extra_discriminator), true)
+ << getValOrNull(dwarf::DW_AT_LLVM_ptrauth_address_discriminated)
+ << ", 0x0"
+ << utohexstr(
+ getValOrNull(dwarf::DW_AT_LLVM_ptrauth_extra_discriminator),
+ true)
<< options << ")";
OS << PtrauthStream.str();
break;
@@ -470,8 +479,8 @@ bool DWARFTypePrinter<DieType>::appendTemplateParameters(DieType D,
} else if (Name == "char" ||
(IsQualifiedChar =
(Name == "unsigned char" || Name == "signed char"))) {
- // FIXME: check T's dwarf::DW_AT_type to see if it's signed or not (since
- // char signedness is implementation defined).
+ // FIXME: check T's dwarf::DW_AT_type to see if it's signed or not
+ // (since char signedness is implementation defined).
auto Val = *V->getAsSignedConstant();
// Copied/hacked up from Clang's CharacterLiteral::print - incomplete
// (doesn't actually support different character types/widths, sign
@@ -573,8 +582,8 @@ void DWARFTypePrinter<DieType>::appendConstVolatileQualifierAfter(DieType N) {
DieType T;
decomposeConstVolatile(N, T, C, V);
if (T && T.getTag() == dwarf::DW_TAG_subroutine_type)
- appendSubroutineNameAfter(T, detail::resolveReferencedType(T), false, C.isValid(),
- V.isValid());
+ appendSubroutineNameAfter(T, detail::resolveReferencedType(T), false,
+ C.isValid(), V.isValid());
else
appendUnqualifiedNameAfter(T, detail::resolveReferencedType(T));
}
@@ -632,7 +641,8 @@ void DWARFTypePrinter<DieType>::appendSubroutineNameAfter(
P.getTag() != dwarf::DW_TAG_unspecified_parameters)
return;
DieType T = detail::resolveReferencedType(P);
- if (SkipFirstParamIfArtificial && RealFirst && P.find(dwarf::DW_AT_artificial)) {
+ if (SkipFirstParamIfArtificial && RealFirst &&
+ P.find(dwarf::DW_AT_artificial)) {
FirstParamIfArtificial = T;
RealFirst = false;
continue;
@@ -752,7 +762,7 @@ void DWARFTypePrinter<DieType>::appendScopes(DieType D) {
return;
if (D.getTag() == dwarf::DW_TAG_lexical_block)
return;
- //D = D.resolveTypeUnitReference();
+ // D = D.resolveTypeUnitReference();
if (DieType P = D.getParent())
appendScopes(P);
appendUnqualifiedName(D);
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.