[Lldb-commits] [lldb] Add support for arm64 registers in minidump core file saving. (PR #72315)
antmox wrote: Thanks @clayborg, the buildbot is now green again : https://lab.llvm.org/buildbot/#/builders/219/builds/6947 https://github.com/llvm/llvm-project/pull/72315 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: DavidSpickett wrote: > This is new for me. Thank you! New to me too actually. I only went looking for it because I was going to suggest a two stage format like `%%%ds` and I got that feeling that someone must have solved this problem before. > In Stream.h, we tried to keep up with the file standard. Hence, the comments: Brilliant, yes it was on my list to check for these comments in fact. Keep them for sure. https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: @@ -231,6 +231,18 @@ class Stream { /// The string to be output to the stream. size_t PutCString(llvm::StringRef cstr); + /// Output a C string to the stream with color highlighting. + /// + /// Print a C string \a text to the stream, applying color highlighting to + /// the specified \a pattern within the string. + /// + /// \param[in] text + /// The string to be output to the stream. + /// + /// \param[in] pattern + /// The portion of the \a text string to be colorized for highlighting. DavidSpickett wrote: It should be noted that this is: * A regex pattern that is matched as many times as possible throughout the string. * If it is nullptr, then no highlighting is done. * The highlight colour is red. https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: @@ -163,7 +166,10 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, dumped_something = true; if (symbol->GetType() == eSymbolTypeTrampoline) s->PutCString("symbol stub for: "); - symbol->GetName().Dump(s); + if (pattern) +Address::DumpName(s, symbol->GetName().GetStringRef(), pattern); + else +symbol->GetName().Dump(s); DavidSpickett wrote: This one still needs fixing, can be one call to PutCString... I think. https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: @@ -231,6 +231,18 @@ class Stream { /// The string to be output to the stream. size_t PutCString(llvm::StringRef cstr); + /// Output a C string to the stream with color highlighting. + /// + /// Print a C string \a text to the stream, applying color highlighting to + /// the specified \a pattern within the string. DavidSpickett wrote: Maybe: Print a C string \a text to the stream, applying color highlighting to the portions of the string matched by the regex pattern \a pattern. Just to emphasise the regex nature of this. (someone may argue to call this parameter `re_pattern` as well, but don't change that now, only if later reviewers feel it's needed) https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: @@ -70,6 +72,32 @@ size_t Stream::PutCString(llvm::StringRef str) { return bytes_written; } +void Stream::PutCStringColorHighlighted(llvm::StringRef text, +const char *pattern) { + if (!pattern) { +PutCString(text.data()); +return; + } + + // If pattern is not nullptr, we should use color + llvm::Regex reg_pattern(pattern); + llvm::SmallVector matches; + llvm::StringRef remaining = text; + std::string format_str = lldb_private::ansi::FormatAnsiTerminalCodes( + "${ansi.fg.red}%s${ansi.normal}"); + size_t last_pos = 0; + while (reg_pattern.match(remaining, &matches)) { +llvm::StringRef match = matches[0]; +size_t match_start_pos = match.data() - remaining.data(); +Write(remaining.data(), match_start_pos); +Printf(format_str.c_str(), match.str().c_str()); DavidSpickett wrote: Oh clever, by using the match instead of the text itself you don't need the `.*s` dance. Good catch! https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
=?utf-8?q?Jos=C3=A9?= L. Junior Message-ID: In-Reply-To: @@ -70,6 +72,32 @@ size_t Stream::PutCString(llvm::StringRef str) { return bytes_written; } +void Stream::PutCStringColorHighlighted(llvm::StringRef text, +const char *pattern) { + if (!pattern) { +PutCString(text.data()); +return; + } + + // If pattern is not nullptr, we should use color + llvm::Regex reg_pattern(pattern); + llvm::SmallVector matches; + llvm::StringRef remaining = text; + std::string format_str = lldb_private::ansi::FormatAnsiTerminalCodes( + "${ansi.fg.red}%s${ansi.normal}"); + size_t last_pos = 0; + while (reg_pattern.match(remaining, &matches)) { +llvm::StringRef match = matches[0]; +size_t match_start_pos = match.data() - remaining.data(); +Write(remaining.data(), match_start_pos); +Printf(format_str.c_str(), match.str().c_str()); +last_pos = match_start_pos + match.size(); +remaining = remaining.drop_front(last_pos); + } + if (remaining.size()) +PutCString(remaining.data()); DavidSpickett wrote: Same here, don't need .data() https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: @@ -70,6 +72,32 @@ size_t Stream::PutCString(llvm::StringRef str) { return bytes_written; } +void Stream::PutCStringColorHighlighted(llvm::StringRef text, +const char *pattern) { + if (!pattern) { +PutCString(text.data()); DavidSpickett wrote: `size_t PutCString(llvm::StringRef cstr);` so you don't need the .data(); What likely happens is that .data gives you const char* and StringRef has a constructor from const char *, so it ends up back as a string ref. https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 35b10ac - [lldb][DWARFASTParserClang] DWARFv5: support DW_TAG_variable static data members declarations (#72236)
Author: Michael Buch Date: 2023-11-15T11:01:52Z New Revision: 35b10acf201ab873fab4423a37ae6dbe52591f6d URL: https://github.com/llvm/llvm-project/commit/35b10acf201ab873fab4423a37ae6dbe52591f6d DIFF: https://github.com/llvm/llvm-project/commit/35b10acf201ab873fab4423a37ae6dbe52591f6d.diff LOG: [lldb][DWARFASTParserClang] DWARFv5: support DW_TAG_variable static data members declarations (#72236) The accepted DWARFv5 issue 161118.1: "DW_TAG for C++ static data members" specifies that static data member declaration be described by DW_TAG_variable. Make sure we recognize such members. Depends on: * https://github.com/llvm/llvm-project/pull/72234 * https://github.com/llvm/llvm-project/pull/72235 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 f5628b2753da2a7..37efe70461977ad 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -144,7 +144,7 @@ static bool ShouldIgnoreArtificialField(llvm::StringRef FieldName) { std::optional DWARFASTParserClang::FindConstantOnVariableDefinition(DWARFDIE die) { - assert(die.Tag() == llvm::dwarf::DW_TAG_member); + assert(die.Tag() == DW_TAG_member || die.Tag() == DW_TAG_variable); auto *dwarf = die.GetDWARF(); if (!dwarf) @@ -2889,7 +2889,7 @@ void DWARFASTParserClang::CreateStaticMemberVariable( const DWARFDIE &die, const MemberAttributes &attrs, const lldb_private::CompilerType &class_clang_type) { Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups); - assert(die.Tag() == DW_TAG_member); + assert(die.Tag() == DW_TAG_member || die.Tag() == DW_TAG_variable); Type *var_type = die.ResolveTypeUID(attrs.encoding_form.Reference()); @@ -2965,6 +2965,7 @@ void DWARFASTParserClang::ParseSingleMember( // data members is DW_AT_declaration, so we check it instead. // FIXME: Since DWARFv5, static data members are marked DW_AT_variable so we // can consistently detect them on both GCC and Clang without below heuristic. + // Remove this block if we ever drop DWARFv4 support. if (attrs.member_byte_offset == UINT32_MAX && attrs.data_bit_offset == UINT64_MAX && attrs.is_declaration) { CreateStaticMemberVariable(die, attrs, class_clang_type); @@ -3195,6 +3196,10 @@ bool DWARFASTParserClang::ParseChildMembers( } break; +case DW_TAG_variable: { + const MemberAttributes attrs(die, parent_die, module_sp); + CreateStaticMemberVariable(die, attrs, class_clang_type); +} break; case DW_TAG_member: ParseSingleMember(die, parent_die, class_clang_type, default_accessibility, layout_info, last_field_info); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] DWARFv5: support DW_TAG_variable static data members declarations (PR #72236)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/72236 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
=?utf-8?q?José?= L. Junior Message-ID: In-Reply-To: DavidSpickett wrote: Guess I'm gonna take the 100th comment here :) This is almost ready for "proper" review (people that aren't me). So first thing is to address the few minor comments I have from this latest review round. Then, since there's so much discussion here already, you need to make it very clear that this is ready for review. So update the PR title and description with what you wish to be shown when the change is landed. The title of the first commit `[lldb] ` is fine (and thank you for including the tag!), just paste that into the PR title. For the body, describe how you've implemented the change and, if you can find it, note the feature request issue that originally started all this (if that's been lost it's fine, this is a good feature regardless). The description should also make it clear who worked on the patch. Given that @taalhaataahir0102 opened the PR, it will be landed with their address (unless changed), so you should add a co-author tag so that everyone gets the proper credit. This also goes into the PR description. See https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors. Then take the opportunity to squash your commits and rebase them onto the latest main branch. You will do fixup commits on top of this when other reviewers request changes, then the final set of commits will be squashed and the PR title/message is used as the commit message. Once you've done that, take the PR out of draft mode and as soon as I see that's done I'll add a comment with some context for reviewers and make sure it gets the right labeling and such. (I did consider making you open a new PR, but it is useful for reviewers to see what we have already discussed so let's just stay with this one, if people complain you can make a new one and blame me :) ) Thank you for sticking with this for as long as you have. Other reviewers will have more comments I'm sure, so don't get disheartened by that, you've already achieved a lot to get to this point. https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
=?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: https://github.com/taalhaataahir0102 updated https://github.com/llvm/llvm-project/pull/69422 >From 2c23aaf231beef11d3e0db6506fe82323a0be6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= Date: Tue, 7 Nov 2023 16:57:18 -0300 Subject: [PATCH 1/4] [lldb] colorize symbols in image lookup --- lldb/include/lldb/Core/Address.h | 7 ++- lldb/include/lldb/Symbol/Symbol.h | 4 +- lldb/include/lldb/Symbol/SymbolContext.h | 8 +-- lldb/source/Commands/CommandObjectTarget.cpp | 15 -- lldb/source/Core/Address.cpp | 53 --- lldb/source/Symbol/Symbol.cpp | 18 --- lldb/source/Symbol/SymbolContext.cpp | 16 -- .../Commands/command-image-lookup-color.test | 25 + 8 files changed, 114 insertions(+), 32 deletions(-) create mode 100644 lldb/test/Shell/Commands/command-image-lookup-color.test diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h index b19e694427546f8..fac0ced910a11d4 100644 --- a/lldb/include/lldb/Core/Address.h +++ b/lldb/include/lldb/Core/Address.h @@ -246,8 +246,11 @@ class Address { /// \see Address::DumpStyle bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style = DumpStyleInvalid, -uint32_t addr_byte_size = UINT32_MAX, -bool all_ranges = false) const; +uint32_t addr_byte_size = UINT32_MAX, bool all_ranges = false, +const char *pattern = nullptr) const; + + static void DumpName(Stream *strm, llvm::StringRef text, + const char *pattern = nullptr); AddressClass GetAddressClass() const; diff --git a/lldb/include/lldb/Symbol/Symbol.h b/lldb/include/lldb/Symbol/Symbol.h index 44a2d560010fe40..0e41cd95e0ef17d 100644 --- a/lldb/include/lldb/Symbol/Symbol.h +++ b/lldb/include/lldb/Symbol/Symbol.h @@ -174,8 +174,8 @@ class Symbol : public SymbolContextScope { void SetFlags(uint32_t flags) { m_flags = flags; } - void GetDescription(Stream *s, lldb::DescriptionLevel level, - Target *target) const; + void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target, + const char *pattern = nullptr) const; bool IsSynthetic() const { return m_is_synthetic; } diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h index b0f5ffead2a1656..9567c3f4384c175 100644 --- a/lldb/include/lldb/Symbol/SymbolContext.h +++ b/lldb/include/lldb/Symbol/SymbolContext.h @@ -150,8 +150,8 @@ class SymbolContext { bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, const Address &so_addr, bool show_fullpaths, bool show_module, bool show_inlined_frames, - bool show_function_arguments, - bool show_function_name) const; + bool show_function_arguments, bool show_function_name, + const char *pattern = nullptr) const; /// Get the address range contained within a symbol context. /// @@ -217,8 +217,8 @@ class SymbolContext { /// The symbol that was found, or \b nullptr if none was found. const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error); - void GetDescription(Stream *s, lldb::DescriptionLevel level, - Target *target) const; + void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target, + const char *pattern = nullptr) const; uint32_t GetResolvedMask() const; diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 8f052d0a7b837e2..a83575ad82d6909 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -8,6 +8,7 @@ #include "CommandObjectTarget.h" +#include "lldb/Core/Address.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/IOHandler.h" #include "lldb/Core/Module.h" @@ -1534,7 +1535,7 @@ static void DumpOsoFilesTable(Stream &strm, static void DumpAddress(ExecutionContextScope *exe_scope, const Address &so_addr, bool verbose, bool all_ranges, -Stream &strm) { +Stream &strm, const char *pattern = nullptr) { strm.IndentMore(); strm.Indent("Address: "); so_addr.Dump(&strm, exe_scope, Address::DumpStyleModuleWithFileAddress); @@ -1544,13 +1545,14 @@ static void DumpAddress(ExecutionContextScope *exe_scope, strm.Indent("Summary: "); const uint32_t save_indent = strm.GetIndentLevel(); strm.SetIndentLevel(save_indent + 13); - so_addr.Dump(&strm, exe_scope, Address::DumpStyleResolvedDescription); + so_addr.Dump(&strm, exe_scope, Address::DumpStyleResolvedDescription, +
[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)
=?utf-8?q?José?= L. Junior ,taalhaataahir0102 <23100...@lums.edu.pk> Message-ID: In-Reply-To: taalhaataahir0102 wrote: Hi David! Thanks, we'll update the required changes. Plus we just updated the test case: Previously added this in the input file: > So foo_bar would be matched twice by (foo|bar). Not sure if there's a symbol > in the program that'll fit that already. If not you could easily add one to > support this test case. But we realized it was failing some other test case (`Commands/command-breakpoint-col.test`) So we just used this technique instead: > You could even use main again. (ma|n\.o$). It might pick up other symbols so > just look for the main line and ignore anything else that comes up. We'll incorporate the rest of the feedback soon. ;) https://github.com/llvm/llvm-project/pull/69422 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [libcxx] [lldb] [compiler-rt] [libc] [clang] [clang-tools-extra] [llvm] ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) (PR #68620)
https://github.com/AaronBallman converted_to_draft https://github.com/llvm/llvm-project/pull/68620 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [mlir] [openmp] [libc] [clang] [libcxx] [flang] [llvm] [clang-tools-extra] GlobalISel: Guard return in llvm::getIConstantSplatVal (PR #71989)
@@ -1116,9 +1116,9 @@ std::optional llvm::getIConstantSplatVal(const Register Reg, const MachineRegisterInfo &MRI) { if (auto SplatValAndReg = getAnyConstantSplat(Reg, MRI, /* AllowUndef */ false)) { -std::optional ValAndVReg = -getIConstantVRegValWithLookThrough(SplatValAndReg->VReg, MRI); -return ValAndVReg->Value; +if (std::optional ValAndVReg = qcolombet wrote: @changpeng A comment here would be nice. E.g., "Even if the value is a splat constant, it may not be an integer one." https://github.com/llvm/llvm-project/pull/71989 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
zmodem wrote: We're seeing crashes after this. Here is a reproducer: https://bugs.chromium.org/p/chromium/issues/detail?id=1502489#c1 Please consider reverting if it can't be fixed quickly (I had a look, but it seems there are some dependent changes on top). https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
Michael137 wrote: > We're seeing crashes after this. Here is a reproducer: > https://bugs.chromium.org/p/chromium/issues/detail?id=1502489#c1 > > Please consider reverting if it can't be fixed quickly (I had a look, but it > seems there are some dependent changes on top). Thanks for reporting, will check and revert if not obvious what's wrong https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
Michael137 wrote: > > We're seeing crashes after this. Here is a reproducer: > > https://bugs.chromium.org/p/chromium/issues/detail?id=1502489#c1 > > Please consider reverting if it can't be fixed quickly (I had a look, but > > it seems there are some dependent changes on top). > > Thanks for reporting, will check and revert if not obvious what's wrong Just based on the backtrace the only cause I see would be if we put a nullptr into `StaticDataMemberDefinitionsToEmit`. We unconditionally dereference it. In which case the fix is pretty straightforward. Building a local debug build to confirm this theory. https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][DWARFASTParserClang] DWARFv5: support DW_TAG_variable static data members declarations (PR #72236)
@@ -2965,6 +2965,7 @@ void DWARFASTParserClang::ParseSingleMember( // data members is DW_AT_declaration, so we check it instead. // FIXME: Since DWARFv5, static data members are marked DW_AT_variable so we // can consistently detect them on both GCC and Clang without below heuristic. + // Remove this block if we ever drop DWARFv4 support. JDevlieghere wrote: FWIW this seems extremely unlikely. It doesn't really matter, but I would've just said that the next block is specific to DWARF4. https://github.com/llvm/llvm-project/pull/72236 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
Michael137 wrote: Ok with ASAN I could trigger this quite consistently. Turns out we can't iterate over the `StaticDataMemberDefinitionsToEmit` using a `for each` because during `EmitGlobalVariable` we can end up adding more things to the vector, invalidating the iterators. Will push a fix for this shortly https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Remove hardware index from watchpoints and breakpoints (PR #72012)
https://github.com/JDevlieghere approved this pull request. LGTM. I would've preferred to return something like `LLDB_INVALID_HARDWARE_INDEX` but as we're deprecating this, it doesn't seem worth adding another define for. https://github.com/llvm/llvm-project/pull/72012 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
Michael137 wrote: @zmodem Fix pushed in `14a84510f5d07b05b348188c7dfbe54076fa1485`. Your reproducer works fine for me now. Let me know if you're still seeing issues. https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Remove `self` references from decorators (PR #72416)
https://github.com/rupprecht created https://github.com/llvm/llvm-project/pull/72416 None >From b3178bb93c0d414857732b08228987894df762d4 Mon Sep 17 00:00:00 2001 From: Jordan Rupprecht Date: Wed, 15 Nov 2023 08:58:17 -0800 Subject: [PATCH] [lldb][test] Move most `self` references out of decorator skip checks. This is partial step toward removing the vendored `unittest2` dep in favor of the `unittest` library in standard python. One of the large differences is when xfail decorators are evaluated. With the `unittest2` vendored dep, this can happen at the moment of calling the test case, and with LLDB's decorator wrappers, we are passed the test class in the decorator arg. With the `unittest` framework, this is determined much earlier; we cannot decide when the test is about to start that we need to xfail. Fortunately, almost none of these checks require any state that can't be determined statically. For this patch, I moved the impl for all the checks to `lldbplatformutil` and pointed the decorators to that, removing as many `self` (i.e. test class object) references as possible. I left wrappers within `TestBase` that forward to `lldbplatformutil` for convenience, but we should probably remove those later. The remaining check that can't be moved statically is the check for the debug info type (e.g. to xfail only for dwarf). Fixing that requires a different approach, so I will postpone that to the next patch. --- .../Python/lldbsuite/test/decorators.py | 87 +++ .../Python/lldbsuite/test/lldbplatformutil.py | 146 +- .../Python/lldbsuite/test/lldbtest.py | 103 ++-- 3 files changed, 207 insertions(+), 129 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index b8fea1e02e864de..14328f3c54a8d1f 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -197,15 +197,17 @@ def _decorateTest( ): def fn(self): skip_for_os = _match_decorator_property( -lldbplatform.translate(oslist), self.getPlatform() +lldbplatform.translate(oslist), lldbplatformutil.getPlatform() ) skip_for_hostos = _match_decorator_property( lldbplatform.translate(hostoslist), lldbplatformutil.getHostPlatform() ) skip_for_compiler = _match_decorator_property( -compiler, self.getCompiler() -) and self.expectedCompilerVersion(compiler_version) -skip_for_arch = _match_decorator_property(archs, self.getArchitecture()) +compiler, lldbplatformutil.getCompiler() +) and lldbplatformutil.expectedCompilerVersion(compiler_version) +skip_for_arch = _match_decorator_property( +archs, lldbplatformutil.getArchitecture() +) skip_for_debug_info = _match_decorator_property(debug_info, self.getDebugInfo()) skip_for_triple = _match_decorator_property( triple, lldb.selected_platform.GetTriple() @@ -236,7 +238,7 @@ def fn(self): ) skip_for_dwarf_version = (dwarf_version is None) or ( _check_expected_version( -dwarf_version[0], dwarf_version[1], self.getDwarfVersion() +dwarf_version[0], dwarf_version[1], lldbplatformutil.getDwarfVersion() ) ) skip_for_setting = (setting is None) or (setting in configuration.settings) @@ -375,7 +377,9 @@ def skipIf( def _skip_for_android(reason, api_levels, archs): def impl(obj): result = lldbplatformutil.match_android_device( -obj.getArchitecture(), valid_archs=archs, valid_api_levels=api_levels +lldbplatformutil.getArchitecture(), +valid_archs=archs, +valid_api_levels=api_levels, ) return reason if result else None @@ -537,7 +541,10 @@ def wrapper(*args, **kwargs): def expectedFlakeyOS(oslist, bugnumber=None, compilers=None): def fn(self): -return self.getPlatform() in oslist and self.expectedCompiler(compilers) +return ( +lldbplatformutil.getPlatform() in oslist +and lldbplatformutil.expectedCompiler(compilers) +) return expectedFlakey(fn, bugnumber) @@ -618,9 +625,11 @@ def are_sb_headers_missing(): def skipIfRosetta(bugnumber): """Skip a test when running the testsuite on macOS under the Rosetta translation layer.""" -def is_running_rosetta(self): +def is_running_rosetta(): if lldbplatformutil.getPlatform() in ["darwin", "macosx"]: -if (platform.uname()[5] == "arm") and (self.getArchitecture() == "x86_64"): +if (platform.uname()[5] == "arm") and ( +lldbplatformutil.getArchitecture() == "x86_64" +): return "skipped under Rosetta" return None @@ -694,7 +703,7 @@ def skipIfWindows(func)
[Lldb-commits] [lldb] [lldb][test] Remove `self` references from decorators (PR #72416)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jordan Rupprecht (rupprecht) Changes --- Patch is 22.83 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/72416.diff 3 Files Affected: - (modified) lldb/packages/Python/lldbsuite/test/decorators.py (+53-34) - (modified) lldb/packages/Python/lldbsuite/test/lldbplatformutil.py (+145-1) - (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+9-94) ``diff diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index b8fea1e02e864de..14328f3c54a8d1f 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -197,15 +197,17 @@ def _decorateTest( ): def fn(self): skip_for_os = _match_decorator_property( -lldbplatform.translate(oslist), self.getPlatform() +lldbplatform.translate(oslist), lldbplatformutil.getPlatform() ) skip_for_hostos = _match_decorator_property( lldbplatform.translate(hostoslist), lldbplatformutil.getHostPlatform() ) skip_for_compiler = _match_decorator_property( -compiler, self.getCompiler() -) and self.expectedCompilerVersion(compiler_version) -skip_for_arch = _match_decorator_property(archs, self.getArchitecture()) +compiler, lldbplatformutil.getCompiler() +) and lldbplatformutil.expectedCompilerVersion(compiler_version) +skip_for_arch = _match_decorator_property( +archs, lldbplatformutil.getArchitecture() +) skip_for_debug_info = _match_decorator_property(debug_info, self.getDebugInfo()) skip_for_triple = _match_decorator_property( triple, lldb.selected_platform.GetTriple() @@ -236,7 +238,7 @@ def fn(self): ) skip_for_dwarf_version = (dwarf_version is None) or ( _check_expected_version( -dwarf_version[0], dwarf_version[1], self.getDwarfVersion() +dwarf_version[0], dwarf_version[1], lldbplatformutil.getDwarfVersion() ) ) skip_for_setting = (setting is None) or (setting in configuration.settings) @@ -375,7 +377,9 @@ def skipIf( def _skip_for_android(reason, api_levels, archs): def impl(obj): result = lldbplatformutil.match_android_device( -obj.getArchitecture(), valid_archs=archs, valid_api_levels=api_levels +lldbplatformutil.getArchitecture(), +valid_archs=archs, +valid_api_levels=api_levels, ) return reason if result else None @@ -537,7 +541,10 @@ def wrapper(*args, **kwargs): def expectedFlakeyOS(oslist, bugnumber=None, compilers=None): def fn(self): -return self.getPlatform() in oslist and self.expectedCompiler(compilers) +return ( +lldbplatformutil.getPlatform() in oslist +and lldbplatformutil.expectedCompiler(compilers) +) return expectedFlakey(fn, bugnumber) @@ -618,9 +625,11 @@ def are_sb_headers_missing(): def skipIfRosetta(bugnumber): """Skip a test when running the testsuite on macOS under the Rosetta translation layer.""" -def is_running_rosetta(self): +def is_running_rosetta(): if lldbplatformutil.getPlatform() in ["darwin", "macosx"]: -if (platform.uname()[5] == "arm") and (self.getArchitecture() == "x86_64"): +if (platform.uname()[5] == "arm") and ( +lldbplatformutil.getArchitecture() == "x86_64" +): return "skipped under Rosetta" return None @@ -694,7 +703,7 @@ def skipIfWindows(func): def skipIfWindowsAndNonEnglish(func): """Decorate the item to skip tests that should be skipped on non-English locales on Windows.""" -def is_Windows_NonEnglish(self): +def is_Windows_NonEnglish(): if sys.platform != "win32": return None kernel = ctypes.windll.kernel32 @@ -724,11 +733,15 @@ def skipUnlessTargetAndroid(func): def skipIfHostIncompatibleWithRemote(func): """Decorate the item to skip tests if binaries built on this host are incompatible.""" -def is_host_incompatible_with_remote(self): -host_arch = self.getLldbArchitecture() +def is_host_incompatible_with_remote(): +host_arch = lldbplatformutil.getLldbArchitecture() host_platform = lldbplatformutil.getHostPlatform() -target_arch = self.getArchitecture() -target_platform = "darwin" if self.platformIsDarwin() else self.getPlatform() +target_arch = lldbplatformutil.getArchitecture() +target_platform = ( +"darwin" +if lldbplatformutil.platformIsDarwin() +else lldbplatformutil.getPlatform() +) if ( not (target_arch == "x86_64" and host_arch == "i386") and h
[Lldb-commits] [lldb] [lldb][test] Remove `self` references from decorators (PR #72416)
https://github.com/rupprecht edited https://github.com/llvm/llvm-project/pull/72416 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/68845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
https://github.com/JDevlieghere approved this pull request. LGTM with a few nits. I like "constituents". This is a pretty big patch which makes reviewing it challenging. I know it's a big change that touches a lot of things but I'm sure that this could've been broken up into smaller patches if you keep that goal in mind from the beginning. Something to look out for in the future. https://github.com/llvm/llvm-project/pull/68845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
@@ -0,0 +1,235 @@ +//===-- StopPointSiteList.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Breakpoint/StopPointSiteList.h" +#include "lldb/Breakpoint/BreakpointSite.h" +#include "lldb/Breakpoint/WatchpointResource.h" + +#include "lldb/Utility/Stream.h" +#include + +using namespace lldb; +using namespace lldb_private; + +// Add site to the list. However, if the element already exists in +// the list, then we don't add it, and return InvalidSiteID. + +template +typename StopPointSite::SiteID +StopPointSiteList::Add(const StopPointSiteSP &site) { + lldb::addr_t site_load_addr = site->GetLoadAddress(); + std::lock_guard guard(m_mutex); + typename collection::iterator iter = m_site_list.find(site_load_addr); + + if (iter == m_site_list.end()) { +#if 0 +m_site_list.insert(iter, collection::value_type(site_load_addr, site)); +#endif +m_site_list[site_load_addr] = site; +return site->GetID(); + } else { +return UINT32_MAX; + } +} + +template +bool StopPointSiteList::ShouldStop( +StoppointCallbackContext *context, typename StopPointSite::SiteID site_id) { + StopPointSiteSP site_sp(FindByID(site_id)); + if (site_sp) { JDevlieghere wrote: ```if(StopPointSiteSP site_sp = FindByID(site_id))``` https://github.com/llvm/llvm-project/pull/68845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
@@ -0,0 +1,235 @@ +//===-- StopPointSiteList.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Breakpoint/StopPointSiteList.h" +#include "lldb/Breakpoint/BreakpointSite.h" +#include "lldb/Breakpoint/WatchpointResource.h" + +#include "lldb/Utility/Stream.h" +#include + +using namespace lldb; +using namespace lldb_private; + +// Add site to the list. However, if the element already exists in +// the list, then we don't add it, and return InvalidSiteID. + +template +typename StopPointSite::SiteID +StopPointSiteList::Add(const StopPointSiteSP &site) { + lldb::addr_t site_load_addr = site->GetLoadAddress(); + std::lock_guard guard(m_mutex); + typename collection::iterator iter = m_site_list.find(site_load_addr); + + if (iter == m_site_list.end()) { +#if 0 +m_site_list.insert(iter, collection::value_type(site_load_addr, site)); +#endif +m_site_list[site_load_addr] = site; +return site->GetID(); + } else { +return UINT32_MAX; + } +} + +template +bool StopPointSiteList::ShouldStop( +StoppointCallbackContext *context, typename StopPointSite::SiteID site_id) { + StopPointSiteSP site_sp(FindByID(site_id)); + if (site_sp) { +// Let the site decide if it should stop here (could not have +// reached it's target hit count yet, or it could have a callback that +// decided it shouldn't stop (shared library loads/unloads). +return site_sp->ShouldStop(context); + } + // We should stop here since this site isn't valid anymore or it + // doesn't exist. + return true; +} + +template +typename StopPointSite::SiteID +StopPointSiteList::FindIDByAddress(lldb::addr_t addr) { + if (StopPointSiteSP site = FindByAddress(addr)) +return site->GetID(); + return UINT32_MAX; +} + +template +bool StopPointSiteList::Remove( +typename StopPointSite::SiteID site_id) { + std::lock_guard guard(m_mutex); + typename collection::iterator pos = GetIDIterator(site_id); // Predicate + if (pos != m_site_list.end()) { +m_site_list.erase(pos); +return true; + } + return false; +} + +template +bool StopPointSiteList::RemoveByAddress(lldb::addr_t address) { + std::lock_guard guard(m_mutex); + typename collection::iterator pos = m_site_list.find(address); + if (pos != m_site_list.end()) { +m_site_list.erase(pos); +return true; + } + return false; +} + +template +typename StopPointSiteList::collection::iterator +StopPointSiteList::GetIDIterator( +typename StopPointSite::SiteID site_id) { + std::lock_guard guard(m_mutex); + auto id_matches = [site_id](const std::pair s) { +return site_id == s.second->GetID(); + }; + return std::find_if(m_site_list.begin(), + m_site_list.end(), // Search full range + id_matches); +} + +template +typename StopPointSiteList::collection::const_iterator +StopPointSiteList::GetIDConstIterator( +typename StopPointSite::SiteID site_id) const { + std::lock_guard guard(m_mutex); + auto id_matches = [site_id](const std::pair s) { +return site_id == s.second->GetID(); + }; + return std::find_if(m_site_list.begin(), + m_site_list.end(), // Search full range + id_matches); +} + +template +typename StopPointSiteList::StopPointSiteSP +StopPointSiteList::FindByID( +typename StopPointSite::SiteID site_id) { + std::lock_guard guard(m_mutex); + StopPointSiteSP stop_sp; + typename collection::iterator pos = GetIDIterator(site_id); + if (pos != m_site_list.end()) +stop_sp = pos->second; + + return stop_sp; +} + +template +const typename StopPointSiteList::StopPointSiteSP +StopPointSiteList::FindByID( +typename StopPointSite::SiteID site_id) const { + std::lock_guard guard(m_mutex); + StopPointSiteSP stop_sp; + typename collection::const_iterator pos = GetIDConstIterator(site_id); + if (pos != m_site_list.end()) +stop_sp = pos->second; + + return stop_sp; +} + +template +typename StopPointSiteList::StopPointSiteSP +StopPointSiteList::FindByAddress(lldb::addr_t addr) { + StopPointSiteSP found_sp; + std::lock_guard guard(m_mutex); + typename collection::iterator iter = m_site_list.find(addr); + if (iter != m_site_list.end()) +found_sp = iter->second; + return found_sp; +} + +// This method is only defined when we're specializing for +// BreakpointSite / BreakpointLocation / Breakpoint. +// Watchpoints don't have a similar structure, they are +// WatchpointResource / Watchpoint +template <> +bool StopPointSiteList::StopPointSiteContainsBreakpoint( +typename BreakpointSite::SiteID site_id, break_id_t bp_id) { + std::lock_guard guard(m_mutex); + typename collection::const_iterator p
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
@@ -0,0 +1,235 @@ +//===-- StopPointSiteList.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Breakpoint/StopPointSiteList.h" +#include "lldb/Breakpoint/BreakpointSite.h" +#include "lldb/Breakpoint/WatchpointResource.h" + +#include "lldb/Utility/Stream.h" +#include + +using namespace lldb; +using namespace lldb_private; + +// Add site to the list. However, if the element already exists in +// the list, then we don't add it, and return InvalidSiteID. + +template +typename StopPointSite::SiteID +StopPointSiteList::Add(const StopPointSiteSP &site) { + lldb::addr_t site_load_addr = site->GetLoadAddress(); + std::lock_guard guard(m_mutex); + typename collection::iterator iter = m_site_list.find(site_load_addr); + + if (iter == m_site_list.end()) { +#if 0 +m_site_list.insert(iter, collection::value_type(site_load_addr, site)); +#endif JDevlieghere wrote: Remove. https://github.com/llvm/llvm-project/pull/68845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
@@ -1787,30 +1788,48 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo( // addresses should be provided as \a wp_addr. StringExtractor desc_extractor(description.c_str()); addr_t wp_addr = desc_extractor.GetU64(LLDB_INVALID_ADDRESS); - uint32_t wp_index = desc_extractor.GetU32(LLDB_INVALID_INDEX32); + wp_resource_id_t wp_hw_index = + desc_extractor.GetU32(LLDB_INVALID_WATCHPOINT_RESOURCE_ID); addr_t wp_hit_addr = desc_extractor.GetU64(LLDB_INVALID_ADDRESS); watch_id_t watch_id = LLDB_INVALID_WATCH_ID; bool silently_continue = false; - WatchpointSP wp_sp; + WatchpointResourceSP wp_resource_sp; + if (wp_hw_index != LLDB_INVALID_WATCHPOINT_RESOURCE_ID) { +wp_resource_sp = m_watchpoint_resource_list.FindByID(wp_hw_index); +if (wp_resource_sp) { + // If we were given an access address, and the Resource we + // found by watchpoint register index does not contain that + // address, then the wp_resource_id's have not tracked the + // hardware watchpoint registers correctly, discard this + // Resource found by ID and look it up by access address. + if (wp_hit_addr != LLDB_INVALID_ADDRESS && + !wp_resource_sp->Contains(wp_hit_addr)) { +wp_resource_sp.reset(); + } +} + } if (wp_hit_addr != LLDB_INVALID_ADDRESS) { -wp_sp = GetTarget().GetWatchpointList().FindByAddress(wp_hit_addr); +wp_resource_sp = +m_watchpoint_resource_list.FindByAddress(wp_hit_addr); // On MIPS, \a wp_hit_addr outside the range of a watched // region means we should silently continue, it is a false hit. ArchSpec::Core core = GetTarget().GetArchitecture().GetCore(); -if (!wp_sp && core >= ArchSpec::kCore_mips_first && +if (!wp_resource_sp && core >= ArchSpec::kCore_mips_first && core <= ArchSpec::kCore_mips_last) silently_continue = true; } - if (!wp_sp && wp_addr != LLDB_INVALID_ADDRESS) -wp_sp = GetTarget().GetWatchpointList().FindByAddress(wp_addr); - if (wp_sp) { -wp_sp->SetHardwareIndex(wp_index); -watch_id = wp_sp->GetID(); - } - if (watch_id == LLDB_INVALID_WATCH_ID) { + if (!wp_resource_sp && wp_addr != LLDB_INVALID_ADDRESS) +wp_resource_sp = m_watchpoint_resource_list.FindByAddress(wp_addr); + if (!wp_resource_sp) { Log *log(GetLog(GDBRLog::Watchpoints)); LLDB_LOGF(log, "failed to find watchpoint"); +abort(); // LWP_TODO FIXME don't continue executing this block if JDevlieghere wrote: ?? https://github.com/llvm/llvm-project/pull/68845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
@@ -0,0 +1,235 @@ +//===-- StopPointSiteList.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Breakpoint/StopPointSiteList.h" +#include "lldb/Breakpoint/BreakpointSite.h" +#include "lldb/Breakpoint/WatchpointResource.h" + +#include "lldb/Utility/Stream.h" +#include + +using namespace lldb; +using namespace lldb_private; + +// Add site to the list. However, if the element already exists in +// the list, then we don't add it, and return InvalidSiteID. + +template +typename StopPointSite::SiteID +StopPointSiteList::Add(const StopPointSiteSP &site) { + lldb::addr_t site_load_addr = site->GetLoadAddress(); + std::lock_guard guard(m_mutex); + typename collection::iterator iter = m_site_list.find(site_load_addr); + + if (iter == m_site_list.end()) { +#if 0 +m_site_list.insert(iter, collection::value_type(site_load_addr, site)); +#endif +m_site_list[site_load_addr] = site; +return site->GetID(); + } else { +return UINT32_MAX; + } +} + +template +bool StopPointSiteList::ShouldStop( +StoppointCallbackContext *context, typename StopPointSite::SiteID site_id) { + StopPointSiteSP site_sp(FindByID(site_id)); + if (site_sp) { +// Let the site decide if it should stop here (could not have +// reached it's target hit count yet, or it could have a callback that +// decided it shouldn't stop (shared library loads/unloads). +return site_sp->ShouldStop(context); + } + // We should stop here since this site isn't valid anymore or it + // doesn't exist. + return true; +} + +template +typename StopPointSite::SiteID +StopPointSiteList::FindIDByAddress(lldb::addr_t addr) { + if (StopPointSiteSP site = FindByAddress(addr)) +return site->GetID(); + return UINT32_MAX; +} + +template +bool StopPointSiteList::Remove( +typename StopPointSite::SiteID site_id) { + std::lock_guard guard(m_mutex); + typename collection::iterator pos = GetIDIterator(site_id); // Predicate + if (pos != m_site_list.end()) { +m_site_list.erase(pos); +return true; + } + return false; +} + +template +bool StopPointSiteList::RemoveByAddress(lldb::addr_t address) { + std::lock_guard guard(m_mutex); + typename collection::iterator pos = m_site_list.find(address); + if (pos != m_site_list.end()) { +m_site_list.erase(pos); +return true; + } + return false; +} + +template +typename StopPointSiteList::collection::iterator +StopPointSiteList::GetIDIterator( +typename StopPointSite::SiteID site_id) { + std::lock_guard guard(m_mutex); + auto id_matches = [site_id](const std::pair s) { +return site_id == s.second->GetID(); + }; + return std::find_if(m_site_list.begin(), + m_site_list.end(), // Search full range + id_matches); +} + +template +typename StopPointSiteList::collection::const_iterator +StopPointSiteList::GetIDConstIterator( +typename StopPointSite::SiteID site_id) const { + std::lock_guard guard(m_mutex); + auto id_matches = [site_id](const std::pair s) { +return site_id == s.second->GetID(); + }; + return std::find_if(m_site_list.begin(), + m_site_list.end(), // Search full range + id_matches); +} + +template +typename StopPointSiteList::StopPointSiteSP +StopPointSiteList::FindByID( +typename StopPointSite::SiteID site_id) { + std::lock_guard guard(m_mutex); + StopPointSiteSP stop_sp; + typename collection::iterator pos = GetIDIterator(site_id); + if (pos != m_site_list.end()) +stop_sp = pos->second; + + return stop_sp; +} + +template +const typename StopPointSiteList::StopPointSiteSP +StopPointSiteList::FindByID( +typename StopPointSite::SiteID site_id) const { + std::lock_guard guard(m_mutex); + StopPointSiteSP stop_sp; + typename collection::const_iterator pos = GetIDConstIterator(site_id); + if (pos != m_site_list.end()) +stop_sp = pos->second; + + return stop_sp; +} + +template +typename StopPointSiteList::StopPointSiteSP +StopPointSiteList::FindByAddress(lldb::addr_t addr) { + StopPointSiteSP found_sp; + std::lock_guard guard(m_mutex); + typename collection::iterator iter = m_site_list.find(addr); + if (iter != m_site_list.end()) +found_sp = iter->second; + return found_sp; +} + +// This method is only defined when we're specializing for +// BreakpointSite / BreakpointLocation / Breakpoint. +// Watchpoints don't have a similar structure, they are +// WatchpointResource / Watchpoint +template <> +bool StopPointSiteList::StopPointSiteContainsBreakpoint( +typename BreakpointSite::SiteID site_id, break_id_t bp_id) { + std::lock_guard guard(m_mutex); + typename collection::const_iterator p
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
@@ -0,0 +1,235 @@ +//===-- StopPointSiteList.cpp -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Breakpoint/StopPointSiteList.h" +#include "lldb/Breakpoint/BreakpointSite.h" +#include "lldb/Breakpoint/WatchpointResource.h" + +#include "lldb/Utility/Stream.h" +#include + +using namespace lldb; +using namespace lldb_private; + +// Add site to the list. However, if the element already exists in +// the list, then we don't add it, and return InvalidSiteID. + +template +typename StopPointSite::SiteID +StopPointSiteList::Add(const StopPointSiteSP &site) { + lldb::addr_t site_load_addr = site->GetLoadAddress(); + std::lock_guard guard(m_mutex); + typename collection::iterator iter = m_site_list.find(site_load_addr); + + if (iter == m_site_list.end()) { +#if 0 +m_site_list.insert(iter, collection::value_type(site_load_addr, site)); +#endif +m_site_list[site_load_addr] = site; +return site->GetID(); + } else { +return UINT32_MAX; + } +} + +template +bool StopPointSiteList::ShouldStop( +StoppointCallbackContext *context, typename StopPointSite::SiteID site_id) { + StopPointSiteSP site_sp(FindByID(site_id)); + if (site_sp) { +// Let the site decide if it should stop here (could not have +// reached it's target hit count yet, or it could have a callback that +// decided it shouldn't stop (shared library loads/unloads). +return site_sp->ShouldStop(context); + } + // We should stop here since this site isn't valid anymore or it + // doesn't exist. + return true; +} + +template +typename StopPointSite::SiteID +StopPointSiteList::FindIDByAddress(lldb::addr_t addr) { + if (StopPointSiteSP site = FindByAddress(addr)) +return site->GetID(); + return UINT32_MAX; +} + +template +bool StopPointSiteList::Remove( +typename StopPointSite::SiteID site_id) { + std::lock_guard guard(m_mutex); + typename collection::iterator pos = GetIDIterator(site_id); // Predicate + if (pos != m_site_list.end()) { +m_site_list.erase(pos); +return true; + } + return false; +} + +template +bool StopPointSiteList::RemoveByAddress(lldb::addr_t address) { + std::lock_guard guard(m_mutex); + typename collection::iterator pos = m_site_list.find(address); + if (pos != m_site_list.end()) { +m_site_list.erase(pos); +return true; + } + return false; +} + +template +typename StopPointSiteList::collection::iterator +StopPointSiteList::GetIDIterator( +typename StopPointSite::SiteID site_id) { + std::lock_guard guard(m_mutex); + auto id_matches = [site_id](const std::pair s) { +return site_id == s.second->GetID(); + }; + return std::find_if(m_site_list.begin(), + m_site_list.end(), // Search full range + id_matches); +} + +template +typename StopPointSiteList::collection::const_iterator +StopPointSiteList::GetIDConstIterator( +typename StopPointSite::SiteID site_id) const { + std::lock_guard guard(m_mutex); + auto id_matches = [site_id](const std::pair s) { +return site_id == s.second->GetID(); + }; + return std::find_if(m_site_list.begin(), + m_site_list.end(), // Search full range + id_matches); +} + +template +typename StopPointSiteList::StopPointSiteSP +StopPointSiteList::FindByID( +typename StopPointSite::SiteID site_id) { + std::lock_guard guard(m_mutex); + StopPointSiteSP stop_sp; + typename collection::iterator pos = GetIDIterator(site_id); + if (pos != m_site_list.end()) +stop_sp = pos->second; + + return stop_sp; +} + +template +const typename StopPointSiteList::StopPointSiteSP +StopPointSiteList::FindByID( +typename StopPointSite::SiteID site_id) const { + std::lock_guard guard(m_mutex); + StopPointSiteSP stop_sp; + typename collection::const_iterator pos = GetIDConstIterator(site_id); + if (pos != m_site_list.end()) +stop_sp = pos->second; + + return stop_sp; +} + +template +typename StopPointSiteList::StopPointSiteSP +StopPointSiteList::FindByAddress(lldb::addr_t addr) { + StopPointSiteSP found_sp; + std::lock_guard guard(m_mutex); + typename collection::iterator iter = m_site_list.find(addr); + if (iter != m_site_list.end()) +found_sp = iter->second; + return found_sp; +} + +// This method is only defined when we're specializing for +// BreakpointSite / BreakpointLocation / Breakpoint. +// Watchpoints don't have a similar structure, they are +// WatchpointResource / Watchpoint +template <> +bool StopPointSiteList::StopPointSiteContainsBreakpoint( +typename BreakpointSite::SiteID site_id, break_id_t bp_id) { + std::lock_guard guard(m_mutex); + typename collection::const_iterator p
[Lldb-commits] [lldb] [llvm] [clang-tools-extra] [libcxx] [clang] [mlir] [compiler-rt] [lld] [libc] [flang] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)
@@ -61,6 +63,7 @@ registerAllGPUToLLVMIRTranslations(DialectRegistry ®istry) { registerLLVMDialectTranslation(registry); registerNVVMDialectTranslation(registry); registerROCDLDialectTranslation(registry); + registerSPIRVDialectTranslation(registry); silee2 wrote: @joker-eph Any thoughts on library vs inlining the call? https://github.com/llvm/llvm-project/pull/71430 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
zmodem wrote: Thanks! https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [llvm] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)
@@ -244,9 +245,38 @@ SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) { TargetSP target_sp(GetSP()); if (target_sp) { FileSpec filespec(core_file); -FileSystem::Instance().Resolve(filespec); +auto file = FileSystem::Instance().Open( +filespec, lldb_private::File::eOpenOptionReadOnly); +if (!file) { + error.SetErrorStringWithFormat("Failed to open the core file: %s", + llvm::toString(file.takeError()).c_str()); + return sb_process; +} +ProcessSP process_sp( +target_sp->CreateProcess(target_sp->GetDebugger().GetListener(), "", + std::move(file.get()), false)); +if (process_sp) { + error.SetError(process_sp->LoadCore()); + if (error.Success()) +sb_process.SetSP(process_sp); +} else { + error.SetErrorString("Failed to create the process"); +} + } else { +error.SetErrorString("SBTarget is invalid"); + } clayborg wrote: If we leave the Target::CreateProcess overload as suggested above, this entire change goes away. https://github.com/llvm/llvm-project/pull/71769 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [clang-tools-extra] [lldb] [clang] Add new API in SBTarget for loading core from SBFile (PR #71769)
@@ -627,7 +628,7 @@ class Target : public std::enable_shared_from_this, // used. const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener_sp, llvm::StringRef plugin_name, - const FileSpec *crash_file, + lldb::FileSP crash_file, bool can_connect); clayborg wrote: I think we can have two interfaces in Target.h: - the previous one that taks a "const FileSpec *" - the new one that takes a lldb::FileSP We have a 4 locations that have to manually create a file the code: ``` auto file = FileSystem::Instance().Open( filespec, lldb_private::File::eOpenOptionReadOnly); ... ``` This will also help reduce the number of changes in this patch. Then the version that takes a "const FileSpec *" can do the `FileSystem::Instance().Open(...)` and just call the other overload that takes a `lldb::FileSP` https://github.com/llvm/llvm-project/pull/71769 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Add new API in SBTarget for loading core from SBFile (PR #71769)
@@ -3174,8 +3174,17 @@ class TargetCreateFormDelegate : public FormDelegate { core_file_directory_spec.SetDirectory(core_file_spec.GetDirectory()); target_sp->AppendExecutableSearchPaths(core_file_directory_spec); -ProcessSP process_sp(target_sp->CreateProcess( -m_debugger.GetListener(), llvm::StringRef(), &core_file_spec, false)); +auto core_file = FileSystem::Instance().Open( +core_file_spec, lldb_private::File::eOpenOptionReadOnly); + +if (!core_file) { + SetError(llvm::toString(core_file.takeError()).c_str()); + return; +} + +ProcessSP process_sp( +target_sp->CreateProcess(m_debugger.GetListener(), llvm::StringRef(), + std::move(core_file.get()), false)); clayborg wrote: All of this goes away if we leave the original Target::CreateProcess overload as mentioned above. https://github.com/llvm/llvm-project/pull/71769 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [clang] [llvm] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)
https://github.com/clayborg requested changes to this pull request. https://github.com/llvm/llvm-project/pull/71769 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [llvm] [clang] Add new API in SBTarget for loading core from SBFile (PR #71769)
https://github.com/clayborg edited https://github.com/llvm/llvm-project/pull/71769 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [clang] [llvm] Add new API in SBTarget for loading core from SBFile (PR #71769)
@@ -194,11 +194,12 @@ void ProcessGDBRemote::Terminate() { PluginManager::UnregisterPlugin(ProcessGDBRemote::CreateInstance); } -lldb::ProcessSP ProcessGDBRemote::CreateInstance( -lldb::TargetSP target_sp, ListenerSP listener_sp, -const FileSpec *crash_file_path, bool can_connect) { +lldb::ProcessSP ProcessGDBRemote::CreateInstance(lldb::TargetSP target_sp, + ListenerSP listener_sp, + lldb::FileSP crash_file_sp, + bool can_connect) { lldb::ProcessSP process_sp; - if (crash_file_path == nullptr) + if (crash_file_sp) clayborg wrote: The logic is inverted from what it used to be, this should be: ``` if (!crash_file_sp) ``` https://github.com/llvm/llvm-project/pull/71769 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [lldb] [llvm] Add new API in SBTarget for loading core from SBFile (PR #71769)
@@ -427,8 +427,17 @@ class CommandObjectTargetCreate : public CommandObjectParsed { core_file_dir.SetDirectory(core_file.GetDirectory()); target_sp->AppendExecutableSearchPaths(core_file_dir); +auto file = FileSystem::Instance().Open( +core_file, lldb_private::File::eOpenOptionReadOnly); +if (!file) { + result.AppendErrorWithFormatv( + "Failed to open the core file '{0}': '{1}.'\n", + core_file.GetPath(), llvm::toString(file.takeError())); +} + ProcessSP process_sp(target_sp->CreateProcess( -GetDebugger().GetListener(), llvm::StringRef(), &core_file, false)); +GetDebugger().GetListener(), llvm::StringRef(), +std::move(file.get()), false)); clayborg wrote: All of this goes away if we leave the original Target::CreateProcess overload as mentioned above. https://github.com/llvm/llvm-project/pull/71769 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [llvm] [clang-tools-extra] [lldb] Add new API in SBTarget for loading core from SBFile (PR #71769)
@@ -102,10 +102,10 @@ void ProcessKDP::Terminate() { lldb::ProcessSP ProcessKDP::CreateInstance(TargetSP target_sp, ListenerSP listener_sp, - const FileSpec *crash_file_path, + FileSP crash_file_sp, bool can_connect) { lldb::ProcessSP process_sp; - if (crash_file_path == NULL) + if (crash_file_sp) clayborg wrote: The logic is inverted from what it used to be, this should be: ``` if (!crash_file_sp) ``` https://github.com/llvm/llvm-project/pull/71769 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Remove `self` references from decorators (PR #72416)
https://github.com/JDevlieghere approved this pull request. 👏 Thanks for doing this! https://github.com/llvm/llvm-project/pull/72416 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Remove `self` references from decorators (PR #72416)
@@ -184,3 +187,144 @@ def hasChattyStderr(test_case): ): return True # The dynamic linker on the device will complain about unknown DT entries return False + + +def builder_module(): +return get_builder(sys.platform) + + +def getArchitecture(): +"""Returns the architecture in effect the test suite is running with.""" +module = builder_module() +arch = module.getArchitecture() +if arch == "amd64": +arch = "x86_64" +if arch in ["armv7l", "armv8l"]: +arch = "arm" +return arch + + +lldbArchitecture = None + + +def getLldbArchitecture(): medismailben wrote: I think we can make an exception for lldb's casing here. ```suggestion def getLLDBArchitecture(): ``` https://github.com/llvm/llvm-project/pull/72416 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Remove `self` references from decorators (PR #72416)
@@ -1310,82 +1308,29 @@ def isAArch64Windows(self): def getArchitecture(self): """Returns the architecture in effect the test suite is running with.""" -module = builder_module() -arch = module.getArchitecture() -if arch == "amd64": -arch = "x86_64" -if arch in ["armv7l", "armv8l"]: -arch = "arm" -return arch +return lldbplatformutil.getArchitecture() def getLldbArchitecture(self): medismailben wrote: ```suggestion def getLLDBArchitecture(self): ``` https://github.com/llvm/llvm-project/pull/72416 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Remove `self` references from decorators (PR #72416)
@@ -1310,82 +1308,29 @@ def isAArch64Windows(self): def getArchitecture(self): """Returns the architecture in effect the test suite is running with.""" -module = builder_module() -arch = module.getArchitecture() -if arch == "amd64": -arch = "x86_64" -if arch in ["armv7l", "armv8l"]: -arch = "arm" -return arch +return lldbplatformutil.getArchitecture() def getLldbArchitecture(self): """Returns the architecture of the lldb binary.""" -if not hasattr(self, "lldbArchitecture"): -# These two target settings prevent lldb from doing setup that does -# nothing but slow down the end goal of printing the architecture. -command = [ -lldbtest_config.lldbExec, -"-x", -"-b", -"-o", -"settings set target.preload-symbols false", -"-o", -"settings set target.load-script-from-symbol-file false", -"-o", -"file " + lldbtest_config.lldbExec, -] - -output = check_output(command) -str = output.decode() - -for line in str.splitlines(): -m = re.search(r"Current executable set to '.*' \((.*)\)\.", line) -if m: -self.lldbArchitecture = m.group(1) -break - -return self.lldbArchitecture +return lldbplatformutil.getLldbArchitecture() medismailben wrote: ```suggestion return lldbplatformutil.getLLDBArchitecture() ``` https://github.com/llvm/llvm-project/pull/72416 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Remove `self` references from decorators (PR #72416)
medismailben wrote: Nice! LGTM with some nits. https://github.com/llvm/llvm-project/pull/72416 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Remove `self` references from decorators (PR #72416)
https://github.com/medismailben approved this pull request. https://github.com/llvm/llvm-project/pull/72416 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a3fe922 - Remove hardware index from watchpoints and breakpoints (#72012)
Author: Jason Molenda Date: 2023-11-15T13:32:42-08:00 New Revision: a3fe9221ab1541a88e784507433cfe7fd13688fd URL: https://github.com/llvm/llvm-project/commit/a3fe9221ab1541a88e784507433cfe7fd13688fd DIFF: https://github.com/llvm/llvm-project/commit/a3fe9221ab1541a88e784507433cfe7fd13688fd.diff LOG: Remove hardware index from watchpoints and breakpoints (#72012) The Watchpoint and Breakpoint objects try to track the hardware index that was used for them, if they are hardware wp/bp's. The majority of our debugging goes over the gdb remote serial protocol, and when we set the watchpoint/breakpoint, there is no (standard) way for the remote stub to communicate to lldb which hardware index was used. We have an lldb-extension packet to query the total number of watchpoint registers. When a watchpoint is hit, there is an lldb extension to the stop reply packet (documented in lldb-gdb-remote.txt) to describe the watchpoint including its actual hardware index, (the third field is specifically needed for MIPS). At this point, if the stub reported these three fields (the stub is only required to provide the first), we can know the actual hardware index for this watchpoint. Breakpoints are worse; there's never any way for us to be notified about which hardware index was used. Breakpoints got this as a side effect of inherting from StoppointSite with Watchpoints. We expose the watchpoint hardware index through "watchpoint list -v" and through SBWatchpoint::GetHardwareIndex. With my large watchpoint support, there is no *single* hardware index that may be used for a watchpoint, it may need multiple resources. Also I don't see what a user is supposed to do with this information, or an IDE. Knowing the total number of watchpoint registers on the target, and knowing how many Watchpoint Resources are currently in use, is helpful. Knowing how many Watchpoint Resources a single user-specified watchpoint needed to be implemented is useful. But knowing which registers were used is an implementation detail and not available until we hit the watchpoint when using gdb remote serial protocol. So given all that, I'm removing watchpoint hardware index numbers. I'm changing the SB API to always return -1. Added: Modified: lldb/bindings/interface/SBTargetDocstrings.i lldb/bindings/interface/SBWatchpointDocstrings.i lldb/docs/use/tutorial.rst lldb/include/lldb/API/SBWatchpoint.h lldb/include/lldb/Breakpoint/StoppointSite.h lldb/source/API/SBWatchpoint.cpp lldb/source/Breakpoint/BreakpointLocation.cpp lldb/source/Breakpoint/BreakpointSite.cpp lldb/source/Breakpoint/StoppointSite.cpp lldb/source/Breakpoint/Watchpoint.cpp lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Target/StopInfo.cpp lldb/test/API/python_api/default-constructor/sb_watchpoint.py lldb/test/API/python_api/watchpoint/TestWatchpointIter.py llvm/docs/ReleaseNotes.rst Removed: diff --git a/lldb/bindings/interface/SBTargetDocstrings.i b/lldb/bindings/interface/SBTargetDocstrings.i index f586552c99108c0..ce4992aade3a694 100644 --- a/lldb/bindings/interface/SBTargetDocstrings.i +++ b/lldb/bindings/interface/SBTargetDocstrings.i @@ -34,7 +34,7 @@ produces: :: Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12' -hw_index = 0 hit_count = 2 ignore_count = 0" +hit_count = 2 ignore_count = 0" ) lldb::SBTarget; %feature("docstring", " diff --git a/lldb/bindings/interface/SBWatchpointDocstrings.i b/lldb/bindings/interface/SBWatchpointDocstrings.i index 4eb7b136282dc30..892a82e6d0519f2 100644 --- a/lldb/bindings/interface/SBWatchpointDocstrings.i +++ b/lldb/bindings/interface/SBWatchpointDocstrings.i @@ -9,7 +9,8 @@ watchpoints of the target." ) lldb::SBWatchpoint; %feature("docstring", " -With -1 representing an invalid hardware index." +Deprecated. Previously: Return the hardware index of the +watchpoint register. Now: -1 is always returned." ) lldb::SBWatchpoint::GetHardwareIndex; %feature("docstring", " diff --git a/lldb/docs/use/tutorial.rst b/lldb/docs/use/tutorial.rst index 85dc173fa37cd33..ff956d750c29f23 100644 --- a/lldb/docs/use/tutorial.rst +++ b/lldb/docs/use/tutorial.rst @@ -431,7 +431,7 @@ a variable called 'global' for write operation, but only stop if the condition Watchpoint 1: addr = 0x11018 size = 4 state = enabled type = w declare @ '/Volumes/data/lldb/svn/ToT/test/functionalities/watchpoint/watchpoint_commands/condition/main.cpp:12' condition = '(global==5)' - hw_index = 0 hit_count = 5 ignore_count = 0 + hit_count = 5 ignore_count
[Lldb-commits] [lldb] [llvm] Remove hardware index from watchpoints and breakpoints (PR #72012)
https://github.com/jasonmolenda closed https://github.com/llvm/llvm-project/pull/72012 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -0,0 +1,154 @@ +//===-- SymbolLocatorDebuginfod.cpp --===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "SymbolLocatorDebuginfod.h" + +#include +#include + +#include "Plugins/ObjectFile/wasm/ObjectFileWasm.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/ModuleList.h" +#include "lldb/Core/ModuleSpec.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" +#include "lldb/Core/Section.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/Host.h" +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Target/Target.h" +#include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/DataBuffer.h" +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" +#include "lldb/Utility/UUID.h" + +#include "llvm/ADT/SmallSet.h" +#include "llvm/Debuginfod/HTTPClient.h" +#include "llvm/Debuginfod/Debuginfod.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/ThreadPool.h" + +using namespace lldb; +using namespace lldb_private; + +LLDB_PLUGIN_DEFINE(SymbolLocatorDebuginfod) + +namespace { + +#define LLDB_PROPERTIES_symbollocatordebuginfod +#include "SymbolLocatorDebuginfodProperties.inc" + +enum { +#define LLDB_PROPERTIES_symbollocatordebuginfod +#include "SymbolLocatorDebuginfodPropertiesEnum.inc" +}; + +class PluginProperties : public Properties { +public: + static llvm::StringRef GetSettingName() { +return SymbolLocatorDebuginfod::GetPluginNameStatic(); + } + + PluginProperties() { +m_collection_sp = std::make_shared(GetSettingName()); +m_collection_sp->Initialize(g_symbollocatordebuginfod_properties); +m_collection_sp->SetValueChangedCallback( +ePropertyURLs, [this] { URLsChangedCallback(); } +); + } + + Args GetDebugInfoDURLs() const { +Args urls; +m_collection_sp->GetPropertyAtIndexAsArgs(ePropertyURLs, urls); +return urls; + } + +private: + void URLsChangedCallback() { +Args urls = GetDebugInfoDURLs(); +llvm::SmallVector dbginfod_urls; +llvm::transform(urls, dbginfod_urls.end(), +[](const auto &obj) { return obj.ref(); }); +llvm::setDefaultDebuginfodUrls(dbginfod_urls); + } +}; + +} // namespace + + +SymbolLocatorDebuginfod::SymbolLocatorDebuginfod() : SymbolLocator() {} + +void SymbolLocatorDebuginfod::Initialize() { + PluginManager::RegisterPlugin( + GetPluginNameStatic(), GetPluginDescriptionStatic(), CreateInstance, + LocateExecutableObjectFile, LocateExecutableSymbolFile, + DownloadObjectAndSymbolFile); + // There's a "safety" concern on this: + // Does plugin initialization occur while things are still single threaded? kevinfrei wrote: It's part of the plugin system now, which works "as properly" as can be done in the world where library users might be doing crazy stuff. https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -0,0 +1,8 @@ +include "../../../../include/lldb/Core/PropertiesBase.td" + +let Definition = "symbollocatordebuginfod" in { + def URLs: Property<"urls", "String">, +Global, +DefaultStringValue<"">, +Desc<"A space-separated, ordered list of Debuginfod server URLs to query for symbols">; +} kevinfrei wrote: It looks like this now: ``` ... plugin.symbol-file.dwarf.ignore-file-indexes (boolean) = false plugin.symbol-locator.debuginfod.server_urls (array of strings) = [0]: "https://debuginfod.centos.org/"; plugin.structured-data.darwin-log.auto-enable-options (string) = ... ``` https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -46,6 +46,10 @@ bool canUseDebuginfod(); /// environment variable. SmallVector getDefaultDebuginfodUrls(); +/// Sets the list of debuginfod server URLs to query. This overrides the +/// environment variable DEBUGINFOD_URLS. kevinfrei wrote: Switched the setting to an array of strings setting, which addresses the usage issues. https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -62,15 +66,25 @@ bool canUseDebuginfod() { } SmallVector getDefaultDebuginfodUrls() { - const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS"); - if (DebuginfodUrlsEnv == nullptr) -return SmallVector(); - - SmallVector DebuginfodUrls; - StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " "); + if (!DebuginfodUrlsSet) { +// Only read from the environment variable if the user hasn't already +// set the value +const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS"); +if (DebuginfodUrlsEnv != nullptr) { + StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " ", -1, false); +} +DebuginfodUrlsSet = true; + } return DebuginfodUrls; } +// Override the default debuginfod URL list. +void setDefaultDebuginfodUrls(SmallVector URLs) { + DebuginfodUrls.clear(); kevinfrei wrote: Switched the setting to an array of strings setting, which addresses the usage issues. https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -0,0 +1,154 @@ +//===-- SymbolLocatorDebuginfod.cpp --===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "SymbolLocatorDebuginfod.h" + +#include +#include + +#include "Plugins/ObjectFile/wasm/ObjectFileWasm.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/ModuleList.h" +#include "lldb/Core/ModuleSpec.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" +#include "lldb/Core/Section.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/Host.h" +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Target/Target.h" +#include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/DataBuffer.h" +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/LLDBLog.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" +#include "lldb/Utility/UUID.h" + +#include "llvm/ADT/SmallSet.h" +#include "llvm/Debuginfod/HTTPClient.h" +#include "llvm/Debuginfod/Debuginfod.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/ThreadPool.h" + +using namespace lldb; +using namespace lldb_private; + +LLDB_PLUGIN_DEFINE(SymbolLocatorDebuginfod) + +namespace { + +#define LLDB_PROPERTIES_symbollocatordebuginfod +#include "SymbolLocatorDebuginfodProperties.inc" + +enum { +#define LLDB_PROPERTIES_symbollocatordebuginfod +#include "SymbolLocatorDebuginfodPropertiesEnum.inc" +}; + +class PluginProperties : public Properties { +public: + static llvm::StringRef GetSettingName() { +return SymbolLocatorDebuginfod::GetPluginNameStatic(); + } + + PluginProperties() { +m_collection_sp = std::make_shared(GetSettingName()); +m_collection_sp->Initialize(g_symbollocatordebuginfod_properties); +m_collection_sp->SetValueChangedCallback( +ePropertyURLs, [this] { URLsChangedCallback(); } +); + } + + Args GetDebugInfoDURLs() const { +Args urls; +m_collection_sp->GetPropertyAtIndexAsArgs(ePropertyURLs, urls); +return urls; + } + +private: + void URLsChangedCallback() { +Args urls = GetDebugInfoDURLs(); +llvm::SmallVector dbginfod_urls; +llvm::transform(urls, dbginfod_urls.end(), +[](const auto &obj) { return obj.ref(); }); +llvm::setDefaultDebuginfodUrls(dbginfod_urls); + } +}; + +} // namespace + + +SymbolLocatorDebuginfod::SymbolLocatorDebuginfod() : SymbolLocator() {} + +void SymbolLocatorDebuginfod::Initialize() { + PluginManager::RegisterPlugin( + GetPluginNameStatic(), GetPluginDescriptionStatic(), CreateInstance, + LocateExecutableObjectFile, LocateExecutableSymbolFile, + DownloadObjectAndSymbolFile); + // There's a "safety" concern on this: + // Does plugin initialization occur while things are still single threaded? + llvm::HTTPClient::initialize(); +} + +void SymbolLocatorDebuginfod::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); + // There's a "safety" concern on this: + // Does plugin termination occur while things are still single threaded? kevinfrei wrote: Nope. Dug in, looks okay. https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -4,7 +4,7 @@ let Definition = "modulelist" in { def EnableExternalLookup: Property<"enable-external-lookup", "Boolean">, Global, DefaultTrue, -Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched.">; +Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched. If all other methods fail, and the DEBUGINFOD_URLS environment variable is specified, the Debuginfod protocol is used to acquire symbols from a compatible Debuginfod service.">; kevinfrei wrote: Significantly changed the wording, here. https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
https://github.com/kevinfrei updated https://github.com/llvm/llvm-project/pull/70996 >From b04c85dbed0b369e747aa2a3823789203156736b Mon Sep 17 00:00:00 2001 From: Kevin Frei Date: Wed, 18 Oct 2023 14:37:34 -0700 Subject: [PATCH 1/5] DEBUGINFOD based DWP acquisition for LLDB Summary: I've plumbed the LLVM DebugInfoD client into LLDB, and added automatic downloading of DWP files to the SymbolFileDWARF.cpp plugin. If you have `DEBUGINFOD_URLS` set to a space delimited set of web servers, LLDB will try to use them as a last resort when searching for DWP files. If you do *not* have that environment variable set, nothing should be changed. There's also a setting, per Greg Clayton's request, that will override the env variable, or can be used instead of the env var. This setting is the reason for the additional API added to the llvm's Debuginfod library. Test Plan: Suggestions are welcome here. I should probably have some positive and negative tests, but I wanted to get the diff up for people who have a clue what they're doing to rip it to pieces before spending too much time validating my implementation. --- lldb/include/lldb/Target/Target.h | 3 +++ lldb/source/Core/CoreProperties.td| 2 +- lldb/source/Core/Debugger.cpp | 5 .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 1 + lldb/source/Symbol/CMakeLists.txt | 1 + lldb/source/Target/Target.cpp | 19 +- lldb/source/Target/TargetProperties.td| 4 +++ llvm/include/llvm/Debuginfod/Debuginfod.h | 4 +++ llvm/lib/Debuginfod/Debuginfod.cpp| 26 ++- 9 files changed, 57 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index c37682e2a03859f..7f10f0409fb1315 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -258,6 +258,8 @@ class TargetProperties : public Properties { bool GetDebugUtilityExpression() const; + Args GetDebugInfoDURLs() const; + private: // Callbacks for m_launch_info. void Arg0ValueChangedCallback(); @@ -270,6 +272,7 @@ class TargetProperties : public Properties { void DisableASLRValueChangedCallback(); void InheritTCCValueChangedCallback(); void DisableSTDIOValueChangedCallback(); + void DebugInfoDURLsChangedCallback(); // Settings checker for target.jit-save-objects-dir: void CheckJITObjectsDir(); diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index 92884258347e9be..865030b0133bbb2 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -4,7 +4,7 @@ let Definition = "modulelist" in { def EnableExternalLookup: Property<"enable-external-lookup", "Boolean">, Global, DefaultTrue, -Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched.">; +Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched. If all other methods fail, and the DEBUGINFOD_URLS environment variable is specified, the Debuginfod protocol is used to acquire symbols from a compatible Debuginfod service.">; def EnableBackgroundLookup: Property<"enable-background-lookup", "Boolean">, Global, DefaultFalse, diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 21f71e449ca5ed0..9a3e82f3e6a2adf 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -61,6 +61,8 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator.h" +#include "llvm/Debuginfod/Debuginfod.h" +#include "llvm/Debuginfod/HTTPClient.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Process.h" @@ -594,6 +596,9 @@ lldb::DWIMPrintVerbosity Debugger::GetDWIMPrintVerbosity() const { void Debugger::Initialize(LoadPluginCallbackType load_plugin_callback) { assert(g_debugger_list_ptr == nullptr && "Debugger::Initialize called more than once!"); + // We might be using the Debuginfod service, s
[Lldb-commits] [lldb] [clang] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
dyung wrote: Hi @Michael137, we are seeing a failure in one of our internal tests that I bisected back to this change. Consider the following code: ```C++ struct X { static const int constant = 1; int x; X() { x = constant; } }; const int X::constant; int main() { X x; x.x = X::constant; x.x = X::constant; x.x = X::constant; x.x = X::constant; x.x = X::constant; return 0; } ``` Prior to your change, the compiler would generate the following DWARF for the constant value: ``` 0x003a: DW_TAG_member DW_AT_name("constant") DW_AT_type(0x0057 "const int") DW_AT_decl_file ("/home/dyung/sandbox/test.cpp") DW_AT_decl_line (3) DW_AT_external(true) DW_AT_declaration (true) DW_AT_const_value (1) ``` After your change, the DW_AT_const_value is gone from this DW_TAG_member group, but doesn't appear anywhere else in the DWARF output which seems to indicate that it was dropped completely which does not seem to be correct. Is this intended or am I missing something? https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
Michael137 wrote: > Hi @Michael137, we are seeing a failure in one of our internal tests that I > bisected back to this change. Consider the following code: > > ```c++ > struct X > { > static const int constant = 1; > int x; > > X() { x = constant; } > }; > const int X::constant; > > int main() > { > X x; > x.x = X::constant; > x.x = X::constant; > x.x = X::constant; > x.x = X::constant; > x.x = X::constant; > return 0; > } > ``` > > Prior to your change, the compiler would generate the following DWARF for the > constant value: > > ``` > 0x003a: DW_TAG_member > DW_AT_name("constant") > DW_AT_type(0x0057 "const int") > DW_AT_decl_file ("/home/dyung/sandbox/test.cpp") > DW_AT_decl_line (3) > DW_AT_external(true) > DW_AT_declaration (true) > DW_AT_const_value (1) > ``` > > After your change, the DW_AT_const_value is gone from this DW_TAG_member > group, but doesn't appear anywhere else in the DWARF output which seems to > indicate that it was dropped completely which does not seem to be correct. Is > this intended or am I missing something? > Hi @Michael137, we are seeing a failure in one of our internal tests that I > bisected back to this change. Consider the following code: > > ```c++ > struct X > { > static const int constant = 1; > int x; > > X() { x = constant; } > }; > const int X::constant; > > int main() > { > X x; > x.x = X::constant; > x.x = X::constant; > x.x = X::constant; > x.x = X::constant; > x.x = X::constant; > return 0; > } > ``` > > Prior to your change, the compiler would generate the following DWARF for the > constant value: > > ``` > 0x003a: DW_TAG_member > DW_AT_name("constant") > DW_AT_type(0x0057 "const int") > DW_AT_decl_file ("/home/dyung/sandbox/test.cpp") > DW_AT_decl_line (3) > DW_AT_external(true) > DW_AT_declaration (true) > DW_AT_const_value (1) > ``` > > After your change, the DW_AT_const_value is gone from this DW_TAG_member > group, but doesn't appear anywhere else in the DWARF output which seems to > indicate that it was dropped completely which does not seem to be correct. Is > this intended or am I missing something? Right, we stopped putting the `DW_AT_const_value` on the declaration. Instead we put either the location or the constant on the definition, depending on what's available. In your example you define the variable out-of-class which would generate a `DW_TAG_variable` with a location, so we don't emit the constant for it on the definition. What's the nature of the failure? Would you instead be able to read the value out of the definition? CC @dwblaikie https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
dyung wrote: > > Hi @Michael137, we are seeing a failure in one of our internal tests that I > > bisected back to this change. Consider the following code: > > ```c++ > > struct X > > { > > static const int constant = 1; > > int x; > > > > X() { x = constant; } > > }; > > const int X::constant; > > > > int main() > > { > > X x; > > x.x = X::constant; > > x.x = X::constant; > > x.x = X::constant; > > x.x = X::constant; > > x.x = X::constant; > > return 0; > > } > > ``` > > > > > > > > > > > > > > > > > > > > > > > > Prior to your change, the compiler would generate the following DWARF for > > the constant value: > > ``` > > 0x003a: DW_TAG_member > > DW_AT_name("constant") > > DW_AT_type(0x0057 "const int") > > DW_AT_decl_file ("/home/dyung/sandbox/test.cpp") > > DW_AT_decl_line (3) > > DW_AT_external(true) > > DW_AT_declaration (true) > > DW_AT_const_value (1) > > ``` > > > > > > > > > > > > > > > > > > > > > > > > After your change, the DW_AT_const_value is gone from this DW_TAG_member > > group, but doesn't appear anywhere else in the DWARF output which seems to > > indicate that it was dropped completely which does not seem to be correct. > > Is this intended or am I missing something? > > Right, we stopped putting the `DW_AT_const_value` on the declaration. Instead > we put either the location or the constant on the definition, depending on > what's available. In your example you define the variable out-of-class which > would generate a `DW_TAG_variable` with a location, so we don't emit the > constant for it on the definition: > > ``` > 0x002e: DW_TAG_variable > DW_AT_specification (0x004a "constant") > DW_AT_location (DW_OP_addr 0x90) > DW_AT_linkage_name ("_ZN1X8constantE") > ``` > > What's the nature of the failure? Would you instead be able to read the value > out of the definition? Our test is expecting to find a DW_AT_const_value somewhere in the dwarf output which it no longer seems to generate. From what I gather from your commit message, the compiler should now be emitting a new DW_TAG_variable section that it previously did not with the DW_AT_const_value attached? Or is my understanding incorrect? https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
pogo59 wrote: The member is const with an initializer in-class. How is the constant value not available for the definition? https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
@@ -1787,30 +1788,48 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo( // addresses should be provided as \a wp_addr. StringExtractor desc_extractor(description.c_str()); addr_t wp_addr = desc_extractor.GetU64(LLDB_INVALID_ADDRESS); - uint32_t wp_index = desc_extractor.GetU32(LLDB_INVALID_INDEX32); + wp_resource_id_t wp_hw_index = + desc_extractor.GetU32(LLDB_INVALID_WATCHPOINT_RESOURCE_ID); addr_t wp_hit_addr = desc_extractor.GetU64(LLDB_INVALID_ADDRESS); watch_id_t watch_id = LLDB_INVALID_WATCH_ID; bool silently_continue = false; - WatchpointSP wp_sp; + WatchpointResourceSP wp_resource_sp; + if (wp_hw_index != LLDB_INVALID_WATCHPOINT_RESOURCE_ID) { +wp_resource_sp = m_watchpoint_resource_list.FindByID(wp_hw_index); +if (wp_resource_sp) { + // If we were given an access address, and the Resource we + // found by watchpoint register index does not contain that + // address, then the wp_resource_id's have not tracked the + // hardware watchpoint registers correctly, discard this + // Resource found by ID and look it up by access address. + if (wp_hit_addr != LLDB_INVALID_ADDRESS && + !wp_resource_sp->Contains(wp_hit_addr)) { +wp_resource_sp.reset(); + } +} + } if (wp_hit_addr != LLDB_INVALID_ADDRESS) { -wp_sp = GetTarget().GetWatchpointList().FindByAddress(wp_hit_addr); +wp_resource_sp = +m_watchpoint_resource_list.FindByAddress(wp_hit_addr); // On MIPS, \a wp_hit_addr outside the range of a watched // region means we should silently continue, it is a false hit. ArchSpec::Core core = GetTarget().GetArchitecture().GetCore(); -if (!wp_sp && core >= ArchSpec::kCore_mips_first && +if (!wp_resource_sp && core >= ArchSpec::kCore_mips_first && core <= ArchSpec::kCore_mips_last) silently_continue = true; } - if (!wp_sp && wp_addr != LLDB_INVALID_ADDRESS) -wp_sp = GetTarget().GetWatchpointList().FindByAddress(wp_addr); - if (wp_sp) { -wp_sp->SetHardwareIndex(wp_index); -watch_id = wp_sp->GetID(); - } - if (watch_id == LLDB_INVALID_WATCH_ID) { + if (!wp_resource_sp && wp_addr != LLDB_INVALID_ADDRESS) +wp_resource_sp = m_watchpoint_resource_list.FindByAddress(wp_addr); + if (!wp_resource_sp) { Log *log(GetLog(GDBRLog::Watchpoints)); LLDB_LOGF(log, "failed to find watchpoint"); +abort(); // LWP_TODO FIXME don't continue executing this block if jasonmolenda wrote: My refactored code added a new nullptr deref, when I saw what I'd done I threw in an abort and a FIXME comment to fix that. But I see how to fix it, let me do that. https://github.com/llvm/llvm-project/pull/68845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
Michael137 wrote: > The member is const with an initializer in-class. How is the constant value > not available for the definition? Right, it is available, we just don't attach it if we have a location for it. Don't see why we couldn't put it on the definition if we have the constant on hand https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
jasonmolenda wrote: > LGTM with a few nits. I like "constituents". > > This is a pretty big patch which makes reviewing it challenging. I know it's > a big change that touches a lot of things but I'm sure that this could've > been broken up into smaller patches if you keep that goal in mind from the > beginning. Something to look out for in the future. Thanks for the feedback. Yeah originally this patch was a bit smaller but it has Grown as I've addressed (correct, good) feedback from everyone and now it's a little bit of a monster. I'm surely going to have to rebase it before I can merge. https://github.com/llvm/llvm-project/pull/68845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [clang] [Profile] Add binary profile correlation to offload profile metadata at runtime. (PR #69493)
https://github.com/ZequanWu edited https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [clang] [llvm] [clang-tools-extra] [lldb] [mlir] [flang] [Profile] Add binary profile correlation to offload profile metadata at runtime. (PR #69493)
@@ -0,0 +1,11 @@ +; RUN: opt < %s -passes=instrprof -profile-correlate=binary -S | FileCheck %s ZequanWu wrote: Moved the test to `coverage.ll` https://github.com/llvm/llvm-project/pull/69493 ___ 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] [clang] [flang] [mlir] [Profile] Add binary profile correlation to offload profile metadata at runtime. (PR #69493)
@@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -mllvm -profile-correlate=binary -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -o - %s | FileCheck %s --check-prefix=BIN-CORRELATE ZequanWu wrote: Not applicable. Removed changes in Clang. https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [clang] [flang] [clang-tools-extra] [lldb] [compiler-rt] [mlir] [Profile] Add binary profile correlation to offload profile metadata at runtime. (PR #69493)
@@ -0,0 +1,46 @@ +// REQUIRES: linux || windows ZequanWu wrote: I think lld is not require, removed `-fuse-ld=lld`. https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [lldb] [compiler-rt] [llvm] [clang-tools-extra] [clang] [mlir] [Profile] Add binary profile correlation to offload profile metadata at runtime. (PR #69493)
@@ -1829,6 +1833,22 @@ void CoverageMappingModuleGen::emit() { llvm::GlobalValue::InternalLinkage, NamesArrVal, llvm::getCoverageUnusedNamesVarName()); } + const StringRef VarName(INSTR_PROF_QUOTE(INSTR_PROF_RAW_VERSION_VAR)); + llvm::Type *IntTy64 = llvm::Type::getInt64Ty(Ctx); + uint64_t ProfileVersion = INSTR_PROF_RAW_VERSION; + if (llvm::ProfileCorrelate == llvm::InstrProfCorrelator::BINARY) +ProfileVersion |= VARIANT_MASK_BIN_CORRELATE; + auto *VersionVariable = new llvm::GlobalVariable( + CGM.getModule(), llvm::Type::getInt64Ty(Ctx), true, + llvm::GlobalValue::WeakAnyLinkage, + llvm::Constant::getIntegerValue(IntTy64, llvm::APInt(64, ProfileVersion)), + VarName); + VersionVariable->setVisibility(llvm::GlobalValue::HiddenVisibility); + llvm::Triple TT(CGM.getModule().getTargetTriple()); + if (TT.supportsCOMDAT()) { ZequanWu wrote: Not applicable. Removed changes in Clang. https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [mlir] [llvm] [clang] [compiler-rt] [flang] [clang-tools-extra] [Profile] Add binary profile correlation to offload profile metadata at runtime. (PR #69493)
@@ -46,14 +73,38 @@ const char *InstrProfCorrelator::NumCountersAttributeName = "Num Counters"; llvm::Expected> InstrProfCorrelator::Context::get(std::unique_ptr Buffer, - const object::ObjectFile &Obj) { + const object::ObjectFile &Obj, + ProfCorrelatorKind FileKind) { + auto C = std::make_unique(); auto CountersSection = getInstrProfSection(Obj, IPSK_cnts); if (auto Err = CountersSection.takeError()) return std::move(Err); - auto C = std::make_unique(); + if (FileKind == InstrProfCorrelator::BINARY) { +auto DataSection = getInstrProfSection(Obj, IPSK_data); +if (auto Err = DataSection.takeError()) + return std::move(Err); +auto DataOrErr = DataSection->getContents(); +if (!DataOrErr) + return DataOrErr.takeError(); +auto NameSection = getInstrProfSection(Obj, IPSK_name); +if (auto Err = NameSection.takeError()) + return std::move(Err); +auto NameOrErr = NameSection->getContents(); +if (!NameOrErr) + return NameOrErr.takeError(); +C->DataStart = DataOrErr->data(); +C->DataEnd = DataOrErr->data() + DataOrErr->size(); +C->NameStart = NameOrErr->data(); +C->NameSize = NameOrErr->size(); + } C->Buffer = std::move(Buffer); C->CountersSectionStart = CountersSection->getAddress(); C->CountersSectionEnd = C->CountersSectionStart + CountersSection->getSize(); + // In COFF object file, there's a null byte at the beginning of the counter + // section which doesn't exist in raw profile. + if (Obj.getTripleObjectFormat() == Triple::COFF) +C->CountersSectionStart++; ZequanWu wrote: Done. https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [flang] [llvm] [clang-tools-extra] [lldb] [compiler-rt] [mlir] [Profile] Add binary profile correlation to offload profile metadata at runtime. (PR #69493)
https://github.com/ZequanWu commented: > "binary" is ambiguous. I wonder whether object file correlation is better. > llvm-symbolizer has an option --obj=xxx. llvm-symbolizer's `--obj` could take an pre-linking object file. But here we need to take post-linked binary for merging. https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [compiler-rt] [lldb] [llvm] [mlir] [clang] [clang-tools-extra] [Profile] Add binary profile correlation to offload profile metadata at runtime. (PR #69493)
@@ -1331,6 +1336,18 @@ static int merge_main(int argc, const char *argv[]) { "(default: 1)")); cl::ParseCommandLineOptions(argc, argv, "LLVM profile data merger\n"); + if (!DebugInfoFilename.empty() && !BinaryFilename.empty()) { +exitWithError("Expected only one of -debug-info, -binary-file"); + } + std::string CorrelateFilename = ""; ZequanWu wrote: Done. https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [flang] [mlir] [llvm] [clang] [clang-tools-extra] [lldb] [Profile] Add binary profile correlation to offload profile metadata at runtime. (PR #69493)
@@ -1331,6 +1336,18 @@ static int merge_main(int argc, const char *argv[]) { "(default: 1)")); cl::ParseCommandLineOptions(argc, argv, "LLVM profile data merger\n"); + if (!DebugInfoFilename.empty() && !BinaryFilename.empty()) { +exitWithError("Expected only one of -debug-info, -binary-file"); ZequanWu wrote: Done. https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang-tools-extra] [clang] [mlir] [flang] [llvm] [compiler-rt] [Profile] Add binary profile correlation to offload profile metadata at runtime. (PR #69493)
@@ -1341,20 +1344,26 @@ void InstrProfiling::createDataVariable(InstrProfCntrInstBase *Inc, } auto *Data = new GlobalVariable(*M, DataTy, false, Linkage, nullptr, DataVarName); - // Reference the counter variable with a label difference (link-time - // constant). - auto *RelativeCounterPtr = - ConstantExpr::getSub(ConstantExpr::getPtrToInt(CounterPtr, IntPtrTy), - ConstantExpr::getPtrToInt(Data, IntPtrTy)); - - // Bitmaps are relative to the same data variable as profile counters. + Constant *RelativeCounterPtr; GlobalVariable *BitmapPtr = PD.RegionBitmaps; Constant *RelativeBitmapPtr = ConstantInt::get(IntPtrTy, 0); - - if (BitmapPtr != nullptr) { -RelativeBitmapPtr = -ConstantExpr::getSub(ConstantExpr::getPtrToInt(BitmapPtr, IntPtrTy), + // By default counter ptr and bitmap ptr are address relative to data section. ZequanWu wrote: Done. https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [compiler-rt] [flang] [llvm] [lldb] [clang-tools-extra] [clang] [mlir] [Profile] Add binary profile correlation to offload profile metadata at runtime. (PR #69493)
@@ -195,8 +195,14 @@ OPTIONS .. option:: --debug-info= Specify the executable or ``.dSYM`` that contains debug info for the raw profile. - When ``-debug-info-correlate`` was used for instrumentation, use this option - to correlate the raw profile. + When ``-profile-correlate=debug-info`` was used for instrumentation, use this ZequanWu wrote: Done. https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [mlir] [clang] [lldb] [compiler-rt] [llvm] [flang] [Profile] Add binary profile correlation to offload profile metadata at runtime. (PR #69493)
@@ -0,0 +1,46 @@ +// REQUIRES: linux || windows +// Default +// RUN: %clang -o %t.normal -fprofile-instr-generate -fcoverage-mapping -fuse-ld=lld %S/Inputs/instrprof-debug-info-correlate-main.cpp %S/Inputs/instrprof-debug-info-correlate-foo.cpp +// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.normal +// RUN: llvm-profdata merge -o %t.normal.profdata %t.profraw +// RUN: llvm-cov report --instr-profile=%t.normal.profdata %t.normal > %t.normal.report +// RUN: llvm-cov show --instr-profile=%t.normal.profdata %t.normal > %t.normal.show + +// With -profile-correlate=binary flag +// RUN: %clang -o %t-1.exe -fprofile-instr-generate -fcoverage-mapping -mllvm -profile-correlate=binary -fuse-ld=lld %S/Inputs/instrprof-debug-info-correlate-main.cpp %S/Inputs/instrprof-debug-info-correlate-foo.cpp ZequanWu wrote: On Windows, it expands to `.tmp.exe`. https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
dyung wrote: > > The member is const with an initializer in-class. How is the constant value > > not available for the definition? > > Right, it is available, we just don't attach it if we have a location for it. > Don't see why we couldn't put it on the definition if we have the constant on > hand So I guess what you are saying in this case is that it is expected and the value is at the location indicated by the DW_AT_location value? As long as the value is still available I suppose that is fine then and the test just needs updating. https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang-tools-extra] [mlir] [clang] [lldb] [compiler-rt] [llvm] [flang] [Profile] Add binary profile correlation for code coverage. (PR #69493)
https://github.com/ZequanWu edited https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [clang] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
pogo59 wrote: I think it is a valuable bit of information for the debugger, to know the constant value without having to read it from memory. I think we should emit both the location and the value. https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
kevinfrei wrote: Looks like I missed committing some staged edits. Hold on before reviewing... https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
https://github.com/kevinfrei updated https://github.com/llvm/llvm-project/pull/70996 >From b04c85dbed0b369e747aa2a3823789203156736b Mon Sep 17 00:00:00 2001 From: Kevin Frei Date: Wed, 18 Oct 2023 14:37:34 -0700 Subject: [PATCH 1/5] DEBUGINFOD based DWP acquisition for LLDB Summary: I've plumbed the LLVM DebugInfoD client into LLDB, and added automatic downloading of DWP files to the SymbolFileDWARF.cpp plugin. If you have `DEBUGINFOD_URLS` set to a space delimited set of web servers, LLDB will try to use them as a last resort when searching for DWP files. If you do *not* have that environment variable set, nothing should be changed. There's also a setting, per Greg Clayton's request, that will override the env variable, or can be used instead of the env var. This setting is the reason for the additional API added to the llvm's Debuginfod library. Test Plan: Suggestions are welcome here. I should probably have some positive and negative tests, but I wanted to get the diff up for people who have a clue what they're doing to rip it to pieces before spending too much time validating my implementation. --- lldb/include/lldb/Target/Target.h | 3 +++ lldb/source/Core/CoreProperties.td| 2 +- lldb/source/Core/Debugger.cpp | 5 .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 1 + lldb/source/Symbol/CMakeLists.txt | 1 + lldb/source/Target/Target.cpp | 19 +- lldb/source/Target/TargetProperties.td| 4 +++ llvm/include/llvm/Debuginfod/Debuginfod.h | 4 +++ llvm/lib/Debuginfod/Debuginfod.cpp| 26 ++- 9 files changed, 57 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index c37682e2a03859f..7f10f0409fb1315 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -258,6 +258,8 @@ class TargetProperties : public Properties { bool GetDebugUtilityExpression() const; + Args GetDebugInfoDURLs() const; + private: // Callbacks for m_launch_info. void Arg0ValueChangedCallback(); @@ -270,6 +272,7 @@ class TargetProperties : public Properties { void DisableASLRValueChangedCallback(); void InheritTCCValueChangedCallback(); void DisableSTDIOValueChangedCallback(); + void DebugInfoDURLsChangedCallback(); // Settings checker for target.jit-save-objects-dir: void CheckJITObjectsDir(); diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index 92884258347e9be..865030b0133bbb2 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -4,7 +4,7 @@ let Definition = "modulelist" in { def EnableExternalLookup: Property<"enable-external-lookup", "Boolean">, Global, DefaultTrue, -Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched.">; +Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched. If all other methods fail, and the DEBUGINFOD_URLS environment variable is specified, the Debuginfod protocol is used to acquire symbols from a compatible Debuginfod service.">; def EnableBackgroundLookup: Property<"enable-background-lookup", "Boolean">, Global, DefaultFalse, diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 21f71e449ca5ed0..9a3e82f3e6a2adf 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -61,6 +61,8 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator.h" +#include "llvm/Debuginfod/Debuginfod.h" +#include "llvm/Debuginfod/HTTPClient.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Process.h" @@ -594,6 +596,9 @@ lldb::DWIMPrintVerbosity Debugger::GetDWIMPrintVerbosity() const { void Debugger::Initialize(LoadPluginCallbackType load_plugin_callback) { assert(g_debugger_list_ptr == nullptr && "Debugger::Initialize called more than once!"); + // We might be using the Debuginfod service, s
[Lldb-commits] [clang] [lldb] Reland "[clang][DebugInfo] Emit global variable definitions for static data members with constant initializers" (PR #71780)
Michael137 wrote: > So I guess what you are saying in this case is that it is expected and the > value is at the location indicated by the DW_AT_location value? As long as > the value is still available I suppose that is fine then and the test just > needs updating. Yup that's exactly right. I'll go ahead with @pogo59's suggestion then and make sure we also emit the constant on the definition when we can. If updating your test to accommodate for only having the DW_AT_location is feasible for now that'd be great since I'll only be able to get to it tomorrow https://github.com/llvm/llvm-project/pull/71780 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [flang] [compiler-rt] [mlir] [llvm] [clang] [clang-tools-extra] [lldb] [Profile] Add binary profile correlation for code coverage. (PR #69493)
https://github.com/ZequanWu edited https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
https://github.com/bulbazord approved this pull request. LGTM as well. I like the name Constituents quite a bit as well! 😄 I think most feedback at this point can probably be handled in follow-ups, esp. since some of it pertains to existing interfaces. https://github.com/llvm/llvm-project/pull/68845 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -62,15 +66,25 @@ bool canUseDebuginfod() { } SmallVector getDefaultDebuginfodUrls() { - const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS"); - if (DebuginfodUrlsEnv == nullptr) -return SmallVector(); - - SmallVector DebuginfodUrls; - StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " "); + if (!DebuginfodUrlsSet) { +// Only read from the environment variable if the user hasn't already +// set the value +const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS"); +if (DebuginfodUrlsEnv != nullptr) { + StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " ", -1, false); +} bulbazord wrote: ```suggestion if (const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS")) StringRef(DebuginfodUrlsEnv).split(DebuginfodUrls, " ", -1, false); ``` https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -0,0 +1,142 @@ +//===-- SymbolLocatorDebuginfod.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "SymbolLocatorDebuginfod.h" + +#include "lldb/Core/PluginManager.h" +#include "lldb/Utility/Args.h" + +#include "llvm/Debuginfod/Debuginfod.h" +#include "llvm/Debuginfod/HTTPClient.h" + +using namespace lldb; +using namespace lldb_private; + +LLDB_PLUGIN_DEFINE(SymbolLocatorDebuginfod) + +namespace { + +#define LLDB_PROPERTIES_symbollocatordebuginfod +#include "SymbolLocatorDebuginfodProperties.inc" + +enum { +#define LLDB_PROPERTIES_symbollocatordebuginfod +#include "SymbolLocatorDebuginfodPropertiesEnum.inc" +}; + +class PluginProperties : public Properties { +public: + static llvm::StringRef GetSettingName() { +return SymbolLocatorDebuginfod::GetPluginNameStatic(); + } + + PluginProperties() { +m_collection_sp = std::make_shared(GetSettingName()); +m_collection_sp->Initialize(g_symbollocatordebuginfod_properties); + +// We need to read the default value first to read the environment variable. +llvm::SmallVector urls = llvm::getDefaultDebuginfodUrls(); +Args arg_urls{urls}; +m_collection_sp->SetPropertyAtIndexFromArgs(ePropertyServerURLs, arg_urls); + +m_collection_sp->SetValueChangedCallback( +ePropertyServerURLs, [this] { ServerURLsChangedCallback(); }); + } + + Args GetDebugInfoDURLs() const { +Args urls; +m_collection_sp->GetPropertyAtIndexAsArgs(ePropertyServerURLs, urls); +return urls; + } + +private: + void ServerURLsChangedCallback() { +Args urls = GetDebugInfoDURLs(); +llvm::SmallVector dbginfod_urls; +llvm::transform(urls, dbginfod_urls.end(), +[](const auto &obj) { return obj.ref(); }); +llvm::setDefaultDebuginfodUrls(dbginfod_urls); + } +}; + +} // namespace + +static PluginProperties &GetGlobalPluginProperties() { + static PluginProperties g_settings; + return g_settings; +} + +SymbolLocatorDebuginfod::SymbolLocatorDebuginfod() : SymbolLocator() {} + +void SymbolLocatorDebuginfod::Initialize() { + static llvm::once_flag g_once_flag; + + llvm::call_once(g_once_flag, []() { +PluginManager::RegisterPlugin( +GetPluginNameStatic(), GetPluginDescriptionStatic(), CreateInstance, +LocateExecutableObjectFile, LocateExecutableSymbolFile, nullptr, +nullptr, SymbolLocatorDebuginfod::DebuggerInitialize); +llvm::HTTPClient::initialize(); + }); +} + +void SymbolLocatorDebuginfod::DebuggerInitialize(Debugger &debugger) { + if (!PluginManager::GetSettingForSymbolLocatorPlugin( + debugger, PluginProperties::GetSettingName())) { +const bool is_global_setting = true; +PluginManager::CreateSettingForSymbolLocatorPlugin( +debugger, GetGlobalPluginProperties().GetValueProperties(), +"Properties for the Debuginfod Symbol Locator plug-in.", +is_global_setting); + } +} + +void SymbolLocatorDebuginfod::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); + llvm::HTTPClient::cleanup(); +} + +llvm::StringRef SymbolLocatorDebuginfod::GetPluginDescriptionStatic() { + return "Debuginfod symbol locator."; +} + +SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() { + return new SymbolLocatorDebuginfod(); bulbazord wrote: You're calling `llvm::canUseDebuginfod` in the methods to actually locate the debug info. Would it not make sense to call that when creating an instance? What would the value be in having a `SymbolLocatorDebuginfod` instance if `llvm::canUseDebuginfod` returns false? https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Remove `self` references from decorators (PR #72416)
https://github.com/bulbazord approved this pull request. Beautiful, thank you for working on this. After this change, what's left to get us using the python-provided `unittest`? https://github.com/llvm/llvm-project/pull/72416 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
@@ -0,0 +1,142 @@ +//===-- SymbolLocatorDebuginfod.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "SymbolLocatorDebuginfod.h" + +#include "lldb/Core/PluginManager.h" +#include "lldb/Utility/Args.h" + +#include "llvm/Debuginfod/Debuginfod.h" +#include "llvm/Debuginfod/HTTPClient.h" + +using namespace lldb; +using namespace lldb_private; + +LLDB_PLUGIN_DEFINE(SymbolLocatorDebuginfod) + +namespace { + +#define LLDB_PROPERTIES_symbollocatordebuginfod +#include "SymbolLocatorDebuginfodProperties.inc" + +enum { +#define LLDB_PROPERTIES_symbollocatordebuginfod +#include "SymbolLocatorDebuginfodPropertiesEnum.inc" +}; + +class PluginProperties : public Properties { +public: + static llvm::StringRef GetSettingName() { +return SymbolLocatorDebuginfod::GetPluginNameStatic(); + } + + PluginProperties() { +m_collection_sp = std::make_shared(GetSettingName()); +m_collection_sp->Initialize(g_symbollocatordebuginfod_properties); + +// We need to read the default value first to read the environment variable. +llvm::SmallVector urls = llvm::getDefaultDebuginfodUrls(); +Args arg_urls{urls}; +m_collection_sp->SetPropertyAtIndexFromArgs(ePropertyServerURLs, arg_urls); + +m_collection_sp->SetValueChangedCallback( +ePropertyServerURLs, [this] { ServerURLsChangedCallback(); }); + } + + Args GetDebugInfoDURLs() const { +Args urls; +m_collection_sp->GetPropertyAtIndexAsArgs(ePropertyServerURLs, urls); +return urls; + } + +private: + void ServerURLsChangedCallback() { +Args urls = GetDebugInfoDURLs(); +llvm::SmallVector dbginfod_urls; +llvm::transform(urls, dbginfod_urls.end(), +[](const auto &obj) { return obj.ref(); }); +llvm::setDefaultDebuginfodUrls(dbginfod_urls); + } +}; + +} // namespace + +static PluginProperties &GetGlobalPluginProperties() { + static PluginProperties g_settings; + return g_settings; +} + +SymbolLocatorDebuginfod::SymbolLocatorDebuginfod() : SymbolLocator() {} + +void SymbolLocatorDebuginfod::Initialize() { + static llvm::once_flag g_once_flag; + + llvm::call_once(g_once_flag, []() { +PluginManager::RegisterPlugin( +GetPluginNameStatic(), GetPluginDescriptionStatic(), CreateInstance, +LocateExecutableObjectFile, LocateExecutableSymbolFile, nullptr, +nullptr, SymbolLocatorDebuginfod::DebuggerInitialize); +llvm::HTTPClient::initialize(); + }); +} + +void SymbolLocatorDebuginfod::DebuggerInitialize(Debugger &debugger) { + if (!PluginManager::GetSettingForSymbolLocatorPlugin( + debugger, PluginProperties::GetSettingName())) { +const bool is_global_setting = true; +PluginManager::CreateSettingForSymbolLocatorPlugin( +debugger, GetGlobalPluginProperties().GetValueProperties(), +"Properties for the Debuginfod Symbol Locator plug-in.", +is_global_setting); + } +} + +void SymbolLocatorDebuginfod::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); + llvm::HTTPClient::cleanup(); +} + +llvm::StringRef SymbolLocatorDebuginfod::GetPluginDescriptionStatic() { + return "Debuginfod symbol locator."; +} + +SymbolLocator *SymbolLocatorDebuginfod::CreateInstance() { + return new SymbolLocatorDebuginfod(); kevinfrei wrote: canUseDebuginfod returns false if the Server URL list is empty. So if someone sets it after the plugin is created, it would have already failed. https://github.com/llvm/llvm-project/pull/70996 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] DEBUGINFOD based DWP acquisition for LLDB (PR #70996)
https://github.com/kevinfrei updated https://github.com/llvm/llvm-project/pull/70996 >From b04c85dbed0b369e747aa2a3823789203156736b Mon Sep 17 00:00:00 2001 From: Kevin Frei Date: Wed, 18 Oct 2023 14:37:34 -0700 Subject: [PATCH 1/6] DEBUGINFOD based DWP acquisition for LLDB Summary: I've plumbed the LLVM DebugInfoD client into LLDB, and added automatic downloading of DWP files to the SymbolFileDWARF.cpp plugin. If you have `DEBUGINFOD_URLS` set to a space delimited set of web servers, LLDB will try to use them as a last resort when searching for DWP files. If you do *not* have that environment variable set, nothing should be changed. There's also a setting, per Greg Clayton's request, that will override the env variable, or can be used instead of the env var. This setting is the reason for the additional API added to the llvm's Debuginfod library. Test Plan: Suggestions are welcome here. I should probably have some positive and negative tests, but I wanted to get the diff up for people who have a clue what they're doing to rip it to pieces before spending too much time validating my implementation. --- lldb/include/lldb/Target/Target.h | 3 +++ lldb/source/Core/CoreProperties.td| 2 +- lldb/source/Core/Debugger.cpp | 5 .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 1 + lldb/source/Symbol/CMakeLists.txt | 1 + lldb/source/Target/Target.cpp | 19 +- lldb/source/Target/TargetProperties.td| 4 +++ llvm/include/llvm/Debuginfod/Debuginfod.h | 4 +++ llvm/lib/Debuginfod/Debuginfod.cpp| 26 ++- 9 files changed, 57 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index c37682e2a03859f..7f10f0409fb1315 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -258,6 +258,8 @@ class TargetProperties : public Properties { bool GetDebugUtilityExpression() const; + Args GetDebugInfoDURLs() const; + private: // Callbacks for m_launch_info. void Arg0ValueChangedCallback(); @@ -270,6 +272,7 @@ class TargetProperties : public Properties { void DisableASLRValueChangedCallback(); void InheritTCCValueChangedCallback(); void DisableSTDIOValueChangedCallback(); + void DebugInfoDURLsChangedCallback(); // Settings checker for target.jit-save-objects-dir: void CheckJITObjectsDir(); diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index 92884258347e9be..865030b0133bbb2 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -4,7 +4,7 @@ let Definition = "modulelist" in { def EnableExternalLookup: Property<"enable-external-lookup", "Boolean">, Global, DefaultTrue, -Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched.">; +Desc<"Control the use of external tools and repositories to locate symbol files. Directories listed in target.debug-file-search-paths and directory of the executable are always checked first for separate debug info files. Then depending on this setting: On macOS, Spotlight would be also used to locate a matching .dSYM bundle based on the UUID of the executable. On NetBSD, directory /usr/libdata/debug would be also searched. On platforms other than NetBSD directory /usr/lib/debug would be also searched. If all other methods fail, and the DEBUGINFOD_URLS environment variable is specified, the Debuginfod protocol is used to acquire symbols from a compatible Debuginfod service.">; def EnableBackgroundLookup: Property<"enable-background-lookup", "Boolean">, Global, DefaultFalse, diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 21f71e449ca5ed0..9a3e82f3e6a2adf 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -61,6 +61,8 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator.h" +#include "llvm/Debuginfod/Debuginfod.h" +#include "llvm/Debuginfod/HTTPClient.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Process.h" @@ -594,6 +596,9 @@ lldb::DWIMPrintVerbosity Debugger::GetDWIMPrintVerbosity() const { void Debugger::Initialize(LoadPluginCallbackType load_plugin_callback) { assert(g_debugger_list_ptr == nullptr && "Debugger::Initialize called more than once!"); + // We might be using the Debuginfod service, s
[Lldb-commits] [lldb] [flang] [clang] [clang-tools-extra] [llvm] [mlir] [compiler-rt] [CodeGen][DebugInfo] Add missing debug info for jump table BB (PR #71021)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/71021 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Emit DIE's size in bits when size is not a multiple of 8 (PR #69741)
adrian-prantl wrote: > I'm arguing it doesn't fit it particularly well. We use it for bit fields - > which are pretty special, for instance, but it seems like this thing isn't > quite like that - it does have a whole byte size (if you allocated an array > of them, for instance, I'm guessing they're a byte each, right?) but then has > some padding bits that can be reused in some circumstances? That's why I'm > saying it seems like it fits more closely to the struct padding > representation. Swift is really clever at packing at packing aggregate types. For example, the discriminator bits for enums are always stored in unused bits of the payload type. For a contrived example, the type Optional> has a size of 3 bits. https://github.com/llvm/llvm-project/pull/69741 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Remove `self` references from decorators (PR #72416)
https://github.com/rupprecht updated https://github.com/llvm/llvm-project/pull/72416 >From b3178bb93c0d414857732b08228987894df762d4 Mon Sep 17 00:00:00 2001 From: Jordan Rupprecht Date: Wed, 15 Nov 2023 08:58:17 -0800 Subject: [PATCH 1/2] [lldb][test] Move most `self` references out of decorator skip checks. This is partial step toward removing the vendored `unittest2` dep in favor of the `unittest` library in standard python. One of the large differences is when xfail decorators are evaluated. With the `unittest2` vendored dep, this can happen at the moment of calling the test case, and with LLDB's decorator wrappers, we are passed the test class in the decorator arg. With the `unittest` framework, this is determined much earlier; we cannot decide when the test is about to start that we need to xfail. Fortunately, almost none of these checks require any state that can't be determined statically. For this patch, I moved the impl for all the checks to `lldbplatformutil` and pointed the decorators to that, removing as many `self` (i.e. test class object) references as possible. I left wrappers within `TestBase` that forward to `lldbplatformutil` for convenience, but we should probably remove those later. The remaining check that can't be moved statically is the check for the debug info type (e.g. to xfail only for dwarf). Fixing that requires a different approach, so I will postpone that to the next patch. --- .../Python/lldbsuite/test/decorators.py | 87 +++ .../Python/lldbsuite/test/lldbplatformutil.py | 146 +- .../Python/lldbsuite/test/lldbtest.py | 103 ++-- 3 files changed, 207 insertions(+), 129 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index b8fea1e02e864de..14328f3c54a8d1f 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -197,15 +197,17 @@ def _decorateTest( ): def fn(self): skip_for_os = _match_decorator_property( -lldbplatform.translate(oslist), self.getPlatform() +lldbplatform.translate(oslist), lldbplatformutil.getPlatform() ) skip_for_hostos = _match_decorator_property( lldbplatform.translate(hostoslist), lldbplatformutil.getHostPlatform() ) skip_for_compiler = _match_decorator_property( -compiler, self.getCompiler() -) and self.expectedCompilerVersion(compiler_version) -skip_for_arch = _match_decorator_property(archs, self.getArchitecture()) +compiler, lldbplatformutil.getCompiler() +) and lldbplatformutil.expectedCompilerVersion(compiler_version) +skip_for_arch = _match_decorator_property( +archs, lldbplatformutil.getArchitecture() +) skip_for_debug_info = _match_decorator_property(debug_info, self.getDebugInfo()) skip_for_triple = _match_decorator_property( triple, lldb.selected_platform.GetTriple() @@ -236,7 +238,7 @@ def fn(self): ) skip_for_dwarf_version = (dwarf_version is None) or ( _check_expected_version( -dwarf_version[0], dwarf_version[1], self.getDwarfVersion() +dwarf_version[0], dwarf_version[1], lldbplatformutil.getDwarfVersion() ) ) skip_for_setting = (setting is None) or (setting in configuration.settings) @@ -375,7 +377,9 @@ def skipIf( def _skip_for_android(reason, api_levels, archs): def impl(obj): result = lldbplatformutil.match_android_device( -obj.getArchitecture(), valid_archs=archs, valid_api_levels=api_levels +lldbplatformutil.getArchitecture(), +valid_archs=archs, +valid_api_levels=api_levels, ) return reason if result else None @@ -537,7 +541,10 @@ def wrapper(*args, **kwargs): def expectedFlakeyOS(oslist, bugnumber=None, compilers=None): def fn(self): -return self.getPlatform() in oslist and self.expectedCompiler(compilers) +return ( +lldbplatformutil.getPlatform() in oslist +and lldbplatformutil.expectedCompiler(compilers) +) return expectedFlakey(fn, bugnumber) @@ -618,9 +625,11 @@ def are_sb_headers_missing(): def skipIfRosetta(bugnumber): """Skip a test when running the testsuite on macOS under the Rosetta translation layer.""" -def is_running_rosetta(self): +def is_running_rosetta(): if lldbplatformutil.getPlatform() in ["darwin", "macosx"]: -if (platform.uname()[5] == "arm") and (self.getArchitecture() == "x86_64"): +if (platform.uname()[5] == "arm") and ( +lldbplatformutil.getArchitecture() == "x86_64" +): return "skipped under Rosetta" return None @@ -694,7 +703,7 @@ def skipIfWindows(func):
[Lldb-commits] [lldb] [lldb][test] Remove `self` references from decorators (PR #72416)
@@ -184,3 +187,144 @@ def hasChattyStderr(test_case): ): return True # The dynamic linker on the device will complain about unknown DT entries return False + + +def builder_module(): +return get_builder(sys.platform) + + +def getArchitecture(): +"""Returns the architecture in effect the test suite is running with.""" +module = builder_module() +arch = module.getArchitecture() +if arch == "amd64": +arch = "x86_64" +if arch in ["armv7l", "armv8l"]: +arch = "arm" +return arch + + +lldbArchitecture = None + + +def getLldbArchitecture(): rupprecht wrote: Thanks, applied https://github.com/llvm/llvm-project/pull/72416 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Remove `self` references from decorators (PR #72416)
rupprecht wrote: > Beautiful, thank you for working on this. After this change, what's left to > get us using the python-provided `unittest`? The giant lambda inside `_decorateTest` has one remaining `self` reference, which is `self.getDebugInfo()` -- i.e. the debug info specific variant created by the metaclass factory. My current approach is basically to annotate the test in a similar way as we do for the `@no_debug_info_test`, with some state that indicates which debug info kinds should be skipped/xfailed, and then when the metaclass creates each variant, it can create them as being wrapped w/ `@skip` or `@expectedFailure` depending on the result of that. After that, not a lot. Both @JDevlieghere and I have made an attempt at this in the past, and so we've already done a lot of cleanup to make things work with either library. https://github.com/llvm/llvm-project/pull/72416 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 212a60e - [lldb][test] Remove `self` references from decorators (#72416)
Author: Jordan Rupprecht Date: 2023-11-15T17:51:25-08:00 New Revision: 212a60ec37322f853e91e171b305479b1abff2f2 URL: https://github.com/llvm/llvm-project/commit/212a60ec37322f853e91e171b305479b1abff2f2 DIFF: https://github.com/llvm/llvm-project/commit/212a60ec37322f853e91e171b305479b1abff2f2.diff LOG: [lldb][test] Remove `self` references from decorators (#72416) This is partial step toward removing the vendored `unittest2` dep in favor of the `unittest` library in standard python. One of the large differences is when xfail decorators are evaluated. With the `unittest2` vendored dep, this can happen at the moment of calling the test case, and with LLDB's decorator wrappers, we are passed the test class in the decorator arg. With the `unittest` framework, this is determined much earlier; we cannot decide when the test is about to start that we need to xfail. Fortunately, almost none of these checks require any state that can't be determined statically. For this patch, I moved the impl for all the checks to `lldbplatformutil` and pointed the decorators to that, removing as many `self` (i.e. test class object) references as possible. I left wrappers within `TestBase` that forward to `lldbplatformutil` for convenience, but we should probably remove those later. The remaining check that can't be moved statically is the check for the debug info type (e.g. to xfail only for dwarf). Fixing that requires a different approach, so I will postpone that to the next patch. Added: Modified: lldb/packages/Python/lldbsuite/test/decorators.py lldb/packages/Python/lldbsuite/test/lldbplatformutil.py lldb/packages/Python/lldbsuite/test/lldbtest.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index b8fea1e02e864de..bb06a5ee20f2532 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -197,15 +197,17 @@ def _decorateTest( ): def fn(self): skip_for_os = _match_decorator_property( -lldbplatform.translate(oslist), self.getPlatform() +lldbplatform.translate(oslist), lldbplatformutil.getPlatform() ) skip_for_hostos = _match_decorator_property( lldbplatform.translate(hostoslist), lldbplatformutil.getHostPlatform() ) skip_for_compiler = _match_decorator_property( -compiler, self.getCompiler() -) and self.expectedCompilerVersion(compiler_version) -skip_for_arch = _match_decorator_property(archs, self.getArchitecture()) +compiler, lldbplatformutil.getCompiler() +) and lldbplatformutil.expectedCompilerVersion(compiler_version) +skip_for_arch = _match_decorator_property( +archs, lldbplatformutil.getArchitecture() +) skip_for_debug_info = _match_decorator_property(debug_info, self.getDebugInfo()) skip_for_triple = _match_decorator_property( triple, lldb.selected_platform.GetTriple() @@ -236,7 +238,7 @@ def fn(self): ) skip_for_dwarf_version = (dwarf_version is None) or ( _check_expected_version( -dwarf_version[0], dwarf_version[1], self.getDwarfVersion() +dwarf_version[0], dwarf_version[1], lldbplatformutil.getDwarfVersion() ) ) skip_for_setting = (setting is None) or (setting in configuration.settings) @@ -375,7 +377,9 @@ def skipIf( def _skip_for_android(reason, api_levels, archs): def impl(obj): result = lldbplatformutil.match_android_device( -obj.getArchitecture(), valid_archs=archs, valid_api_levels=api_levels +lldbplatformutil.getArchitecture(), +valid_archs=archs, +valid_api_levels=api_levels, ) return reason if result else None @@ -537,7 +541,10 @@ def wrapper(*args, **kwargs): def expectedFlakeyOS(oslist, bugnumber=None, compilers=None): def fn(self): -return self.getPlatform() in oslist and self.expectedCompiler(compilers) +return ( +lldbplatformutil.getPlatform() in oslist +and lldbplatformutil.expectedCompiler(compilers) +) return expectedFlakey(fn, bugnumber) @@ -618,9 +625,11 @@ def are_sb_headers_missing(): def skipIfRosetta(bugnumber): """Skip a test when running the testsuite on macOS under the Rosetta translation layer.""" -def is_running_rosetta(self): +def is_running_rosetta(): if lldbplatformutil.getPlatform() in ["darwin", "macosx"]: -if (platform.uname()[5] == "arm") and (self.getArchitecture() == "x86_64"): +if (platform.uname()[5] == "arm") and ( +lldbplatformutil.getArchitecture() == "x86_64" +): return "skipped under Rose
[Lldb-commits] [lldb] [lldb][test] Remove `self` references from decorators (PR #72416)
https://github.com/rupprecht closed https://github.com/llvm/llvm-project/pull/72416 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [compiler-rt] [clang-tools-extra] [lldb] [clang] [flang] [mlir] [Profile] Add binary profile correlation for code coverage. (PR #69493)
https://github.com/ZequanWu edited https://github.com/llvm/llvm-project/pull/69493 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits