[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/95738 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
@@ -0,0 +1,165 @@ +(* LLDB Debug Expressions, a subset of C++ *) +(* Insired by https://www.nongnu.org/hcb *) + +expression = assignment_expression ; + +assignment_expression = conditional_expression +logical_or_expression assignment_operator assignment_expression ; + +assignment_operator = "=" +| "*=" +| "/=" +| "%=" +| "+=" +| "-=" +| ">>=" +| "<<=" +| "&=" +| "^=" +| "|=" ; + +conditional_expression = logical_or_expression + | logical_or_expression "?" expression ":" assignment_expression ; + +logical_or_expression = logical_and_expression {"||" logical_and_expression} ; + +logical_and_expression = inclusive_or_expression {"&&" inclusive_or_expression} ; + +inclusive_or_expression = exclusive_or_expression {"|" exclusive_or_expression} ; + +exclusive_or_expression = and_expression {"^" and_expression} ; + +and_expression = equality_expression {"&" equality_expression} ; + +equality_expression = relational_expression {"==" relational_expression} +| relational_expression {"!=" relational_expression} ; + +relational_expression = shift_expression {"<" shift_expression} + | shift_expression {">" shift_expression} + | shift_expression {"<=" shift_expression} + | shift_expression {">=" shift_expression} ; + +shift_expression = additive_expression {"<<" additive_expression} + | additive_expression {">>" additive_expression} ; + +additive_expression = multiplicative_expression {"+" multiplicative_expression} +| multiplicative_expression {"-" multiplicative_expression} ; + +multiplicative_expression = cast_expression {"*" cast_expression} + | cast_expression {"/" cast_expression} + | cast_expression {"%" cast_expression} ; + +cast_expression = unary_expression +| "(" type_id ")" cast_expression ; + +unary_expression = postfix_expression Michael137 wrote: Do we really want to allow state-changing expressions in the `frame var` language? https://github.com/llvm/llvm-project/pull/95738 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
https://github.com/Michael137 commented: Haven't gone through this in detail yet (having an example of how these structures will be used would be helpful), but something I was curious about is whether this `DIL` is going to be used in the implementation of a new command, or if we're going to extend the `frame var` language? I didn't see a concrete conclusion on this in the RFC https://github.com/llvm/llvm-project/pull/95738 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
@@ -0,0 +1,165 @@ +(* LLDB Debug Expressions, a subset of C++ *) +(* Insired by https://www.nongnu.org/hcb *) + +expression = assignment_expression ; + +assignment_expression = conditional_expression +logical_or_expression assignment_operator assignment_expression ; + +assignment_operator = "=" +| "*=" +| "/=" +| "%=" +| "+=" +| "-=" +| ">>=" +| "<<=" +| "&=" +| "^=" +| "|=" ; + +conditional_expression = logical_or_expression + | logical_or_expression "?" expression ":" assignment_expression ; + +logical_or_expression = logical_and_expression {"||" logical_and_expression} ; + +logical_and_expression = inclusive_or_expression {"&&" inclusive_or_expression} ; + +inclusive_or_expression = exclusive_or_expression {"|" exclusive_or_expression} ; + +exclusive_or_expression = and_expression {"^" and_expression} ; + +and_expression = equality_expression {"&" equality_expression} ; + +equality_expression = relational_expression {"==" relational_expression} +| relational_expression {"!=" relational_expression} ; + +relational_expression = shift_expression {"<" shift_expression} + | shift_expression {">" shift_expression} + | shift_expression {"<=" shift_expression} + | shift_expression {">=" shift_expression} ; + +shift_expression = additive_expression {"<<" additive_expression} + | additive_expression {">>" additive_expression} ; + +additive_expression = multiplicative_expression {"+" multiplicative_expression} +| multiplicative_expression {"-" multiplicative_expression} ; + +multiplicative_expression = cast_expression {"*" cast_expression} + | cast_expression {"/" cast_expression} + | cast_expression {"%" cast_expression} ; + +cast_expression = unary_expression +| "(" type_id ")" cast_expression ; + +unary_expression = postfix_expression + | "++" cast_expression + | "--" cast_expression + | unary_operator cast_expression + | "sizeof" unary_expression + | "sizeof" "(" type_id ")" ; + +unary_operator = "*" | "&" | "+" | "-" | "!" | "~" ; + +postfix_expression = primary_expression + | postfix_expression "[" expression "]" + | postfix_expression "." id_expression + | postfix_expression "->" id_expression + | postfix_expression "++" + | postfix_expression "--" + | static_cast "<" type_id ">" "(" expression ")" + | dynamic_cast "<" type_id ">" "(" expression ")" + | reinterpret_cast "<" type_id ">" "(" expression ")" ; + +primary_expression = numeric_literal + | boolean_literal + | pointer_literal + | id_expression + | "this" + | "(" expression ")" + | builtin_func ; + +type_id = type_specifier_seq [abstract_declarator] ; + +type_specifier_seq = type_specifier [type_specifier_seq] ; + +type_specifier = simple_type_specifier + | cv_qualifier ; + +simple_type_specifier = ["::"] [nested_name_specifier] type_name + | "char" + | "char16_t" + | "char32_t" + | "wchar_t" + | "bool" + | "short" + | "int" + | "long" + | "signed" + | "unsigned" + | "float" + | "double" + | "void" ; + +nested_name_specifier = type_name "::" + | namespace_name '::' + | nested_name_specifier identifier "::" + | nested_name_specifier simple_template_id "::"; + +type_name = class_name + | enum_name + | typedef_name + | simple_template_id ; + +class_name = identifier ; + +enum_name = identifier ; + +typedef_name = identifier ; + +simple_template_id = template_name "<" [template_argument_list] ">" ; + +template_name = identifier ; + +template_argument_list = template_argument + | template_argument_list "," template_argument ; + +template_argument = type_id + | numeric_literal + | id_expression ; + +namespace_name = identifier ; + +cv_qualifier = "const" | "volatile" ; + +cv_qualifier_seq = cv_qualifier [cv_qualifier_seq] ; + +abstract_declarator = ptr_operator [abstract_declarator] ; + +ptr_operator = "*" [cv_qualifier_seq] + | "&" ; + +id_express
[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
@@ -0,0 +1,165 @@ +(* LLDB Debug Expressions, a subset of C++ *) +(* Insired by https://www.nongnu.org/hcb *) + +expression = assignment_expression ; + +assignment_expression = conditional_expression +logical_or_expression assignment_operator assignment_expression ; + +assignment_operator = "=" +| "*=" +| "/=" +| "%=" +| "+=" +| "-=" +| ">>=" +| "<<=" +| "&=" +| "^=" +| "|=" ; + +conditional_expression = logical_or_expression + | logical_or_expression "?" expression ":" assignment_expression ; + +logical_or_expression = logical_and_expression {"||" logical_and_expression} ; + +logical_and_expression = inclusive_or_expression {"&&" inclusive_or_expression} ; + +inclusive_or_expression = exclusive_or_expression {"|" exclusive_or_expression} ; + +exclusive_or_expression = and_expression {"^" and_expression} ; + +and_expression = equality_expression {"&" equality_expression} ; + +equality_expression = relational_expression {"==" relational_expression} +| relational_expression {"!=" relational_expression} ; + +relational_expression = shift_expression {"<" shift_expression} + | shift_expression {">" shift_expression} + | shift_expression {"<=" shift_expression} + | shift_expression {">=" shift_expression} ; + +shift_expression = additive_expression {"<<" additive_expression} + | additive_expression {">>" additive_expression} ; + +additive_expression = multiplicative_expression {"+" multiplicative_expression} +| multiplicative_expression {"-" multiplicative_expression} ; + +multiplicative_expression = cast_expression {"*" cast_expression} + | cast_expression {"/" cast_expression} + | cast_expression {"%" cast_expression} ; + +cast_expression = unary_expression +| "(" type_id ")" cast_expression ; + +unary_expression = postfix_expression + | "++" cast_expression + | "--" cast_expression + | unary_operator cast_expression + | "sizeof" unary_expression + | "sizeof" "(" type_id ")" ; + +unary_operator = "*" | "&" | "+" | "-" | "!" | "~" ; + +postfix_expression = primary_expression + | postfix_expression "[" expression "]" + | postfix_expression "." id_expression + | postfix_expression "->" id_expression + | postfix_expression "++" + | postfix_expression "--" + | static_cast "<" type_id ">" "(" expression ")" + | dynamic_cast "<" type_id ">" "(" expression ")" + | reinterpret_cast "<" type_id ">" "(" expression ")" ; + +primary_expression = numeric_literal + | boolean_literal + | pointer_literal + | id_expression + | "this" + | "(" expression ")" + | builtin_func ; + +type_id = type_specifier_seq [abstract_declarator] ; + +type_specifier_seq = type_specifier [type_specifier_seq] ; + +type_specifier = simple_type_specifier + | cv_qualifier ; + +simple_type_specifier = ["::"] [nested_name_specifier] type_name + | "char" + | "char16_t" + | "char32_t" + | "wchar_t" + | "bool" + | "short" + | "int" + | "long" + | "signed" + | "unsigned" + | "float" + | "double" + | "void" ; + +nested_name_specifier = type_name "::" + | namespace_name '::' + | nested_name_specifier identifier "::" + | nested_name_specifier simple_template_id "::"; + +type_name = class_name + | enum_name + | typedef_name + | simple_template_id ; + +class_name = identifier ; + +enum_name = identifier ; + +typedef_name = identifier ; + +simple_template_id = template_name "<" [template_argument_list] ">" ; Michael137 wrote: Also how will this be implemented? I guess the simple-template-names infrastructure could help here? AFAIU in the expression evaluator templates would ideally be supported by either using modules or extending DWARF in a way that allows us to construct more faithful ASTs. https://github.com/llvm/llvm-project/pull/95738 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
@@ -0,0 +1,165 @@ +(* LLDB Debug Expressions, a subset of C++ *) +(* Insired by https://www.nongnu.org/hcb *) + +expression = assignment_expression ; + +assignment_expression = conditional_expression +logical_or_expression assignment_operator assignment_expression ; + +assignment_operator = "=" +| "*=" +| "/=" +| "%=" +| "+=" +| "-=" +| ">>=" +| "<<=" +| "&=" +| "^=" +| "|=" ; + +conditional_expression = logical_or_expression + | logical_or_expression "?" expression ":" assignment_expression ; + +logical_or_expression = logical_and_expression {"||" logical_and_expression} ; + +logical_and_expression = inclusive_or_expression {"&&" inclusive_or_expression} ; + +inclusive_or_expression = exclusive_or_expression {"|" exclusive_or_expression} ; + +exclusive_or_expression = and_expression {"^" and_expression} ; + +and_expression = equality_expression {"&" equality_expression} ; + +equality_expression = relational_expression {"==" relational_expression} +| relational_expression {"!=" relational_expression} ; + +relational_expression = shift_expression {"<" shift_expression} + | shift_expression {">" shift_expression} + | shift_expression {"<=" shift_expression} + | shift_expression {">=" shift_expression} ; + +shift_expression = additive_expression {"<<" additive_expression} + | additive_expression {">>" additive_expression} ; + +additive_expression = multiplicative_expression {"+" multiplicative_expression} +| multiplicative_expression {"-" multiplicative_expression} ; + +multiplicative_expression = cast_expression {"*" cast_expression} + | cast_expression {"/" cast_expression} + | cast_expression {"%" cast_expression} ; + +cast_expression = unary_expression +| "(" type_id ")" cast_expression ; + +unary_expression = postfix_expression + | "++" cast_expression + | "--" cast_expression + | unary_operator cast_expression + | "sizeof" unary_expression + | "sizeof" "(" type_id ")" ; + +unary_operator = "*" | "&" | "+" | "-" | "!" | "~" ; + +postfix_expression = primary_expression + | postfix_expression "[" expression "]" + | postfix_expression "." id_expression + | postfix_expression "->" id_expression + | postfix_expression "++" + | postfix_expression "--" + | static_cast "<" type_id ">" "(" expression ")" + | dynamic_cast "<" type_id ">" "(" expression ")" + | reinterpret_cast "<" type_id ">" "(" expression ")" ; + +primary_expression = numeric_literal + | boolean_literal + | pointer_literal + | id_expression + | "this" + | "(" expression ")" + | builtin_func ; + +type_id = type_specifier_seq [abstract_declarator] ; + +type_specifier_seq = type_specifier [type_specifier_seq] ; + +type_specifier = simple_type_specifier + | cv_qualifier ; + +simple_type_specifier = ["::"] [nested_name_specifier] type_name + | "char" + | "char16_t" + | "char32_t" + | "wchar_t" + | "bool" + | "short" + | "int" + | "long" + | "signed" + | "unsigned" + | "float" + | "double" + | "void" ; + +nested_name_specifier = type_name "::" + | namespace_name '::' + | nested_name_specifier identifier "::" + | nested_name_specifier simple_template_id "::"; + +type_name = class_name + | enum_name + | typedef_name + | simple_template_id ; + +class_name = identifier ; + +enum_name = identifier ; + +typedef_name = identifier ; + +simple_template_id = template_name "<" [template_argument_list] ">" ; Michael137 wrote: Curious what the use-case for instantiating templates is in the DIL. I guess referencing static data members of different instantiations? https://github.com/llvm/llvm-project/pull/95738 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
@@ -0,0 +1,165 @@ +(* LLDB Debug Expressions, a subset of C++ *) +(* Insired by https://www.nongnu.org/hcb *) + +expression = assignment_expression ; + +assignment_expression = conditional_expression +logical_or_expression assignment_operator assignment_expression ; + +assignment_operator = "=" +| "*=" +| "/=" +| "%=" +| "+=" +| "-=" +| ">>=" +| "<<=" +| "&=" +| "^=" +| "|=" ; + +conditional_expression = logical_or_expression + | logical_or_expression "?" expression ":" assignment_expression ; + +logical_or_expression = logical_and_expression {"||" logical_and_expression} ; + +logical_and_expression = inclusive_or_expression {"&&" inclusive_or_expression} ; + +inclusive_or_expression = exclusive_or_expression {"|" exclusive_or_expression} ; + +exclusive_or_expression = and_expression {"^" and_expression} ; + +and_expression = equality_expression {"&" equality_expression} ; + +equality_expression = relational_expression {"==" relational_expression} +| relational_expression {"!=" relational_expression} ; + +relational_expression = shift_expression {"<" shift_expression} + | shift_expression {">" shift_expression} + | shift_expression {"<=" shift_expression} + | shift_expression {">=" shift_expression} ; + +shift_expression = additive_expression {"<<" additive_expression} + | additive_expression {">>" additive_expression} ; + +additive_expression = multiplicative_expression {"+" multiplicative_expression} +| multiplicative_expression {"-" multiplicative_expression} ; + +multiplicative_expression = cast_expression {"*" cast_expression} + | cast_expression {"/" cast_expression} + | cast_expression {"%" cast_expression} ; + +cast_expression = unary_expression +| "(" type_id ")" cast_expression ; + +unary_expression = postfix_expression + | "++" cast_expression + | "--" cast_expression + | unary_operator cast_expression + | "sizeof" unary_expression + | "sizeof" "(" type_id ")" ; + +unary_operator = "*" | "&" | "+" | "-" | "!" | "~" ; + +postfix_expression = primary_expression + | postfix_expression "[" expression "]" + | postfix_expression "." id_expression + | postfix_expression "->" id_expression + | postfix_expression "++" + | postfix_expression "--" + | static_cast "<" type_id ">" "(" expression ")" + | dynamic_cast "<" type_id ">" "(" expression ")" + | reinterpret_cast "<" type_id ">" "(" expression ")" ; Michael137 wrote: Wouldn't `C-style` casts suffice? https://github.com/llvm/llvm-project/pull/95738 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/95738 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/95738 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/DWARF] Optimize DIEToType handling (PR #96308)
https://github.com/Michael137 approved this pull request. Nice, this is much more understandable, thanks! https://github.com/llvm/llvm-project/pull/96308 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)
AlexK0 wrote: > Anyway, tl;dr, I believe this will fix it: > > ``` > --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp > +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp > @@ -442,6 +442,7 @@ void ProcessWindows::RefreshStateAfterStop() { > m_session_data->m_debugger->GetProcess().GetProcessId(), pc, > site->GetID()); > > + stop_thread->SetThreadHitBreakpointAtAddr(pc); >if (site->ValidForThisThread(*stop_thread)) { > LLDB_LOG(log, > "Breakpoint site {0} is valid for this thread ({1:x}), " > ``` > > I'll push it right now. Sorry for my confusion, and thanks again for looking > at it, this was a big help. @jasonmolenda unfortunately, the test still fails :( I did a little investigation, here is a possible patch that fixes the test: ``` diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp index 231b22f5f189..fb0404f1c4b9 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp @@ -382,7 +382,7 @@ void ProcessWindows::RefreshStateAfterStop() { RegisterContextSP register_context = stop_thread->GetRegisterContext(); const uint64_t pc = register_context->GetPC(); BreakpointSiteSP site(GetBreakpointSiteList().FindByAddress(pc)); -if (site) +if (site && site->ValidForThisThread(*stop_thread)) stop_thread->SetThreadStoppedAtBreakpointSite(pc); auto *reg_ctx = static_cast( stop_thread->GetRegisterContext().get()); ``` https://github.com/llvm/llvm-project/pull/96260 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 41a4db1 - [lldb/DWARF] Optimize DIEToType handling (#96308)
Author: Pavel Labath Date: 2024-06-24T13:35:16+02:00 New Revision: 41a4db1ba6591169069dd2352e00364d9113fbeb URL: https://github.com/llvm/llvm-project/commit/41a4db1ba6591169069dd2352e00364d9113fbeb DIFF: https://github.com/llvm/llvm-project/commit/41a4db1ba6591169069dd2352e00364d9113fbeb.diff LOG: [lldb/DWARF] Optimize DIEToType handling (#96308) - move type insertion from individual parse methods into ParseTypeFromDWARF - optimize sentinel (TYPE_IS_BEING_PARSED) insertion to avoid double map lookup - as this requires the map to not have nullptr values, I've replaced all `operator[]` queries with calls to `lookup`. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index ae3eaf88ff4a8..52f4d765cbbd4 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -223,7 +223,6 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc, nullptr, LLDB_INVALID_UID, Type::eEncodingInvalid, &pcm_type_sp->GetDeclaration(), type, Type::ResolveState::Forward, TypePayloadClang(GetOwningClangModule(die))); - dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); clang::TagDecl *tag_decl = TypeSystemClang::GetAsTagDecl(type); if (tag_decl) { LinkDeclContextToDIE(tag_decl, die); @@ -458,90 +457,78 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc, DW_TAG_value_to_name(die.Tag()), die.Tag(), die.GetName()); } - Type *type_ptr = dwarf->GetDIEToType().lookup(die.GetDIE()); - if (type_ptr == DIE_IS_BEING_PARSED) -return nullptr; - if (type_ptr) -return type_ptr->shared_from_this(); // Set a bit that lets us know that we are currently parsing this - dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED; + if (auto [it, inserted] = + dwarf->GetDIEToType().try_emplace(die.GetDIE(), DIE_IS_BEING_PARSED); + !inserted) { +if (it->getSecond() == nullptr || it->getSecond() == DIE_IS_BEING_PARSED) + return nullptr; +return it->getSecond()->shared_from_this(); + } ParsedDWARFTypeAttributes attrs(die); + TypeSP type_sp; if (DWARFDIE signature_die = attrs.signature.Reference()) { -if (TypeSP type_sp = -ParseTypeFromDWARF(sc, signature_die, type_is_new_ptr)) { - dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); +type_sp = ParseTypeFromDWARF(sc, signature_die, type_is_new_ptr); +if (type_sp) { if (clang::DeclContext *decl_ctx = GetCachedClangDeclContextForDIE(signature_die)) LinkDeclContextToDIE(decl_ctx, die); - return type_sp; } -return nullptr; - } - - if (type_is_new_ptr) -*type_is_new_ptr = true; - - const dw_tag_t tag = die.Tag(); - - TypeSP type_sp; - - switch (tag) { - case DW_TAG_typedef: - case DW_TAG_base_type: - case DW_TAG_pointer_type: - case DW_TAG_reference_type: - case DW_TAG_rvalue_reference_type: - case DW_TAG_const_type: - case DW_TAG_restrict_type: - case DW_TAG_volatile_type: - case DW_TAG_LLVM_ptrauth_type: - case DW_TAG_atomic_type: - case DW_TAG_unspecified_type: { -type_sp = ParseTypeModifier(sc, die, attrs); -break; - } - - case DW_TAG_structure_type: - case DW_TAG_union_type: - case DW_TAG_class_type: { -type_sp = ParseStructureLikeDIE(sc, die, attrs); -break; - } + } else { +if (type_is_new_ptr) + *type_is_new_ptr = true; - case DW_TAG_enumeration_type: { -type_sp = ParseEnum(sc, die, attrs); -break; - } +const dw_tag_t tag = die.Tag(); - case DW_TAG_inlined_subroutine: - case DW_TAG_subprogram: - case DW_TAG_subroutine_type: { -type_sp = ParseSubroutine(die, attrs); -break; - } - case DW_TAG_array_type: { -type_sp = ParseArrayType(die, attrs); -break; - } - case DW_TAG_ptr_to_member_type: { -type_sp = ParsePointerToMemberType(die, attrs); -break; +switch (tag) { +case DW_TAG_typedef: +case DW_TAG_base_type: +case DW_TAG_pointer_type: +case DW_TAG_reference_type: +case DW_TAG_rvalue_reference_type: +case DW_TAG_const_type: +case DW_TAG_restrict_type: +case DW_TAG_volatile_type: +case DW_TAG_LLVM_ptrauth_type: +case DW_TAG_atomic_type: +case DW_TAG_unspecified_type: + type_sp = ParseTypeModifier(sc, die, attrs); + break; +case DW_TAG_structure_type: +case DW_TAG_union_type: +case DW_TAG_class_type: + type_sp = ParseStructureLikeDIE(sc, die, attrs); + break; +case DW_TAG_enumeration_type: + type_sp = ParseEnum(sc, die, attrs); + break; +case DW_TAG_inlined_subroutine: +case DW_TAG_subprogram: +case DW_TAG_subroutine_type: +
[Lldb-commits] [lldb] [lldb/DWARF] Optimize DIEToType handling (PR #96308)
https://github.com/labath closed https://github.com/llvm/llvm-project/pull/96308 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] c053ec9 - [lldb] Fix TestDAP_runInTerminal for #96256
Author: Pavel Labath Date: 2024-06-24T14:16:24+02:00 New Revision: c053ec95f7e66ff212c8a867426cc7275a4dace6 URL: https://github.com/llvm/llvm-project/commit/c053ec95f7e66ff212c8a867426cc7275a4dace6 DIFF: https://github.com/llvm/llvm-project/commit/c053ec95f7e66ff212c8a867426cc7275a4dace6.diff LOG: [lldb] Fix TestDAP_runInTerminal for #96256 change the expected error msg. Added: Modified: lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py Removed: diff --git a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py index 9fcd210122d54..b214b512c0de3 100644 --- a/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py +++ b/lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py @@ -105,7 +105,7 @@ def test_runInTerminalInvalidTarget(self): ) self.assertFalse(response["success"]) self.assertIn( -"Could not create a target for a program 'INVALIDPROGRAM': unable to find executable", +"Could not create a target for a program 'INVALIDPROGRAM': 'INVALIDPROGRAM' does not exist", response["message"], ) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/DWARF] Remove parsing recursion when searching for definition DIEs (PR #96484)
https://github.com/labath created https://github.com/llvm/llvm-project/pull/96484 If ParseStructureLikeDIE (or ParseEnum) encountered a declaration DIE, it would call FindDefinitionTypeForDIE. This returned a fully formed type, which it achieved by recursing back into ParseStructureLikeDIE with the definition DIE. This obscured the control flow and caused us to repeat some work (e.g. the UniqueDWARFASTTypeMap lookup), but it mostly worked until we tried to delay the definition search in #90663. After this patch, the two ParseStructureLikeDIE calls were no longer recursive, but rather the second call happened as a part of the CompleteType() call. This opened the door to inconsistencies, as the second ParseStructureLikeDIE call was not aware it was called to process a definition die for an existing type. To make that possible, this patch removes the recusive type resolution from this function, and leaves just the "find definition die" functionality. After finding the definition DIE, we just go back to the original ParseStructureLikeDIE call, and have it finish the parsing process with the new DIE. While this patch is motivated by the work on delaying the definition searching, I believe it is also useful on its own. >From 52db8db036c24264647340c15ec4ee6d3553cf60 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 24 Jun 2024 11:17:47 +0200 Subject: [PATCH] [lldb/DWARF] Remove parsing recursion when searching for definition DIEs If ParseStructureLikeDIE (or ParseEnum) encountered a declaration DIE, it would call FindDefinitionTypeForDIE. This returned a fully formed type, which it achieved by recursing back into ParseStructureLikeDIE with the definition DIE. This obscured the control flow and caused us to repeat some work (e.g. the UniqueDWARFASTTypeMap lookup), but it mostly worked until we tried to delay the definition search in #90663. After this patch, the two ParseStructureLikeDIE calls were no longer recursive, but rather the second call happened as a part of the CompleteType() call. This opened the door to inconsistencies, as the second ParseStructureLikeDIE call was not aware it was called to process a definition die for an existing type. To make that possible, this patch removes the recusive type resolution from this function, and leaves just the "find definition die" functionality. After finding the definition DIE, we just go back to the original ParseStructureLikeDIE call, and have it finish the parsing process with the new DIE. While this patch is motivated by the work on delaying the definition searching, I believe it is also useful on its own. --- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 210 +- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 187 .../SymbolFile/DWARF/SymbolFileDWARF.h| 3 +- .../DWARF/SymbolFileDWARFDebugMap.cpp | 11 +- .../DWARF/SymbolFileDWARFDebugMap.h | 2 +- .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp | 5 +- .../SymbolFile/DWARF/SymbolFileDWARFDwo.h | 3 +- 7 files changed, 208 insertions(+), 213 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 52f4d765cbbd4..ad58e0cbb5a59 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -39,10 +39,12 @@ #include "lldb/Utility/StreamString.h" #include "clang/AST/CXXInheritance.h" +#include "clang/AST/DeclBase.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/Type.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/Demangle/Demangle.h" #include @@ -835,54 +837,50 @@ DWARFASTParserClang::GetDIEClassTemplateParams(const DWARFDIE &die) { } TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc, - const DWARFDIE &die, + const DWARFDIE &decl_die, ParsedDWARFTypeAttributes &attrs) { Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups); - SymbolFileDWARF *dwarf = die.GetDWARF(); - const dw_tag_t tag = die.Tag(); - TypeSP type_sp; + SymbolFileDWARF *dwarf = decl_die.GetDWARF(); + const dw_tag_t tag = decl_die.Tag(); + DWARFDIE def_die; if (attrs.is_forward_declaration) { -type_sp = ParseTypeFromClangModule(sc, die, log); -if (type_sp) +if (TypeSP type_sp = ParseTypeFromClangModule(sc, decl_die, log)) return type_sp; -type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die); +def_die = dwarf->FindDefinitionDIE(decl_die); -if (!type_sp) { +if (!def_die) { SymbolFileDWARFDebugMap *debug_map_symfile = dwarf->GetDebugMapSymfile(); if (debug_map_symfile) { // We weren't able to find a full declaration in this DWARF, // see if we have a dec
[Lldb-commits] [lldb] [lldb/DWARF] Remove parsing recursion when searching for definition DIEs (PR #96484)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Pavel Labath (labath) Changes If ParseStructureLikeDIE (or ParseEnum) encountered a declaration DIE, it would call FindDefinitionTypeForDIE. This returned a fully formed type, which it achieved by recursing back into ParseStructureLikeDIE with the definition DIE. This obscured the control flow and caused us to repeat some work (e.g. the UniqueDWARFASTTypeMap lookup), but it mostly worked until we tried to delay the definition search in #90663. After this patch, the two ParseStructureLikeDIE calls were no longer recursive, but rather the second call happened as a part of the CompleteType() call. This opened the door to inconsistencies, as the second ParseStructureLikeDIE call was not aware it was called to process a definition die for an existing type. To make that possible, this patch removes the recusive type resolution from this function, and leaves just the "find definition die" functionality. After finding the definition DIE, we just go back to the original ParseStructureLikeDIE call, and have it finish the parsing process with the new DIE. While this patch is motivated by the work on delaying the definition searching, I believe it is also useful on its own. --- Patch is 32.26 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/96484.diff 7 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+107-103) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+91-96) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (+1-2) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (+5-6) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (+1-1) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp (+2-3) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h (+1-2) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 52f4d765cbbd4..ad58e0cbb5a59 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -39,10 +39,12 @@ #include "lldb/Utility/StreamString.h" #include "clang/AST/CXXInheritance.h" +#include "clang/AST/DeclBase.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/Type.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/Demangle/Demangle.h" #include @@ -835,54 +837,50 @@ DWARFASTParserClang::GetDIEClassTemplateParams(const DWARFDIE &die) { } TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc, - const DWARFDIE &die, + const DWARFDIE &decl_die, ParsedDWARFTypeAttributes &attrs) { Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups); - SymbolFileDWARF *dwarf = die.GetDWARF(); - const dw_tag_t tag = die.Tag(); - TypeSP type_sp; + SymbolFileDWARF *dwarf = decl_die.GetDWARF(); + const dw_tag_t tag = decl_die.Tag(); + DWARFDIE def_die; if (attrs.is_forward_declaration) { -type_sp = ParseTypeFromClangModule(sc, die, log); -if (type_sp) +if (TypeSP type_sp = ParseTypeFromClangModule(sc, decl_die, log)) return type_sp; -type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die); +def_die = dwarf->FindDefinitionDIE(decl_die); -if (!type_sp) { +if (!def_die) { SymbolFileDWARFDebugMap *debug_map_symfile = dwarf->GetDebugMapSymfile(); if (debug_map_symfile) { // We weren't able to find a full declaration in this DWARF, // see if we have a declaration anywhere else... -type_sp = debug_map_symfile->FindDefinitionTypeForDWARFDeclContext(die); +def_die = debug_map_symfile->FindDefinitionDIE(decl_die); } } -if (type_sp) { - if (log) { -dwarf->GetObjectFile()->GetModule()->LogMessage( -log, -"SymbolFileDWARF({0:p}) - {1:x16}}: {2} ({3}) type \"{4}\" is a " -"forward declaration, complete type is {5:x8}", -static_cast(this), die.GetOffset(), -DW_TAG_value_to_name(tag), tag, attrs.name.GetCString(), -type_sp->GetID()); - } - - // We found a real definition for this type elsewhere so must link its - // DeclContext to this die. - if (clang::DeclContext *defn_decl_ctx = - GetCachedClangDeclContextForDIE(dwarf->GetDIE(type_sp->GetID( -LinkDeclContextToDIE(defn_decl_ctx, die); - return type_sp; +if (log) { + dwarf->GetObjectFile()->GetModule()->LogMessage( + log, + "SymbolFileDWARF({0:p}) - {1:x16}}: {2} ({3}) type \"{4}\" is a " + "forward declarat
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)
labath wrote: Hi there. Nice to see interest in this patch. Zequan has been OOO for the past couple of weeks, so I've sort of taken this up in the mean time. The problem with the simplified template names is actually already fixed (by #95905), but in the mean time, I've discovered a very similar problem with type units (basically, just take the test case from #95905, but build it with -fdebug-types-section instead). While this could (and should) be fixed in similar way, this led me to believe that the overall approach in this patch was too fragile. When completing a type, it basically does something like: - look up the (declaration) die for the type being completed (using the `ForwardDeclCompilerTypeToDIE` map) - look up the definition die (using the dwarf index) - look up the type for the definition die (using the UniqueDWARFASTTypeMap) The last step, besides being completely unnecessary (we already know the type we're supposed to complete), is also a big liability, because here we are implicitly relying on the the map to return the same type that we started with. If it does not then we will end up creating a new type instead of completing the existing one, and things will quickly go sideways. The meeting that David alluded to is tomorrow, and I hope we're going to try to figure out who's going to do what and in what order. In the mean time, I've added you as a reviewer to one of my pending patches. https://github.com/llvm/llvm-project/pull/92328 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/DWARF] Remove parsing recursion when searching for definition DIEs (PR #96484)
https://github.com/Michael137 approved this pull request. Makes sense to me Do we make sure that the type lookup map is updated so we don't re-parse when calling `ParseTypeFromDWARF` with either the declaration or the definition DIE? https://github.com/llvm/llvm-project/pull/96484 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/DWARF] Remove parsing recursion when searching for definition DIEs (PR #96484)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/96484 >From 52db8db036c24264647340c15ec4ee6d3553cf60 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 24 Jun 2024 11:17:47 +0200 Subject: [PATCH 1/2] [lldb/DWARF] Remove parsing recursion when searching for definition DIEs If ParseStructureLikeDIE (or ParseEnum) encountered a declaration DIE, it would call FindDefinitionTypeForDIE. This returned a fully formed type, which it achieved by recursing back into ParseStructureLikeDIE with the definition DIE. This obscured the control flow and caused us to repeat some work (e.g. the UniqueDWARFASTTypeMap lookup), but it mostly worked until we tried to delay the definition search in #90663. After this patch, the two ParseStructureLikeDIE calls were no longer recursive, but rather the second call happened as a part of the CompleteType() call. This opened the door to inconsistencies, as the second ParseStructureLikeDIE call was not aware it was called to process a definition die for an existing type. To make that possible, this patch removes the recusive type resolution from this function, and leaves just the "find definition die" functionality. After finding the definition DIE, we just go back to the original ParseStructureLikeDIE call, and have it finish the parsing process with the new DIE. While this patch is motivated by the work on delaying the definition searching, I believe it is also useful on its own. --- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 210 +- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 187 .../SymbolFile/DWARF/SymbolFileDWARF.h| 3 +- .../DWARF/SymbolFileDWARFDebugMap.cpp | 11 +- .../DWARF/SymbolFileDWARFDebugMap.h | 2 +- .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp | 5 +- .../SymbolFile/DWARF/SymbolFileDWARFDwo.h | 3 +- 7 files changed, 208 insertions(+), 213 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 52f4d765cbbd4..ad58e0cbb5a59 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -39,10 +39,12 @@ #include "lldb/Utility/StreamString.h" #include "clang/AST/CXXInheritance.h" +#include "clang/AST/DeclBase.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/Type.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/Demangle/Demangle.h" #include @@ -835,54 +837,50 @@ DWARFASTParserClang::GetDIEClassTemplateParams(const DWARFDIE &die) { } TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc, - const DWARFDIE &die, + const DWARFDIE &decl_die, ParsedDWARFTypeAttributes &attrs) { Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups); - SymbolFileDWARF *dwarf = die.GetDWARF(); - const dw_tag_t tag = die.Tag(); - TypeSP type_sp; + SymbolFileDWARF *dwarf = decl_die.GetDWARF(); + const dw_tag_t tag = decl_die.Tag(); + DWARFDIE def_die; if (attrs.is_forward_declaration) { -type_sp = ParseTypeFromClangModule(sc, die, log); -if (type_sp) +if (TypeSP type_sp = ParseTypeFromClangModule(sc, decl_die, log)) return type_sp; -type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die); +def_die = dwarf->FindDefinitionDIE(decl_die); -if (!type_sp) { +if (!def_die) { SymbolFileDWARFDebugMap *debug_map_symfile = dwarf->GetDebugMapSymfile(); if (debug_map_symfile) { // We weren't able to find a full declaration in this DWARF, // see if we have a declaration anywhere else... -type_sp = debug_map_symfile->FindDefinitionTypeForDWARFDeclContext(die); +def_die = debug_map_symfile->FindDefinitionDIE(decl_die); } } -if (type_sp) { - if (log) { -dwarf->GetObjectFile()->GetModule()->LogMessage( -log, -"SymbolFileDWARF({0:p}) - {1:x16}}: {2} ({3}) type \"{4}\" is a " -"forward declaration, complete type is {5:x8}", -static_cast(this), die.GetOffset(), -DW_TAG_value_to_name(tag), tag, attrs.name.GetCString(), -type_sp->GetID()); - } - - // We found a real definition for this type elsewhere so must link its - // DeclContext to this die. - if (clang::DeclContext *defn_decl_ctx = - GetCachedClangDeclContextForDIE(dwarf->GetDIE(type_sp->GetID( -LinkDeclContextToDIE(defn_decl_ctx, die); - return type_sp; +if (log) { + dwarf->GetObjectFile()->GetModule()->LogMessage( + log, + "SymbolFileDWARF({0:p}) - {1:x16}}: {2} ({3}) type \"{4}\" is a " + "forward declaration, complete DIE is {5}", + static_c
[Lldb-commits] [lldb] [lldb/DWARF] Remove parsing recursion when searching for definition DIEs (PR #96484)
labath wrote: > Makes sense to me Do we make sure that the type lookup map is updated so we > don't re-parse when calling `ParseTypeFromDWARF` with either the declaration > or the definition DIE? Good catch. I've been meaning to add that, but I forgot. Things should still work even without the DieToType update, as the type will be caught by the UniqueDWARFASTTypeMap, but this is definitely faster. The way that the definition dies are currently handled is a bit clumsy now, but I didn't want to implement anything more elaborate as this should go away once we stop eagerly searching for the definition. https://github.com/llvm/llvm-project/pull/96484 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/DWARF] Remove parsing recursion when searching for definition DIEs (PR #96484)
Michael137 wrote: Latest update LGTM https://github.com/llvm/llvm-project/pull/96484 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 10bd5ad - [lldb][API] Add Find(Ranges)InMemory() to Process SB API (#95007)
Author: Miro Bucko Date: 2024-06-24T11:06:20-04:00 New Revision: 10bd5ad0a133fe73ffc1b05e63bc3fb2d56ba79c URL: https://github.com/llvm/llvm-project/commit/10bd5ad0a133fe73ffc1b05e63bc3fb2d56ba79c DIFF: https://github.com/llvm/llvm-project/commit/10bd5ad0a133fe73ffc1b05e63bc3fb2d56ba79c.diff LOG: [lldb][API] Add Find(Ranges)InMemory() to Process SB API (#95007) Test Plan: llvm-lit llvm-project/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py llvm-project/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py Reviewers: clayborg Tasks: lldb Added: lldb/test/API/python_api/find_in_memory/Makefile lldb/test/API/python_api/find_in_memory/TestFindInMemory.py lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py lldb/test/API/python_api/find_in_memory/address_ranges_helper.py lldb/test/API/python_api/find_in_memory/main.cpp Modified: lldb/bindings/python/python-typemaps.swig lldb/include/lldb/API/SBProcess.h lldb/include/lldb/Core/AddressRangeListImpl.h lldb/include/lldb/Target/Process.h lldb/source/API/SBProcess.cpp lldb/source/Target/Process.cpp Removed: diff --git a/lldb/bindings/python/python-typemaps.swig b/lldb/bindings/python/python-typemaps.swig index c39594c7df041..f8c33e15c03e6 100644 --- a/lldb/bindings/python/python-typemaps.swig +++ b/lldb/bindings/python/python-typemaps.swig @@ -257,7 +257,8 @@ AND call SWIG_fail at the same time, because it will result in a double free. } // For SBProcess::WriteMemory, SBTarget::GetInstructions and SBDebugger::DispatchInput. %typemap(in) (const void *buf, size_t size), - (const void *data, size_t data_len) { + (const void *data, size_t data_len), + (const void *buf, uint64_t size) { if (PythonString::Check($input)) { PythonString str(PyRefType::Borrowed, $input); $1 = (void *)str.GetString().data(); diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index f1b5d1fb92ce2..a6ab7ae759918 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -209,6 +209,16 @@ class LLDB_API SBProcess { lldb::addr_t ReadPointerFromMemory(addr_t addr, lldb::SBError &error); + lldb::SBAddressRangeList FindRangesInMemory(const void *buf, uint64_t size, + const SBAddressRangeList &ranges, + uint32_t alignment, + uint32_t max_matches, + SBError &error); + + lldb::addr_t FindInMemory(const void *buf, uint64_t size, +const SBAddressRange &range, uint32_t alignment, +SBError &error); + // Events static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event); diff --git a/lldb/include/lldb/Core/AddressRangeListImpl.h b/lldb/include/lldb/Core/AddressRangeListImpl.h index 46ebfe73d4d92..6742e6ead87de 100644 --- a/lldb/include/lldb/Core/AddressRangeListImpl.h +++ b/lldb/include/lldb/Core/AddressRangeListImpl.h @@ -13,7 +13,9 @@ #include namespace lldb { +class SBAddressRangeList; class SBBlock; +class SBProcess; } namespace lldb_private { @@ -39,7 +41,9 @@ class AddressRangeListImpl { lldb_private::AddressRange GetAddressRangeAtIndex(size_t index); private: + friend class lldb::SBAddressRangeList; friend class lldb::SBBlock; + friend class lldb::SBProcess; AddressRanges &ref(); diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index eec337c15f7ed..ceaf547ebddaf 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -2685,6 +2685,15 @@ void PruneThreadPlans(); lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high, const uint8_t *buf, size_t size); + AddressRanges FindRangesInMemory(const uint8_t *buf, uint64_t size, + const AddressRanges &ranges, + size_t alignment, size_t max_matches, + Status &error); + + lldb::addr_t FindInMemory(const uint8_t *buf, uint64_t size, +const AddressRange &range, size_t alignment, +Status &error); + protected: friend class Trace; @@ -2800,6 +2809,11 @@ void PruneThreadPlans(); virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error) = 0; + virtual void DoFindInMemory(lldb::addr_t start_addr, lldb::addr_t end_addr, + const uint8_t *buf, size_t size, + AddressRanges &matches, size_t alignment, + size_t max_matches); + /// DoGetMemoryRegionInfo is call
[Lldb-commits] [lldb] [lldb][API] Add Find(Ranges)InMemory() to Process SB API (PR #95007)
https://github.com/mbucko closed https://github.com/llvm/llvm-project/pull/95007 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -216,6 +228,35 @@ u64 GetShadowCount(uptr p, u32 size) { return count; } +// Accumulates the access count from the shadow for the given pointer and size. +// See memprof_mapping.h for an overview on histogram counters. +u64 GetShadowCountHistogram(uptr p, u32 size) { + u8 *shadow = (u8 *)HISTOGRAM_MEM_TO_SHADOW(p); + u8 *shadow_end = (u8 *)HISTOGRAM_MEM_TO_SHADOW(p + size); + u64 count = 0; + for (; shadow <= shadow_end; shadow++) +count += *shadow; + return count; +} + +// If we use the normal approach from clearCountersWithoutHistogram, the +// histogram will clear too much data and may overwrite shadow counters that are +// in use. Likely because of rounding up the shadow_end pointer. +// See memprof_mapping.h for an overview on histogram counters. +void clearCountersHistogram(uptr addr, uptr size) { + u8 *shadow_8 = (u8 *)HISTOGRAM_MEM_TO_SHADOW(addr); + u8 *shadow_end_8 = (u8 *)HISTOGRAM_MEM_TO_SHADOW(addr + size); + for (; shadow_8 < shadow_end_8; shadow_8++) { mattweingarten wrote: changed. https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -216,6 +228,35 @@ u64 GetShadowCount(uptr p, u32 size) { return count; } +// Accumulates the access count from the shadow for the given pointer and size. +// See memprof_mapping.h for an overview on histogram counters. +u64 GetShadowCountHistogram(uptr p, u32 size) { + u8 *shadow = (u8 *)HISTOGRAM_MEM_TO_SHADOW(p); + u8 *shadow_end = (u8 *)HISTOGRAM_MEM_TO_SHADOW(p + size); + u64 count = 0; + for (; shadow <= shadow_end; shadow++) +count += *shadow; + return count; +} + +// If we use the normal approach from clearCountersWithoutHistogram, the +// histogram will clear too much data and may overwrite shadow counters that are +// in use. Likely because of rounding up the shadow_end pointer. +// See memprof_mapping.h for an overview on histogram counters. +void clearCountersHistogram(uptr addr, uptr size) { + u8 *shadow_8 = (u8 *)HISTOGRAM_MEM_TO_SHADOW(addr); + u8 *shadow_end_8 = (u8 *)HISTOGRAM_MEM_TO_SHADOW(addr + size); + for (; shadow_8 < shadow_end_8; shadow_8++) { +*shadow_8 = 0; + } +} + +void clearCountersWithoutHistogram(uptr addr, uptr size) { + uptr shadow_beg = MEM_TO_SHADOW(addr); + uptr shadow_end = MEM_TO_SHADOW(addr + size - SHADOW_GRANULARITY) + 1; + REAL(memset)((void *)shadow_beg, 0, shadow_end - shadow_beg); +} + // Clears the shadow counters (when memory is allocated). void ClearShadow(uptr addr, uptr size) { mattweingarten wrote: This function uses the MEM_TO_SHADOW computed pointers "kind of", but in reality it just rounds these pointers up to nearest page_sizes. So in effect, full pages should be cleared no matter if it is with histogram or without. https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -38,4 +38,5 @@ MEMPROF_FLAG(bool, allocator_frees_and_returns_null_on_realloc_zero, true, MEMPROF_FLAG(bool, print_text, false, "If set, prints the heap profile in text format. Else use the raw binary serialization format.") MEMPROF_FLAG(bool, print_terse, false, - "If set, prints memory profile in a terse format. Only applicable if print_text = true.") + "If set, prints memory profile in a terse format. Only applicable " mattweingarten wrote: done. https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -205,8 +205,14 @@ class RawMemProfReader final : public MemProfReader { object::SectionedAddress getModuleOffset(uint64_t VirtualAddress); + llvm::SmallVector> + readMemInfoBlocks(const char *Ptr); + // The profiled binary. object::OwningBinary Binary; + // Version of raw memprof binary currently being read. Defaults to most update mattweingarten wrote: done. https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -96,19 +102,63 @@ llvm::SmallVector readSegmentEntries(const char *Ptr) { } llvm::SmallVector> -readMemInfoBlocks(const char *Ptr) { +readMemInfoBlocksV3(const char *Ptr) { using namespace support; const uint64_t NumItemsToRead = - endian::readNext(Ptr); + endian::readNext(Ptr); + llvm::SmallVector> Items; for (uint64_t I = 0; I < NumItemsToRead; I++) { const uint64_t Id = -endian::readNext(Ptr); -const MemInfoBlock MIB = *reinterpret_cast(Ptr); +endian::readNext(Ptr); + +// We cheat a bit here and remove the const from cast to set the +// Histogram Pointer to newly allocated buffer. We also cheat, since V3 and +// V4 do not have the same fields. V3 is missing AccessHistogramSize and +// AccessHistogram. This means we read "dirty" data in here, but it should +// not segfault, since there will be callstack data placed after this in the +// binary format. +MemInfoBlock MIB = *reinterpret_cast(Ptr); +// Overwrite dirty data. mattweingarten wrote: My thought process is that the MemInfoBlock MIB is a allocated on the stack, since its a local variable and not a pointer. Meaning the reinterpret_cast copies the information from the data-buffer into the stack variable. Correct me if I am wrong https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -610,13 +670,33 @@ RawMemProfReader::peekBuildIds(MemoryBuffer *DataBuffer) { return BuildIds.takeVector(); } +// FIXME: Add a schema for serializing similiar to IndexedMemprofReader. This +// will help being able to deserialize different versions raw memprof versions +// more easily. +llvm::SmallVector> +RawMemProfReader::readMemInfoBlocks(const char *Ptr) { + if (MemprofRawVersion == 3ULL) { +errs() << "Reading V3\n"; mattweingarten wrote: done. https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -508,7 +519,26 @@ void createProfileFileNameVar(Module &M) { } } +// Set MemprofHistogramFlag as a Global veriable in IR. This makes it accessible +// to mattweingarten wrote: done. https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -508,7 +519,26 @@ void createProfileFileNameVar(Module &M) { } } +// Set MemprofHistogramFlag as a Global veriable in IR. This makes it accessible +// to +// the runtime, changing shadow count behavior. +void createMemprofHistogramFlagVar(Module &M) { + const StringRef VarName(MemProfHistogramFlagVar); + Type *IntTy1 = Type::getInt1Ty(M.getContext()); + auto MemprofHistogramFlag = new GlobalVariable( + M, IntTy1, true, GlobalValue::WeakAnyLinkage, + Constant::getIntegerValue(IntTy1, APInt(1, ClHistogram)), VarName); + // MemprofHistogramFlag->setVisibility(GlobalValue::HiddenVisibility); mattweingarten wrote: done. https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -0,0 +1,101 @@ +REQUIRES: x86_64-linux + +This is a copy of memprof-basict.test with slight changes to check that we can still read v3 of memprofraw. mattweingarten wrote: done https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -0,0 +1,101 @@ +REQUIRES: x86_64-linux + +This is a copy of memprof-basict.test with slight changes to check that we can still read v3 of memprofraw. + +To update the inputs used below run Inputs/update_memprof_inputs.sh /path/to/updated/clang mattweingarten wrote: yes, good point! done. https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -20,25 +20,25 @@ CHECK-NEXT: - CHECK: Records: CHECK-NEXT: - -CHECK-NEXT:FunctionGUID: 15505678318020221912 +CHECK-NEXT:FunctionGUID: 3873612792189045660 CHECK-NEXT:AllocSites: CHECK-NEXT:- CHECK-NEXT: Callstack: CHECK-NEXT: - -CHECK-NEXT:Function: 15505678318020221912 -CHECK-NEXT:SymbolName: qux +CHECK-NEXT:Function: 3873612792189045660 +CHECK-NEXT:SymbolName: _Z3quxi mattweingarten wrote: good question, I suspect this test has not been regenerated in a long time and something changed in meantime in memprof? I think it might have to do with the SymbolNames being mangled vs demangled, which changes the hash value? Is it a problem that the hash value changed? https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -124,6 +124,13 @@ struct PortableMemInfoBlock { OS << "" << #Name << ": " << Name << "\n"; #include "llvm/ProfileData/MIBEntryDef.inc" #undef MIBEntryDef +if (AccessHistogramSize > 0) { + OS << "" << "AccessHistogramValues" << ":"; + for (uint32_t I = 0; I < AccessHistogramSize; ++I) { +OS << " -" << ((uint64_t *)AccessHistogram)[I]; mattweingarten wrote: I though only having space delimiting did not produce valid yaml, I double checked and was wrong. Changed to space delimiting, thanks! https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/DWARF] Remove parsing recursion when searching for definition DIEs (PR #96484)
dwblaikie wrote: This patch as-is is NFC? (no tests) but without this patch, the other delay-definition-die patch would have had a problem? Is it possible to add a test in this patch that would exercise the thing that would become buggy if the delay-definition-die patch were to be recommitted? https://github.com/llvm/llvm-project/pull/96484 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][API] Add Find(Ranges)InMemory() to Process SB API (PR #95007)
chelcassanova wrote: Hey Miro, looks like this change broke the LLDB MacOS buildbot: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6353/ https://github.com/llvm/llvm-project/pull/95007 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix failing TestFind(Ranges)InMemory.py tests. (PR #96511)
https://github.com/mbucko created https://github.com/llvm/llvm-project/pull/96511 Tests added in #95007. >From 4f5588a6928080833a428fc7e1356a807a333a0e Mon Sep 17 00:00:00 2001 From: Miro Bucko Date: Mon, 24 Jun 2024 09:15:36 -0700 Subject: [PATCH] [lldb] Fix TestFind(Ranges)InMemory.py tests. --- lldb/test/API/python_api/find_in_memory/address_ranges_helper.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py index 0544100f97b29..2c11fba80766f 100644 --- a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py +++ b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py @@ -35,7 +35,6 @@ def GetRangeFromAddrValue(test_base, addr): ) test_base.assertTrue(region.IsReadable()) -test_base.assertFalse(region.IsExecutable()) address_start = lldb.SBAddress(region.GetRegionBase(), test_base.target) stack_size = region.GetRegionEnd() - region.GetRegionBase() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix failing TestFind(Ranges)InMemory.py tests. (PR #96511)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Miro Bucko (mbucko) Changes Tests added in #95007. --- Full diff: https://github.com/llvm/llvm-project/pull/96511.diff 1 Files Affected: - (modified) lldb/test/API/python_api/find_in_memory/address_ranges_helper.py (-1) ``diff diff --git a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py index 0544100f97b29..2c11fba80766f 100644 --- a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py +++ b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py @@ -35,7 +35,6 @@ def GetRangeFromAddrValue(test_base, addr): ) test_base.assertTrue(region.IsReadable()) -test_base.assertFalse(region.IsExecutable()) address_start = lldb.SBAddress(region.GetRegionBase(), test_base.target) stack_size = region.GetRegionEnd() - region.GetRegionBase() `` https://github.com/llvm/llvm-project/pull/96511 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix failing TestFind(Ranges)InMemory.py tests. (PR #96511)
https://github.com/JDevlieghere approved this pull request. Looks like this is to unblock the bots? Is the test actually incorrect or is this a temporary fix while you investigate? Would be nice to mention that in the commit message. https://github.com/llvm/llvm-project/pull/96511 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix failing TestFind(Ranges)InMemory.py tests. (PR #96511)
https://github.com/mbucko edited https://github.com/llvm/llvm-project/pull/96511 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 347206f - Add a unit test for SBBreakpoint::SetCallback (#96001)
Author: Chelsea Cassanova Date: 2024-06-24T09:50:42-07:00 New Revision: 347206f9570446340da6d7dadc13d10b0aac4528 URL: https://github.com/llvm/llvm-project/commit/347206f9570446340da6d7dadc13d10b0aac4528 DIFF: https://github.com/llvm/llvm-project/commit/347206f9570446340da6d7dadc13d10b0aac4528.diff LOG: Add a unit test for SBBreakpoint::SetCallback (#96001) This commit adds a unit test for SBBreakpoint::SetCallback as it wasn't being tested before. Added: lldb/unittests/Callback/CMakeLists.txt lldb/unittests/Callback/TestBreakpointSetCallback.cpp Modified: lldb/include/lldb/lldb-private-interfaces.h lldb/source/Breakpoint/BreakpointOptions.cpp lldb/unittests/CMakeLists.txt Removed: diff --git a/lldb/include/lldb/lldb-private-interfaces.h b/lldb/include/lldb/lldb-private-interfaces.h index 53d5fbb84cc92..cdd9b51d9329c 100644 --- a/lldb/include/lldb/lldb-private-interfaces.h +++ b/lldb/include/lldb/lldb-private-interfaces.h @@ -99,10 +99,10 @@ typedef std::optional (*SymbolLocatorLocateExecutableSymbolFile)( typedef bool (*SymbolLocatorDownloadObjectAndSymbolFile)( ModuleSpec &module_spec, Status &error, bool force_lookup, bool copy_executable); -typedef bool (*BreakpointHitCallback)(void *baton, - StoppointCallbackContext *context, - lldb::user_id_t break_id, - lldb::user_id_t break_loc_id); +using BreakpointHitCallback = +std::function; + typedef bool (*WatchpointHitCallback)(void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id); diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp b/lldb/source/Breakpoint/BreakpointOptions.cpp index 6c6037dd9edd3..1db8401698114 100644 --- a/lldb/source/Breakpoint/BreakpointOptions.cpp +++ b/lldb/source/Breakpoint/BreakpointOptions.cpp @@ -102,19 +102,11 @@ const char *BreakpointOptions::g_option_names[( "ConditionText", "IgnoreCount", "EnabledState", "OneShotState", "AutoContinue"}; -bool BreakpointOptions::NullCallback(void *baton, - StoppointCallbackContext *context, - lldb::user_id_t break_id, - lldb::user_id_t break_loc_id) { - return true; -} - // BreakpointOptions constructor BreakpointOptions::BreakpointOptions(bool all_flags_set) -: m_callback(BreakpointOptions::NullCallback), - m_baton_is_command_baton(false), m_callback_is_synchronous(false), - m_enabled(true), m_one_shot(false), m_ignore_count(0), - m_condition_text_hash(0), m_inject_condition(false), +: m_callback(nullptr), m_baton_is_command_baton(false), + m_callback_is_synchronous(false), m_enabled(true), m_one_shot(false), + m_ignore_count(0), m_condition_text_hash(0), m_inject_condition(false), m_auto_continue(false), m_set_flags(0) { if (all_flags_set) m_set_flags.Set(~((Flags::ValueType)0)); @@ -420,7 +412,7 @@ void BreakpointOptions::SetCallback( } void BreakpointOptions::ClearCallback() { - m_callback = BreakpointOptions::NullCallback; + m_callback = nullptr; m_callback_is_synchronous = false; m_callback_baton_sp.reset(); m_baton_is_command_baton = false; @@ -449,7 +441,7 @@ bool BreakpointOptions::InvokeCallback(StoppointCallbackContext *context, } bool BreakpointOptions::HasCallback() const { - return m_callback != BreakpointOptions::NullCallback; + return static_cast(m_callback); } bool BreakpointOptions::GetCommandLineCallbacks(StringList &command_list) { diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt index a2585a94b6155..cc9d45ebf981d 100644 --- a/lldb/unittests/CMakeLists.txt +++ b/lldb/unittests/CMakeLists.txt @@ -52,6 +52,7 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows") add_subdirectory(API) endif() add_subdirectory(Breakpoint) +add_subdirectory(Callback) add_subdirectory(Core) add_subdirectory(DataFormatter) add_subdirectory(Disassembler) diff --git a/lldb/unittests/Callback/CMakeLists.txt b/lldb/unittests/Callback/CMakeLists.txt new file mode 100644 index 0..b9e0ef5a396e3 --- /dev/null +++ b/lldb/unittests/Callback/CMakeLists.txt @@ -0,0 +1,12 @@ +add_lldb_unittest(LLDBCallbackTests + TestBreakpointSetCallback.cpp + + LINK_LIBS +lldbBreakpoint +lldbCore +LLVMTestingSupport +lldbUtilityHelpers +lldbPluginPlatformMacOSX + LINK_COMPONENTS +Support + ) diff --git a/lldb/unittests/Callback/TestBreakpointSetCallback.cpp b/lldb/unittests/Callback/TestBreakpointSetCallback.cpp new file mode 100644 index 0..2a7070f9349c0 --- /dev/null +++ b/lldb/unittests/Callback/TestBreakpointSetCallback.cpp @@ -0,0 +1,85 @@ +//===-- TestBreakpointSetCallback.cpp +//---
[Lldb-commits] [lldb] Add a unit test for SBBreakpoint::SetCallback (PR #96001)
https://github.com/chelcassanova closed https://github.com/llvm/llvm-project/pull/96001 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)
https://github.com/clayborg updated https://github.com/llvm/llvm-project/pull/87740 >From 3f99b41eac0e04e15bdb99bea2ee75703936ea00 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Sat, 30 Mar 2024 10:50:34 -0700 Subject: [PATCH 01/12] Add support for using foreign type units in .debug_names. This patch adds support for the new foreign type unit support in .debug_names. Features include: - don't manually index foreign TUs if we have info for them - only use the type unit entries that match the .dwo files when we have a .dwp file - fix crashers that happen due to PeekDIEName() using wrong offsets --- .../SymbolFile/DWARF/DWARFDebugInfo.cpp | 18 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h | 2 + .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 65 - .../SymbolFile/DWARF/DebugNamesDWARFIndex.h | 6 +- .../SymbolFile/DWARF/ManualDWARFIndex.cpp | 6 +- .../SymbolFile/DWARF/ManualDWARFIndex.h | 7 +- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 66 -- .../SymbolFile/DWARF/SymbolFileDWARF.h| 9 ++ .../DWARF/x86/dwp-foreign-type-units.cpp | 91 +++ .../DebugInfo/DWARF/DWARFAcceleratorTable.h | 11 +++ .../DebugInfo/DWARF/DWARFAcceleratorTable.cpp | 13 +++ 11 files changed, 257 insertions(+), 37 deletions(-) create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index c37cc91e08ed12..056c6d4b0605f8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -222,6 +222,20 @@ DWARFUnit *DWARFDebugInfo::GetUnitAtOffset(DIERef::Section section, return result; } +DWARFUnit *DWARFDebugInfo::GetUnit(const DIERef &die_ref) { + // Make sure we get the correct SymbolFileDWARF from the DIERef before + // asking for information from a debug info object. We might start with the + // DWARFDebugInfo for the main executable in a split DWARF and the DIERef + // might be pointing to a specific .dwo file or to the .dwp file. So this + // makes sure we get the right SymbolFileDWARF instance before finding the + // DWARFUnit that contains the offset. If we just use this object to do the + // search, we might be using the wrong .debug_info section from the wrong + // file with an offset meant for a different section. + SymbolFileDWARF *dwarf = m_dwarf.GetDIERefSymbolFile(die_ref); + return dwarf->DebugInfo().GetUnitContainingDIEOffset(die_ref.section(), + die_ref.die_offset()); +} + DWARFUnit * DWARFDebugInfo::GetUnitContainingDIEOffset(DIERef::Section section, dw_offset_t die_offset) { @@ -232,6 +246,10 @@ DWARFDebugInfo::GetUnitContainingDIEOffset(DIERef::Section section, return result; } +const std::shared_ptr DWARFDebugInfo::GetDwpSymbolFile() { + return m_dwarf.GetDwpSymbolFile(); +} + DWARFTypeUnit *DWARFDebugInfo::GetTypeUnitForHash(uint64_t hash) { auto pos = llvm::lower_bound(m_type_hash_to_unit_index, std::make_pair(hash, 0u), llvm::less_first()); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index 4706b55d38ea98..4d4555a3382529 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -52,6 +52,8 @@ class DWARFDebugInfo { const DWARFDebugAranges &GetCompileUnitAranges(); + const std::shared_ptr GetDwpSymbolFile(); + protected: typedef std::vector UnitColl; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index 1d17f20670eed4..d815d345b08ee7 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -34,6 +34,18 @@ DebugNamesDWARFIndex::Create(Module &module, DWARFDataExtractor debug_names, module, std::move(index_up), debug_names, debug_str, dwarf)); } + +llvm::DenseSet +DebugNamesDWARFIndex::GetTypeUnitSigs(const DebugNames &debug_names) { + llvm::DenseSet result; + for (const DebugNames::NameIndex &ni : debug_names) { +const uint32_t num_tus = ni.getForeignTUCount(); +for (uint32_t tu = 0; tu < num_tus; ++tu) + result.insert(ni.getForeignTUSignature(tu)); + } + return result; +} + llvm::DenseSet DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) { llvm::DenseSet result; @@ -48,17 +60,22 @@ DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) { return result; } +DWARFTypeUnit * +DebugNamesDWARFIndex::GetForeignTypeUnit(const DebugNames::Entry &entry) const { + std::optional type_sig = entry.getForeignTUTypeSignature(); + if (type_sig) +if (
[Lldb-commits] [lldb] 3b5b814 - Add support for using foreign type units in .debug_names. (#87740)
Author: Greg Clayton Date: 2024-06-24T09:59:59-07:00 New Revision: 3b5b814647ef83ab763cf7871b6d74edfca67438 URL: https://github.com/llvm/llvm-project/commit/3b5b814647ef83ab763cf7871b6d74edfca67438 DIFF: https://github.com/llvm/llvm-project/commit/3b5b814647ef83ab763cf7871b6d74edfca67438.diff LOG: Add support for using foreign type units in .debug_names. (#87740) This patch adds support for the new foreign type unit support in .debug_names. Features include: - don't manually index foreign TUs if we have info for them - only use the type unit entries that match the .dwo files when we have a .dwp file - fix type unit lookups for .dwo files - fix crashers that happen due to PeekDIEName() using wrong offsets where an entry had DW_IDX_comp_unit and DW_IDX_type_unit entries and when we had no type unit support, it would cause us to think it was a normal DIE in .debug_info from the main executable. - Co-authored-by: paperchalice Added: lldb/test/Shell/SymbolFile/DWARF/x86/dwp-foreign-type-units.cpp Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index c37cc91e08ed1..f7df38d240191 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -232,6 +232,10 @@ DWARFDebugInfo::GetUnitContainingDIEOffset(DIERef::Section section, return result; } +const std::shared_ptr &DWARFDebugInfo::GetDwpSymbolFile() { + return m_dwarf.GetDwpSymbolFile(); +} + DWARFTypeUnit *DWARFDebugInfo::GetTypeUnitForHash(uint64_t hash) { auto pos = llvm::lower_bound(m_type_hash_to_unit_index, std::make_pair(hash, 0u), llvm::less_first()); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index 4706b55d38ea9..598739bf3cb95 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -52,6 +52,8 @@ class DWARFDebugInfo { const DWARFDebugAranges &GetCompileUnitAranges(); + const std::shared_ptr &GetDwpSymbolFile(); + protected: typedef std::vector UnitColl; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index 1d17f20670eed..7e66b3dccf97f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -10,6 +10,7 @@ #include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h" #include "Plugins/SymbolFile/DWARF/DWARFDeclContext.h" #include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h" +#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h" #include "lldb/Core/Module.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" @@ -34,6 +35,17 @@ DebugNamesDWARFIndex::Create(Module &module, DWARFDataExtractor debug_names, module, std::move(index_up), debug_names, debug_str, dwarf)); } +llvm::DenseSet +DebugNamesDWARFIndex::GetTypeUnitSignatures(const DebugNames &debug_names) { + llvm::DenseSet result; + for (const DebugNames::NameIndex &ni : debug_names) { +const uint32_t num_tus = ni.getForeignTUCount(); +for (uint32_t tu = 0; tu < num_tus; ++tu) + result.insert(ni.getForeignTUSignature(tu)); + } + return result; +} + llvm::DenseSet DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) { llvm::DenseSet result; @@ -48,20 +60,80 @@ DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) { return result; } +std::optional +DebugNamesDWARFIndex::GetForeignTypeUnit(const DebugNames::Entry &entry) const { + std::optional type_sig = entry.getForeignTUTypeSignature(); + if (!type_sig.has_value()) +return std::nullopt; + + // Ask the entry for the skeleton compile unit offset and fetch the .dwo + // file from it and get the type unit by signature from there. If we find + // the type unit in the .dwo file, we don't need to check that the + // DW_AT_dwo_name matches because each .dwo file can have its o
[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)
https://github.com/clayborg closed https://github.com/llvm/llvm-project/pull/87740 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] fc066ca - Fix buildbots for https://github.com/llvm/llvm-project/pull/87740
Author: Greg Clayton Date: 2024-06-24T10:16:39-07:00 New Revision: fc066ca1c32b4aef549f3e371dc70589804aba0f URL: https://github.com/llvm/llvm-project/commit/fc066ca1c32b4aef549f3e371dc70589804aba0f DIFF: https://github.com/llvm/llvm-project/commit/fc066ca1c32b4aef549f3e371dc70589804aba0f.diff LOG: Fix buildbots for https://github.com/llvm/llvm-project/pull/87740 Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index bd81618ac914d..70aa4b9e1f203 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1746,7 +1746,7 @@ SymbolFileDWARF *SymbolFileDWARF::GetDIERefSymbolFile(const DIERef &die_ref) { if (file_index) { // We have a SymbolFileDWARFDebugMap, so let it find the right file -\if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) +if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) return debug_map->GetSymbolFileByOSOIndex(*file_index); // Handle the .dwp file case correctly ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)
clayborg wrote: An extra character snuck in and messed with the buildbots, fixed with: ``` commit fc066ca1c32b4aef549f3e371dc70589804aba0f (HEAD -> main, origin/main, origin/HEAD) Author: Greg Clayton Date: Mon Jun 24 10:15:55 2024 -0700 Fix buildbots for https://github.com/llvm/llvm-project/pull/87740 ``` https://github.com/llvm/llvm-project/pull/87740 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
https://github.com/mattweingarten updated https://github.com/llvm/llvm-project/pull/94264 error: too big or took too long to generate ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
https://github.com/mattweingarten edited https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a27164c - [LLDB][Minidump] Add 64b support to LLDB's minidump file builder. (#95312)
Author: Jacob Lalonde Date: 2024-06-24T10:48:01-07:00 New Revision: a27164cb33162bb42642c091703f9c6f8829785c URL: https://github.com/llvm/llvm-project/commit/a27164cb33162bb42642c091703f9c6f8829785c DIFF: https://github.com/llvm/llvm-project/commit/a27164cb33162bb42642c091703f9c6f8829785c.diff LOG: [LLDB][Minidump] Add 64b support to LLDB's minidump file builder. (#95312) Currently, LLDB does not support taking a minidump over the 4.2gb limit imposed by uint32. In fact, currently it writes the RVA's and the headers to the end of the file, which can become corrupted due to the header offset only supporting a 32b offset. This change reorganizes how the file structure is laid out. LLDB will precalculate the number of directories required and preallocate space at the top of the file to fill in later. Additionally, thread stacks require a 32b offset, and we provision empty descriptors and keep track of them to clean up once we write the 32b memory list. For [MemoryList64](https://learn.microsoft.com/en-us/windows/win32/api/minidumpapiset/ns-minidumpapiset-minidump_memory64_list), the RVA to the start of the section itself will remain in a 32b addressable space. We achieve this by predetermining the space the memory regions will take, and only writing up to 4.2 gb of data with some buffer to allow all the MemoryDescriptor64s to also still be 32b addressable. I did not add any explicit tests to this PR because allocating 4.2gb+ to test is very expensive. However, we have 32b automation tests and I validated with in several ways, including with 5gb+ array/object and would be willing to add this as a test case. Added: Modified: lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.cpp llvm/include/llvm/BinaryFormat/Minidump.h Removed: diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp index 7231433619ffb..7a09c6104d08c 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp @@ -20,25 +20,100 @@ #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/ThreadList.h" +#include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/Utility/RegisterValue.h" #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/Minidump.h" #include "llvm/Support/ConvertUTF.h" +#include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" +#include "llvm/TargetParser/Triple.h" #include "Plugins/Process/minidump/MinidumpTypes.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" +#include #include +#include +#include +#include +#include +#include +#include +#include +#include using namespace lldb; using namespace lldb_private; using namespace llvm::minidump; -void MinidumpFileBuilder::AddDirectory(StreamType type, size_t stream_size) { +Status MinidumpFileBuilder::AddHeaderAndCalculateDirectories() { + // First set the offset on the file, and on the bytes saved + m_saved_data_size = HEADER_SIZE; + // We know we will have at least Misc, SystemInfo, Modules, and ThreadList + // (corresponding memory list for stacks) And an additional memory list for + // non-stacks. + lldb_private::Target &target = m_process_sp->GetTarget(); + m_expected_directories = 6; + // Check if OS is linux and reserve directory space for all linux specific + // breakpad extension directories. + if (target.GetArchitecture().GetTriple().getOS() == + llvm::Triple::OSType::Linux) +m_expected_directories += 9; + + // Go through all of the threads and check for exceptions. + lldb_private::ThreadList thread_list = m_process_sp->GetThreadList(); + const uint32_t num_threads = thread_list.GetSize(); + for (uint32_t thread_idx = 0; thread_idx < num_threads; ++thread_idx) { +ThreadSP thread_sp(thread_list.GetThreadAtIndex(thread_idx)); +StopInfoSP stop_info_sp = thread_sp->GetStopInfo(); +if (stop_info_sp) { + const StopReason &stop_reason = stop_info_sp->GetStopReason(); + if (stop_reason == StopReason::eStopReasonException || + stop_reason == StopReason::eStopReasonSignal) +m_expected_directories++; +} + } + + m_saved_data_size += + m_expected_directories * sizeof(llvm::minidump::Directory); + Status error; + offset_t new_offset = m_core_file->SeekFromStart(m_saved_data_size); + if (new_offset != m_saved_data_size) +error.SetErrorStringWithFormat("Failed to fill in header and directory " +
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Add 64b support to LLDB's minidump file builder. (PR #95312)
https://github.com/clayborg closed https://github.com/llvm/llvm-project/pull/95312 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 33a9c57 - [lldb] Fix failing TestFind(Ranges)InMemory.py tests. (#96511)
Author: Miro Bucko Date: 2024-06-24T11:38:05-07:00 New Revision: 33a9c57b89c3ea901a057c3fcc9c9160eaf5a625 URL: https://github.com/llvm/llvm-project/commit/33a9c57b89c3ea901a057c3fcc9c9160eaf5a625 DIFF: https://github.com/llvm/llvm-project/commit/33a9c57b89c3ea901a057c3fcc9c9160eaf5a625.diff LOG: [lldb] Fix failing TestFind(Ranges)InMemory.py tests. (#96511) This is to unblock #95007. Will investigate why the assertion is failing on some arch. Added: Modified: lldb/test/API/python_api/find_in_memory/address_ranges_helper.py Removed: diff --git a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py index 0544100f97b29..2c11fba80766f 100644 --- a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py +++ b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py @@ -35,7 +35,6 @@ def GetRangeFromAddrValue(test_base, addr): ) test_base.assertTrue(region.IsReadable()) -test_base.assertFalse(region.IsExecutable()) address_start = lldb.SBAddress(region.GetRegionBase(), test_base.target) stack_size = region.GetRegionEnd() - region.GetRegionBase() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix failing TestFind(Ranges)InMemory.py tests. (PR #96511)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/96511 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb/DWARF] Remove parsing recursion when searching for definition DIEs (PR #96484)
labath wrote: > This patch as-is is NFC? NFC**I**, I would say :) I don't think this should change the behavior in any way, but it's pretty hard to guarantee that. > (no tests) but without this patch, the other delay-definition-die patch would > have had a problem? > > Is it possible to add a test in this patch that would exercise the thing that > would become buggy if the delay-definition-die patch were to be recommitted? Sort of. The situation is a bit complicated, because this touches pretty much the same code as the other patch, so the other patch will not apply cleanly or become magically correct. It's more like a building block that enables us to rewrite the other patch in a more robust manner -- which brings us to the second way this is complicated: It's not that the other patch was wrong on its own. It was just very sensitive to the other bugs. Previously, if we failed to unique the types correctly, we would "just" get the wrong type (or maybe no type). With the patch, that situation would trigger a hard assert. On its own, that might even be considered a good thing (easier to find bugs), we're it not for the fact that this made the logic of the patch very hard to follow. So, this is my attempt to make it more straight-forward. As for tests, it is possible to write a test which would reproduce a crash with the original patch, but that test is contingent on the existence of another bug. When I reverted that patch, I added a test (in de3f1b6d68ab8a0e827db84b328803857a4f60df) which triggered the crash. However, now that that bug is fixed (#95905), it does not crash anymore. Now, I happen to know of another bug (which happens to be triggered by the same code, only compiled with type units), but the same thing will happen once that bug is fixed. Given all of that, I don't think another test case is needed with this particular patch. It might be interesting for the final delay patch, if we don't fix the type unit thing by then, but I think of this patch mostly as a cleanup. https://github.com/llvm/llvm-project/pull/96484 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply PR/87550 (again) (PR #95571)
https://github.com/oontvoo updated https://github.com/llvm/llvm-project/pull/95571 >From 018c7a6052add708e0b0d09b911a904b52199da5 Mon Sep 17 00:00:00 2001 From: Vy Nguyen Date: Tue, 11 Jun 2024 14:15:43 -0400 Subject: [PATCH 1/5] Reapply "Reapply PR/87550 (#94625)" This reverts commit adcf33f8fbcc0f068bd4b8254994b16dda525009. --- lldb/include/lldb/API/SBDebugger.h| 2 + lldb/include/lldb/Symbol/TypeSystem.h | 1 + lldb/source/API/SBDebugger.cpp| 4 ++ lldb/source/Symbol/TypeSystem.cpp | 11 + lldb/tools/lldb-dap/DAP.cpp | 61 ++- lldb/tools/lldb-dap/DAP.h | 5 ++- lldb/tools/lldb-dap/lldb-dap.cpp | 6 ++- 7 files changed, 77 insertions(+), 13 deletions(-) diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index af19b1faf3bf5..84ea9c0f772e1 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -57,6 +57,8 @@ class LLDB_API SBDebugger { static const char *GetBroadcasterClass(); + static bool SupportsLanguage(lldb::LanguageType language); + lldb::SBBroadcaster GetBroadcaster(); /// Get progress data from a SBEvent whose type is eBroadcastBitProgress. diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index b4025c173a186..7d48f9b316138 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface, // TypeSystems can support more than one language virtual bool SupportsLanguage(lldb::LanguageType language) = 0; + static bool SupportsLanguageStatic(lldb::LanguageType language); // Type Completion virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0; diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 7ef0d6efd4aaa..29da7d33dd80b 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested() { return m_opaque_sp->InterruptRequested(); return false; } + +bool SBDebugger::SupportsLanguage(lldb::LanguageType language) { + return TypeSystem::SupportsLanguageStatic(language); +} diff --git a/lldb/source/Symbol/TypeSystem.cpp b/lldb/source/Symbol/TypeSystem.cpp index 4956f10a0b0a7..5d56d9b1829da 100644 --- a/lldb/source/Symbol/TypeSystem.cpp +++ b/lldb/source/Symbol/TypeSystem.cpp @@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language, } return GetTypeSystemForLanguage(language); } + +bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) { + if (language == eLanguageTypeUnknown) +return false; + + LanguageSet languages = + PluginManager::GetAllTypeSystemSupportedLanguagesForTypes(); + if (languages.Empty()) +return false; + return languages[language]; +} diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index d419f821999e6..263e841b7254d 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -32,14 +32,7 @@ namespace lldb_dap { DAP g_dap; DAP::DAP() -: broadcaster("lldb-dap"), - exception_breakpoints( - {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus}, - {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus}, - {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC}, - {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC}, - {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift}, - {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}), +: broadcaster("lldb-dap"), exception_breakpoints(), focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), is_attach(false), enable_auto_variable_summaries(false), enable_synthetic_child_debugging(false), @@ -65,8 +58,51 @@ DAP::DAP() DAP::~DAP() = default; +void DAP::PopulateExceptionBreakpoints() { + llvm::call_once(initExceptionBreakpoints, [this]() { +exception_breakpoints = {}; +if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) { + exception_breakpoints->emplace_back("cpp_catch", "C++ Catch", + lldb::eLanguageTypeC_plus_plus); + exception_breakpoints->emplace_back("cpp_throw", "C++ Throw", + lldb::eLanguageTypeC_plus_plus); +} +if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeObjC)) { + exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch", + lldb::eLanguageTypeObjC); + exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw", + lldb::eLanguageTypeObjC); +} +if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeSwift)) { + exception_breakpoints->emplace_back("swift_catch", "Swift Catch", +
[Lldb-commits] [lldb] Reapply PR/87550 (again) (PR #95571)
@@ -65,16 +58,67 @@ DAP::DAP() DAP::~DAP() = default; +void DAP::PopulateExceptionBreakpoints() { + llvm::call_once(initExceptionBreakpoints, [this]() { +exception_breakpoints = std::vector {}; + +if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) { + exception_breakpoints->emplace_back("cpp_catch", "C++ Catch", + lldb::eLanguageTypeC_plus_plus); + exception_breakpoints->emplace_back("cpp_throw", "C++ Throw", + lldb::eLanguageTypeC_plus_plus); +} +if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeObjC)) { + exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch", + lldb::eLanguageTypeObjC); + exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw", + lldb::eLanguageTypeObjC); +} +if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeSwift)) { + exception_breakpoints->emplace_back("swift_catch", "Swift Catch", + lldb::eLanguageTypeSwift); + exception_breakpoints->emplace_back("swift_throw", "Swift Throw", + lldb::eLanguageTypeSwift); +} +assert(exception_breakpoints.has_value() && "should have been initted"); +assert(!exception_breakpoints->empty() && "should not be empty"); + }); +} + ExceptionBreakpoint *DAP::GetExceptionBreakpoint(const std::string &filter) { - for (auto &bp : exception_breakpoints) { + // PopulateExceptionBreakpoints() is called after g_dap.debugger is created + // in a request-initialize. + // + // But this GetExceptionBreakpoint() method may be called before attaching, in + // which case, we may not have populated the filter yet. + // + // We also cannot call PopulateExceptionBreakpoints() in DAP::DAP() because + // we need SBDebugger::Initialize() to have been called before this. + // + // So just calling PopulateExceptionBreakoints(),which does lazy-populating + // seems easiest. Two other options include: + // + call g_dap.PopulateExceptionBreakpoints() in lldb-dap.cpp::main() + //right after the call to SBDebugger::Initialize() + // + Just call PopulateExceptionBreakpoints() to get a fresh list everytime + //we query (a bit overkill since it's not likely to change?) + PopulateExceptionBreakpoints(); + assert(exception_breakpoints.has_value() && + "exception_breakpoints must have been populated"); oontvoo wrote: done - i've removed the unnecessary asserts(but keeping the method name to make it clearer that this function's job is to popualte the list) https://github.com/llvm/llvm-project/pull/95571 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/96538 This patch is in preparation for the `__compressed_pair` refactor in https://github.com/llvm/llvm-project/pull/76756. This gets the formatter tests to at least pass. Currently in draft because there's still some cleanup to be done. >From 3b4d9629a68c9e75dfd139ee2745bf00db979ecd Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 29 Jan 2024 16:23:16 + Subject: [PATCH] [lldb] Support new libc++ __compressed_pair layout This patch is in preparation for the `__compressed_pair` refactor in https://github.com/llvm/llvm-project/pull/76756. This gets the formatter tests to at least pass. Currently in draft because there's still some cleanup to be done. --- lldb/examples/synthetic/libcxx.py | 26 -- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 61 ++ .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 83 --- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 68 +++ .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 73 +++- .../Language/CPlusPlus/LibCxxVector.cpp | 40 + .../list/TestDataFormatterGenericList.py | 3 +- .../libcxx/string/simulator/main.cpp | 1 + .../TestDataFormatterLibcxxUniquePtr.py | 7 +- 9 files changed, 256 insertions(+), 106 deletions(-) diff --git a/lldb/examples/synthetic/libcxx.py b/lldb/examples/synthetic/libcxx.py index 474aaa428fa23..060ff90100849 100644 --- a/lldb/examples/synthetic/libcxx.py +++ b/lldb/examples/synthetic/libcxx.py @@ -721,6 +721,12 @@ def _get_value_of_compressed_pair(self, pair): def update(self): logger = lldb.formatters.Logger.Logger() try: +has_compressed_pair_layout = True +alloc_valobj = self.valobj.GetChildMemberWithName("__alloc_") +size_valobj = self.valobj.GetChildMemberWithName("__size_") +if alloc_valobj.IsValid() and size_valobj.IsValid(): +has_compressed_pair_layout = False + # A deque is effectively a two-dim array, with fixed width. # 'map' contains pointers to the rows of this array. The # full memory area allocated by the deque is delimited @@ -734,9 +740,13 @@ def update(self): # variable tells which element in this NxM array is the 0th # one, and the 'size' element gives the number of elements # in the deque. -count = self._get_value_of_compressed_pair( -self.valobj.GetChildMemberWithName("__size_") -) +if has_compressed_pair_layout: +count = self._get_value_of_compressed_pair( +self.valobj.GetChildMemberWithName("__size_") +) +else: +count = size_valobj.GetValueAsUnsigned(0) + # give up now if we cant access memory reliably if self.block_size < 0: logger.write("block_size < 0") @@ -748,9 +758,13 @@ def update(self): self.map_begin = map_.GetChildMemberWithName("__begin_") map_begin = self.map_begin.GetValueAsUnsigned(0) map_end = map_.GetChildMemberWithName("__end_").GetValueAsUnsigned(0) -map_endcap = self._get_value_of_compressed_pair( -map_.GetChildMemberWithName("__end_cap_") -) + +if has_compressed_pair_layout: +map_endcap = self._get_value_of_compressed_pair( +map_.GetChildMemberWithName("__end_cap_") +) +else: +map_endcap = map_.GetChildMemberWithName("__end_cap_").GetValueAsUnsigned(0) # check consistency if not map_first <= map_begin <= map_end <= map_endcap: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index b0e6fb7d6f5af..928b790317b6e 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -27,6 +27,7 @@ #include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" #include #include @@ -176,9 +177,9 @@ bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider( if (!ptr_sp) return false; - ptr_sp = GetFirstValueOfLibCXXCompressedPair(*ptr_sp); - if (!ptr_sp) -return false; + if (ValueObjectSP compressed_pair_value__sp = + GetFirstValueOfLibCXXCompressedPair(*ptr_sp)) +ptr_sp = std::move(compressed_pair_value__sp); if (ptr_sp->GetValueAsUnsigned(0) == 0) { stream.Printf("nullptr"); @@ -701,15 +702,28 @@ lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() { if (!ptr_sp) return lldb::ChildCacheState::eRefetch; + bool has_compressed_pair_layout = true; + ValueO
[Lldb-commits] [lldb] [lldb/DWARF] Remove parsing recursion when searching for definition DIEs (PR #96484)
dwblaikie wrote: > > This patch as-is is NFC? > > NFC_**I**_, I would say :) I don't think this should change the behavior in > any way, but it's pretty hard to guarantee that. Sure enough - I take any claim as a statement of intent/belief, not of something mathematically proved, etc. > > (no tests) but without this patch, the other delay-definition-die patch > > would have had a problem? > > Is it possible to add a test in this patch that would exercise the thing > > that would become buggy if the delay-definition-die patch were to be > > recommitted? > > Sort of. The situation is a bit complicated, because this touches pretty much > the same code as the other patch, so the other patch will not apply cleanly > or become magically correct. It's more like a building block that enables us > to rewrite the other patch in a more robust manner -- which brings us to the > second way this is complicated: It's not that the other patch was wrong on > its own. It was just very sensitive to the other bugs. Previously, if we > failed to unique the types correctly, we would "just" get the wrong type (or > maybe no type). With the patch, that situation would trigger a hard assert. > On its own, that might even be considered a good thing (easier to find bugs), > we're it not for the fact that this made the logic of the patch very hard to > follow. So, this is my attempt to make it more straight-forward. > > As for tests, it is possible to write a test which would reproduce a crash > with the original patch, but that test is contingent on the existence of > another bug. When I reverted that patch, I added a test (in > [de3f1b6](https://github.com/llvm/llvm-project/commit/de3f1b6d68ab8a0e827db84b328803857a4f60df)) > which triggered the crash. Having a bit of a hard time following this - is the test you added the same as the test you speculated is possible to write in the prior sentence? > However, now that that bug is fixed (#95905), it does not crash anymore. Now, > I happen to know of another bug (which happens to be triggered by the same > code, only compiled with type units), but the same thing will happen once > that bug is fixed. OK - I think I'm following. > Given all of that, I don't think another test case is needed with this > particular patch. It might be interesting for the final delay patch, if we > don't fix the type unit thing by then, but I think of this patch mostly as a > cleanup. Perhaps a separate commit could add another RUN line to the existing test you added to demonstrate the reason for the revert? Rather than worrying about which comes first (the type unit patch or the delay patch) But in any case, I /think/ I understand why this patch doesn't need a test (because this patch avoids the delay patch causing a crash (yeah, more complex than that because the patch doesn't apply cleanly over this one) and that crash already has a test committed) - thanks for the explanation. https://github.com/llvm/llvm-project/pull/96484 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r 62baf21daa377c4ec1a641b26931063c1117d262...3b4d9629a68c9e75dfd139ee2745bf00db979ecd lldb/examples/synthetic/libcxx.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py `` View the diff from darker here. ``diff --- examples/synthetic/libcxx.py2024-06-24 19:22:02.00 + +++ examples/synthetic/libcxx.py2024-06-24 19:26:18.844345 + @@ -762,11 +762,13 @@ if has_compressed_pair_layout: map_endcap = self._get_value_of_compressed_pair( map_.GetChildMemberWithName("__end_cap_") ) else: -map_endcap = map_.GetChildMemberWithName("__end_cap_").GetValueAsUnsigned(0) +map_endcap = map_.GetChildMemberWithName( +"__end_cap_" +).GetValueAsUnsigned(0) # check consistency if not map_first <= map_begin <= map_end <= map_endcap: logger.write("map pointers are not monotonic") return --- test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py 2024-06-24 19:22:02.00 + +++ test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py 2024-06-24 19:26:18.939102 + @@ -60,12 +60,12 @@ self.runCmd("type format add -f hex int") self.expect( "frame variable numbers_list --raw", matching=False, -#substrs=["size=0", "{}"], # TODO: if __padding_ members aren't added this isn't needed -substrs=["size=0"] +# substrs=["size=0", "{}"], # TODO: if __padding_ members aren't added this isn't needed +substrs=["size=0"], ) if stdlib_type == USE_LIBSTDCPP: self.expect( "frame variable &numbers_list._M_impl._M_node --raw", --- test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py 2024-06-24 19:22:02.00 + +++ test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py 2024-06-24 19:26:18.994855 + @@ -43,11 +43,11 @@ valobj = self.expect_var_path( "up_empty", type=self.make_expected_type("int"), summary="nullptr", -#children=[ValueCheck(name="pointer"), ValueCheck(name="deleter")], # TODO: shouldn't be printing deleter +# children=[ValueCheck(name="pointer"), ValueCheck(name="deleter")], # TODO: shouldn't be printing deleter children=[ValueCheck(name="pointer")], ) self.assertEqual( valobj.child[0].GetValueAsUnsigned(lldb.LLDB_INVALID_ADDRESS), 0 ) @@ -58,38 +58,38 @@ valobj = self.expect_var_path( "up_int", type=self.make_expected_type("int"), summary="10", -#children=[ValueCheck(name="pointer"), ValueCheck(name="deleter")], # TODO: shouldn't be printing deleter +# children=[ValueCheck(name="pointer"), ValueCheck(name="deleter")], # TODO: shouldn't be printing deleter children=[ValueCheck(name="pointer")], ) self.assertNotEqual(valobj.child[0].unsigned, 0) valobj = self.expect_var_path( "up_int_ref", type=self.make_expected_type("int", qualifiers="&"), summary="10", -#children=[ValueCheck(name="pointer"), ValueCheck(name="deleter")], # TODO: shouldn't be printing deleter +# children=[ValueCheck(name="pointer"), ValueCheck(name="deleter")], # TODO: shouldn't be printing deleter children=[ValueCheck(name="pointer")], ) self.assertNotEqual(valobj.child[0].unsigned, 0) valobj = self.expect_var_path( "up_int_ref_ref", type=self.make_expected_type("int", qualifiers="&&"), summary="10", -#children=[ValueCheck(name="pointer"), ValueCheck(name="deleter")], # TODO: shouldn't be printing deleter +# children=[ValueCheck(name="pointer"), ValueCheck(name="deleter")], # TODO: shouldn't be printing deleter children=[ValueCheck(name="pointer")], ) self.assertNotEqual(valobj.child[0].unsigned, 0) valobj = self.expect_var_path( "up_str", type=self.make_expected_basic_string_ptr(), summary='"hello"', -#children=[ValueCheck(name="pointer"), Val
[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `llvm-x86_64-debian-dylib` running on `gribozavr4` while building `lldb,llvm` at step 5 "build-unified-tree". Full details are available at: https://lab.llvm.org/buildbot/#/builders/60/builds/803 Here is the relevant piece of the build log for the reference: ``` Step 5 (build-unified-tree) failure: build (failure) ... 44.575 [114/14/6770] Building CXX object tools/lldb/source/Plugins/SymbolFile/DWARF/CMakeFiles/lldbPluginSymbolFileDWARF.dir/DWARFDebugInfo.cpp.o 44.818 [114/13/6771] Building CXX object tools/lldb/source/Plugins/SymbolFile/DWARF/CMakeFiles/lldbPluginSymbolFileDWARF.dir/DWARFIndex.cpp.o 44.924 [114/12/6772] Building CXX object tools/lldb/source/Plugins/SymbolFile/DWARF/CMakeFiles/lldbPluginSymbolFileDWARF.dir/DWARFASTParser.cpp.o 45.685 [114/11/6773] Building CXX object tools/lldb/source/Plugins/SymbolFile/DWARF/CMakeFiles/lldbPluginSymbolFileDWARF.dir/ManualDWARFIndex.cpp.o 45.944 [114/10/6774] Building CXX object tools/lldb/source/Plugins/SymbolFile/DWARF/CMakeFiles/lldbPluginSymbolFileDWARF.dir/SymbolFileDWARFDebugMap.cpp.o 46.307 [114/9/6775] Building CXX object tools/lldb/source/Expression/CMakeFiles/lldbExpression.dir/DWARFExpression.cpp.o 46.458 [114/8/6776] Building CXX object tools/lld/ELF/CMakeFiles/lldELF.dir/InputSection.cpp.o 48.597 [114/7/6777] Building CXX object tools/lld/ELF/CMakeFiles/lldELF.dir/Relocations.cpp.o 49.905 [114/6/6778] Building CXX object tools/lld/ELF/CMakeFiles/lldELF.dir/Writer.cpp.o 50.272 [114/5/6779] Building CXX object tools/lldb/source/Plugins/SymbolFile/DWARF/CMakeFiles/lldbPluginSymbolFileDWARF.dir/SymbolFileDWARF.cpp.o FAILED: tools/lldb/source/Plugins/SymbolFile/DWARF/CMakeFiles/lldbPluginSymbolFileDWARF.dir/SymbolFileDWARF.cpp.o CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/source/Plugins/SymbolFile/DWARF -I/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF -I/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/include -I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/include -I/b/1/llvm-x86_64-debian-dylib/build/include -I/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/include -I/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/../clang/include -I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/../clang/include -I/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source -I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/source -isystem /usr/include/libxml2 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register -Wno-vla-extension -O3 -DNDEBUG -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/lldb/source/Plugins/SymbolFile/DWARF/CMakeFiles/lldbPluginSymbolFileDWARF.dir/SymbolFileDWARF.cpp.o -MF tools/lldb/source/Plugins/SymbolFile/DWARF/CMakeFiles/lldbPluginSymbolFileDWARF.dir/SymbolFileDWARF.cpp.o.d -o tools/lldb/source/Plugins/SymbolFile/DWARF/CMakeFiles/lldbPluginSymbolFileDWARF.dir/SymbolFileDWARF.cpp.o -c /b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp /b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:1749:1: error: expected expression \if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) ^ 1 error generated. 53.142 [114/4/6780] Building CXX object tools/lld/ELF/CMakeFiles/lldELF.dir/InputFiles.cpp.o 55.217 [114/3/6781] Building CXX object tools/lld/ELF/CMakeFiles/lldELF.dir/Driver.cpp.o 55.652 [114/2/6782] Building CXX object tools/lldb/source/Plugins/SymbolFile/DWARF/CMakeFiles/lldbPluginSymbolFileDWARF.dir/DWARFASTParserClang.cpp.o 57.506 [114/1/6783] Building CXX object tools/lld/ELF/CMakeFiles/lldELF.dir/SyntheticSections.cpp.o ninja: build stopped: subcommand failed. ``` https://github.com/llvm/llvm-project/pull/87740 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Add 64b support to LLDB's minidump file builder. (PR #95312)
petrhosek wrote: This broke the Windows build with the following error: ``` C:\b\s\w\ir\x\w\cipd\bin\clang-cl.exe /nologo -TP -DGTEST_HAS_RTTI=0 -DLIBXML_STATIC -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:\b\s\w\ir\x\w\llvm_build\tools\lldb\source\Plugins\ObjectFile\Minidump -IC:\b\s\w\ir\x\w\llvm-llvm-project\lldb\source\Plugins\ObjectFile\Minidump -IC:\b\s\w\ir\x\w\llvm-llvm-project\lldb\include -IC:\b\s\w\ir\x\w\llvm_build\tools\lldb\include -IC:\b\s\w\ir\x\w\rc\tensorflow-venv\store\python_venv-51qj4upsi8nrslpsnfp48k5j14\contents\Lib\site-packages\tensorflow\include -IC:\b\s\w\ir\x\w\llvm_build\include -IC:\b\s\w\ir\x\w\llvm-llvm-project\llvm\include -IC:\b\s\w\ir\x\w\lldb_install\python3\include -IC:\b\s\w\ir\x\w\llvm-llvm-project\llvm\..\clang\include -IC:\b\s\w\ir\x\w\llvm_build\tools\lldb\..\clang\include -IC:\b\s\w\ir\x\w\llvm-llvm-project\lldb\source -IC:\b\s\w\ir\x\w\llvm_build\tools\lldb\source -imsvcC:\b\s\w\ir\x\w\libxml2_install_target\include\libxml2 -imsvcC:\b\s\w\ir\x\w\zlib_install_target\include -imsvcC:\b\s\w\ir\x\w\zstd_install\include /DWIN32 /D_WINDOWS /Zc:inline /Zc:__cplusplus /Oi /Brepro /bigobj /permissive- -Werror=unguarded-availability-new /W4 -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported /Gw -Wno-deprecated-register -Wno-vla-extension /O2 /Ob2 -std:c++17 -MT -wd4018 -wd4068 -wd4150 -wd4201 -wd4251 -wd4521 -wd4530 -wd4589 /EHs-c- /GR- -UNDEBUG /showIncludes /Fotools\lldb\source\Plugins\ObjectFile\Minidump\CMakeFiles\lldbPluginObjectFileMinidump.dir\MinidumpFileBuilder.cpp.obj /Fdtools\lldb\source\Plugins\ObjectFile\Minidump\CMakeFiles\lldbPluginObjectFileMinidump.dir\lldbPluginObjectFileMinidump.pdb -c -- C:\b\s\w\ir\x\w\llvm-llvm-project\lldb\source\Plugins\ObjectFile\Minidump\MinidumpFileBuilder.cpp In file included from C:\b\s\w\ir\x\w\llvm-llvm-project\lldb\source\Plugins\ObjectFile\Minidump\MinidumpFileBuilder.cpp:9: C:\b\s\w\ir\x\w\llvm-llvm-project\lldb\source\Plugins\ObjectFile\Minidump\MinidumpFileBuilder.h(149,3): error: unknown type name 'uint'; did you mean 'int'? 149 | uint m_expected_directories = 0; | ^~~~ | int 1 error generated. ``` Would it be possible to take a look and revert if necessary? https://github.com/llvm/llvm-project/pull/95312 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert commits that add `TestFind(Ranges)InMemory.py` (PR #96560)
https://github.com/chelcassanova created https://github.com/llvm/llvm-project/pull/96560 Reverting to unblock macOS buildbots which are currently failing on these tests. https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6377/ >From 22127178761968b01be207a1c83c7048dc3ec47d Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Mon, 24 Jun 2024 14:17:09 -0700 Subject: [PATCH 1/2] Revert "[lldb] Fix failing TestFind(Ranges)InMemory.py tests. (#96511)" This reverts commit 33a9c57b89c3ea901a057c3fcc9c9160eaf5a625. Alongside 10bd5ad this is being reverted as these commits are blocking the macOS buildbots: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6375/ --- lldb/test/API/python_api/find_in_memory/address_ranges_helper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py index 2c11fba80766f..0544100f97b29 100644 --- a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py +++ b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py @@ -35,6 +35,7 @@ def GetRangeFromAddrValue(test_base, addr): ) test_base.assertTrue(region.IsReadable()) +test_base.assertFalse(region.IsExecutable()) address_start = lldb.SBAddress(region.GetRegionBase(), test_base.target) stack_size = region.GetRegionEnd() - region.GetRegionBase() >From 10b926cb193292252bc8df6d0ed8345dc73c30e5 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Mon, 24 Jun 2024 14:18:51 -0700 Subject: [PATCH 2/2] Revert "[lldb][API] Add Find(Ranges)InMemory() to Process SB API (#95007)" This reverts commit 10bd5ad0a133fe73ffc1b05e63bc3fb2d56ba79c. Alongside 33a9c57 this commit is being reverted to unblock the macOS buildbots. --- lldb/bindings/python/python-typemaps.swig | 3 +- lldb/include/lldb/API/SBProcess.h | 10 - lldb/include/lldb/Core/AddressRangeListImpl.h | 4 - lldb/include/lldb/Target/Process.h| 14 -- lldb/source/API/SBProcess.cpp | 58 + lldb/source/Target/Process.cpp| 123 -- .../API/python_api/find_in_memory/Makefile| 3 - .../find_in_memory/TestFindInMemory.py| 131 --- .../find_in_memory/TestFindRangesInMemory.py | 221 -- .../find_in_memory/address_ranges_helper.py | 73 -- .../API/python_api/find_in_memory/main.cpp| 27 --- 11 files changed, 6 insertions(+), 661 deletions(-) delete mode 100644 lldb/test/API/python_api/find_in_memory/Makefile delete mode 100644 lldb/test/API/python_api/find_in_memory/TestFindInMemory.py delete mode 100644 lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py delete mode 100644 lldb/test/API/python_api/find_in_memory/address_ranges_helper.py delete mode 100644 lldb/test/API/python_api/find_in_memory/main.cpp diff --git a/lldb/bindings/python/python-typemaps.swig b/lldb/bindings/python/python-typemaps.swig index f8c33e15c03e6..c39594c7df041 100644 --- a/lldb/bindings/python/python-typemaps.swig +++ b/lldb/bindings/python/python-typemaps.swig @@ -257,8 +257,7 @@ AND call SWIG_fail at the same time, because it will result in a double free. } // For SBProcess::WriteMemory, SBTarget::GetInstructions and SBDebugger::DispatchInput. %typemap(in) (const void *buf, size_t size), - (const void *data, size_t data_len), - (const void *buf, uint64_t size) { + (const void *data, size_t data_len) { if (PythonString::Check($input)) { PythonString str(PyRefType::Borrowed, $input); $1 = (void *)str.GetString().data(); diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index a6ab7ae759918..f1b5d1fb92ce2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -209,16 +209,6 @@ class LLDB_API SBProcess { lldb::addr_t ReadPointerFromMemory(addr_t addr, lldb::SBError &error); - lldb::SBAddressRangeList FindRangesInMemory(const void *buf, uint64_t size, - const SBAddressRangeList &ranges, - uint32_t alignment, - uint32_t max_matches, - SBError &error); - - lldb::addr_t FindInMemory(const void *buf, uint64_t size, -const SBAddressRange &range, uint32_t alignment, -SBError &error); - // Events static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event); diff --git a/lldb/include/lldb/Core/AddressRangeListImpl.h b/lldb/include/lldb/Core/AddressRangeListImpl.h index 6742e6ead87de..46ebfe73d4d92 100644 --- a/lldb/include/lldb/Core/AddressRangeListImpl.h +++ b/lldb/include/lldb/Core/AddressRangeListImpl.h @@ -13,9 +13,7 @@ #include namespace lldb { -class SBAddressRangeList;
[Lldb-commits] [lldb] Revert commits that add `TestFind(Ranges)InMemory.py` (PR #96560)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Chelsea Cassanova (chelcassanova) Changes Reverting to unblock macOS buildbots which are currently failing on these tests. https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6377/ --- Patch is 28.12 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/96560.diff 11 Files Affected: - (modified) lldb/bindings/python/python-typemaps.swig (+1-2) - (modified) lldb/include/lldb/API/SBProcess.h (-10) - (modified) lldb/include/lldb/Core/AddressRangeListImpl.h (-4) - (modified) lldb/include/lldb/Target/Process.h (-14) - (modified) lldb/source/API/SBProcess.cpp (+5-53) - (modified) lldb/source/Target/Process.cpp (-123) - (removed) lldb/test/API/python_api/find_in_memory/Makefile (-3) - (removed) lldb/test/API/python_api/find_in_memory/TestFindInMemory.py (-131) - (removed) lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py (-221) - (removed) lldb/test/API/python_api/find_in_memory/address_ranges_helper.py (-72) - (removed) lldb/test/API/python_api/find_in_memory/main.cpp (-27) ``diff diff --git a/lldb/bindings/python/python-typemaps.swig b/lldb/bindings/python/python-typemaps.swig index f8c33e15c03e6..c39594c7df041 100644 --- a/lldb/bindings/python/python-typemaps.swig +++ b/lldb/bindings/python/python-typemaps.swig @@ -257,8 +257,7 @@ AND call SWIG_fail at the same time, because it will result in a double free. } // For SBProcess::WriteMemory, SBTarget::GetInstructions and SBDebugger::DispatchInput. %typemap(in) (const void *buf, size_t size), - (const void *data, size_t data_len), - (const void *buf, uint64_t size) { + (const void *data, size_t data_len) { if (PythonString::Check($input)) { PythonString str(PyRefType::Borrowed, $input); $1 = (void *)str.GetString().data(); diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index a6ab7ae759918..f1b5d1fb92ce2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -209,16 +209,6 @@ class LLDB_API SBProcess { lldb::addr_t ReadPointerFromMemory(addr_t addr, lldb::SBError &error); - lldb::SBAddressRangeList FindRangesInMemory(const void *buf, uint64_t size, - const SBAddressRangeList &ranges, - uint32_t alignment, - uint32_t max_matches, - SBError &error); - - lldb::addr_t FindInMemory(const void *buf, uint64_t size, -const SBAddressRange &range, uint32_t alignment, -SBError &error); - // Events static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event); diff --git a/lldb/include/lldb/Core/AddressRangeListImpl.h b/lldb/include/lldb/Core/AddressRangeListImpl.h index 6742e6ead87de..46ebfe73d4d92 100644 --- a/lldb/include/lldb/Core/AddressRangeListImpl.h +++ b/lldb/include/lldb/Core/AddressRangeListImpl.h @@ -13,9 +13,7 @@ #include namespace lldb { -class SBAddressRangeList; class SBBlock; -class SBProcess; } namespace lldb_private { @@ -41,9 +39,7 @@ class AddressRangeListImpl { lldb_private::AddressRange GetAddressRangeAtIndex(size_t index); private: - friend class lldb::SBAddressRangeList; friend class lldb::SBBlock; - friend class lldb::SBProcess; AddressRanges &ref(); diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index ceaf547ebddaf..eec337c15f7ed 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -2685,15 +2685,6 @@ void PruneThreadPlans(); lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high, const uint8_t *buf, size_t size); - AddressRanges FindRangesInMemory(const uint8_t *buf, uint64_t size, - const AddressRanges &ranges, - size_t alignment, size_t max_matches, - Status &error); - - lldb::addr_t FindInMemory(const uint8_t *buf, uint64_t size, -const AddressRange &range, size_t alignment, -Status &error); - protected: friend class Trace; @@ -2809,11 +2800,6 @@ void PruneThreadPlans(); virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error) = 0; - virtual void DoFindInMemory(lldb::addr_t start_addr, lldb::addr_t end_addr, - const uint8_t *buf, size_t size, - AddressRanges &matches, size_t alignment, - size_t max_matches); - /// DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has /// removed non address bits from load_addr. Override this method
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Add 64b support to LLDB's minidump file builder. (PR #95312)
Jlalond wrote: @petrhosek because it's just going to be a change to something like `size_t`, would you mind if I just did a quick commit to fix this and assign you as the reviewer? https://github.com/llvm/llvm-project/pull/95312 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][Minidum] Change expected directories to the correct type; size_t (PR #96564)
https://github.com/Jlalond created https://github.com/llvm/llvm-project/pull/96564 In !95312 I incorrectly set `m_expected_directories` to uint, this broke the windows build and is the incorrect type. `size_t` is more accurate because this value only ever represents the expected upper bound of the directory vector. >From d675ccf2313d6605c28357029e4a2014a9591dcd Mon Sep 17 00:00:00 2001 From: Jacob Lalonde Date: Mon, 24 Jun 2024 14:51:03 -0700 Subject: [PATCH] Change expected directories to the correct type; size_t --- lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp | 2 +- lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp index 7a09c6104d08c..de212c6b20da7 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp @@ -109,7 +109,7 @@ Status MinidumpFileBuilder::AddDirectory(StreamType type, if (m_directories.size() + 1 > m_expected_directories) { error.SetErrorStringWithFormat( "Unable to add directory for stream type %x, exceeded expected number " -"of directories %d.", +"of directories %zu.", (uint32_t)type, m_expected_directories); return error; } diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h index b606f925f9912..20564e0661f2a 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h @@ -146,7 +146,7 @@ class MinidumpFileBuilder { lldb_private::DataBufferHeap m_data; lldb::ProcessSP m_process_sp; - uint m_expected_directories = 0; + size_t m_expected_directories = 0; uint64_t m_saved_data_size = 0; lldb::offset_t m_thread_list_start = 0; // We set the max write amount to 128 mb, this is arbitrary ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][Minidump] Change expected directories to the correct type; size_t (PR #96564)
https://github.com/Jlalond edited https://github.com/llvm/llvm-project/pull/96564 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][Minidump] Change expected directories to the correct type; size_t (PR #96564)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jacob Lalonde (Jlalond) Changes In !95312 I incorrectly set `m_expected_directories` to uint, this broke the windows build and is the incorrect type. `size_t` is more accurate because this value only ever represents the expected upper bound of the directory vector. --- Full diff: https://github.com/llvm/llvm-project/pull/96564.diff 2 Files Affected: - (modified) lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp (+1-1) - (modified) lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h (+1-1) ``diff diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp index 7a09c6104d08c..de212c6b20da7 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp @@ -109,7 +109,7 @@ Status MinidumpFileBuilder::AddDirectory(StreamType type, if (m_directories.size() + 1 > m_expected_directories) { error.SetErrorStringWithFormat( "Unable to add directory for stream type %x, exceeded expected number " -"of directories %d.", +"of directories %zu.", (uint32_t)type, m_expected_directories); return error; } diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h index b606f925f9912..20564e0661f2a 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h @@ -146,7 +146,7 @@ class MinidumpFileBuilder { lldb_private::DataBufferHeap m_data; lldb::ProcessSP m_process_sp; - uint m_expected_directories = 0; + size_t m_expected_directories = 0; uint64_t m_saved_data_size = 0; lldb::offset_t m_thread_list_start = 0; // We set the max write amount to 128 mb, this is arbitrary `` https://github.com/llvm/llvm-project/pull/96564 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][Minidump] Change expected directories to the correct type; size_t (PR #96564)
https://github.com/petrhosek approved this pull request. Thanks for a quick fix! https://github.com/llvm/llvm-project/pull/96564 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix tests for FindInMemory SB API introduced in #95007. (PR #96565)
https://github.com/mbucko created https://github.com/llvm/llvm-project/pull/96565 None >From b19c3daa8eb513eac9de77f9348b25035bdd9697 Mon Sep 17 00:00:00 2001 From: Miro Bucko Date: Mon, 24 Jun 2024 17:54:05 -0400 Subject: [PATCH] [lldb] Fix tests for FindInMemory SB API introduced in #95007. --- .../find_in_memory/TestFindInMemory.py| 25 ++- .../find_in_memory/address_ranges_helper.py | 3 ++- .../API/python_api/find_in_memory/main.cpp| 21 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py index 4a459c47bcc02..9ab4619b1f8f4 100644 --- a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py +++ b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py @@ -21,10 +21,33 @@ def setUp(self): self.thread, self.bp, ) = lldbutil.run_to_source_breakpoint( -self, "break here", lldb.SBFileSpec("main.cpp") +self, +"break here", +lldb.SBFileSpec("main.cpp"), ) self.assertTrue(self.bp.IsValid()) +def test_check_stack_pointer(self): +"""Make sure the 'stack_pointer' variable lives on the stack""" +self.assertTrue(self.process, PROCESS_IS_VALID) +self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) + +frame = self.thread.GetSelectedFrame() +ex = frame.EvaluateExpression("&stack_pointer") +variable_region = lldb.SBMemoryRegionInfo() +self.assertTrue( +self.process.GetMemoryRegionInfo( +ex.GetValueAsUnsigned(), variable_region +).Success(), +) + +stack_region = lldb.SBMemoryRegionInfo() +self.assertTrue( +self.process.GetMemoryRegionInfo(frame.GetSP(), stack_region).Success(), +) + +self.assertEqual(variable_region, stack_region) + def test_find_in_memory_ok(self): """Make sure a match exists in the heap memory and the right address ranges are provided""" self.assertTrue(self.process, PROCESS_IS_VALID) diff --git a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py index 2c11fba80766f..810fb9fee3861 100644 --- a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py +++ b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py @@ -15,7 +15,7 @@ def GetAlignedRange(test_base): def GetStackRange(test_base): frame = test_base.thread.GetSelectedFrame() -ex = frame.EvaluateExpression("stack_pointer") +ex = frame.EvaluateExpression("&stack_pointer") test_base.assertTrue(ex.IsValid()) return GetRangeFromAddrValue(test_base, ex) @@ -35,6 +35,7 @@ def GetRangeFromAddrValue(test_base, addr): ) test_base.assertTrue(region.IsReadable()) +test_base.assertFalse(region.IsExecutable()) address_start = lldb.SBAddress(region.GetRegionBase(), test_base.target) stack_size = region.GetRegionEnd() - region.GetRegionBase() diff --git a/lldb/test/API/python_api/find_in_memory/main.cpp b/lldb/test/API/python_api/find_in_memory/main.cpp index 98d378cb48b84..bb23ddd7389dd 100644 --- a/lldb/test/API/python_api/find_in_memory/main.cpp +++ b/lldb/test/API/python_api/find_in_memory/main.cpp @@ -1,10 +1,10 @@ -#include #include +#include #include int main() { // Stack - const char *stack_pointer = "stack_there_is_only_one_of_me"; + const char stack_pointer[] = "stack_there_is_only_one_of_me"; // Heap const std::string heap_string1("heap_there_is_exactly_two_of_me"); @@ -14,14 +14,25 @@ int main() { // Aligned Heap constexpr char aligned_string[] = "i_am_unaligned_string_on_the_heap"; + constexpr size_t buffer_size = 100; constexpr size_t len = sizeof(aligned_string) + 1; // Allocate memory aligned to 8-byte boundary - void *aligned_string_ptr = aligned_alloc(8, len); + void *aligned_string_ptr = new size_t[buffer_size]; + if (aligned_string_ptr == nullptr) { +return -1; + } + // Zero out the memory + memset(aligned_string_ptr, 0, buffer_size); + + // Align the pointer to a multiple of 8 bytes + size_t size = buffer_size; + aligned_string_ptr = std::align(8, len, aligned_string_ptr, size); + + // Copy the string to aligned memory memcpy(aligned_string_ptr, aligned_string, len); (void)stack_pointer; (void)heap_pointer1; - (void)heap_pointer2; - (void)aligned_string_ptr; // break here + (void)heap_pointer2; // break here return 0; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix tests for FindInMemory SB API introduced in #95007. (PR #96565)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Miro Bucko (mbucko) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/96565.diff 3 Files Affected: - (modified) lldb/test/API/python_api/find_in_memory/TestFindInMemory.py (+24-1) - (modified) lldb/test/API/python_api/find_in_memory/address_ranges_helper.py (+2-1) - (modified) lldb/test/API/python_api/find_in_memory/main.cpp (+16-5) ``diff diff --git a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py index 4a459c47bcc02..9ab4619b1f8f4 100644 --- a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py +++ b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py @@ -21,10 +21,33 @@ def setUp(self): self.thread, self.bp, ) = lldbutil.run_to_source_breakpoint( -self, "break here", lldb.SBFileSpec("main.cpp") +self, +"break here", +lldb.SBFileSpec("main.cpp"), ) self.assertTrue(self.bp.IsValid()) +def test_check_stack_pointer(self): +"""Make sure the 'stack_pointer' variable lives on the stack""" +self.assertTrue(self.process, PROCESS_IS_VALID) +self.assertState(self.process.GetState(), lldb.eStateStopped, PROCESS_STOPPED) + +frame = self.thread.GetSelectedFrame() +ex = frame.EvaluateExpression("&stack_pointer") +variable_region = lldb.SBMemoryRegionInfo() +self.assertTrue( +self.process.GetMemoryRegionInfo( +ex.GetValueAsUnsigned(), variable_region +).Success(), +) + +stack_region = lldb.SBMemoryRegionInfo() +self.assertTrue( +self.process.GetMemoryRegionInfo(frame.GetSP(), stack_region).Success(), +) + +self.assertEqual(variable_region, stack_region) + def test_find_in_memory_ok(self): """Make sure a match exists in the heap memory and the right address ranges are provided""" self.assertTrue(self.process, PROCESS_IS_VALID) diff --git a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py index 2c11fba80766f..810fb9fee3861 100644 --- a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py +++ b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py @@ -15,7 +15,7 @@ def GetAlignedRange(test_base): def GetStackRange(test_base): frame = test_base.thread.GetSelectedFrame() -ex = frame.EvaluateExpression("stack_pointer") +ex = frame.EvaluateExpression("&stack_pointer") test_base.assertTrue(ex.IsValid()) return GetRangeFromAddrValue(test_base, ex) @@ -35,6 +35,7 @@ def GetRangeFromAddrValue(test_base, addr): ) test_base.assertTrue(region.IsReadable()) +test_base.assertFalse(region.IsExecutable()) address_start = lldb.SBAddress(region.GetRegionBase(), test_base.target) stack_size = region.GetRegionEnd() - region.GetRegionBase() diff --git a/lldb/test/API/python_api/find_in_memory/main.cpp b/lldb/test/API/python_api/find_in_memory/main.cpp index 98d378cb48b84..bb23ddd7389dd 100644 --- a/lldb/test/API/python_api/find_in_memory/main.cpp +++ b/lldb/test/API/python_api/find_in_memory/main.cpp @@ -1,10 +1,10 @@ -#include #include +#include #include int main() { // Stack - const char *stack_pointer = "stack_there_is_only_one_of_me"; + const char stack_pointer[] = "stack_there_is_only_one_of_me"; // Heap const std::string heap_string1("heap_there_is_exactly_two_of_me"); @@ -14,14 +14,25 @@ int main() { // Aligned Heap constexpr char aligned_string[] = "i_am_unaligned_string_on_the_heap"; + constexpr size_t buffer_size = 100; constexpr size_t len = sizeof(aligned_string) + 1; // Allocate memory aligned to 8-byte boundary - void *aligned_string_ptr = aligned_alloc(8, len); + void *aligned_string_ptr = new size_t[buffer_size]; + if (aligned_string_ptr == nullptr) { +return -1; + } + // Zero out the memory + memset(aligned_string_ptr, 0, buffer_size); + + // Align the pointer to a multiple of 8 bytes + size_t size = buffer_size; + aligned_string_ptr = std::align(8, len, aligned_string_ptr, size); + + // Copy the string to aligned memory memcpy(aligned_string_ptr, aligned_string, len); (void)stack_pointer; (void)heap_pointer1; - (void)heap_pointer2; - (void)aligned_string_ptr; // break here + (void)heap_pointer2; // break here return 0; } `` https://github.com/llvm/llvm-project/pull/96565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a32b719 - Revert commits that add `TestFind(Ranges)InMemory.py` (#96560)
Author: Chelsea Cassanova Date: 2024-06-24T15:12:49-07:00 New Revision: a32b7199f0c15ea1c6c9490b6166c019c9d4bd2b URL: https://github.com/llvm/llvm-project/commit/a32b7199f0c15ea1c6c9490b6166c019c9d4bd2b DIFF: https://github.com/llvm/llvm-project/commit/a32b7199f0c15ea1c6c9490b6166c019c9d4bd2b.diff LOG: Revert commits that add `TestFind(Ranges)InMemory.py` (#96560) Reverting to unblock macOS buildbots which are currently failing on these tests. https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6377/ Added: Modified: lldb/bindings/python/python-typemaps.swig lldb/include/lldb/API/SBProcess.h lldb/include/lldb/Core/AddressRangeListImpl.h lldb/include/lldb/Target/Process.h lldb/source/API/SBProcess.cpp lldb/source/Target/Process.cpp Removed: lldb/test/API/python_api/find_in_memory/Makefile lldb/test/API/python_api/find_in_memory/TestFindInMemory.py lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py lldb/test/API/python_api/find_in_memory/address_ranges_helper.py lldb/test/API/python_api/find_in_memory/main.cpp diff --git a/lldb/bindings/python/python-typemaps.swig b/lldb/bindings/python/python-typemaps.swig index f8c33e15c03e6..c39594c7df041 100644 --- a/lldb/bindings/python/python-typemaps.swig +++ b/lldb/bindings/python/python-typemaps.swig @@ -257,8 +257,7 @@ AND call SWIG_fail at the same time, because it will result in a double free. } // For SBProcess::WriteMemory, SBTarget::GetInstructions and SBDebugger::DispatchInput. %typemap(in) (const void *buf, size_t size), - (const void *data, size_t data_len), - (const void *buf, uint64_t size) { + (const void *data, size_t data_len) { if (PythonString::Check($input)) { PythonString str(PyRefType::Borrowed, $input); $1 = (void *)str.GetString().data(); diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index a6ab7ae759918..f1b5d1fb92ce2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -209,16 +209,6 @@ class LLDB_API SBProcess { lldb::addr_t ReadPointerFromMemory(addr_t addr, lldb::SBError &error); - lldb::SBAddressRangeList FindRangesInMemory(const void *buf, uint64_t size, - const SBAddressRangeList &ranges, - uint32_t alignment, - uint32_t max_matches, - SBError &error); - - lldb::addr_t FindInMemory(const void *buf, uint64_t size, -const SBAddressRange &range, uint32_t alignment, -SBError &error); - // Events static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event); diff --git a/lldb/include/lldb/Core/AddressRangeListImpl.h b/lldb/include/lldb/Core/AddressRangeListImpl.h index 6742e6ead87de..46ebfe73d4d92 100644 --- a/lldb/include/lldb/Core/AddressRangeListImpl.h +++ b/lldb/include/lldb/Core/AddressRangeListImpl.h @@ -13,9 +13,7 @@ #include namespace lldb { -class SBAddressRangeList; class SBBlock; -class SBProcess; } namespace lldb_private { @@ -41,9 +39,7 @@ class AddressRangeListImpl { lldb_private::AddressRange GetAddressRangeAtIndex(size_t index); private: - friend class lldb::SBAddressRangeList; friend class lldb::SBBlock; - friend class lldb::SBProcess; AddressRanges &ref(); diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index ceaf547ebddaf..eec337c15f7ed 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -2685,15 +2685,6 @@ void PruneThreadPlans(); lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high, const uint8_t *buf, size_t size); - AddressRanges FindRangesInMemory(const uint8_t *buf, uint64_t size, - const AddressRanges &ranges, - size_t alignment, size_t max_matches, - Status &error); - - lldb::addr_t FindInMemory(const uint8_t *buf, uint64_t size, -const AddressRange &range, size_t alignment, -Status &error); - protected: friend class Trace; @@ -2809,11 +2800,6 @@ void PruneThreadPlans(); virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error) = 0; - virtual void DoFindInMemory(lldb::addr_t start_addr, lldb::addr_t end_addr, - const uint8_t *buf, size_t size, - AddressRanges &matches, size_t alignment, - size_t max_matches); - /// DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has /// re
[Lldb-commits] [lldb] Revert commits that add `TestFind(Ranges)InMemory.py` (PR #96560)
https://github.com/chelcassanova closed https://github.com/llvm/llvm-project/pull/96560 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Parse and display register field enums (PR #95768)
https://github.com/bulbazord commented: I'm a bit late to the party, I was out sick last week. :p I think I understand this change and it looks fine to me overall. One thing I noticed is that a lot of things that could be considered errors are only written to the logs and then are silently glossed over. That information is contained only within these parse functions, so it can't really be percolated back up and displayed to developers in any meaningful way. From a developer's perspective, something may just not work because the debug stub gave you invalid data and only by hunting in the logs can you determine what went wrong. Perhaps this could be changed (not in this PR) to return not only the parsed data but also some error information? Like some union of (ParsedData, ParsingErrors) and the callers can determine what to do with the error? The error could then be surfaced back in a meaningful way, like "hey the server gave me some bunk data so pretty-printing registers might look weird". What do you think? https://github.com/llvm/llvm-project/pull/95768 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Parse and display register field enums (PR #95768)
https://github.com/bulbazord edited https://github.com/llvm/llvm-project/pull/95768 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Parse and display register field enums (PR #95768)
@@ -4179,21 +4179,124 @@ struct GdbServerTargetInfo { RegisterSetMap reg_set_map; }; -static std::vector ParseFlagsFields(XMLNode flags_node, - unsigned size) { +static FieldEnum::Enumerators ParseEnumEvalues(const XMLNode &enum_node) { + Log *log(GetLog(GDBRLog::Process)); + // We will use the last instance of each value. Also we preserve the order + // of declaration in the XML, as it may not be numerical. + std::map enumerators; bulbazord wrote: Do we know the density of the keys here? Might be a good candidate for `llvm::IndexedMap`? https://github.com/llvm/llvm-project/pull/95768 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung edited https://github.com/llvm/llvm-project/pull/95821 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix tests for FindInMemory SB API introduced in #95007. (PR #96565)
https://github.com/clayborg commented: Just add a description to what this test had wrong, what is fixed and any other needed details and this should be good to go https://github.com/llvm/llvm-project/pull/96565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 9452bd574023a7aef75b609d36e0ffac68e1e03d Mon Sep 17 00:00:00 2001 From: Sayhaan Siddiqui Date: Mon, 17 Jun 2024 11:11:07 -0700 Subject: [PATCH 01/21] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20?= =?UTF-8?q?changes=20to=20main=20this=20commit=20is=20based=20on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 [skip ci] --- bolt/include/bolt/Rewrite/DWARFRewriter.h | 4 +- bolt/lib/Core/BinaryEmitter.cpp | 1 + bolt/lib/Rewrite/DWARFRewriter.cpp| 61 ++--- clang/include/clang/Driver/Options.td | 4 + clang/lib/Driver/ToolChains/Gnu.cpp | 29 +++ cross-project-tests/lit.cfg.py| 14 +- cross-project-tests/lit.site.cfg.py.in| 4 + lldb/test/API/lit.cfg.py | 5 + lldb/test/API/lit.site.cfg.py.in | 8 + lldb/test/Shell/helper/toolchain.py | 5 + lldb/test/Shell/lit.site.cfg.py.in| 9 + llvm/CMakeLists.txt | 4 + llvm/include/llvm/MC/MCFragment.h | 22 ++ llvm/include/llvm/MC/MCObjectStreamer.h | 2 + llvm/include/llvm/MC/MCStreamer.h | 6 + llvm/lib/MC/MCAssembler.cpp | 118 ++ llvm/lib/MC/MCExpr.cpp| 10 +- llvm/lib/MC/MCFragment.cpp| 12 + llvm/lib/MC/MCObjectStreamer.cpp | 5 + llvm/lib/MC/MCStreamer.cpp| 2 + .../lib/Target/X86/AsmParser/X86AsmParser.cpp | 24 ++ llvm/test/MC/X86/directive-avoid_end_align.s | 208 ++ 22 files changed, 483 insertions(+), 74 deletions(-) create mode 100644 llvm/test/MC/X86/directive-avoid_end_align.s diff --git a/bolt/include/bolt/Rewrite/DWARFRewriter.h b/bolt/include/bolt/Rewrite/DWARFRewriter.h index 8dec32de9008e..3cc9d823c815b 100644 --- a/bolt/include/bolt/Rewrite/DWARFRewriter.h +++ b/bolt/include/bolt/Rewrite/DWARFRewriter.h @@ -12,6 +12,7 @@ #include "bolt/Core/DIEBuilder.h" #include "bolt/Core/DebugData.h" #include "bolt/Core/DebugNames.h" +#include "bolt/Core/GDBIndex.h" #include "llvm/ADT/StringRef.h" #include "llvm/CodeGen/DIE.h" #include "llvm/DWP/DWP.h" @@ -131,7 +132,8 @@ class DWARFRewriter { makeFinalLocListsSection(DWARFVersion Version); /// Finalize type sections in the main binary. - CUOffsetMap finalizeTypeSections(DIEBuilder &DIEBlder, DIEStreamer &Streamer); + CUOffsetMap finalizeTypeSections(DIEBuilder &DIEBlder, DIEStreamer &Streamer, + GDBIndex &GDBIndexSection); /// Process and write out CUs that are passsed in. void finalizeCompileUnits(DIEBuilder &DIEBlder, DIEStreamer &Streamer, diff --git a/bolt/lib/Core/BinaryEmitter.cpp b/bolt/lib/Core/BinaryEmitter.cpp index 5793963f9b80d..c231fffa0d5ff 100644 --- a/bolt/lib/Core/BinaryEmitter.cpp +++ b/bolt/lib/Core/BinaryEmitter.cpp @@ -487,6 +487,7 @@ void BinaryEmitter::emitFunctionBody(BinaryFunction &BF, FunctionFragment &FF, // This assumes the second instruction in the macro-op pair will get // assigned to its own MCRelaxableFragment. Since all JCC instructions // are relaxable, we should be safe. +Streamer.emitNeverAlignCodeAtEnd(/*Alignment to avoid=*/64, *BC.STI); } if (!EmitCodeOnly) { diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp index 8814ebbd10aa5..7b62999dfb2b6 100644 --- a/bolt/lib/Rewrite/DWARFRewriter.cpp +++ b/bolt/lib/Rewrite/DWARFRewriter.cpp @@ -185,6 +185,7 @@ namespace bolt { class DIEStreamer : public DwarfStreamer { DIEBuilder *DIEBldr; DWARFRewriter &Rewriter; + GDBIndex &GDBIndexSection; private: /// Emit the compilation unit header for \p Unit in the debug_info @@ -247,7 +248,7 @@ class DIEStreamer : public DwarfStreamer { const uint64_t TypeSignature = cast(Unit).getTypeHash(); DIE *TypeDIE = DIEBldr->getTypeDIE(Unit); const DIEBuilder::DWARFUnitInfo &UI = DIEBldr->getUnitInfoByDwarfUnit(Unit); -Rewriter.addGDBTypeUnitEntry( +GDBIndexSection.addGDBTypeUnitEntry( {UI.UnitOffset, TypeSignature, TypeDIE->getOffset()}); if (Unit.getVersion() < 5) { // Switch the section to .debug_types section. @@ -279,11 +280,12 @@ class DIEStreamer : public DwarfStreamer { public: DIEStreamer(DIEBuilder *DIEBldr, DWARFRewriter &Rewriter, + GDBIndex &GDBIndexSection, DWARFLinkerBase::OutputFileType OutFileType, raw_pwrite_stream &OutFile, DWARFLinkerBase::MessageHandlerTy Warning) : DwarfStreamer(OutFileType, OutFile, Warning), DIEBldr(DIEBldr), -Rewriter(Rewriter){}; +Rewriter(Rewriter), GDBIndexSection(GDBIndexSection) {}; using DwarfStreamer::emitCompileUnitHeader; @@ -326,12 +328,11 @@ static
[Lldb-commits] [clang] [lldb] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung closed https://github.com/llvm/llvm-project/pull/95821 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][Minidump] Change expected directories to the correct type; size_t (PR #96564)
https://github.com/Jlalond edited https://github.com/llvm/llvm-project/pull/96564 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Add 64b support to LLDB's minidump file builder. (PR #95312)
Jlalond wrote: Fixed uint issue in #96564 https://github.com/llvm/llvm-project/pull/95312 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix tests for FindInMemory SB API introduced in #95007. (PR #96565)
https://github.com/mbucko closed https://github.com/llvm/llvm-project/pull/96565 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [BOLT] Hash-based function matching (PR #95821)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `bolt-x86_64-ubuntu-shared` running on `bolt-worker` while building `bolt` at step 5 "build-bolt". Full details are available at: https://lab.llvm.org/buildbot/#/builders/151/builds/367 Here is the relevant piece of the build log for the reference: ``` Step 5 (build-bolt) failure: build (failure) ... 1.012 [10/6/12] Linking CXX shared library lib/libLLVMBOLTTargetX86.so.19.0git 1.018 [9/6/13] Creating library symlink lib/libLLVMBOLTTargetAArch64.so 1.018 [9/5/14] Creating library symlink lib/libLLVMBOLTTargetX86.so 1.019 [9/4/15] Creating library symlink lib/libLLVMBOLTTargetRISCV.so 1.026 [9/3/16] Linking CXX shared library lib/libLLVMBOLTPasses.so.19.0git 1.032 [8/3/17] Creating library symlink lib/libLLVMBOLTPasses.so 1.058 [7/3/18] Linking CXX shared library lib/libLLVMBOLTRuntimeLibs.so.19.0git 1.064 [6/3/19] Creating library symlink lib/libLLVMBOLTRuntimeLibs.so 6.552 [6/2/20] Building CXX object tools/bolt/lib/Profile/CMakeFiles/LLVMBOLTProfile.dir/YAMLProfileReader.cpp.o 6.586 [5/2/21] Linking CXX shared library lib/libLLVMBOLTProfile.so.19.0git FAILED: lib/libLLVMBOLTProfile.so.19.0git : && /usr/bin/c++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=lld -Wl,--color-diagnostics -Wl,--gc-sections -shared -Wl,-soname,libLLVMBOLTProfile.so.19.0git -o lib/libLLVMBOLTProfile.so.19.0git tools/bolt/lib/Profile/CMakeFiles/LLVMBOLTProfile.dir/BoltAddressTranslation.cpp.o tools/bolt/lib/Profile/CMakeFiles/LLVMBOLTProfile.dir/DataAggregator.cpp.o tools/bolt/lib/Profile/CMakeFiles/LLVMBOLTProfile.dir/DataReader.cpp.o tools/bolt/lib/Profile/CMakeFiles/LLVMBOLTProfile.dir/Heatmap.cpp.o tools/bolt/lib/Profile/CMakeFiles/LLVMBOLTProfile.dir/StaleProfileMatching.cpp.o tools/bolt/lib/Profile/CMakeFiles/LLVMBOLTProfile.dir/YAMLProfileReader.cpp.o tools/bolt/lib/Profile/CMakeFiles/LLVMBOLTProfile.dir/YAMLProfileWriter.cpp.o -Wl,-rpath,"\$ORIGIN/../lib:/home/worker/bolt-worker2/bolt-x86_64-ubuntu-shared/build/lib:" lib/libLLVMBOLTCore.so.19.0git lib/libLLVMBOLTUtils.so.19.0git lib/libLLVMTransformUtils.so.19.0git lib/libLLVMSupport.so.19.0git -Wl,-rpath-link,/home/worker/bolt-worker2/bolt-x86_64-ubuntu-shared/build/lib && : ld.lld: error: undefined symbol: opts::Lite >>> referenced by YAMLProfileReader.cpp >>> >>> tools/bolt/lib/Profile/CMakeFiles/LLVMBOLTProfile.dir/YAMLProfileReader.cpp.o:(llvm::bolt::YAMLProfileReader::readProfile(llvm::bolt::BinaryContext&) >>> (.localalias)) collect2: error: ld returned 1 exit status 19.429 [5/1/22] Building CXX object tools/bolt/lib/Rewrite/CMakeFiles/LLVMBOLTRewrite.dir/RewriteInstance.cpp.o ninja: build stopped: subcommand failed. ``` https://github.com/llvm/llvm-project/pull/95821 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][API] Add Find(Ranges)InMemory() to Process SB API (PR #96569)
https://github.com/mbucko created https://github.com/llvm/llvm-project/pull/96569 This is a second attempt to land #95007 Test Plan: llvm-lit llvm-project/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py llvm-project/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py Reviewers: clayborg Tasks: lldb >From fd0cd8dbfda45125d94e1a3db4e2ecf022e0456f Mon Sep 17 00:00:00 2001 From: Miro Bucko Date: Tue, 4 Jun 2024 12:01:48 -0700 Subject: [PATCH] [lldb][API] Add Find(Ranges)InMemory() to Process SB API This is a second attempt to land #95007 Test Plan: llvm-lit llvm-project/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py llvm-project/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py Reviewers: clayborg Tasks: lldb --- lldb/bindings/python/python-typemaps.swig | 3 +- lldb/include/lldb/API/SBProcess.h | 10 + lldb/include/lldb/Core/AddressRangeListImpl.h | 4 + lldb/include/lldb/Target/Process.h| 14 ++ lldb/source/API/SBProcess.cpp | 58 - lldb/source/Target/Process.cpp| 123 ++ .../API/python_api/find_in_memory/Makefile| 3 + .../find_in_memory/TestFindInMemory.py| 154 .../find_in_memory/TestFindRangesInMemory.py | 221 ++ .../find_in_memory/address_ranges_helper.py | 73 ++ .../API/python_api/find_in_memory/main.cpp| 38 +++ 11 files changed, 695 insertions(+), 6 deletions(-) create mode 100644 lldb/test/API/python_api/find_in_memory/Makefile create mode 100644 lldb/test/API/python_api/find_in_memory/TestFindInMemory.py create mode 100644 lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py create mode 100644 lldb/test/API/python_api/find_in_memory/address_ranges_helper.py create mode 100644 lldb/test/API/python_api/find_in_memory/main.cpp diff --git a/lldb/bindings/python/python-typemaps.swig b/lldb/bindings/python/python-typemaps.swig index c39594c7df041..f8c33e15c03e6 100644 --- a/lldb/bindings/python/python-typemaps.swig +++ b/lldb/bindings/python/python-typemaps.swig @@ -257,7 +257,8 @@ AND call SWIG_fail at the same time, because it will result in a double free. } // For SBProcess::WriteMemory, SBTarget::GetInstructions and SBDebugger::DispatchInput. %typemap(in) (const void *buf, size_t size), - (const void *data, size_t data_len) { + (const void *data, size_t data_len), + (const void *buf, uint64_t size) { if (PythonString::Check($input)) { PythonString str(PyRefType::Borrowed, $input); $1 = (void *)str.GetString().data(); diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index f1b5d1fb92ce2..a6ab7ae759918 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -209,6 +209,16 @@ class LLDB_API SBProcess { lldb::addr_t ReadPointerFromMemory(addr_t addr, lldb::SBError &error); + lldb::SBAddressRangeList FindRangesInMemory(const void *buf, uint64_t size, + const SBAddressRangeList &ranges, + uint32_t alignment, + uint32_t max_matches, + SBError &error); + + lldb::addr_t FindInMemory(const void *buf, uint64_t size, +const SBAddressRange &range, uint32_t alignment, +SBError &error); + // Events static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event); diff --git a/lldb/include/lldb/Core/AddressRangeListImpl.h b/lldb/include/lldb/Core/AddressRangeListImpl.h index 46ebfe73d4d92..6742e6ead87de 100644 --- a/lldb/include/lldb/Core/AddressRangeListImpl.h +++ b/lldb/include/lldb/Core/AddressRangeListImpl.h @@ -13,7 +13,9 @@ #include namespace lldb { +class SBAddressRangeList; class SBBlock; +class SBProcess; } namespace lldb_private { @@ -39,7 +41,9 @@ class AddressRangeListImpl { lldb_private::AddressRange GetAddressRangeAtIndex(size_t index); private: + friend class lldb::SBAddressRangeList; friend class lldb::SBBlock; + friend class lldb::SBProcess; AddressRanges &ref(); diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index eec337c15f7ed..ceaf547ebddaf 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -2685,6 +2685,15 @@ void PruneThreadPlans(); lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high, const uint8_t *buf, size_t size); + AddressRanges FindRangesInMemory(const uint8_t *buf, uint64_t size, + const AddressRanges &ranges, + size_t alignment, size_t max_matches, + Status &error); + + lldb::addr_t FindInMemory(const uint8_t *buf, uint64_t size, +
[Lldb-commits] [lldb] [lldb][API] Add Find(Ranges)InMemory() to Process SB API (PR #96569)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Miro Bucko (mbucko) Changes This is a second attempt to land #95007 Test Plan: llvm-lit llvm-project/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py llvm-project/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py Reviewers: clayborg Tasks: lldb --- Patch is 29.31 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/96569.diff 11 Files Affected: - (modified) lldb/bindings/python/python-typemaps.swig (+2-1) - (modified) lldb/include/lldb/API/SBProcess.h (+10) - (modified) lldb/include/lldb/Core/AddressRangeListImpl.h (+4) - (modified) lldb/include/lldb/Target/Process.h (+14) - (modified) lldb/source/API/SBProcess.cpp (+53-5) - (modified) lldb/source/Target/Process.cpp (+123) - (added) lldb/test/API/python_api/find_in_memory/Makefile (+3) - (added) lldb/test/API/python_api/find_in_memory/TestFindInMemory.py (+154) - (added) lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py (+221) - (added) lldb/test/API/python_api/find_in_memory/address_ranges_helper.py (+73) - (added) lldb/test/API/python_api/find_in_memory/main.cpp (+38) ``diff diff --git a/lldb/bindings/python/python-typemaps.swig b/lldb/bindings/python/python-typemaps.swig index c39594c7df041..f8c33e15c03e6 100644 --- a/lldb/bindings/python/python-typemaps.swig +++ b/lldb/bindings/python/python-typemaps.swig @@ -257,7 +257,8 @@ AND call SWIG_fail at the same time, because it will result in a double free. } // For SBProcess::WriteMemory, SBTarget::GetInstructions and SBDebugger::DispatchInput. %typemap(in) (const void *buf, size_t size), - (const void *data, size_t data_len) { + (const void *data, size_t data_len), + (const void *buf, uint64_t size) { if (PythonString::Check($input)) { PythonString str(PyRefType::Borrowed, $input); $1 = (void *)str.GetString().data(); diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index f1b5d1fb92ce2..a6ab7ae759918 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -209,6 +209,16 @@ class LLDB_API SBProcess { lldb::addr_t ReadPointerFromMemory(addr_t addr, lldb::SBError &error); + lldb::SBAddressRangeList FindRangesInMemory(const void *buf, uint64_t size, + const SBAddressRangeList &ranges, + uint32_t alignment, + uint32_t max_matches, + SBError &error); + + lldb::addr_t FindInMemory(const void *buf, uint64_t size, +const SBAddressRange &range, uint32_t alignment, +SBError &error); + // Events static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event); diff --git a/lldb/include/lldb/Core/AddressRangeListImpl.h b/lldb/include/lldb/Core/AddressRangeListImpl.h index 46ebfe73d4d92..6742e6ead87de 100644 --- a/lldb/include/lldb/Core/AddressRangeListImpl.h +++ b/lldb/include/lldb/Core/AddressRangeListImpl.h @@ -13,7 +13,9 @@ #include namespace lldb { +class SBAddressRangeList; class SBBlock; +class SBProcess; } namespace lldb_private { @@ -39,7 +41,9 @@ class AddressRangeListImpl { lldb_private::AddressRange GetAddressRangeAtIndex(size_t index); private: + friend class lldb::SBAddressRangeList; friend class lldb::SBBlock; + friend class lldb::SBProcess; AddressRanges &ref(); diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index eec337c15f7ed..ceaf547ebddaf 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -2685,6 +2685,15 @@ void PruneThreadPlans(); lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high, const uint8_t *buf, size_t size); + AddressRanges FindRangesInMemory(const uint8_t *buf, uint64_t size, + const AddressRanges &ranges, + size_t alignment, size_t max_matches, + Status &error); + + lldb::addr_t FindInMemory(const uint8_t *buf, uint64_t size, +const AddressRange &range, size_t alignment, +Status &error); + protected: friend class Trace; @@ -2800,6 +2809,11 @@ void PruneThreadPlans(); virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error) = 0; + virtual void DoFindInMemory(lldb::addr_t start_addr, lldb::addr_t end_addr, + const uint8_t *buf, size_t size, + AddressRanges &matches, size_t alignment, + size_t max_matches); + /// DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has
[Lldb-commits] [lldb] [lldb][API] Add Find(Ranges)InMemory() to Process SB API (PR #96569)
https://github.com/mbucko updated https://github.com/llvm/llvm-project/pull/96569 >From 6b1720e9e93d20eecbade7d63d8c2ae5e671c440 Mon Sep 17 00:00:00 2001 From: Miro Bucko Date: Tue, 4 Jun 2024 12:01:48 -0700 Subject: [PATCH] [lldb][API] Add Find(Ranges)InMemory() to Process SB API This is a second attempt to land #95007 Test Plan: llvm-lit llvm-project/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py llvm-project/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py Reviewers: clayborg Tasks: lldb --- lldb/bindings/python/python-typemaps.swig | 3 +- lldb/include/lldb/API/SBProcess.h | 10 + lldb/include/lldb/Core/AddressRangeListImpl.h | 4 + lldb/include/lldb/Target/Process.h| 14 ++ lldb/source/API/SBProcess.cpp | 58 - lldb/source/Target/Process.cpp| 123 ++ .../API/python_api/find_in_memory/Makefile| 3 + .../find_in_memory/TestFindInMemory.py| 154 .../find_in_memory/TestFindRangesInMemory.py | 221 ++ .../find_in_memory/address_ranges_helper.py | 73 ++ .../API/python_api/find_in_memory/main.cpp| 40 11 files changed, 697 insertions(+), 6 deletions(-) create mode 100644 lldb/test/API/python_api/find_in_memory/Makefile create mode 100644 lldb/test/API/python_api/find_in_memory/TestFindInMemory.py create mode 100644 lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py create mode 100644 lldb/test/API/python_api/find_in_memory/address_ranges_helper.py create mode 100644 lldb/test/API/python_api/find_in_memory/main.cpp diff --git a/lldb/bindings/python/python-typemaps.swig b/lldb/bindings/python/python-typemaps.swig index c39594c7df041..f8c33e15c03e6 100644 --- a/lldb/bindings/python/python-typemaps.swig +++ b/lldb/bindings/python/python-typemaps.swig @@ -257,7 +257,8 @@ AND call SWIG_fail at the same time, because it will result in a double free. } // For SBProcess::WriteMemory, SBTarget::GetInstructions and SBDebugger::DispatchInput. %typemap(in) (const void *buf, size_t size), - (const void *data, size_t data_len) { + (const void *data, size_t data_len), + (const void *buf, uint64_t size) { if (PythonString::Check($input)) { PythonString str(PyRefType::Borrowed, $input); $1 = (void *)str.GetString().data(); diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index f1b5d1fb92ce2..a6ab7ae759918 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -209,6 +209,16 @@ class LLDB_API SBProcess { lldb::addr_t ReadPointerFromMemory(addr_t addr, lldb::SBError &error); + lldb::SBAddressRangeList FindRangesInMemory(const void *buf, uint64_t size, + const SBAddressRangeList &ranges, + uint32_t alignment, + uint32_t max_matches, + SBError &error); + + lldb::addr_t FindInMemory(const void *buf, uint64_t size, +const SBAddressRange &range, uint32_t alignment, +SBError &error); + // Events static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event); diff --git a/lldb/include/lldb/Core/AddressRangeListImpl.h b/lldb/include/lldb/Core/AddressRangeListImpl.h index 46ebfe73d4d92..6742e6ead87de 100644 --- a/lldb/include/lldb/Core/AddressRangeListImpl.h +++ b/lldb/include/lldb/Core/AddressRangeListImpl.h @@ -13,7 +13,9 @@ #include namespace lldb { +class SBAddressRangeList; class SBBlock; +class SBProcess; } namespace lldb_private { @@ -39,7 +41,9 @@ class AddressRangeListImpl { lldb_private::AddressRange GetAddressRangeAtIndex(size_t index); private: + friend class lldb::SBAddressRangeList; friend class lldb::SBBlock; + friend class lldb::SBProcess; AddressRanges &ref(); diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index eec337c15f7ed..ceaf547ebddaf 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -2685,6 +2685,15 @@ void PruneThreadPlans(); lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high, const uint8_t *buf, size_t size); + AddressRanges FindRangesInMemory(const uint8_t *buf, uint64_t size, + const AddressRanges &ranges, + size_t alignment, size_t max_matches, + Status &error); + + lldb::addr_t FindInMemory(const uint8_t *buf, uint64_t size, +const AddressRange &range, size_t alignment, +Status &error); + protected: friend class Trace; @@ -2800,6 +2809,11 @@ void PruneThreadPlans(); virtual size_t DoReadMemory(lldb::addr_t vm_add
[Lldb-commits] [lldb] [lldb][API] Add Find(Ranges)InMemory() to Process SB API (PR #96569)
https://github.com/clayborg approved this pull request. https://github.com/llvm/llvm-project/pull/96569 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0d4da0d - [lldb][API] Add Find(Ranges)InMemory() to Process SB API (#96569)
Author: Miro Bucko Date: 2024-06-24T18:51:12-04:00 New Revision: 0d4da0df166ea7512c6e97e182b21cd706293eaa URL: https://github.com/llvm/llvm-project/commit/0d4da0df166ea7512c6e97e182b21cd706293eaa DIFF: https://github.com/llvm/llvm-project/commit/0d4da0df166ea7512c6e97e182b21cd706293eaa.diff LOG: [lldb][API] Add Find(Ranges)InMemory() to Process SB API (#96569) This is a second attempt to land #95007 Test Plan: llvm-lit llvm-project/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py llvm-project/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py Reviewers: clayborg Tasks: lldb Added: lldb/test/API/python_api/find_in_memory/Makefile lldb/test/API/python_api/find_in_memory/TestFindInMemory.py lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py lldb/test/API/python_api/find_in_memory/address_ranges_helper.py lldb/test/API/python_api/find_in_memory/main.cpp Modified: lldb/bindings/python/python-typemaps.swig lldb/include/lldb/API/SBProcess.h lldb/include/lldb/Core/AddressRangeListImpl.h lldb/include/lldb/Target/Process.h lldb/source/API/SBProcess.cpp lldb/source/Target/Process.cpp Removed: diff --git a/lldb/bindings/python/python-typemaps.swig b/lldb/bindings/python/python-typemaps.swig index c39594c7df041..f8c33e15c03e6 100644 --- a/lldb/bindings/python/python-typemaps.swig +++ b/lldb/bindings/python/python-typemaps.swig @@ -257,7 +257,8 @@ AND call SWIG_fail at the same time, because it will result in a double free. } // For SBProcess::WriteMemory, SBTarget::GetInstructions and SBDebugger::DispatchInput. %typemap(in) (const void *buf, size_t size), - (const void *data, size_t data_len) { + (const void *data, size_t data_len), + (const void *buf, uint64_t size) { if (PythonString::Check($input)) { PythonString str(PyRefType::Borrowed, $input); $1 = (void *)str.GetString().data(); diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index f1b5d1fb92ce2..a6ab7ae759918 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -209,6 +209,16 @@ class LLDB_API SBProcess { lldb::addr_t ReadPointerFromMemory(addr_t addr, lldb::SBError &error); + lldb::SBAddressRangeList FindRangesInMemory(const void *buf, uint64_t size, + const SBAddressRangeList &ranges, + uint32_t alignment, + uint32_t max_matches, + SBError &error); + + lldb::addr_t FindInMemory(const void *buf, uint64_t size, +const SBAddressRange &range, uint32_t alignment, +SBError &error); + // Events static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event); diff --git a/lldb/include/lldb/Core/AddressRangeListImpl.h b/lldb/include/lldb/Core/AddressRangeListImpl.h index 46ebfe73d4d92..6742e6ead87de 100644 --- a/lldb/include/lldb/Core/AddressRangeListImpl.h +++ b/lldb/include/lldb/Core/AddressRangeListImpl.h @@ -13,7 +13,9 @@ #include namespace lldb { +class SBAddressRangeList; class SBBlock; +class SBProcess; } namespace lldb_private { @@ -39,7 +41,9 @@ class AddressRangeListImpl { lldb_private::AddressRange GetAddressRangeAtIndex(size_t index); private: + friend class lldb::SBAddressRangeList; friend class lldb::SBBlock; + friend class lldb::SBProcess; AddressRanges &ref(); diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index eec337c15f7ed..ceaf547ebddaf 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -2685,6 +2685,15 @@ void PruneThreadPlans(); lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high, const uint8_t *buf, size_t size); + AddressRanges FindRangesInMemory(const uint8_t *buf, uint64_t size, + const AddressRanges &ranges, + size_t alignment, size_t max_matches, + Status &error); + + lldb::addr_t FindInMemory(const uint8_t *buf, uint64_t size, +const AddressRange &range, size_t alignment, +Status &error); + protected: friend class Trace; @@ -2800,6 +2809,11 @@ void PruneThreadPlans(); virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error) = 0; + virtual void DoFindInMemory(lldb::addr_t start_addr, lldb::addr_t end_addr, + const uint8_t *buf, size_t size, + AddressRanges &matches, size_t alignment, + size_t max_matches)
[Lldb-commits] [lldb] [lldb][API] Add Find(Ranges)InMemory() to Process SB API (PR #96569)
https://github.com/mbucko closed https://github.com/llvm/llvm-project/pull/96569 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)
jasonmolenda wrote: Thanks @AlexK0 ! After Pavel's suggestion, I need to do a minor bit of changes to the patch soon I think, for all platforms, so I'll see if this is easier to express in ProcessWindows that way. I've was thinking about @labath 's suggestion over the weekend and I agree that the way the patch is written today isn't ideal about tracking state at stop-time and resume-time, as I developed the change I had to change its behavior and I didn't rethink what I was doing. The original goal was: If we hit a breakpoint (whether it is enabled for this thread or not), when we Resume the thread, we silently instruction step past that breakpoint instruction before resuming. Then I realized the problem of "user sets a breakpoint at $pc, or changes $pc to a BreakpointSite" and I want to also silently step past the breakpoint in that case, so I added a separate variable to track that. Looking at the total requirements, the rule can be condensed to: If this thread stopped at a BreakpointSite which it did not execute, we should execute the breakpoint on Resume. In any other case, a thread sitting at a BreakpointSite should silently step past it and resume execution. So when a thread stops at a BreakpointSite that has executed (whether it is valid for this thread or not), we record nothing. When a thread stops at a BreakpointSite that has not executed, we need to record the address of that BreakpointSite. And on Resume, if the thread is still at this same address, we want to hit the breakpoint. I don't think we can store this information in the StopInfo easily, because a thread with no stop reason (e.g. a multi-threaded program that hits a breakpoint on one thread, but the others were executing normally) wouldn't have a way to record that they were sitting at a BreakpointSite that needed to be hit still. I outlined the idea of storing this data in the StopInfo to @jimingham earlier today briefly, and he agreed that we should have StopInfos around until we Resume, but I hadn't thought this through enough to account for threads with no stop reason. I'll check in with him about the details on this before I make the change, but I think I need to keep tracking this in the Thread object. https://github.com/llvm/llvm-project/pull/96260 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 361543e - [LLDB][Minidump] Change expected directories to the correct type; size_t (#96564)
Author: Jacob Lalonde Date: 2024-06-24T16:33:09-07:00 New Revision: 361543e4100defe14334cfb11481be44a977e627 URL: https://github.com/llvm/llvm-project/commit/361543e4100defe14334cfb11481be44a977e627 DIFF: https://github.com/llvm/llvm-project/commit/361543e4100defe14334cfb11481be44a977e627.diff LOG: [LLDB][Minidump] Change expected directories to the correct type; size_t (#96564) In #95312 I incorrectly set `m_expected_directories` to uint, this broke the windows build and is the incorrect type. `size_t` is more accurate because this value only ever represents the expected upper bound of the directory vector. Added: Modified: lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h Removed: diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp index 7a09c6104d08c..de212c6b20da7 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp @@ -109,7 +109,7 @@ Status MinidumpFileBuilder::AddDirectory(StreamType type, if (m_directories.size() + 1 > m_expected_directories) { error.SetErrorStringWithFormat( "Unable to add directory for stream type %x, exceeded expected number " -"of directories %d.", +"of directories %zu.", (uint32_t)type, m_expected_directories); return error; } diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h index b606f925f9912..20564e0661f2a 100644 --- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h +++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h @@ -146,7 +146,7 @@ class MinidumpFileBuilder { lldb_private::DataBufferHeap m_data; lldb::ProcessSP m_process_sp; - uint m_expected_directories = 0; + size_t m_expected_directories = 0; uint64_t m_saved_data_size = 0; lldb::offset_t m_thread_list_start = 0; // We set the max write amount to 128 mb, this is arbitrary ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][Minidump] Change expected directories to the correct type; size_t (PR #96564)
https://github.com/Jlalond closed https://github.com/llvm/llvm-project/pull/96564 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -216,6 +228,35 @@ u64 GetShadowCount(uptr p, u32 size) { return count; } +// Accumulates the access count from the shadow for the given pointer and size. +// See memprof_mapping.h for an overview on histogram counters. +u64 GetShadowCountHistogram(uptr p, u32 size) { + u8 *shadow = (u8 *)HISTOGRAM_MEM_TO_SHADOW(p); + u8 *shadow_end = (u8 *)HISTOGRAM_MEM_TO_SHADOW(p + size); + u64 count = 0; + for (; shadow <= shadow_end; shadow++) +count += *shadow; + return count; +} + +// If we use the normal approach from clearCountersWithoutHistogram, the +// histogram will clear too much data and may overwrite shadow counters that are +// in use. Likely because of rounding up the shadow_end pointer. +// See memprof_mapping.h for an overview on histogram counters. +void clearCountersHistogram(uptr addr, uptr size) { + u8 *shadow_8 = (u8 *)HISTOGRAM_MEM_TO_SHADOW(addr); + u8 *shadow_end_8 = (u8 *)HISTOGRAM_MEM_TO_SHADOW(addr + size); + for (; shadow_8 < shadow_end_8; shadow_8++) { +*shadow_8 = 0; + } +} + +void clearCountersWithoutHistogram(uptr addr, uptr size) { + uptr shadow_beg = MEM_TO_SHADOW(addr); + uptr shadow_end = MEM_TO_SHADOW(addr + size - SHADOW_GRANULARITY) + 1; + REAL(memset)((void *)shadow_beg, 0, shadow_end - shadow_beg); +} + // Clears the shadow counters (when memory is allocated). void ClearShadow(uptr addr, uptr size) { teresajohnson wrote: I guess it works, because the shadow granularities are less than the page size, and because they are both scaling by the same 8 to 1 scale, and also I guess because the clear_shadow_mmap_threshold is an optimization and doesn't need to be exact. However, it still feels a little wonky to me (and also means that we have to do extra mapping operations here and again in `clearCounters*`). I do think I would prefer to have it be something like: ``` uptr shadow_beg; uptr shadow_end; if (__memprof_histogram) { shadow_beg = HISTOGRAM_MEM_TO_SHADOW(addr); shadow_end = HISTOGRAM_MEM_TO_SHADOW(addr + size); } else { shadow_beg = MEM_TO_SHADOW(addr); shadow_end = MEM_TO_SHADOW(addr + size - SHADOW_GRANULARITY) + 1; } if (shadow_end - shadow_beg < common_flags()->clear_shadow_mmap_threshold) { REAL(memset)((void *)shadow_beg, 0, shadow_end - shadow_beg); } else { ... ``` I.e. set shadow_beg/end based on whether we are doing the histogramming or not, leave the rest as-is. Would that work? https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -96,19 +102,63 @@ llvm::SmallVector readSegmentEntries(const char *Ptr) { } llvm::SmallVector> -readMemInfoBlocks(const char *Ptr) { +readMemInfoBlocksV3(const char *Ptr) { using namespace support; const uint64_t NumItemsToRead = - endian::readNext(Ptr); + endian::readNext(Ptr); + llvm::SmallVector> Items; for (uint64_t I = 0; I < NumItemsToRead; I++) { const uint64_t Id = -endian::readNext(Ptr); -const MemInfoBlock MIB = *reinterpret_cast(Ptr); +endian::readNext(Ptr); + +// We cheat a bit here and remove the const from cast to set the +// Histogram Pointer to newly allocated buffer. We also cheat, since V3 and +// V4 do not have the same fields. V3 is missing AccessHistogramSize and +// AccessHistogram. This means we read "dirty" data in here, but it should +// not segfault, since there will be callstack data placed after this in the +// binary format. +MemInfoBlock MIB = *reinterpret_cast(Ptr); +// Overwrite dirty data. teresajohnson wrote: Oh yes you are right, I missed the first `*` which means it is making a copy of what was in the memory pointed to by Ptr. https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [Memprof] Adds the option to collect AccessCountHistograms for memprof. (PR #94264)
@@ -20,25 +20,25 @@ CHECK-NEXT: - CHECK: Records: CHECK-NEXT: - -CHECK-NEXT:FunctionGUID: 15505678318020221912 +CHECK-NEXT:FunctionGUID: 3873612792189045660 CHECK-NEXT:AllocSites: CHECK-NEXT:- CHECK-NEXT: Callstack: CHECK-NEXT: - -CHECK-NEXT:Function: 15505678318020221912 -CHECK-NEXT:SymbolName: qux +CHECK-NEXT:Function: 3873612792189045660 +CHECK-NEXT:SymbolName: _Z3quxi teresajohnson wrote: Not a problem, just struck me as odd since your patch shouldn't change. But like you said, probably some prior change was made that didn't require updating this test to get it to pass, and now those changes are showing up. https://github.com/llvm/llvm-project/pull/94264 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
cmtice wrote: > Haven't gone through this in detail yet (having an example of how these > structures will be used would be helpful), but something I was curious about > is whether this `DIL` is going to be used in the implementation of a new > command, or if we're going to extend the `frame var` language? I didn't see a > concrete conclusion on this in the RFC The plan is for the DIL implementation to eventually replace the current 'frame variable' command (see Milestone 1 in the implementation plan). Once that is done, it will be expanded to also replace calls to GetValueForExpressionPath, for parsing & handling pieces of LLDB's data formatters. I couldn't put the whole implementation into a single PR, as it would have been much too big to review (even some of the pieces are going to be pretty big). So I broke it up into: the helper functions (which have already been committed now); the AST (this PR); and then three more PR's, each one coming after the preceding one is approved: the DIL Parser (a recursive-descent parser), which constructs (and returns) the appropriate DIL AST; the DIL Evaluator, which takes a DIL AST, evaluates it in the current context (frame), and returns an appropriate ValueObjectSP; and the code to actually hook this up to the 'frame variable' command. I have the whole thing implemented (complete with test cases). If you really want to dig through the complete code, you can see it at https://github.com/cmtice/llvm-project/tree/DIL-work-new/ (note that I will be cleaning up the Parser & Evaluator code before actually being put into a PR). The current implementation there still has both implementations for 'frame variable' (original and DIL), and with 'original' being the default and 'DIL' being turned on by an option. https://github.com/llvm/llvm-project/pull/95738 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Add 64b support to LLDB's minidump file builder. (PR #95312)
vvereschaka wrote: Hi @Jlalond , here is still a problem with the window builds: ``` FAILED: tools/lldb/source/Plugins/ObjectFile/Minidump/CMakeFiles/lldbPluginObjectFileMinidump.dir/ObjectFileMinidump.cpp.obj ccache C:\PROGRA~1\LLVM\bin\clang-cl.exe /nologo -TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\source\Plugins\ObjectFile\Minidump -IC:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\source\Plugins\ObjectFile\Minidump -IC:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\include -IC:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\include -IC:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\include -IC:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\include -IC:\Users\tcwg\AppData\Local\Programs\Python\Python311-arm64\include -IC:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\llvm\..\clang\include -IC:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\..\clang\include -IC:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\source -IC:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\source /DWIN32 /D_WINDOWS /Zc:inline /Zc:__cplusplus /Oi /Brepro /bigobj /permissive- -Werror=unguarded-availability-new /W4 -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported /Gw -Wno-deprecated-register -Wno-vla-extension /O2 /Ob2 /DNDEBUG -MD -wd4018 -wd4068 -wd4150 -wd4201 -wd4251 -wd4521 -wd4530 -wd4589 /EHs-c- /GR- -std:c++17 /showIncludes /Fotools\lldb\source\Plugins\ObjectFile\Minidump\CMakeFiles\lldbPluginObjectFileMinidump.dir\ObjectFileMinidump.cpp.obj /Fdtools\lldb\source\Plugins\ObjectFile\Minidump\CMakeFiles\lldbPluginObjectFileMinidump.dir\lldbPluginObjectFileMinidump.pdb -c -- C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\source\Plugins\ObjectFile\Minidump\ObjectFileMinidump.cpp C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\source\Plugins\ObjectFile\Minidump\ObjectFileMinidump.cpp(21,10): fatal error: 'unistd.h' file not found 21 | #include | ^~ 1 error generated. ``` * https://lab.llvm.org/buildbot/#/builders/141/builds/266 * https://lab.llvm.org/buildbot/#/builders/141/builds/250 https://github.com/llvm/llvm-project/pull/95312 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply PR/87550 (again) (PR #95571)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/95571 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)
labath wrote: Thanks for the explanation, Jason. I believe I understand the problem now. Here, we're concerned with whether the physical breakpoint opcode got executed, and not about the higher level machinery (conditional breakpoints, ignore count, ...), which builds on top of that and can cause a breakpoint hit to "disappear". Since StopInfo tracks the "logical" stop reason of the process (after all of these filters are applied), using it to track the "physical" one would be tricky at best. > Looking at the total requirements, the rule can be condensed to: If this > thread stopped at a BreakpointSite which it did not execute, we should > execute the breakpoint on Resume. In any other case, a thread sitting at a > BreakpointSite should silently step past it and resume execution. So, IIUC, there would just be one field (the "unexecuted breakpoint site") instead of two. I'll take that, I think having just one field to think about would make it easier to understand the overall logic. https://github.com/llvm/llvm-project/pull/96260 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits