[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
jasonmolenda wrote: I think I'm going open a new PR with the base class address masking added to the patch. I think having these API and the unwritten caveat is "they may be no-ops if you're using an ABI that doesn't do FixAddress" is going to confuse people. I still want to investigate why my API test failed on aarch64 linux because I didn't expect that, it's possible there's something else going on. But the ABI thing is definitely something I think should be addressed. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for sorting by size to `target module dump symtab` (PR #83527)
https://github.com/medismailben approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/83527 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for sorting by size to `target module dump symtab` (PR #83527)
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/83527 >From 5236e15ad14b5bacd566bcefa329268b8dadd9e8 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 29 Feb 2024 21:36:05 -0800 Subject: [PATCH] [lldb] Add support for sorting by size to `target module dump symtab` This patch adds support to sort the symbol table by size. The command already supports sorting and it already reports sizes. Sorting by size helps diagnosing size issues. rdar://123788375 --- .../Interpreter/CommandOptionArgumentTable.h | 5 lldb/include/lldb/lldb-private-enumerations.h | 7 +- lldb/source/Symbol/Symtab.cpp | 23 ++- .../Breakpad/symtab-sorted-by-size.test | 11 + 4 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test diff --git a/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h b/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h index 9248e2ac814461..b5e989633ea3fc 100644 --- a/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h +++ b/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h @@ -50,6 +50,11 @@ static constexpr OptionEnumValueElement g_sort_option_enumeration[] = { "name", "Sort output by symbol name.", }, +{ +eSortOrderBySize, +"size", +"Sort output by symbol byte size.", +}, }; // Note that the negation in the argument name causes a slightly confusing diff --git a/lldb/include/lldb/lldb-private-enumerations.h b/lldb/include/lldb/lldb-private-enumerations.h index 9e8ab56305bef3..b8f504529683ad 100644 --- a/lldb/include/lldb/lldb-private-enumerations.h +++ b/lldb/include/lldb/lldb-private-enumerations.h @@ -108,7 +108,12 @@ enum ArgumentRepetitionType { // optional }; -enum SortOrder { eSortOrderNone, eSortOrderByAddress, eSortOrderByName }; +enum SortOrder { + eSortOrderNone, + eSortOrderByAddress, + eSortOrderByName, + eSortOrderBySize +}; // LazyBool is for boolean values that need to be calculated lazily. Values // start off set to eLazyBoolCalculate, and then they can be calculated once diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index 564a3a94cfa202..b7837892d7e26d 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -124,12 +124,8 @@ void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order, DumpSymbolHeader(s); std::multimap name_map; - for (const_iterator pos = m_symbols.begin(), end = m_symbols.end(); - pos != end; ++pos) { -const char *name = pos->GetName().AsCString(); -if (name && name[0]) - name_map.insert(std::make_pair(name, &(*pos))); - } + for (const Symbol : m_symbols) +name_map.emplace(llvm::StringRef(symbol.GetName()), ); for (const auto _to_symbol : name_map) { const Symbol *symbol = name_to_symbol.second; @@ -138,6 +134,21 @@ void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order, } } break; +case eSortOrderBySize: { + s->PutCString(" (sorted by size):\n"); + DumpSymbolHeader(s); + + std::multimap> size_map; + for (const Symbol : m_symbols) +size_map.emplace(symbol.GetByteSize(), ); + + for (const auto _to_symbol : size_map) { +const Symbol *symbol = size_to_symbol.second; +s->Indent(); +symbol->Dump(s, target, symbol - _symbols[0], name_preference); + } +} break; + case eSortOrderByAddress: s->PutCString(" (sorted by address):\n"); DumpSymbolHeader(s); diff --git a/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test b/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test new file mode 100644 index 00..a9b6c0b1ef09b0 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test @@ -0,0 +1,11 @@ +# RUN: yaml2obj %S/Inputs/basic-elf.yaml -o %T/symtab.out +# RUN: %lldb %T/symtab.out -o "target symbols add -s symtab.out %S/Inputs/symtab.syms" \ +# RUN: -s %s | FileCheck %s + +# CHECK: num_symbols = 4 (sorted by size): +# CHECK: [0] 0 SX Code0x0040 0x00b0 0x ___lldb_unnamed_symbol0 +# CHECK: [3] 0 X Code0x004000d0 0x0022 0x _start +# CHECK: [1] 0 X Code0x004000b0 0x0010 0x f1 +# CHECK: [2] 0 X Code0x004000c0 0x0010 0x f2 + +image dump symtab -s size symtab.out ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add support for sorting by size to `target module dump symtab` (PR #83527)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes This patch adds support to sort the symbol table by size. The command already supports sorting and it already reports sizes. Sorting by size helps diagnosing size issues. rdar://123788375 --- Full diff: https://github.com/llvm/llvm-project/pull/83527.diff 4 Files Affected: - (modified) lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h (+5) - (modified) lldb/include/lldb/lldb-private-enumerations.h (+20-15) - (modified) lldb/source/Symbol/Symtab.cpp (+17-6) - (added) lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test (+11) ``diff diff --git a/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h b/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h index 9248e2ac814461..b5e989633ea3fc 100644 --- a/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h +++ b/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h @@ -50,6 +50,11 @@ static constexpr OptionEnumValueElement g_sort_option_enumeration[] = { "name", "Sort output by symbol name.", }, +{ +eSortOrderBySize, +"size", +"Sort output by symbol byte size.", +}, }; // Note that the negation in the argument name causes a slightly confusing diff --git a/lldb/include/lldb/lldb-private-enumerations.h b/lldb/include/lldb/lldb-private-enumerations.h index 9e8ab56305bef3..7649fe00a84ad4 100644 --- a/lldb/include/lldb/lldb-private-enumerations.h +++ b/lldb/include/lldb/lldb-private-enumerations.h @@ -108,7 +108,12 @@ enum ArgumentRepetitionType { // optional }; -enum SortOrder { eSortOrderNone, eSortOrderByAddress, eSortOrderByName }; +enum SortOrder { + eSortOrderNone, + eSortOrderByAddress, + eSortOrderByName, + eSortOrderBySize +}; // LazyBool is for boolean values that need to be calculated lazily. Values // start off set to eLazyBoolCalculate, and then they can be calculated once @@ -236,19 +241,19 @@ enum LoadDependentFiles { }; inline std::string GetStatDescription(lldb_private::StatisticKind K) { - switch (K) { - case StatisticKind::ExpressionSuccessful: - return "Number of expr evaluation successes"; - case StatisticKind::ExpressionFailure: - return "Number of expr evaluation failures"; - case StatisticKind::FrameVarSuccess: - return "Number of frame var successes"; - case StatisticKind::FrameVarFailure: - return "Number of frame var failures"; - case StatisticKind::StatisticMax: - return ""; - } - llvm_unreachable("Statistic not registered!"); + switch (K) { + case StatisticKind::ExpressionSuccessful: +return "Number of expr evaluation successes"; + case StatisticKind::ExpressionFailure: +return "Number of expr evaluation failures"; + case StatisticKind::FrameVarSuccess: +return "Number of frame var successes"; + case StatisticKind::FrameVarFailure: +return "Number of frame var failures"; + case StatisticKind::StatisticMax: +return ""; + } + llvm_unreachable("Statistic not registered!"); } } // namespace lldb_private @@ -271,7 +276,7 @@ template <> struct format_provider { Stream << "invalid"; } }; -} +} // namespace llvm enum SelectMostRelevant : bool { SelectMostRelevantFrame = true, diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index 564a3a94cfa202..b7837892d7e26d 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -124,12 +124,8 @@ void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order, DumpSymbolHeader(s); std::multimap name_map; - for (const_iterator pos = m_symbols.begin(), end = m_symbols.end(); - pos != end; ++pos) { -const char *name = pos->GetName().AsCString(); -if (name && name[0]) - name_map.insert(std::make_pair(name, &(*pos))); - } + for (const Symbol : m_symbols) +name_map.emplace(llvm::StringRef(symbol.GetName()), ); for (const auto _to_symbol : name_map) { const Symbol *symbol = name_to_symbol.second; @@ -138,6 +134,21 @@ void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order, } } break; +case eSortOrderBySize: { + s->PutCString(" (sorted by size):\n"); + DumpSymbolHeader(s); + + std::multimap> size_map; + for (const Symbol : m_symbols) +size_map.emplace(symbol.GetByteSize(), ); + + for (const auto _to_symbol : size_map) { +const Symbol *symbol = size_to_symbol.second; +s->Indent(); +symbol->Dump(s, target, symbol - _symbols[0], name_preference); + } +} break; + case eSortOrderByAddress: s->PutCString(" (sorted by address):\n"); DumpSymbolHeader(s); diff --git a/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test b/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test new file mode 100644 index
[Lldb-commits] [lldb] [lldb] Add support for sorting by size to `target module dump symtab` (PR #83527)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/83527 This patch adds support to sort the symbol table by size. The command already supports sorting and it already reports sizes. Sorting by size helps diagnosing size issues. rdar://123788375 >From 5e399ab6d01c9467daa73f13a20a8e420e130acd Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 29 Feb 2024 21:31:51 -0800 Subject: [PATCH] [lldb] Add support for sorting by size to `target module dump symtab` This patch adds support to sort the symbol table by size. The command already supports sorting and it already reports sizes. Sorting by size helps diagnosing size issues. rdar://123788375 --- .../Interpreter/CommandOptionArgumentTable.h | 5 +++ lldb/include/lldb/lldb-private-enumerations.h | 35 +++ lldb/source/Symbol/Symtab.cpp | 23 .../Breakpad/symtab-sorted-by-size.test | 11 ++ 4 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test diff --git a/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h b/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h index 9248e2ac814461..b5e989633ea3fc 100644 --- a/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h +++ b/lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h @@ -50,6 +50,11 @@ static constexpr OptionEnumValueElement g_sort_option_enumeration[] = { "name", "Sort output by symbol name.", }, +{ +eSortOrderBySize, +"size", +"Sort output by symbol byte size.", +}, }; // Note that the negation in the argument name causes a slightly confusing diff --git a/lldb/include/lldb/lldb-private-enumerations.h b/lldb/include/lldb/lldb-private-enumerations.h index 9e8ab56305bef3..7649fe00a84ad4 100644 --- a/lldb/include/lldb/lldb-private-enumerations.h +++ b/lldb/include/lldb/lldb-private-enumerations.h @@ -108,7 +108,12 @@ enum ArgumentRepetitionType { // optional }; -enum SortOrder { eSortOrderNone, eSortOrderByAddress, eSortOrderByName }; +enum SortOrder { + eSortOrderNone, + eSortOrderByAddress, + eSortOrderByName, + eSortOrderBySize +}; // LazyBool is for boolean values that need to be calculated lazily. Values // start off set to eLazyBoolCalculate, and then they can be calculated once @@ -236,19 +241,19 @@ enum LoadDependentFiles { }; inline std::string GetStatDescription(lldb_private::StatisticKind K) { - switch (K) { - case StatisticKind::ExpressionSuccessful: - return "Number of expr evaluation successes"; - case StatisticKind::ExpressionFailure: - return "Number of expr evaluation failures"; - case StatisticKind::FrameVarSuccess: - return "Number of frame var successes"; - case StatisticKind::FrameVarFailure: - return "Number of frame var failures"; - case StatisticKind::StatisticMax: - return ""; - } - llvm_unreachable("Statistic not registered!"); + switch (K) { + case StatisticKind::ExpressionSuccessful: +return "Number of expr evaluation successes"; + case StatisticKind::ExpressionFailure: +return "Number of expr evaluation failures"; + case StatisticKind::FrameVarSuccess: +return "Number of frame var successes"; + case StatisticKind::FrameVarFailure: +return "Number of frame var failures"; + case StatisticKind::StatisticMax: +return ""; + } + llvm_unreachable("Statistic not registered!"); } } // namespace lldb_private @@ -271,7 +276,7 @@ template <> struct format_provider { Stream << "invalid"; } }; -} +} // namespace llvm enum SelectMostRelevant : bool { SelectMostRelevantFrame = true, diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index 564a3a94cfa202..b7837892d7e26d 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -124,12 +124,8 @@ void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order, DumpSymbolHeader(s); std::multimap name_map; - for (const_iterator pos = m_symbols.begin(), end = m_symbols.end(); - pos != end; ++pos) { -const char *name = pos->GetName().AsCString(); -if (name && name[0]) - name_map.insert(std::make_pair(name, &(*pos))); - } + for (const Symbol : m_symbols) +name_map.emplace(llvm::StringRef(symbol.GetName()), ); for (const auto _to_symbol : name_map) { const Symbol *symbol = name_to_symbol.second; @@ -138,6 +134,21 @@ void Symtab::Dump(Stream *s, Target *target, SortOrder sort_order, } } break; +case eSortOrderBySize: { + s->PutCString(" (sorted by size):\n"); + DumpSymbolHeader(s); + + std::multimap> size_map; + for (const Symbol : m_symbols) +size_map.emplace(symbol.GetByteSize(), ); + + for (const auto _to_symbol : size_map) { +const Symbol *symbol =
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
jasonmolenda wrote: It does occur to me that I'm going to need to only run this API test on targets which have a FixAddress method in their ABI, the base class own't do it. Maybe it should have a base class impl that can be overridden, and use the Process masks if they are set. (they're all initialized to 0 which is an impossible mask value (no address bits)) The base class impl would need to be overridden for different architectures, e.g. on AArch64 where TBI or MTE are used, in addition to clearing/setting the top byte, we need to use b55 to determine if the non-address bits are set to 1 or 0. On armv7 the 0th bit can be used for metadata on TypeCode fixes, etc. But still I'd expect the lldb-aarch64-ubuntu bot to have had a FixAddress impl in its ABI. will check out when I build it up. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [debugserver] fix qLaunchSuccess error, add QErrorStringInPacketSupported (PR #82593)
https://github.com/jasonmolenda closed https://github.com/llvm/llvm-project/pull/82593 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 4551f53 - [lldb] [debugserver] fix qLaunchSuccess error, add QErrorStringInPacketSupported (#82593)
Author: Jason Molenda Date: 2024-02-29T20:22:12-08:00 New Revision: 4551f53523074cd4e2f93a6f79313ca2cdcc40d2 URL: https://github.com/llvm/llvm-project/commit/4551f53523074cd4e2f93a6f79313ca2cdcc40d2 DIFF: https://github.com/llvm/llvm-project/commit/4551f53523074cd4e2f93a6f79313ca2cdcc40d2.diff LOG: [lldb] [debugserver] fix qLaunchSuccess error, add QErrorStringInPacketSupported (#82593) Pavel added an extension to lldb's gdb remote serial protocol that allows the debug stub to append an error message (ascii hex encoded) after an error response packet Exx. This was added in 2017 in https://reviews.llvm.org/D34945 . lldb sends the QErrorStringInPacketSupported packet and then the remote stub may add these error strings. debugserver has two bugs in its use of extended error messages: the vAttach family would send the extended error string without checking if the mode had been enabled. And qLaunchSuccess would not properly format its error response packet (missing the hex digits, did not asciihex encode the string). There is also a bug in the HandlePacket_D (detach) packet where the error packets did not include hex digits, but this one does not append an error string. I'm adding a new RNBRemote::SendErrorPacket() and routing all error packet returns though this one method. It takes an optional second string which is the longer error message; it now handles appending it to the Exx response or not, depending on the QErrorStringInPacketSupported state. I updated all packets to send their errors via this method. Added: Modified: lldb/tools/debugserver/source/RNBRemote.cpp lldb/tools/debugserver/source/RNBRemote.h Removed: diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index 03d427d3fc5954..f22d626c4af2c6 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -143,6 +143,39 @@ uint64_t decode_uint64(const char *p, int base, char **end = nullptr, return addr; } +void append_hex_value(std::ostream , const void *buf, size_t buf_size, + bool swap) { + int i; + const uint8_t *p = (const uint8_t *)buf; + if (swap) { +for (i = static_cast(buf_size) - 1; i >= 0; i--) + ostrm << RAWHEX8(p[i]); + } else { +for (size_t i = 0; i < buf_size; i++) + ostrm << RAWHEX8(p[i]); + } +} + +std::string cstring_to_asciihex_string(const char *str) { + std::string hex_str; + hex_str.reserve(strlen(str) * 2); + while (str && *str) { +uint8_t c = *str++; +char hexbuf[5]; +snprintf(hexbuf, sizeof(hexbuf), "%02x", c); +hex_str += hexbuf; + } + return hex_str; +} + +void append_hexified_string(std::ostream , const std::string ) { + size_t string_size = string.size(); + const char *string_buf = string.c_str(); + for (size_t i = 0; i < string_size; i++) { +ostrm << RAWHEX8(*(string_buf + i)); + } +} + extern void ASLLogCallback(void *baton, uint32_t flags, const char *format, va_list args); @@ -171,7 +204,8 @@ RNBRemote::RNBRemote() m_extended_mode(false), m_noack_mode(false), m_thread_suffix_supported(false), m_list_threads_in_stop_reply(false), m_compression_minsize(384), m_enable_compression_next_send_packet(false), - m_compression_mode(compression_types::none) { + m_compression_mode(compression_types::none), + m_enable_error_strings(false) { DNBLogThreadedIf(LOG_RNB_REMOTE, "%s", __PRETTY_FUNCTION__); CreatePacketTable(); } @@ -365,6 +399,11 @@ void RNBRemote::CreatePacketTable() { t.push_back(Packet( query_symbol_lookup, ::HandlePacket_qSymbol, NULL, "qSymbol:", "Notify that host debugger is ready to do symbol lookups")); + t.push_back(Packet(enable_error_strings, + ::HandlePacket_QEnableErrorStrings, NULL, + "QEnableErrorStrings", + "Tell " DEBUGSERVER_PROGRAM_NAME + " it can append descriptive error messages in replies.")); t.push_back(Packet(json_query_thread_extended_info, ::HandlePacket_jThreadExtendedInfo, NULL, "jThreadExtendedInfo", @@ -769,6 +808,15 @@ rnb_err_t RNBRemote::SendPacket(const std::string ) { return rnb_err; } +rnb_err_t RNBRemote::SendErrorPacket(std::string errcode, + const std::string ) { + if (m_enable_error_strings && !errmsg.empty()) { +errcode += ";"; +errcode += cstring_to_asciihex_string(errmsg.c_str()); + } + return SendPacket(errcode); +} + /* Get a packet via gdb remote protocol. Strip off the prefix/suffix, verify the checksum to make sure a valid packet was received, send an ACK if they match. */ @@ -884,7 +932,7 @@ rnb_err_t RNBRemote::HandlePacket_ILLFORMED(const char *file, int line, DNBLogThreadedIf(LOG_RNB_PACKETS,
[Lldb-commits] [lldb] [lldb] [debugserver] fix qLaunchSuccess error, add QErrorStringInPacketSupported (PR #82593)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/82593 >From 0ba4e6402969028fa6152c366a56063a56acded1 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Wed, 21 Feb 2024 22:48:36 -0800 Subject: [PATCH 1/3] [lldb] [debugserver] fix qLaunchSuccess error, add QErrorStringInPacketSupported Pavel added an extension to lldb's gdb remote serial protocol that allows the debug stub to append an error message (ascii hex encoded) after an error response packet Exx. This was added in 2017 in https://reviews.llvm.org/D34945 . lldb sends the QErrorStringInPacketSupported packet and then the remote stub may add these error strings. debugserver has added these strings to the vAttach family of packets to explain why an attach failed, without waiting to see the QErrorStringInPacketSupported packet to enable the mode. debugserver also has a bad implementation of this for the qLaunchSuccess packet, where "E" is sent followed by the literal characters of the error, instead of Exx;, which lldb can have problems parsing. This patch moves three utility functions earlier in RNBRemote.cpp, it accepts the QErrorStringInPacketSupported packet and only appends the expanded error messages when that has been sent (lldb always sends it at the beginning of a connection), fixes the error string returned by qLaunchSuccess and changes the vAttach error returns to only add the error string when the mode is enabled. --- lldb/tools/debugserver/source/RNBRemote.cpp | 157 lldb/tools/debugserver/source/RNBRemote.h | 5 + 2 files changed, 103 insertions(+), 59 deletions(-) diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index feea4c914ec536..8338e4d0032870 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -143,6 +143,39 @@ uint64_t decode_uint64(const char *p, int base, char **end = nullptr, return addr; } +void append_hex_value(std::ostream , const void *buf, size_t buf_size, + bool swap) { + int i; + const uint8_t *p = (const uint8_t *)buf; + if (swap) { +for (i = static_cast(buf_size) - 1; i >= 0; i--) + ostrm << RAWHEX8(p[i]); + } else { +for (size_t i = 0; i < buf_size; i++) + ostrm << RAWHEX8(p[i]); + } +} + +std::string cstring_to_asciihex_string(const char *str) { + std::string hex_str; + hex_str.reserve(strlen(str) * 2); + while (str && *str) { +uint8_t c = *str++; +char hexbuf[5]; +snprintf(hexbuf, sizeof(hexbuf), "%02x", c); +hex_str += hexbuf; + } + return hex_str; +} + +void append_hexified_string(std::ostream , const std::string ) { + size_t string_size = string.size(); + const char *string_buf = string.c_str(); + for (size_t i = 0; i < string_size; i++) { +ostrm << RAWHEX8(*(string_buf + i)); + } +} + extern void ASLLogCallback(void *baton, uint32_t flags, const char *format, va_list args); @@ -171,7 +204,8 @@ RNBRemote::RNBRemote() m_extended_mode(false), m_noack_mode(false), m_thread_suffix_supported(false), m_list_threads_in_stop_reply(false), m_compression_minsize(384), m_enable_compression_next_send_packet(false), - m_compression_mode(compression_types::none) { + m_compression_mode(compression_types::none), + m_enable_error_strings(false) { DNBLogThreadedIf(LOG_RNB_REMOTE, "%s", __PRETTY_FUNCTION__); CreatePacketTable(); } @@ -365,6 +399,11 @@ void RNBRemote::CreatePacketTable() { t.push_back(Packet( query_symbol_lookup, ::HandlePacket_qSymbol, NULL, "qSymbol:", "Notify that host debugger is ready to do symbol lookups")); + t.push_back(Packet(enable_error_strings, + ::HandlePacket_QEnableErrorStrings, NULL, + "QEnableErrorStrings", + "Tell " DEBUGSERVER_PROGRAM_NAME + " it can append descriptive error messages in replies.")); t.push_back(Packet(json_query_thread_extended_info, ::HandlePacket_jThreadExtendedInfo, NULL, "jThreadExtendedInfo", @@ -1566,11 +1605,13 @@ rnb_err_t RNBRemote::HandlePacket_qLaunchSuccess(const char *p) { if (m_ctx.HasValidProcessID() || m_ctx.LaunchStatus().Status() == 0) return SendPacket("OK"); std::ostringstream ret_str; - std::string status_str; - std::string error_quoted = binary_encode_string - (m_ctx.LaunchStatusAsString(status_str)); - ret_str << "E" << error_quoted; - + ret_str << "E89"; + if (m_enable_error_strings) { +std::string status_str; +std::string error_quoted = +cstring_to_asciihex_string(m_ctx.LaunchStatusAsString(status_str)); +ret_str << ";" << error_quoted; + } return SendPacket(ret_str.str()); } @@ -2534,39 +2575,6 @@ rnb_err_t RNBRemote::HandlePacket_QSetProcessEvent(const char *p) { return SendPacket("OK"); } -void
[Lldb-commits] [lldb] [lldb][progress][NFC] Fix Doxygen information (PR #83502)
https://github.com/chelcassanova closed https://github.com/llvm/llvm-project/pull/83502 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 8171f6d - [lldb][progress][NFC] Fix Doxygen information (#83502)
Author: Chelsea Cassanova Date: 2024-02-29T19:22:23-08:00 New Revision: 8171f6d12eafbd4a67ad263770c142d51504d834 URL: https://github.com/llvm/llvm-project/commit/8171f6d12eafbd4a67ad263770c142d51504d834 DIFF: https://github.com/llvm/llvm-project/commit/8171f6d12eafbd4a67ad263770c142d51504d834.diff LOG: [lldb][progress][NFC] Fix Doxygen information (#83502) Added: Modified: lldb/include/lldb/Core/Progress.h Removed: diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index eb4d9f9d7af08e..9549e3b5aea950 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -64,6 +64,9 @@ class Progress { /// /// @param [in] title The title of this progress activity. /// + /// @param [in] details Specific information about what the progress report + /// is currently working on. + /// /// @param [in] total The total units of work to be done if specified, if /// set to std::nullopt then an indeterminate progress indicator should be /// displayed. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
https://github.com/JDevlieghere deleted https://github.com/llvm/llvm-project/pull/83069 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change the return type of CalculateNumChildren to uint32_t. (PR #83501)
bulbazord wrote: Why not increase TypeSystem::GetNumChildren to return a size_t instead? https://github.com/llvm/llvm-project/pull/83501 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [debugserver] fix qLaunchSuccess error, add QErrorStringInPacketSupported (PR #82593)
https://github.com/bulbazord approved this pull request. Looks great!!! Thanks for fixing the bug and gardening! https://github.com/llvm/llvm-project/pull/82593 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
@@ -22,38 +23,47 @@ std::atomic Progress::g_id(0); Progress::Progress(std::string title, std::string details, std::optional total, lldb_private::Debugger *debugger) -: m_title(title), m_details(details), m_id(++g_id), m_completed(0), - m_total(Progress::kNonDeterministicTotal) { +: m_progress_data{title, + details, + ++g_id, + /*m_progress_data.completed*/ 0, JDevlieghere wrote: Nit: llvm uses this style: ```/*m_progress_data.completed=*/0,``` https://github.com/llvm/llvm-project/pull/83069 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
https://github.com/JDevlieghere approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/83069 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/83069 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Extract getter function for experimental target properties (NFC) (PR #83504)
https://github.com/JDevlieghere approved this pull request. LGMT, thanks for improving this! https://github.com/llvm/llvm-project/pull/83504 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "XFAIL TestLocalVariables.py on Windows" (PR #83454)
github-actions[bot] wrote: @amordo Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may recieve a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/83454 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "XFAIL TestLocalVariables.py on Windows" (PR #83454)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/83454 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5b6e58c - Revert "XFAIL TestLocalVariables.py on Windows" (#83454)
Author: Alexander M Date: 2024-02-29T18:23:12-08:00 New Revision: 5b6e58c565cf809e4133a10ff9d9b096754bea1e URL: https://github.com/llvm/llvm-project/commit/5b6e58c565cf809e4133a10ff9d9b096754bea1e DIFF: https://github.com/llvm/llvm-project/commit/5b6e58c565cf809e4133a10ff9d9b096754bea1e.diff LOG: Revert "XFAIL TestLocalVariables.py on Windows" (#83454) This reverts commit 3434472ed74141848634b5eb3cd625d651e22562. Closes #43097. Added: Modified: lldb/test/API/lang/c/local_variables/TestLocalVariables.py Removed: diff --git a/lldb/test/API/lang/c/local_variables/TestLocalVariables.py b/lldb/test/API/lang/c/local_variables/TestLocalVariables.py index cccb8cac013ff2..686636119314ef 100644 --- a/lldb/test/API/lang/c/local_variables/TestLocalVariables.py +++ b/lldb/test/API/lang/c/local_variables/TestLocalVariables.py @@ -19,7 +19,6 @@ def setUp(self): self.source = "main.c" self.line = line_number(self.source, "// Set break point at this line.") -@skipIfWindows def test_c_local_variables(self): """Test local variable value.""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "XFAIL TestLocalVariables.py on Windows" (PR #83454)
https://github.com/JDevlieghere approved this pull request. Thanks! https://github.com/llvm/llvm-project/pull/83454 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress][NFC] Fix Doxygen information (PR #83502)
https://github.com/bulbazord approved this pull request. https://github.com/llvm/llvm-project/pull/83502 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress][NFC] Fix Doxygen information (PR #83502)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/83502 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
jasonmolenda wrote: Temporarily reverted this change while I investigate why the tests failed on all the linux bots (lldb-x86_64-debian, lldb-arm-ubuntu, lldb-aarch64-ubuntu), I'll build up in a VM and debug. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e8ce864 - Revert "[lldb] Add SBProcess methods for get/set/use address masks (#83095)"
Author: Jason Molenda Date: 2024-02-29T17:29:24-08:00 New Revision: e8ce864a36ba02ddb63877905d49f1e9ac60b544 URL: https://github.com/llvm/llvm-project/commit/e8ce864a36ba02ddb63877905d49f1e9ac60b544 DIFF: https://github.com/llvm/llvm-project/commit/e8ce864a36ba02ddb63877905d49f1e9ac60b544.diff LOG: Revert "[lldb] Add SBProcess methods for get/set/use address masks (#83095)" This reverts commit 9a12b0a60084b2b92f728e1bddec884a47458459. TestAddressMasks fails its first test on lldb-x86_64-debian, lldb-arm-ubuntu, lldb-aarch64-ubuntu bots. Reverting while investigating. Added: Modified: lldb/include/lldb/API/SBProcess.h lldb/include/lldb/Utility/AddressableBits.h lldb/include/lldb/lldb-defines.h lldb/include/lldb/lldb-enumerations.h lldb/source/API/SBProcess.cpp lldb/source/Target/Process.cpp lldb/source/Utility/AddressableBits.cpp Removed: lldb/test/API/python_api/process/address-masks/Makefile lldb/test/API/python_api/process/address-masks/TestAddressMasks.py lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 7da3335a7234b7..4f92a41f3028a2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,120 +407,6 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); - /// \{ - /// \group Mask Address Methods - /// - /// \a type - /// All of the methods in this group take \a type argument - /// which is an AddressMaskType enum value. - /// There can be diff erent address masks for code addresses and - /// data addresses, this argument can select which to get/set, - /// or to use when clearing non-addressable bits from an address. - /// This choice of mask can be important for example on AArch32 - /// systems. Where instructions where instructions start on even addresses, - /// the 0th bit may be used to indicate that a function is thumb code. On - /// such a target, the eAddressMaskTypeCode may clear the 0th bit from an - /// address to get the actual address Whereas eAddressMaskTypeData would not. - /// - /// \a addr_range - /// Many of the methods in this group take an \a addr_range argument - /// which is an AddressMaskRange enum value. - /// Needing to specify the address range is highly unusual, and the - /// default argument can be used in nearly all circumstances. - /// On some architectures (e.g., AArch64), it is possible to have - /// diff erent page table setups for low and high memory, so diff erent - /// numbers of bits relevant to addressing. It is possible to have - /// a program running in one half of memory and accessing the other - /// as heap, so we need to maintain two diff erent sets of address masks - /// to debug this correctly. - - /// Get the current address mask that will be applied to addresses - /// before reading from memory. - /// - /// \param[in] type - /// See \ref Mask Address Methods description of this argument. - /// eAddressMaskTypeAny is often a suitable value when code and - /// data masks are the same on a given target. - /// - /// \param[in] addr_range - /// See \ref Mask Address Methods description of this argument. - /// This will default to eAddressMaskRangeLow which is the - /// only set of masks used normally. - /// - /// \return - /// The address mask currently in use. Bits which are not used - /// for addressing will be set to 1 in the mask. - lldb::addr_t GetAddressMask( - lldb::AddressMaskType type, - lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); - - /// Set the current address mask that can be applied to addresses - /// before reading from memory. - /// - /// \param[in] type - /// See \ref Mask Address Methods description of this argument. - /// eAddressMaskTypeAll is often a suitable value when the - /// same mask is being set for both code and data. - /// - /// \param[in] mask - /// The address mask to set. Bits which are not used for addressing - /// should be set to 1 in the mask. - /// - /// \param[in] addr_range - /// See \ref Mask Address Methods description of this argument. - /// This will default to eAddressMaskRangeLow which is the - /// only set of masks used normally. - void SetAddressMask( - lldb::AddressMaskType type, lldb::addr_t mask, - lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); - - /// Set the number of bits used for addressing in this Process. - /// - /// On Darwin and similar systems, the addressable bits are expressed - /// as the number of low order bits that are relevant to addressing, - /// instead of a more general address mask. - /// This method calculates the correct mask value for a given number - /// of
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda closed https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 9a12b0a - [lldb] Add SBProcess methods for get/set/use address masks (#83095)
Author: Jason Molenda Date: 2024-02-29T17:02:42-08:00 New Revision: 9a12b0a60084b2b92f728e1bddec884a47458459 URL: https://github.com/llvm/llvm-project/commit/9a12b0a60084b2b92f728e1bddec884a47458459 DIFF: https://github.com/llvm/llvm-project/commit/9a12b0a60084b2b92f728e1bddec884a47458459.diff LOG: [lldb] Add SBProcess methods for get/set/use address masks (#83095) I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 Added: lldb/test/API/python_api/process/address-masks/Makefile lldb/test/API/python_api/process/address-masks/TestAddressMasks.py lldb/test/API/python_api/process/address-masks/main.c Modified: lldb/include/lldb/API/SBProcess.h lldb/include/lldb/Utility/AddressableBits.h lldb/include/lldb/lldb-defines.h lldb/include/lldb/lldb-enumerations.h lldb/source/API/SBProcess.cpp lldb/source/Target/Process.cpp lldb/source/Utility/AddressableBits.cpp Removed: diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7da3335a7234b7 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,120 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be diff erent address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// This choice of mask can be important for example on AArch32 + /// systems. Where instructions where instructions start on even addresses, + /// the 0th bit may be used to indicate that a function is thumb code. On + /// such a target, the eAddressMaskTypeCode may clear the 0th bit from an + /// address to get the actual address Whereas eAddressMaskTypeData would not. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures (e.g., AArch64), it is possible to have + /// diff erent page table setups for low and high memory, so diff erent + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two diff erent sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods description of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods description of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods description of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods description of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of
[Lldb-commits] [lldb] [lldb] [debugserver] fix qLaunchSuccess error, add QErrorStringInPacketSupported (PR #82593)
jasonmolenda wrote: Going back to this PR, @bulbazord @clayborg and I agreed that having a single method for sending error reply packets, which correctly encode the error string it if is available and extended-error-responses has been enabled, would be worth modifying all the error returns, so I did that. I found an additional bad error response in HandlePacket_D where it did not include hex digits on its error response. I think we're good to land this now. https://github.com/llvm/llvm-project/pull/82593 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] [debugserver] fix qLaunchSuccess error, add QErrorStringInPacketSupported (PR #82593)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/82593 >From 0ba4e6402969028fa6152c366a56063a56acded1 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Wed, 21 Feb 2024 22:48:36 -0800 Subject: [PATCH 1/3] [lldb] [debugserver] fix qLaunchSuccess error, add QErrorStringInPacketSupported Pavel added an extension to lldb's gdb remote serial protocol that allows the debug stub to append an error message (ascii hex encoded) after an error response packet Exx. This was added in 2017 in https://reviews.llvm.org/D34945 . lldb sends the QErrorStringInPacketSupported packet and then the remote stub may add these error strings. debugserver has added these strings to the vAttach family of packets to explain why an attach failed, without waiting to see the QErrorStringInPacketSupported packet to enable the mode. debugserver also has a bad implementation of this for the qLaunchSuccess packet, where "E" is sent followed by the literal characters of the error, instead of Exx;, which lldb can have problems parsing. This patch moves three utility functions earlier in RNBRemote.cpp, it accepts the QErrorStringInPacketSupported packet and only appends the expanded error messages when that has been sent (lldb always sends it at the beginning of a connection), fixes the error string returned by qLaunchSuccess and changes the vAttach error returns to only add the error string when the mode is enabled. --- lldb/tools/debugserver/source/RNBRemote.cpp | 157 lldb/tools/debugserver/source/RNBRemote.h | 5 + 2 files changed, 103 insertions(+), 59 deletions(-) diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index feea4c914ec536..8338e4d0032870 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -143,6 +143,39 @@ uint64_t decode_uint64(const char *p, int base, char **end = nullptr, return addr; } +void append_hex_value(std::ostream , const void *buf, size_t buf_size, + bool swap) { + int i; + const uint8_t *p = (const uint8_t *)buf; + if (swap) { +for (i = static_cast(buf_size) - 1; i >= 0; i--) + ostrm << RAWHEX8(p[i]); + } else { +for (size_t i = 0; i < buf_size; i++) + ostrm << RAWHEX8(p[i]); + } +} + +std::string cstring_to_asciihex_string(const char *str) { + std::string hex_str; + hex_str.reserve(strlen(str) * 2); + while (str && *str) { +uint8_t c = *str++; +char hexbuf[5]; +snprintf(hexbuf, sizeof(hexbuf), "%02x", c); +hex_str += hexbuf; + } + return hex_str; +} + +void append_hexified_string(std::ostream , const std::string ) { + size_t string_size = string.size(); + const char *string_buf = string.c_str(); + for (size_t i = 0; i < string_size; i++) { +ostrm << RAWHEX8(*(string_buf + i)); + } +} + extern void ASLLogCallback(void *baton, uint32_t flags, const char *format, va_list args); @@ -171,7 +204,8 @@ RNBRemote::RNBRemote() m_extended_mode(false), m_noack_mode(false), m_thread_suffix_supported(false), m_list_threads_in_stop_reply(false), m_compression_minsize(384), m_enable_compression_next_send_packet(false), - m_compression_mode(compression_types::none) { + m_compression_mode(compression_types::none), + m_enable_error_strings(false) { DNBLogThreadedIf(LOG_RNB_REMOTE, "%s", __PRETTY_FUNCTION__); CreatePacketTable(); } @@ -365,6 +399,11 @@ void RNBRemote::CreatePacketTable() { t.push_back(Packet( query_symbol_lookup, ::HandlePacket_qSymbol, NULL, "qSymbol:", "Notify that host debugger is ready to do symbol lookups")); + t.push_back(Packet(enable_error_strings, + ::HandlePacket_QEnableErrorStrings, NULL, + "QEnableErrorStrings", + "Tell " DEBUGSERVER_PROGRAM_NAME + " it can append descriptive error messages in replies.")); t.push_back(Packet(json_query_thread_extended_info, ::HandlePacket_jThreadExtendedInfo, NULL, "jThreadExtendedInfo", @@ -1566,11 +1605,13 @@ rnb_err_t RNBRemote::HandlePacket_qLaunchSuccess(const char *p) { if (m_ctx.HasValidProcessID() || m_ctx.LaunchStatus().Status() == 0) return SendPacket("OK"); std::ostringstream ret_str; - std::string status_str; - std::string error_quoted = binary_encode_string - (m_ctx.LaunchStatusAsString(status_str)); - ret_str << "E" << error_quoted; - + ret_str << "E89"; + if (m_enable_error_strings) { +std::string status_str; +std::string error_quoted = +cstring_to_asciihex_string(m_ctx.LaunchStatusAsString(status_str)); +ret_str << ";" << error_quoted; + } return SendPacket(ret_str.str()); } @@ -2534,39 +2575,6 @@ rnb_err_t RNBRemote::HandlePacket_QSetProcessEvent(const char *p) { return SendPacket("OK"); } -void
[Lldb-commits] [lldb] [lldb] [debugserver] fix qLaunchSuccess error, add QErrorStringInPacketSupported (PR #82593)
https://github.com/jasonmolenda edited https://github.com/llvm/llvm-project/pull/82593 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/9] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] [debugserver] fix qLaunchSuccess error, add QErrorStringInPacketSupported (PR #82593)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/82593 >From 0ba4e6402969028fa6152c366a56063a56acded1 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Wed, 21 Feb 2024 22:48:36 -0800 Subject: [PATCH 1/2] [lldb] [debugserver] fix qLaunchSuccess error, add QErrorStringInPacketSupported Pavel added an extension to lldb's gdb remote serial protocol that allows the debug stub to append an error message (ascii hex encoded) after an error response packet Exx. This was added in 2017 in https://reviews.llvm.org/D34945 . lldb sends the QErrorStringInPacketSupported packet and then the remote stub may add these error strings. debugserver has added these strings to the vAttach family of packets to explain why an attach failed, without waiting to see the QErrorStringInPacketSupported packet to enable the mode. debugserver also has a bad implementation of this for the qLaunchSuccess packet, where "E" is sent followed by the literal characters of the error, instead of Exx;, which lldb can have problems parsing. This patch moves three utility functions earlier in RNBRemote.cpp, it accepts the QErrorStringInPacketSupported packet and only appends the expanded error messages when that has been sent (lldb always sends it at the beginning of a connection), fixes the error string returned by qLaunchSuccess and changes the vAttach error returns to only add the error string when the mode is enabled. --- lldb/tools/debugserver/source/RNBRemote.cpp | 157 lldb/tools/debugserver/source/RNBRemote.h | 5 + 2 files changed, 103 insertions(+), 59 deletions(-) diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index feea4c914ec536..8338e4d0032870 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -143,6 +143,39 @@ uint64_t decode_uint64(const char *p, int base, char **end = nullptr, return addr; } +void append_hex_value(std::ostream , const void *buf, size_t buf_size, + bool swap) { + int i; + const uint8_t *p = (const uint8_t *)buf; + if (swap) { +for (i = static_cast(buf_size) - 1; i >= 0; i--) + ostrm << RAWHEX8(p[i]); + } else { +for (size_t i = 0; i < buf_size; i++) + ostrm << RAWHEX8(p[i]); + } +} + +std::string cstring_to_asciihex_string(const char *str) { + std::string hex_str; + hex_str.reserve(strlen(str) * 2); + while (str && *str) { +uint8_t c = *str++; +char hexbuf[5]; +snprintf(hexbuf, sizeof(hexbuf), "%02x", c); +hex_str += hexbuf; + } + return hex_str; +} + +void append_hexified_string(std::ostream , const std::string ) { + size_t string_size = string.size(); + const char *string_buf = string.c_str(); + for (size_t i = 0; i < string_size; i++) { +ostrm << RAWHEX8(*(string_buf + i)); + } +} + extern void ASLLogCallback(void *baton, uint32_t flags, const char *format, va_list args); @@ -171,7 +204,8 @@ RNBRemote::RNBRemote() m_extended_mode(false), m_noack_mode(false), m_thread_suffix_supported(false), m_list_threads_in_stop_reply(false), m_compression_minsize(384), m_enable_compression_next_send_packet(false), - m_compression_mode(compression_types::none) { + m_compression_mode(compression_types::none), + m_enable_error_strings(false) { DNBLogThreadedIf(LOG_RNB_REMOTE, "%s", __PRETTY_FUNCTION__); CreatePacketTable(); } @@ -365,6 +399,11 @@ void RNBRemote::CreatePacketTable() { t.push_back(Packet( query_symbol_lookup, ::HandlePacket_qSymbol, NULL, "qSymbol:", "Notify that host debugger is ready to do symbol lookups")); + t.push_back(Packet(enable_error_strings, + ::HandlePacket_QEnableErrorStrings, NULL, + "QEnableErrorStrings", + "Tell " DEBUGSERVER_PROGRAM_NAME + " it can append descriptive error messages in replies.")); t.push_back(Packet(json_query_thread_extended_info, ::HandlePacket_jThreadExtendedInfo, NULL, "jThreadExtendedInfo", @@ -1566,11 +1605,13 @@ rnb_err_t RNBRemote::HandlePacket_qLaunchSuccess(const char *p) { if (m_ctx.HasValidProcessID() || m_ctx.LaunchStatus().Status() == 0) return SendPacket("OK"); std::ostringstream ret_str; - std::string status_str; - std::string error_quoted = binary_encode_string - (m_ctx.LaunchStatusAsString(status_str)); - ret_str << "E" << error_quoted; - + ret_str << "E89"; + if (m_enable_error_strings) { +std::string status_str; +std::string error_quoted = +cstring_to_asciihex_string(m_ctx.LaunchStatusAsString(status_str)); +ret_str << ";" << error_quoted; + } return SendPacket(ret_str.str()); } @@ -2534,39 +2575,6 @@ rnb_err_t RNBRemote::HandlePacket_QSetProcessEvent(const char *p) { return SendPacket("OK"); } -void
[Lldb-commits] [lldb] Change the return type of CalculateNumChildren to uint32_t. (PR #83501)
jimingham wrote: Theoretically someone could make a synthetic type or an array with more than UINT32_MAX elements, and with this change we can't support displaying that. I did get one bug report that this didn't work a few years back, though this likely a very uncommon case. If it were easy to go the other way, and pipe num_children as a size_t meaningfully through clang and lldb, that would be formally better. But that's a nice to have, and if the clang changes would be disruptive, then this change is also fine by me. Better to not lie to ourselves about what we can do. https://github.com/llvm/llvm-project/pull/83501 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Extract getter function for experimental target properties (NFC) (PR #83504)
@@ -4227,28 +4228,21 @@ void TargetProperties::UpdateLaunchInfoFromProperties() { DisableSTDIOValueChangedCallback(); } -bool TargetProperties::GetInjectLocalVariables( -ExecutionContext *exe_ctx) const { +std::optional TargetProperties::GetExperimentalPropertyValue( +size_t prop_idx, ExecutionContext *exe_ctx) const { const Property *exp_property = m_collection_sp->GetPropertyAtIndex(ePropertyExperimental, exe_ctx); OptionValueProperties *exp_values = exp_property->GetValue()->GetAsProperties(); if (exp_values) -return exp_values -->GetPropertyAtIndexAs(ePropertyInjectLocalVars, exe_ctx) -.value_or(true); - else -return true; +return exp_values->GetPropertyAtIndexAs(prop_idx, exe_ctx); + return std::nullopt; } -void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx, - bool b) { kastiglione wrote: huh, `b` wasn't even being used. https://github.com/llvm/llvm-project/pull/83504 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Extract getter function for experimental target properties (NFC) (PR #83504)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/83504 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Extract getter function for experimental target properties (NFC) (PR #83504)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Dave Lee (kastiglione) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/83504.diff 2 Files Affected: - (modified) lldb/include/lldb/Target/Target.h (+4-2) - (modified) lldb/source/Target/Target.cpp (+9-15) ``diff diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 8f57358981d4d2..2c2e6b2831ccee 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -244,8 +244,6 @@ class TargetProperties : public Properties { bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const; - void SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b); - void SetRequireHardwareBreakpoints(bool b); bool GetRequireHardwareBreakpoints() const; @@ -259,6 +257,10 @@ class TargetProperties : public Properties { bool GetDebugUtilityExpression() const; private: + std::optional + GetExperimentalPropertyValue(size_t prop_idx, + ExecutionContext *exe_ctx = nullptr) const; + // Callbacks for m_launch_info. void Arg0ValueChangedCallback(); void RunArgsValueChangedCallback(); diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index e982a30a3ae4ff..09b0ac42631d1a 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -43,6 +43,7 @@ #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Target/ABI.h" +#include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Language.h" #include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/Process.h" @@ -4227,28 +4228,21 @@ void TargetProperties::UpdateLaunchInfoFromProperties() { DisableSTDIOValueChangedCallback(); } -bool TargetProperties::GetInjectLocalVariables( -ExecutionContext *exe_ctx) const { +std::optional TargetProperties::GetExperimentalPropertyValue( +size_t prop_idx, ExecutionContext *exe_ctx) const { const Property *exp_property = m_collection_sp->GetPropertyAtIndex(ePropertyExperimental, exe_ctx); OptionValueProperties *exp_values = exp_property->GetValue()->GetAsProperties(); if (exp_values) -return exp_values -->GetPropertyAtIndexAs(ePropertyInjectLocalVars, exe_ctx) -.value_or(true); - else -return true; +return exp_values->GetPropertyAtIndexAs(prop_idx, exe_ctx); + return std::nullopt; } -void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx, - bool b) { - const Property *exp_property = - m_collection_sp->GetPropertyAtIndex(ePropertyExperimental, exe_ctx); - OptionValueProperties *exp_values = - exp_property->GetValue()->GetAsProperties(); - if (exp_values) -exp_values->SetPropertyAtIndex(ePropertyInjectLocalVars, true, exe_ctx); +bool TargetProperties::GetInjectLocalVariables( +ExecutionContext *exe_ctx) const { + return GetExperimentalPropertyValue(ePropertyInjectLocalVars, exe_ctx) + .value_or(true); } ArchSpec TargetProperties::GetDefaultArchitecture() const { `` https://github.com/llvm/llvm-project/pull/83504 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Extract getter function for experimental target properties (NFC) (PR #83504)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/83504 None >From 969f441344e179c9167fe707cf8f01edae6dbfc5 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 29 Feb 2024 15:38:22 -0800 Subject: [PATCH] [lldb] Extract getter function for experimental target properties (NFC) --- lldb/include/lldb/Target/Target.h | 6 -- lldb/source/Target/Target.cpp | 24 +--- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 8f57358981d4d2..2c2e6b2831ccee 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -244,8 +244,6 @@ class TargetProperties : public Properties { bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const; - void SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b); - void SetRequireHardwareBreakpoints(bool b); bool GetRequireHardwareBreakpoints() const; @@ -259,6 +257,10 @@ class TargetProperties : public Properties { bool GetDebugUtilityExpression() const; private: + std::optional + GetExperimentalPropertyValue(size_t prop_idx, + ExecutionContext *exe_ctx = nullptr) const; + // Callbacks for m_launch_info. void Arg0ValueChangedCallback(); void RunArgsValueChangedCallback(); diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index e982a30a3ae4ff..09b0ac42631d1a 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -43,6 +43,7 @@ #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Target/ABI.h" +#include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Language.h" #include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/Process.h" @@ -4227,28 +4228,21 @@ void TargetProperties::UpdateLaunchInfoFromProperties() { DisableSTDIOValueChangedCallback(); } -bool TargetProperties::GetInjectLocalVariables( -ExecutionContext *exe_ctx) const { +std::optional TargetProperties::GetExperimentalPropertyValue( +size_t prop_idx, ExecutionContext *exe_ctx) const { const Property *exp_property = m_collection_sp->GetPropertyAtIndex(ePropertyExperimental, exe_ctx); OptionValueProperties *exp_values = exp_property->GetValue()->GetAsProperties(); if (exp_values) -return exp_values -->GetPropertyAtIndexAs(ePropertyInjectLocalVars, exe_ctx) -.value_or(true); - else -return true; +return exp_values->GetPropertyAtIndexAs(prop_idx, exe_ctx); + return std::nullopt; } -void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx, - bool b) { - const Property *exp_property = - m_collection_sp->GetPropertyAtIndex(ePropertyExperimental, exe_ctx); - OptionValueProperties *exp_values = - exp_property->GetValue()->GetAsProperties(); - if (exp_values) -exp_values->SetPropertyAtIndex(ePropertyInjectLocalVars, true, exe_ctx); +bool TargetProperties::GetInjectLocalVariables( +ExecutionContext *exe_ctx) const { + return GetExperimentalPropertyValue(ePropertyInjectLocalVars, exe_ctx) + .value_or(true); } ArchSpec TargetProperties::GetDefaultArchitecture() const { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change the return type of CalculateNumChildren to uint32_t. (PR #83501)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 21be2fbd17f9ff6f3f04e0ababc91c9cdd5aed85 242da8f612a4d7ce4f58d4e61be05dff711e469f -- lldb/include/lldb/Core/ValueObject.h lldb/include/lldb/Core/ValueObjectCast.h lldb/include/lldb/Core/ValueObjectChild.h lldb/include/lldb/Core/ValueObjectConstResult.h lldb/include/lldb/Core/ValueObjectDynamicValue.h lldb/include/lldb/Core/ValueObjectMemory.h lldb/include/lldb/Core/ValueObjectRegister.h lldb/include/lldb/Core/ValueObjectSyntheticFilter.h lldb/include/lldb/Core/ValueObjectVTable.h lldb/include/lldb/Core/ValueObjectVariable.h lldb/include/lldb/DataFormatters/TypeSynthetic.h lldb/include/lldb/DataFormatters/VectorIterator.h lldb/include/lldb/Target/StackFrameRecognizer.h lldb/source/Core/ValueObjectCast.cpp lldb/source/Core/ValueObjectChild.cpp lldb/source/Core/ValueObjectConstResult.cpp lldb/source/Core/ValueObjectDynamicValue.cpp lldb/source/Core/ValueObjectMemory.cpp lldb/source/Core/ValueObjectRegister.cpp lldb/source/Core/ValueObjectSyntheticFilter.cpp lldb/source/Core/ValueObjectVTable.cpp lldb/source/Core/ValueObjectVariable.cpp lldb/source/DataFormatters/TypeSynthetic.cpp lldb/source/DataFormatters/VectorType.cpp lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp lldb/source/Plugins/Language/CPlusPlus/Coroutines.h lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxx.h lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp lldb/source/Plugins/Language/ObjC/Cocoa.cpp lldb/source/Plugins/Language/ObjC/NSArray.cpp lldb/source/Plugins/Language/ObjC/NSDictionary.cpp lldb/source/Plugins/Language/ObjC/NSError.cpp lldb/source/Plugins/Language/ObjC/NSException.cpp lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp lldb/source/Plugins/Language/ObjC/NSSet.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp index b03bd9a80e..0c4ec14f18 100644 --- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp +++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp @@ -31,7 +31,9 @@ public: DummySyntheticFrontEnd(ValueObject ) : SyntheticChildrenFrontEnd(backend) {} - uint32_t CalculateNumChildren() override { return m_backend.GetNumChildren(); } + uint32_t CalculateNumChildren() override { +return m_backend.GetNumChildren(); + } lldb::ValueObjectSP GetChildAtIndex(size_t idx) override { return m_backend.GetChildAtIndex(idx); diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp b/lldb/source/DataFormatters/TypeSynthetic.cpp index a05fbe9a73..bbf5462277 100644 --- a/lldb/source/DataFormatters/TypeSynthetic.cpp +++ b/lldb/source/DataFormatters/TypeSynthetic.cpp @@ -184,7 +184,8 @@ uint32_t ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren() { return m_interpreter->CalculateNumChildren(m_wrapper_sp, UINT32_MAX); } -uint32_t ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren(uint32_t max) { +uint32_t +ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren(uint32_t max) { if (!m_wrapper_sp || m_interpreter == nullptr) return 0; return m_interpreter->CalculateNumChildren(m_wrapper_sp, max); diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp index b2249d2396..4f656ee7c3 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -371,7 +371,9 @@ LibStdcppSharedPtrSyntheticFrontEnd::LibStdcppSharedPtrSyntheticFrontEnd( Update(); } -uint32_t LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() { return 1; } +uint32_t LibStdcppSharedPtrSyntheticFrontEnd::CalculateNumChildren() { + return 1; +} lldb::ValueObjectSP
[Lldb-commits] [lldb] Change the return type of CalculateNumChildren to uint32_t. (PR #83501)
https://github.com/adrian-prantl updated https://github.com/llvm/llvm-project/pull/83501 >From 44e21455e042a674f12f872be24ca9b7bb7d6dec Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Thu, 29 Feb 2024 15:06:28 -0800 Subject: [PATCH 1/2] Change the return type of ValueObject::CalculateNumChildren to uint32_t. In the end this value comes from TypeSystem::GetNumChildren which returns a uint32_t, so ValueObject should be consistent with that. --- lldb/include/lldb/Core/ValueObject.h| 2 +- lldb/include/lldb/Core/ValueObjectCast.h| 2 +- lldb/include/lldb/Core/ValueObjectChild.h | 2 +- lldb/include/lldb/Core/ValueObjectConstResult.h | 2 +- lldb/include/lldb/Core/ValueObjectDynamicValue.h| 2 +- lldb/include/lldb/Core/ValueObjectMemory.h | 2 +- lldb/include/lldb/Core/ValueObjectRegister.h| 4 ++-- lldb/include/lldb/Core/ValueObjectSyntheticFilter.h | 2 +- lldb/include/lldb/Core/ValueObjectVTable.h | 2 +- lldb/include/lldb/Core/ValueObjectVariable.h| 2 +- lldb/include/lldb/Target/StackFrameRecognizer.h | 2 +- lldb/source/Core/ValueObjectCast.cpp| 2 +- lldb/source/Core/ValueObjectChild.cpp | 2 +- lldb/source/Core/ValueObjectConstResult.cpp | 2 +- lldb/source/Core/ValueObjectDynamicValue.cpp| 2 +- lldb/source/Core/ValueObjectMemory.cpp | 2 +- lldb/source/Core/ValueObjectRegister.cpp| 4 ++-- lldb/source/Core/ValueObjectSyntheticFilter.cpp | 2 +- lldb/source/Core/ValueObjectVTable.cpp | 4 ++-- lldb/source/Core/ValueObjectVariable.cpp| 2 +- 20 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 4c0b0b2dae6cd4..05dd64f5634fda 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -958,7 +958,7 @@ class ValueObject { int32_t synthetic_index); /// Should only be called by ValueObject::GetNumChildren(). - virtual size_t CalculateNumChildren(uint32_t max = UINT32_MAX) = 0; + virtual uint32_t CalculateNumChildren(uint32_t max = UINT32_MAX) = 0; void SetNumChildren(size_t num_children); diff --git a/lldb/include/lldb/Core/ValueObjectCast.h b/lldb/include/lldb/Core/ValueObjectCast.h index fe053c12d9c343..51c647680d5227 100644 --- a/lldb/include/lldb/Core/ValueObjectCast.h +++ b/lldb/include/lldb/Core/ValueObjectCast.h @@ -33,7 +33,7 @@ class ValueObjectCast : public ValueObject { std::optional GetByteSize() override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t max) override; lldb::ValueType GetValueType() const override; diff --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h index 46b14e6840f0dc..47a13be08bb83b 100644 --- a/lldb/include/lldb/Core/ValueObjectChild.h +++ b/lldb/include/lldb/Core/ValueObjectChild.h @@ -39,7 +39,7 @@ class ValueObjectChild : public ValueObject { lldb::ValueType GetValueType() const override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t max) override; ConstString GetTypeName() override; diff --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h index d61df859bebce4..9f1246cf2a7874 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResult.h +++ b/lldb/include/lldb/Core/ValueObjectConstResult.h @@ -67,7 +67,7 @@ class ValueObjectConstResult : public ValueObject { lldb::ValueType GetValueType() const override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t max) override; ConstString GetTypeName() override; diff --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h index 2758b4e5bb564d..21a9b409fd5bd7 100644 --- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h +++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h @@ -43,7 +43,7 @@ class ValueObjectDynamicValue : public ValueObject { ConstString GetDisplayTypeName() override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t max) override; lldb::ValueType GetValueType() const override; diff --git a/lldb/include/lldb/Core/ValueObjectMemory.h b/lldb/include/lldb/Core/ValueObjectMemory.h index 3c01df388d2e6d..a74b325546b03c 100644 --- a/lldb/include/lldb/Core/ValueObjectMemory.h +++ b/lldb/include/lldb/Core/ValueObjectMemory.h @@ -47,7 +47,7 @@ class ValueObjectMemory : public ValueObject { ConstString GetDisplayTypeName() override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t max) override; lldb::ValueType GetValueType() const override; diff --git
[Lldb-commits] [lldb] Change the return type of CalculateNumChildren to uint32_t. (PR #83501)
https://github.com/kastiglione approved this pull request. https://github.com/llvm/llvm-project/pull/83501 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress][NFC] Fix Doxygen information (PR #83502)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Chelsea Cassanova (chelcassanova) Changes The `details` field in the constructor for `Progress` is missing Doxygen documentation, this commit adds this. --- Full diff: https://github.com/llvm/llvm-project/pull/83502.diff 1 Files Affected: - (modified) lldb/include/lldb/Core/Progress.h (+3) ``diff diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index eb4d9f9d7af08e..9549e3b5aea950 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -64,6 +64,9 @@ class Progress { /// /// @param [in] title The title of this progress activity. /// + /// @param [in] details Specific information about what the progress report + /// is currently working on. + /// /// @param [in] total The total units of work to be done if specified, if /// set to std::nullopt then an indeterminate progress indicator should be /// displayed. `` https://github.com/llvm/llvm-project/pull/83502 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress][NFC] Fix Doxygen information (PR #83502)
https://github.com/chelcassanova created https://github.com/llvm/llvm-project/pull/83502 The `details` field in the constructor for `Progress` is missing Doxygen documentation, this commit adds this. >From 7b26213416e45853514e98d5043255ccd42153a9 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Thu, 29 Feb 2024 15:15:27 -0800 Subject: [PATCH] [lldb][progress][NFC] Fix Doxygen information The `details` field in the constructor for `Progress` is missing Doxygen documentation, this commit adds this. --- lldb/include/lldb/Core/Progress.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index eb4d9f9d7af08e..9549e3b5aea950 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -64,6 +64,9 @@ class Progress { /// /// @param [in] title The title of this progress activity. /// + /// @param [in] details Specific information about what the progress report + /// is currently working on. + /// /// @param [in] total The total units of work to be done if specified, if /// set to std::nullopt then an indeterminate progress indicator should be /// displayed. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Change the return type of CalculateNumChildren to uint32_t. (PR #83501)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Adrian Prantl (adrian-prantl) Changes In the end this value comes from TypeSystem::GetNumChildren which returns a uint32_t, so ValueObject should be consistent with that. --- Full diff: https://github.com/llvm/llvm-project/pull/83501.diff 20 Files Affected: - (modified) lldb/include/lldb/Core/ValueObject.h (+1-1) - (modified) lldb/include/lldb/Core/ValueObjectCast.h (+1-1) - (modified) lldb/include/lldb/Core/ValueObjectChild.h (+1-1) - (modified) lldb/include/lldb/Core/ValueObjectConstResult.h (+1-1) - (modified) lldb/include/lldb/Core/ValueObjectDynamicValue.h (+1-1) - (modified) lldb/include/lldb/Core/ValueObjectMemory.h (+1-1) - (modified) lldb/include/lldb/Core/ValueObjectRegister.h (+2-2) - (modified) lldb/include/lldb/Core/ValueObjectSyntheticFilter.h (+1-1) - (modified) lldb/include/lldb/Core/ValueObjectVTable.h (+1-1) - (modified) lldb/include/lldb/Core/ValueObjectVariable.h (+1-1) - (modified) lldb/include/lldb/Target/StackFrameRecognizer.h (+1-1) - (modified) lldb/source/Core/ValueObjectCast.cpp (+1-1) - (modified) lldb/source/Core/ValueObjectChild.cpp (+1-1) - (modified) lldb/source/Core/ValueObjectConstResult.cpp (+1-1) - (modified) lldb/source/Core/ValueObjectDynamicValue.cpp (+1-1) - (modified) lldb/source/Core/ValueObjectMemory.cpp (+1-1) - (modified) lldb/source/Core/ValueObjectRegister.cpp (+2-2) - (modified) lldb/source/Core/ValueObjectSyntheticFilter.cpp (+1-1) - (modified) lldb/source/Core/ValueObjectVTable.cpp (+2-2) - (modified) lldb/source/Core/ValueObjectVariable.cpp (+1-1) ``diff diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 4c0b0b2dae6cd4..05dd64f5634fda 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -958,7 +958,7 @@ class ValueObject { int32_t synthetic_index); /// Should only be called by ValueObject::GetNumChildren(). - virtual size_t CalculateNumChildren(uint32_t max = UINT32_MAX) = 0; + virtual uint32_t CalculateNumChildren(uint32_t max = UINT32_MAX) = 0; void SetNumChildren(size_t num_children); diff --git a/lldb/include/lldb/Core/ValueObjectCast.h b/lldb/include/lldb/Core/ValueObjectCast.h index fe053c12d9c343..51c647680d5227 100644 --- a/lldb/include/lldb/Core/ValueObjectCast.h +++ b/lldb/include/lldb/Core/ValueObjectCast.h @@ -33,7 +33,7 @@ class ValueObjectCast : public ValueObject { std::optional GetByteSize() override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t max) override; lldb::ValueType GetValueType() const override; diff --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h index 46b14e6840f0dc..47a13be08bb83b 100644 --- a/lldb/include/lldb/Core/ValueObjectChild.h +++ b/lldb/include/lldb/Core/ValueObjectChild.h @@ -39,7 +39,7 @@ class ValueObjectChild : public ValueObject { lldb::ValueType GetValueType() const override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t max) override; ConstString GetTypeName() override; diff --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h index d61df859bebce4..9f1246cf2a7874 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResult.h +++ b/lldb/include/lldb/Core/ValueObjectConstResult.h @@ -67,7 +67,7 @@ class ValueObjectConstResult : public ValueObject { lldb::ValueType GetValueType() const override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t max) override; ConstString GetTypeName() override; diff --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h index 2758b4e5bb564d..21a9b409fd5bd7 100644 --- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h +++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h @@ -43,7 +43,7 @@ class ValueObjectDynamicValue : public ValueObject { ConstString GetDisplayTypeName() override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t max) override; lldb::ValueType GetValueType() const override; diff --git a/lldb/include/lldb/Core/ValueObjectMemory.h b/lldb/include/lldb/Core/ValueObjectMemory.h index 3c01df388d2e6d..a74b325546b03c 100644 --- a/lldb/include/lldb/Core/ValueObjectMemory.h +++ b/lldb/include/lldb/Core/ValueObjectMemory.h @@ -47,7 +47,7 @@ class ValueObjectMemory : public ValueObject { ConstString GetDisplayTypeName() override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t max) override; lldb::ValueType GetValueType() const override; diff --git a/lldb/include/lldb/Core/ValueObjectRegister.h b/lldb/include/lldb/Core/ValueObjectRegister.h index 2e47eee3d7f793..6c470c1a686503
[Lldb-commits] [lldb] Change the return type of CalculateNumChildren to uint32_t. (PR #83501)
https://github.com/adrian-prantl created https://github.com/llvm/llvm-project/pull/83501 In the end this value comes from TypeSystem::GetNumChildren which returns a uint32_t, so ValueObject should be consistent with that. >From 056c198efc3c224cb87edbd8f56344bdbb3e204a Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Thu, 29 Feb 2024 15:06:28 -0800 Subject: [PATCH] Change the return type of CalculateNumChildren to uint32_t. In the end this value comes from TypeSystem::GetNumChildren which returns a uint32_t, so ValueObject should be consistent with that. --- lldb/include/lldb/Core/ValueObject.h| 2 +- lldb/include/lldb/Core/ValueObjectCast.h| 2 +- lldb/include/lldb/Core/ValueObjectChild.h | 2 +- lldb/include/lldb/Core/ValueObjectConstResult.h | 2 +- lldb/include/lldb/Core/ValueObjectDynamicValue.h| 2 +- lldb/include/lldb/Core/ValueObjectMemory.h | 2 +- lldb/include/lldb/Core/ValueObjectRegister.h| 4 ++-- lldb/include/lldb/Core/ValueObjectSyntheticFilter.h | 2 +- lldb/include/lldb/Core/ValueObjectVTable.h | 2 +- lldb/include/lldb/Core/ValueObjectVariable.h| 2 +- lldb/include/lldb/Target/StackFrameRecognizer.h | 2 +- lldb/source/Core/ValueObjectCast.cpp| 2 +- lldb/source/Core/ValueObjectChild.cpp | 2 +- lldb/source/Core/ValueObjectConstResult.cpp | 2 +- lldb/source/Core/ValueObjectDynamicValue.cpp| 2 +- lldb/source/Core/ValueObjectMemory.cpp | 2 +- lldb/source/Core/ValueObjectRegister.cpp| 4 ++-- lldb/source/Core/ValueObjectSyntheticFilter.cpp | 2 +- lldb/source/Core/ValueObjectVTable.cpp | 4 ++-- lldb/source/Core/ValueObjectVariable.cpp| 2 +- 20 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 4c0b0b2dae6cd4..05dd64f5634fda 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -958,7 +958,7 @@ class ValueObject { int32_t synthetic_index); /// Should only be called by ValueObject::GetNumChildren(). - virtual size_t CalculateNumChildren(uint32_t max = UINT32_MAX) = 0; + virtual uint32_t CalculateNumChildren(uint32_t max = UINT32_MAX) = 0; void SetNumChildren(size_t num_children); diff --git a/lldb/include/lldb/Core/ValueObjectCast.h b/lldb/include/lldb/Core/ValueObjectCast.h index fe053c12d9c343..51c647680d5227 100644 --- a/lldb/include/lldb/Core/ValueObjectCast.h +++ b/lldb/include/lldb/Core/ValueObjectCast.h @@ -33,7 +33,7 @@ class ValueObjectCast : public ValueObject { std::optional GetByteSize() override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t max) override; lldb::ValueType GetValueType() const override; diff --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h index 46b14e6840f0dc..47a13be08bb83b 100644 --- a/lldb/include/lldb/Core/ValueObjectChild.h +++ b/lldb/include/lldb/Core/ValueObjectChild.h @@ -39,7 +39,7 @@ class ValueObjectChild : public ValueObject { lldb::ValueType GetValueType() const override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t max) override; ConstString GetTypeName() override; diff --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h index d61df859bebce4..9f1246cf2a7874 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResult.h +++ b/lldb/include/lldb/Core/ValueObjectConstResult.h @@ -67,7 +67,7 @@ class ValueObjectConstResult : public ValueObject { lldb::ValueType GetValueType() const override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t max) override; ConstString GetTypeName() override; diff --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h index 2758b4e5bb564d..21a9b409fd5bd7 100644 --- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h +++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h @@ -43,7 +43,7 @@ class ValueObjectDynamicValue : public ValueObject { ConstString GetDisplayTypeName() override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t max) override; lldb::ValueType GetValueType() const override; diff --git a/lldb/include/lldb/Core/ValueObjectMemory.h b/lldb/include/lldb/Core/ValueObjectMemory.h index 3c01df388d2e6d..a74b325546b03c 100644 --- a/lldb/include/lldb/Core/ValueObjectMemory.h +++ b/lldb/include/lldb/Core/ValueObjectMemory.h @@ -47,7 +47,7 @@ class ValueObjectMemory : public ValueObject { ConstString GetDisplayTypeName() override; - size_t CalculateNumChildren(uint32_t max) override; + uint32_t CalculateNumChildren(uint32_t
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/JDevlieghere approved this pull request. LGTM but please fix the formatting issue before merging. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/83069 >From 5fcab5d9b7af70861bbc46f096032dce7de41517 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Tue, 20 Feb 2024 13:56:53 -0800 Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress manager This commit adds the functionality to broadcast events using the `Debugger::eBroadcastProgressCategory` bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these reports with the `ProgressManager` class (https://github.com/llvm/llvm-project/pull/81319). The new bit is used in such a way that it will only broadcast the initial and final progress reports for specific progress categories that are managed by the progress manager. This commit also adds a new test to the progress report unit test that checks that only the initial/final reports are broadcasted when using the new bit. --- lldb/include/lldb/Core/Debugger.h | 10 ++- lldb/include/lldb/Core/Progress.h | 37 ++--- lldb/source/Core/Debugger.cpp | 19 +++-- lldb/source/Core/Progress.cpp | 56 + lldb/unittests/Core/ProgressReportTest.cpp | 93 +- 5 files changed, 177 insertions(+), 38 deletions(-) diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 6ba90eb6ed8fdf..b65ec1029ab24b 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -593,6 +593,7 @@ class Debugger : public std::enable_shared_from_this, friend class CommandInterpreter; friend class REPL; friend class Progress; + friend class ProgressManager; /// Report progress events. /// @@ -623,10 +624,11 @@ class Debugger : public std::enable_shared_from_this, /// debugger identifier that this progress should be delivered to. If this /// optional parameter does not have a value, the progress will be /// delivered to all debuggers. - static void ReportProgress(uint64_t progress_id, std::string title, - std::string details, uint64_t completed, - uint64_t total, - std::optional debugger_id); + static void + ReportProgress(uint64_t progress_id, std::string title, std::string details, + uint64_t completed, uint64_t total, + std::optional debugger_id, + uint32_t progress_category_bit = eBroadcastBitProgress); static void ReportDiagnosticImpl(DiagnosticEventData::Type type, std::string message, diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index eb4d9f9d7af08e..766bda0cf1c5e5 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -9,10 +9,11 @@ #ifndef LLDB_CORE_PROGRESS_H #define LLDB_CORE_PROGRESS_H -#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" #include "llvm/ADT/StringMap.h" #include +#include #include #include @@ -97,27 +98,36 @@ class Progress { /// Used to indicate a non-deterministic progress report static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX; + /// Data belonging to this Progress event that is used for bookkeeping by + /// ProgressManager. + struct ProgressData { +/// The title of the progress activity, also used as a category. +std::string title; +/// A unique integer identifier for progress reporting. +uint64_t progress_id; +/// The optional debugger ID to report progress to. If this has no value +/// then all debuggers will receive this event. +std::optional debugger_id; + }; + private: void ReportProgress(); static std::atomic g_id; - /// The title of the progress activity. - std::string m_title; + /// More specific information about the current file being displayed in the + /// report. std::string m_details; - std::mutex m_mutex; - /// A unique integer identifier for progress reporting. - const uint64_t m_id; /// How much work ([0...m_total]) that has been completed. uint64_t m_completed; /// Total amount of work, use a std::nullopt in the constructor for non /// deterministic progress. uint64_t m_total; - /// The optional debugger ID to report progress to. If this has no value then - /// all debuggers will receive this event. - std::optional m_debugger_id; + std::mutex m_mutex; /// Set to true when progress has been reported where m_completed == m_total /// to ensure that we don't send progress updates after progress has /// completed. bool m_complete = false; + /// Data needed by the debugger to broadcast a progress event. + ProgressData m_progress_data; }; /// A class used to group progress reports by category. This is done by using a @@ -130,13 +140,16 @@ class ProgressManager { ~ProgressManager(); /// Control the refcount of the progress report
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/8] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda edited https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -33,18 +33,26 @@ void AddressableBits::SetHighmemAddressableBits( m_high_memory_addr_bits = highmem_addressing_bits; } +addr_t AddressableBits::AddressableBitToMask(uint32_t addressable_bits) { + assert(addressable_bits <= sizeof(addr_t) * 8); jasonmolenda wrote: I forgot that I was duplicating the addressable-bits-to-mask calculation in Process.cpp when I read the settings values. I pushed a change to use the new static method in AddressableBits which includes the assert. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/7] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/6] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/5] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 86f6caa562255f81b93e72a501a926b17f5ad244 dceaef27675b724309f353aa22999563cf036cd3 -- lldb/test/API/python_api/process/address-masks/main.c lldb/include/lldb/API/SBProcess.h lldb/include/lldb/Utility/AddressableBits.h lldb/include/lldb/lldb-enumerations.h lldb/source/API/SBProcess.cpp lldb/source/Utility/AddressableBits.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index e2a6922724..b60a0c3591 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -488,8 +488,8 @@ public: /// /// \param[in] num_bits /// Number of bits that are used for addressing. - /// For example, a value of 42 indicates that the low 42 bits are relevant for - /// addressing, and that higher-order bits may be used for various + /// For example, a value of 42 indicates that the low 42 bits are relevant + /// for addressing, and that higher-order bits may be used for various /// metadata like pointer authentication, Type Byte Ignore, etc. /// /// \param[in] addr_range `` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/4] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -1255,6 +1255,95 @@ lldb::SBFileSpec SBProcess::GetCoreFile() { return SBFileSpec(core_file); } +addr_t SBProcess::GetAddressMask(AddressMaskType type, + AddressMaskRange addr_range) { + LLDB_INSTRUMENT_VA(this, type, addr_range); + addr_t default_mask = 0; jasonmolenda wrote: A mask value of 0 would be an invalid address mask -- no bits are used for addressing. The variable name "default_mask" was a poor choice. But explicitly returning LLDB_INVALID_ADDRESS_MASK if we don't find any value might be the correct choice, it would mean you passed an invalid enum argument (or the SBProcess can't access its Process) https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ClangASTImporter] Import record layouts from origin if available (PR #83295)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/83295 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 07ffb7e - [lldb][ClangASTImporter] Import record layouts from origin if available (#83295)
Author: Michael Buch Date: 2024-02-29T21:40:02Z New Revision: 07ffb7e294767b74e43f90e9ab3d713da929b907 URL: https://github.com/llvm/llvm-project/commit/07ffb7e294767b74e43f90e9ab3d713da929b907 DIFF: https://github.com/llvm/llvm-project/commit/07ffb7e294767b74e43f90e9ab3d713da929b907.diff LOG: [lldb][ClangASTImporter] Import record layouts from origin if available (#83295) Layout information for a record gets stored in the `ClangASTImporter` associated with the `DWARFASTParserClang` that originally parsed the record. LLDB sometimes moves clang types from one AST to another (in the reproducer the origin AST was a precompiled-header and the destination was the AST backing the executable). When clang then asks LLDB to `layoutRecordType`, it will do so with the help of the `ClangASTImporter` the type is associated with. If the type's origin is actually in a different LLDB module (and thus a different `DWARFASTParserClang` was used to set its layout info), we won't find the layout info in our local `ClangASTImporter`. In the reproducer this meant we would drop the alignment info of the origin type and misread a variable's contents with `frame var` and `expr`. There is logic in `ClangASTSource::layoutRecordType` to import an origin's layout info. This patch re-uses that infrastructure to import an origin's layout from one `ClangASTImporter` instance to another. rdar://123274144 Added: lldb/test/API/lang/cpp/gmodules/alignment/Makefile lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py lldb/test/API/lang/cpp/gmodules/alignment/main.cpp lldb/test/API/lang/cpp/gmodules/alignment/pch.h Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 99d210c347a21d..30b50df79da90f 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -760,7 +760,6 @@ bool ClangASTImporter::LayoutRecordType( _offsets) { RecordDeclToLayoutMap::iterator pos = m_record_decl_to_layout_map.find(record_decl); - bool success = false; base_offsets.clear(); vbase_offsets.clear(); if (pos != m_record_decl_to_layout_map.end()) { @@ -770,13 +769,23 @@ bool ClangASTImporter::LayoutRecordType( base_offsets.swap(pos->second.base_offsets); vbase_offsets.swap(pos->second.vbase_offsets); m_record_decl_to_layout_map.erase(pos); -success = true; - } else { -bit_size = 0; -alignment = 0; -field_offsets.clear(); +return true; } - return success; + + // It's possible that we calculated the layout in a diff erent + // ClangASTImporter instance. Try to import such layout if + // our decl has an origin. + if (auto origin = GetDeclOrigin(record_decl); origin.Valid()) +if (importRecordLayoutFromOrigin(record_decl, bit_size, alignment, + field_offsets, base_offsets, + vbase_offsets)) + return true; + + bit_size = 0; + alignment = 0; + field_offsets.clear(); + + return false; } void ClangASTImporter::SetRecordLayout(clang::RecordDecl *decl, diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/Makefile b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile new file mode 100644 index 00..a6c3e8ca84a3e4 --- /dev/null +++ b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile @@ -0,0 +1,4 @@ +PCH_CXX_SOURCE = pch.h +CXX_SOURCES = main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py new file mode 100644 index 00..535dd13d0ada48 --- /dev/null +++ b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py @@ -0,0 +1,60 @@ +""" +Tests that we correctly track AST layout info +(specifically alignment) when moving AST nodes +between ClangASTImporter instances (in this case, +from pch to executable to expression AST). +""" + +import lldb +import os +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestPchAlignment(TestBase): +@add_test_categories(["gmodules"]) +def test_expr(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "return data", lldb.SBFileSpec("main.cpp") +) + +self.expect( +"frame variable data", +substrs=["row = 1", "col = 2", "row = 3", "col = 4", "stride = 5"], +) + +@add_test_categories(["gmodules"]) +def test_frame_var(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "return data", lldb.SBFileSpec("main.cpp") +) + +
[Lldb-commits] [lldb] [lldb][ClangASTImporter] Import record layouts from origin if available (PR #83295)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/83295 >From 7b3d74a917446ad03e605f57fcf9158eee1d21c5 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 28 Feb 2024 13:52:54 + Subject: [PATCH] [lldb][ClangASTImporter] Import record layouts from origin if available --- .../Clang/ClangASTImporter.cpp| 23 --- .../API/lang/cpp/gmodules/alignment/Makefile | 4 ++ .../gmodules/alignment/TestPchAlignment.py| 60 +++ .../API/lang/cpp/gmodules/alignment/main.cpp | 10 .../API/lang/cpp/gmodules/alignment/pch.h | 21 +++ 5 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/Makefile create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/main.cpp create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/pch.h diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 99d210c347a21d..30b50df79da90f 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -760,7 +760,6 @@ bool ClangASTImporter::LayoutRecordType( _offsets) { RecordDeclToLayoutMap::iterator pos = m_record_decl_to_layout_map.find(record_decl); - bool success = false; base_offsets.clear(); vbase_offsets.clear(); if (pos != m_record_decl_to_layout_map.end()) { @@ -770,13 +769,23 @@ bool ClangASTImporter::LayoutRecordType( base_offsets.swap(pos->second.base_offsets); vbase_offsets.swap(pos->second.vbase_offsets); m_record_decl_to_layout_map.erase(pos); -success = true; - } else { -bit_size = 0; -alignment = 0; -field_offsets.clear(); +return true; } - return success; + + // It's possible that we calculated the layout in a different + // ClangASTImporter instance. Try to import such layout if + // our decl has an origin. + if (auto origin = GetDeclOrigin(record_decl); origin.Valid()) +if (importRecordLayoutFromOrigin(record_decl, bit_size, alignment, + field_offsets, base_offsets, + vbase_offsets)) + return true; + + bit_size = 0; + alignment = 0; + field_offsets.clear(); + + return false; } void ClangASTImporter::SetRecordLayout(clang::RecordDecl *decl, diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/Makefile b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile new file mode 100644 index 00..a6c3e8ca84a3e4 --- /dev/null +++ b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile @@ -0,0 +1,4 @@ +PCH_CXX_SOURCE = pch.h +CXX_SOURCES = main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py new file mode 100644 index 00..535dd13d0ada48 --- /dev/null +++ b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py @@ -0,0 +1,60 @@ +""" +Tests that we correctly track AST layout info +(specifically alignment) when moving AST nodes +between ClangASTImporter instances (in this case, +from pch to executable to expression AST). +""" + +import lldb +import os +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestPchAlignment(TestBase): +@add_test_categories(["gmodules"]) +def test_expr(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "return data", lldb.SBFileSpec("main.cpp") +) + +self.expect( +"frame variable data", +substrs=["row = 1", "col = 2", "row = 3", "col = 4", "stride = 5"], +) + +@add_test_categories(["gmodules"]) +def test_frame_var(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "return data", lldb.SBFileSpec("main.cpp") +) + +self.expect_expr( +"data", +result_type="MatrixData", +result_children=[ +ValueCheck( +name="section", +children=[ +ValueCheck( +name="origin", +children=[ +ValueCheck(name="row", value="1"), +ValueCheck(name="col", value="2"), +], +), +ValueCheck( +name="size", +children=[ +ValueCheck(name="row", value="3"), +ValueCheck(name="col", value="4"), +], +), +], +
[Lldb-commits] [lldb] [lldb][ClangASTImporter] Import record layouts from origin if available (PR #83295)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/83295 >From 9a6ed480fd407f9a9f12d6faccffbad952de0855 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 28 Feb 2024 13:52:54 + Subject: [PATCH] [lldb][ClangASTImporter] Import record layouts from origin if available --- .../Clang/ClangASTImporter.cpp| 23 --- .../API/lang/cpp/gmodules/alignment/Makefile | 4 ++ .../gmodules/alignment/TestPchAlignment.py| 60 +++ .../API/lang/cpp/gmodules/alignment/main.cpp | 10 .../API/lang/cpp/gmodules/alignment/pch.h | 21 +++ 5 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/Makefile create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/main.cpp create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/pch.h diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 62a30c14912bc9..754191ad83fe8a 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -527,7 +527,6 @@ bool ClangASTImporter::LayoutRecordType( _offsets) { RecordDeclToLayoutMap::iterator pos = m_record_decl_to_layout_map.find(record_decl); - bool success = false; base_offsets.clear(); vbase_offsets.clear(); if (pos != m_record_decl_to_layout_map.end()) { @@ -537,13 +536,23 @@ bool ClangASTImporter::LayoutRecordType( base_offsets.swap(pos->second.base_offsets); vbase_offsets.swap(pos->second.vbase_offsets); m_record_decl_to_layout_map.erase(pos); -success = true; - } else { -bit_size = 0; -alignment = 0; -field_offsets.clear(); +return true; } - return success; + + // It's possible that we calculated the layout in a different + // ClangASTImporter instance. Try to import such layout if + // our decl has an origin. + if (auto origin = GetDeclOrigin(record_decl); origin.Valid()) +if (importRecordLayoutFromOrigin(record_decl, bit_size, alignment, + field_offsets, base_offsets, + vbase_offsets)) + return true; + + bit_size = 0; + alignment = 0; + field_offsets.clear(); + + return false; } void ClangASTImporter::SetRecordLayout(clang::RecordDecl *decl, diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/Makefile b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile new file mode 100644 index 00..a6c3e8ca84a3e4 --- /dev/null +++ b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile @@ -0,0 +1,4 @@ +PCH_CXX_SOURCE = pch.h +CXX_SOURCES = main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py new file mode 100644 index 00..535dd13d0ada48 --- /dev/null +++ b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py @@ -0,0 +1,60 @@ +""" +Tests that we correctly track AST layout info +(specifically alignment) when moving AST nodes +between ClangASTImporter instances (in this case, +from pch to executable to expression AST). +""" + +import lldb +import os +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestPchAlignment(TestBase): +@add_test_categories(["gmodules"]) +def test_expr(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "return data", lldb.SBFileSpec("main.cpp") +) + +self.expect( +"frame variable data", +substrs=["row = 1", "col = 2", "row = 3", "col = 4", "stride = 5"], +) + +@add_test_categories(["gmodules"]) +def test_frame_var(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "return data", lldb.SBFileSpec("main.cpp") +) + +self.expect_expr( +"data", +result_type="MatrixData", +result_children=[ +ValueCheck( +name="section", +children=[ +ValueCheck( +name="origin", +children=[ +ValueCheck(name="row", value="1"), +ValueCheck(name="col", value="2"), +], +), +ValueCheck( +name="size", +children=[ +ValueCheck(name="row", value="3"), +ValueCheck(name="col", value="4"), +], +), +], +
[Lldb-commits] [lldb] [lldb][ClangASTImporter] Import record layouts from origin if available (PR #83295)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/83295 >From 9a6ed480fd407f9a9f12d6faccffbad952de0855 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 28 Feb 2024 13:52:54 + Subject: [PATCH] [lldb][ClangASTImporter] Import record layouts from origin if available --- .../Clang/ClangASTImporter.cpp| 23 --- .../API/lang/cpp/gmodules/alignment/Makefile | 4 ++ .../gmodules/alignment/TestPchAlignment.py| 60 +++ .../API/lang/cpp/gmodules/alignment/main.cpp | 10 .../API/lang/cpp/gmodules/alignment/pch.h | 21 +++ 5 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/Makefile create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/main.cpp create mode 100644 lldb/test/API/lang/cpp/gmodules/alignment/pch.h diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 62a30c14912bc9..754191ad83fe8a 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -527,7 +527,6 @@ bool ClangASTImporter::LayoutRecordType( _offsets) { RecordDeclToLayoutMap::iterator pos = m_record_decl_to_layout_map.find(record_decl); - bool success = false; base_offsets.clear(); vbase_offsets.clear(); if (pos != m_record_decl_to_layout_map.end()) { @@ -537,13 +536,23 @@ bool ClangASTImporter::LayoutRecordType( base_offsets.swap(pos->second.base_offsets); vbase_offsets.swap(pos->second.vbase_offsets); m_record_decl_to_layout_map.erase(pos); -success = true; - } else { -bit_size = 0; -alignment = 0; -field_offsets.clear(); +return true; } - return success; + + // It's possible that we calculated the layout in a different + // ClangASTImporter instance. Try to import such layout if + // our decl has an origin. + if (auto origin = GetDeclOrigin(record_decl); origin.Valid()) +if (importRecordLayoutFromOrigin(record_decl, bit_size, alignment, + field_offsets, base_offsets, + vbase_offsets)) + return true; + + bit_size = 0; + alignment = 0; + field_offsets.clear(); + + return false; } void ClangASTImporter::SetRecordLayout(clang::RecordDecl *decl, diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/Makefile b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile new file mode 100644 index 00..a6c3e8ca84a3e4 --- /dev/null +++ b/lldb/test/API/lang/cpp/gmodules/alignment/Makefile @@ -0,0 +1,4 @@ +PCH_CXX_SOURCE = pch.h +CXX_SOURCES = main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py new file mode 100644 index 00..535dd13d0ada48 --- /dev/null +++ b/lldb/test/API/lang/cpp/gmodules/alignment/TestPchAlignment.py @@ -0,0 +1,60 @@ +""" +Tests that we correctly track AST layout info +(specifically alignment) when moving AST nodes +between ClangASTImporter instances (in this case, +from pch to executable to expression AST). +""" + +import lldb +import os +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestPchAlignment(TestBase): +@add_test_categories(["gmodules"]) +def test_expr(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "return data", lldb.SBFileSpec("main.cpp") +) + +self.expect( +"frame variable data", +substrs=["row = 1", "col = 2", "row = 3", "col = 4", "stride = 5"], +) + +@add_test_categories(["gmodules"]) +def test_frame_var(self): +self.build() +lldbutil.run_to_source_breakpoint( +self, "return data", lldb.SBFileSpec("main.cpp") +) + +self.expect_expr( +"data", +result_type="MatrixData", +result_children=[ +ValueCheck( +name="section", +children=[ +ValueCheck( +name="origin", +children=[ +ValueCheck(name="row", value="1"), +ValueCheck(name="col", value="2"), +], +), +ValueCheck( +name="size", +children=[ +ValueCheck(name="row", value="3"), +ValueCheck(name="col", value="4"), +], +), +], +
[Lldb-commits] [lldb] [lldb][NFC] Move helpers to import record layout into ClangASTImporter (PR #83291)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/83291 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 8c10032 - [lldb][NFC] Move helpers to import record layout into ClangASTImporter (#83291)
Author: Michael Buch Date: 2024-02-29T21:32:28Z New Revision: 8c1003266520ac396ce2a9e799f318af30efdd19 URL: https://github.com/llvm/llvm-project/commit/8c1003266520ac396ce2a9e799f318af30efdd19 DIFF: https://github.com/llvm/llvm-project/commit/8c1003266520ac396ce2a9e799f318af30efdd19.diff LOG: [lldb][NFC] Move helpers to import record layout into ClangASTImporter (#83291) This patch moves the logic for copying the layout info of a `RecordDecl`s origin into a target AST. A follow-up patch re-uses the logic from within the `ClangASTImporter`, so the natural choice was to move it there. Added: Modified: lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h Removed: diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 62a30c14912bc9..99d210c347a21d 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -10,9 +10,11 @@ #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" +#include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/RecordLayout.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Sema.h" #include "llvm/Support/raw_ostream.h" @@ -26,6 +28,7 @@ #include #include +#include using namespace lldb_private; using namespace clang; @@ -517,6 +520,236 @@ bool ClangASTImporter::CompleteType(const CompilerType _type) { return false; } +/// Copy layout information from \ref source_map to the \ref destination_map. +/// +/// In the process of copying over layout info, we may need to import +/// decls from the \ref source_map. This function will use the supplied +/// \ref importer to import the necessary decls into \ref dest_ctx. +/// +/// \param[in,out] dest_ctx Destination ASTContext into which we import +/// decls from the \ref source_map. +/// \param[out]destination_map A map from decls in \ref dest_ctx to an +///integral offest, which will be copies +///of the decl/offest pairs in \ref source_map +///if successful. +/// \param[in] source_map A map from decls to integral offests. These will +/// be copied into \ref destination_map. +/// \param[in,out] importer Used to import decls into \ref dest_ctx. +/// +/// \returns On success, will return 'true' and the offsets in \ref +/// destination_map +/// are usable copies of \ref source_map. +template +static bool ImportOffsetMap(clang::ASTContext *dest_ctx, +llvm::DenseMap _map, +llvm::DenseMap _map, +ClangASTImporter ) { + // When importing fields into a new record, clang has a hard requirement that + // fields be imported in field offset order. Since they are stored in a + // DenseMap with a pointer as the key type, this means we cannot simply + // iterate over the map, as the order will be non-deterministic. Instead we + // have to sort by the offset and then insert in sorted order. + typedef llvm::DenseMap MapType; + typedef typename MapType::value_type PairType; + std::vector sorted_items; + sorted_items.reserve(source_map.size()); + sorted_items.assign(source_map.begin(), source_map.end()); + llvm::sort(sorted_items, llvm::less_second()); + + for (const auto : sorted_items) { +DeclFromUser user_decl(const_cast(item.first)); +DeclFromParser parser_decl(user_decl.Import(dest_ctx, importer)); +if (parser_decl.IsInvalid()) + return false; +destination_map.insert( +std::pair(parser_decl.decl, item.second)); + } + + return true; +} + +/// Given a CXXRecordDecl, will calculate and populate \ref base_offsets +/// with the integral offsets of any of its (possibly virtual) base classes. +/// +/// \param[in] record_layout ASTRecordLayout of \ref record. +/// \param[in] record The record that we're calculating the base layouts of. +/// \param[out] base_offsets Map of base-class decl to integral offset which +/// this function will fill in. +/// +/// \returns On success, will return 'true' and the offsets in \ref base_offsets +/// are usable. +template +bool ExtractBaseOffsets(const ASTRecordLayout _layout, +DeclFromUser , +llvm::DenseMap _offsets) { + for (CXXRecordDecl::base_class_const_iterator + bi = (IsVirtual ?
[Lldb-commits] [lldb] [lldb][NFC] Move helpers to import record layout into ClangASTImporter (PR #83291)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 07d8a457ad8bb9a14974b9cb47072746c7f5e489 391e87f97ee17281ef4a91b3cc1ca6cec8626058 -- lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h `` View the diff from clang-format here. ``diff diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index be39e4c5ed..99d210c347 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -535,8 +535,9 @@ bool ClangASTImporter::CompleteType(const CompilerType _type) { /// \param[in] source_map A map from decls to integral offests. These will /// be copied into \ref destination_map. /// \param[in,out] importer Used to import decls into \ref dest_ctx. -/// -/// \returns On success, will return 'true' and the offsets in \ref destination_map +/// +/// \returns On success, will return 'true' and the offsets in \ref +/// destination_map /// are usable copies of \ref source_map. template static bool ImportOffsetMap(clang::ASTContext *dest_ctx, @@ -574,7 +575,7 @@ static bool ImportOffsetMap(clang::ASTContext *dest_ctx, /// \param[in] record The record that we're calculating the base layouts of. /// \param[out] base_offsets Map of base-class decl to integral offset which /// this function will fill in. -/// +/// /// \returns On success, will return 'true' and the offsets in \ref base_offsets /// are usable. template diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h index 98cf4ba360..bc962e544d 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h @@ -139,8 +139,8 @@ public: /// \param[out] vbase_offsets Offsets of virtual base classes of \ref record. /// /// \returns Returns 'false' if no valid origin was found for \ref record or - /// this function failed to import the layout from the origin. Otherwise, returns - /// 'true' and the offsets/size/alignment are valid for use. + /// this function failed to import the layout from the origin. Otherwise, + /// returns 'true' and the offsets/size/alignment are valid for use. bool importRecordLayoutFromOrigin( const clang::RecordDecl *record, uint64_t , uint64_t , llvm::DenseMap _offsets, `` https://github.com/llvm/llvm-project/pull/83291 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Move helpers to import record layout into ClangASTImporter (PR #83291)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/83291 >From 7ffc5c966a7a0542cbde20ead3144344e68e648f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 28 Feb 2024 13:32:01 + Subject: [PATCH 1/4] [lldb][NFC] Move helpers to import record layout into ClangASTImporter --- .../Clang/ClangASTImporter.cpp| 204 + .../ExpressionParser/Clang/ClangASTImporter.h | 61 .../ExpressionParser/Clang/ClangASTSource.cpp | 278 ++ .../ExpressionParser/Clang/ClangASTSource.h | 5 + 4 files changed, 290 insertions(+), 258 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 62a30c14912bc9..b9f2c834dd1197 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -10,9 +10,11 @@ #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" +#include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/RecordLayout.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Sema.h" #include "llvm/Support/raw_ostream.h" @@ -26,6 +28,7 @@ #include #include +#include using namespace lldb_private; using namespace clang; @@ -517,6 +520,207 @@ bool ClangASTImporter::CompleteType(const CompilerType _type) { return false; } +template +static bool ImportOffsetMap(clang::ASTContext *dest_ctx, +llvm::DenseMap _map, +llvm::DenseMap _map, +ClangASTImporter ) { + // When importing fields into a new record, clang has a hard requirement that + // fields be imported in field offset order. Since they are stored in a + // DenseMap with a pointer as the key type, this means we cannot simply + // iterate over the map, as the order will be non-deterministic. Instead we + // have to sort by the offset and then insert in sorted order. + typedef llvm::DenseMap MapType; + typedef typename MapType::value_type PairType; + std::vector sorted_items; + sorted_items.reserve(source_map.size()); + sorted_items.assign(source_map.begin(), source_map.end()); + llvm::sort(sorted_items, llvm::less_second()); + + for (const auto : sorted_items) { +DeclFromUser user_decl(const_cast(item.first)); +DeclFromParser parser_decl(user_decl.Import(dest_ctx, importer)); +if (parser_decl.IsInvalid()) + return false; +destination_map.insert( +std::pair(parser_decl.decl, item.second)); + } + + return true; +} + +template +bool ExtractBaseOffsets(const ASTRecordLayout _layout, +DeclFromUser , +llvm::DenseMap _offsets) { + for (CXXRecordDecl::base_class_const_iterator + bi = (IsVirtual ? record->vbases_begin() : record->bases_begin()), + be = (IsVirtual ? record->vbases_end() : record->bases_end()); + bi != be; ++bi) { +if (!IsVirtual && bi->isVirtual()) + continue; + +const clang::Type *origin_base_type = bi->getType().getTypePtr(); +const clang::RecordType *origin_base_record_type = +origin_base_type->getAs(); + +if (!origin_base_record_type) + return false; + +DeclFromUser origin_base_record( +origin_base_record_type->getDecl()); + +if (origin_base_record.IsInvalid()) + return false; + +DeclFromUser origin_base_cxx_record( +DynCast(origin_base_record)); + +if (origin_base_cxx_record.IsInvalid()) + return false; + +CharUnits base_offset; + +if (IsVirtual) + base_offset = + record_layout.getVBaseClassOffset(origin_base_cxx_record.decl); +else + base_offset = + record_layout.getBaseClassOffset(origin_base_cxx_record.decl); + +base_offsets.insert(std::pair( +origin_base_cxx_record.decl, base_offset)); + } + + return true; +} + +bool ClangASTImporter::importRecordLayoutFromOrigin( +const RecordDecl *record, uint64_t , uint64_t , +llvm::DenseMap _offsets, +llvm::DenseMap +_offsets, +llvm::DenseMap +_offsets) { + + Log *log = GetLog(LLDBLog::Expressions); + + clang::ASTContext _ctx = record->getASTContext(); + LLDB_LOG(log, + "LayoutRecordType on (ASTContext*){0} '{1}' for (RecordDecl*)" + "{2} [name = '{3}']", + _ctx, + TypeSystemClang::GetASTContext(_ctx)->getDisplayName(), record, + record->getName()); + + DeclFromParser parser_record(record); + DeclFromUser origin_record(parser_record.GetOrigin(*this)); + + if (origin_record.IsInvalid()) +return false; + + std::remove_reference_t origin_field_offsets; + std::remove_reference_t origin_base_offsets; + std::remove_reference_t origin_virtual_base_offsets; + +
[Lldb-commits] [lldb] [lldb][NFC] Move helpers to import record layout into ClangASTImporter (PR #83291)
@@ -517,6 +520,207 @@ bool ClangASTImporter::CompleteType(const CompilerType _type) { return false; } +template Michael137 wrote: done https://github.com/llvm/llvm-project/pull/83291 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Move helpers to import record layout into ClangASTImporter (PR #83291)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/83291 >From 7ffc5c966a7a0542cbde20ead3144344e68e648f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 28 Feb 2024 13:32:01 + Subject: [PATCH 1/3] [lldb][NFC] Move helpers to import record layout into ClangASTImporter --- .../Clang/ClangASTImporter.cpp| 204 + .../ExpressionParser/Clang/ClangASTImporter.h | 61 .../ExpressionParser/Clang/ClangASTSource.cpp | 278 ++ .../ExpressionParser/Clang/ClangASTSource.h | 5 + 4 files changed, 290 insertions(+), 258 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 62a30c14912bc9..b9f2c834dd1197 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -10,9 +10,11 @@ #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" +#include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/RecordLayout.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Sema.h" #include "llvm/Support/raw_ostream.h" @@ -26,6 +28,7 @@ #include #include +#include using namespace lldb_private; using namespace clang; @@ -517,6 +520,207 @@ bool ClangASTImporter::CompleteType(const CompilerType _type) { return false; } +template +static bool ImportOffsetMap(clang::ASTContext *dest_ctx, +llvm::DenseMap _map, +llvm::DenseMap _map, +ClangASTImporter ) { + // When importing fields into a new record, clang has a hard requirement that + // fields be imported in field offset order. Since they are stored in a + // DenseMap with a pointer as the key type, this means we cannot simply + // iterate over the map, as the order will be non-deterministic. Instead we + // have to sort by the offset and then insert in sorted order. + typedef llvm::DenseMap MapType; + typedef typename MapType::value_type PairType; + std::vector sorted_items; + sorted_items.reserve(source_map.size()); + sorted_items.assign(source_map.begin(), source_map.end()); + llvm::sort(sorted_items, llvm::less_second()); + + for (const auto : sorted_items) { +DeclFromUser user_decl(const_cast(item.first)); +DeclFromParser parser_decl(user_decl.Import(dest_ctx, importer)); +if (parser_decl.IsInvalid()) + return false; +destination_map.insert( +std::pair(parser_decl.decl, item.second)); + } + + return true; +} + +template +bool ExtractBaseOffsets(const ASTRecordLayout _layout, +DeclFromUser , +llvm::DenseMap _offsets) { + for (CXXRecordDecl::base_class_const_iterator + bi = (IsVirtual ? record->vbases_begin() : record->bases_begin()), + be = (IsVirtual ? record->vbases_end() : record->bases_end()); + bi != be; ++bi) { +if (!IsVirtual && bi->isVirtual()) + continue; + +const clang::Type *origin_base_type = bi->getType().getTypePtr(); +const clang::RecordType *origin_base_record_type = +origin_base_type->getAs(); + +if (!origin_base_record_type) + return false; + +DeclFromUser origin_base_record( +origin_base_record_type->getDecl()); + +if (origin_base_record.IsInvalid()) + return false; + +DeclFromUser origin_base_cxx_record( +DynCast(origin_base_record)); + +if (origin_base_cxx_record.IsInvalid()) + return false; + +CharUnits base_offset; + +if (IsVirtual) + base_offset = + record_layout.getVBaseClassOffset(origin_base_cxx_record.decl); +else + base_offset = + record_layout.getBaseClassOffset(origin_base_cxx_record.decl); + +base_offsets.insert(std::pair( +origin_base_cxx_record.decl, base_offset)); + } + + return true; +} + +bool ClangASTImporter::importRecordLayoutFromOrigin( +const RecordDecl *record, uint64_t , uint64_t , +llvm::DenseMap _offsets, +llvm::DenseMap +_offsets, +llvm::DenseMap +_offsets) { + + Log *log = GetLog(LLDBLog::Expressions); + + clang::ASTContext _ctx = record->getASTContext(); + LLDB_LOG(log, + "LayoutRecordType on (ASTContext*){0} '{1}' for (RecordDecl*)" + "{2} [name = '{3}']", + _ctx, + TypeSystemClang::GetASTContext(_ctx)->getDisplayName(), record, + record->getName()); + + DeclFromParser parser_record(record); + DeclFromUser origin_record(parser_record.GetOrigin(*this)); + + if (origin_record.IsInvalid()) +return false; + + std::remove_reference_t origin_field_offsets; + std::remove_reference_t origin_base_offsets; + std::remove_reference_t origin_virtual_base_offsets; + +
[Lldb-commits] [lldb] [lldb][NFC] Move helpers to import record layout into ClangASTImporter (PR #83291)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/83291 >From 7ffc5c966a7a0542cbde20ead3144344e68e648f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 28 Feb 2024 13:32:01 + Subject: [PATCH 1/2] [lldb][NFC] Move helpers to import record layout into ClangASTImporter --- .../Clang/ClangASTImporter.cpp| 204 + .../ExpressionParser/Clang/ClangASTImporter.h | 61 .../ExpressionParser/Clang/ClangASTSource.cpp | 278 ++ .../ExpressionParser/Clang/ClangASTSource.h | 5 + 4 files changed, 290 insertions(+), 258 deletions(-) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp index 62a30c14912bc9..b9f2c834dd1197 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -10,9 +10,11 @@ #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" +#include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/RecordLayout.h" #include "clang/Sema/Lookup.h" #include "clang/Sema/Sema.h" #include "llvm/Support/raw_ostream.h" @@ -26,6 +28,7 @@ #include #include +#include using namespace lldb_private; using namespace clang; @@ -517,6 +520,207 @@ bool ClangASTImporter::CompleteType(const CompilerType _type) { return false; } +template +static bool ImportOffsetMap(clang::ASTContext *dest_ctx, +llvm::DenseMap _map, +llvm::DenseMap _map, +ClangASTImporter ) { + // When importing fields into a new record, clang has a hard requirement that + // fields be imported in field offset order. Since they are stored in a + // DenseMap with a pointer as the key type, this means we cannot simply + // iterate over the map, as the order will be non-deterministic. Instead we + // have to sort by the offset and then insert in sorted order. + typedef llvm::DenseMap MapType; + typedef typename MapType::value_type PairType; + std::vector sorted_items; + sorted_items.reserve(source_map.size()); + sorted_items.assign(source_map.begin(), source_map.end()); + llvm::sort(sorted_items, llvm::less_second()); + + for (const auto : sorted_items) { +DeclFromUser user_decl(const_cast(item.first)); +DeclFromParser parser_decl(user_decl.Import(dest_ctx, importer)); +if (parser_decl.IsInvalid()) + return false; +destination_map.insert( +std::pair(parser_decl.decl, item.second)); + } + + return true; +} + +template +bool ExtractBaseOffsets(const ASTRecordLayout _layout, +DeclFromUser , +llvm::DenseMap _offsets) { + for (CXXRecordDecl::base_class_const_iterator + bi = (IsVirtual ? record->vbases_begin() : record->bases_begin()), + be = (IsVirtual ? record->vbases_end() : record->bases_end()); + bi != be; ++bi) { +if (!IsVirtual && bi->isVirtual()) + continue; + +const clang::Type *origin_base_type = bi->getType().getTypePtr(); +const clang::RecordType *origin_base_record_type = +origin_base_type->getAs(); + +if (!origin_base_record_type) + return false; + +DeclFromUser origin_base_record( +origin_base_record_type->getDecl()); + +if (origin_base_record.IsInvalid()) + return false; + +DeclFromUser origin_base_cxx_record( +DynCast(origin_base_record)); + +if (origin_base_cxx_record.IsInvalid()) + return false; + +CharUnits base_offset; + +if (IsVirtual) + base_offset = + record_layout.getVBaseClassOffset(origin_base_cxx_record.decl); +else + base_offset = + record_layout.getBaseClassOffset(origin_base_cxx_record.decl); + +base_offsets.insert(std::pair( +origin_base_cxx_record.decl, base_offset)); + } + + return true; +} + +bool ClangASTImporter::importRecordLayoutFromOrigin( +const RecordDecl *record, uint64_t , uint64_t , +llvm::DenseMap _offsets, +llvm::DenseMap +_offsets, +llvm::DenseMap +_offsets) { + + Log *log = GetLog(LLDBLog::Expressions); + + clang::ASTContext _ctx = record->getASTContext(); + LLDB_LOG(log, + "LayoutRecordType on (ASTContext*){0} '{1}' for (RecordDecl*)" + "{2} [name = '{3}']", + _ctx, + TypeSystemClang::GetASTContext(_ctx)->getDisplayName(), record, + record->getName()); + + DeclFromParser parser_record(record); + DeclFromUser origin_record(parser_record.GetOrigin(*this)); + + if (origin_record.IsInvalid()) +return false; + + std::remove_reference_t origin_field_offsets; + std::remove_reference_t origin_base_offsets; + std::remove_reference_t origin_virtual_base_offsets; + +
[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)
https://github.com/rastogishubham closed https://github.com/llvm/llvm-project/pull/83312 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 82c1bfc - Increase timeout to reduce test failure rate. (#83312)
Author: Shubham Sandeep Rastogi Date: 2024-02-29T13:12:03-08:00 New Revision: 82c1bfc44ecee97425582f345d04e787f066b899 URL: https://github.com/llvm/llvm-project/commit/82c1bfc44ecee97425582f345d04e787f066b899 DIFF: https://github.com/llvm/llvm-project/commit/82c1bfc44ecee97425582f345d04e787f066b899.diff LOG: Increase timeout to reduce test failure rate. (#83312) The timeout for this test was set to 1.0s which is very low, it should be a default of 10s and be increased by a factor of 10 if ASAN is enabled. This will help reduce the falkiness of the test, especially in ASAN builds. Added: Modified: lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py Removed: diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 288cc8cf9a48c8..23f650d2d36fdd 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -6,6 +6,9 @@ class DAPTestCaseBase(TestBase): +# set timeout based on whether ASAN was enabled or not. Increase +# timeout by a factor of 10 if ASAN is enabled. +timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1) NO_DEBUG_INFO_TESTCASE = True def create_debug_adaptor(self, lldbDAPEnv=None): diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py index 04d741c1d47201..0760d358d9c0b3 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -44,7 +44,7 @@ def test_termination(self): self.dap_server.request_disconnect() # Wait until the underlying lldb-dap process dies. -self.dap_server.process.wait(timeout=10) + self.dap_server.process.wait(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) # Check the return code self.assertEqual(self.dap_server.process.poll(), 0) @@ -334,14 +334,14 @@ def test_commands(self): # Get output from the console. This should contain both the # "stopCommands" that were run after the first breakpoint was hit self.continue_to_breakpoints(breakpoint_ids) -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue again and hit the second breakpoint. # Get output from the console. This should contain both the # "stopCommands" that were run after the second breakpoint was hit self.continue_to_breakpoints(breakpoint_ids) -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue until the program exits @@ -402,21 +402,21 @@ def test_extra_launch_commands(self): self.verify_commands("launchCommands", output, launchCommands) # Verify the "stopCommands" here self.continue_to_next_stop() -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue and hit the second breakpoint. # Get output from the console. This should contain both the # "stopCommands" that were run after the first breakpoint was hit self.continue_to_next_stop() -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue until the program exits self.continue_to_exit() # Get output from the console. This should contain both the # "exitCommands" that were run after the second breakpoint was hit -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("exitCommands", output, exitCommands) @skipIfWindows ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)
https://github.com/rastogishubham updated https://github.com/llvm/llvm-project/pull/83312 >From cef723783edd5ba89fd5b9b0ec800fa1439ffb90 Mon Sep 17 00:00:00 2001 From: Shubham Sandeep Rastogi Date: Wed, 28 Feb 2024 10:28:55 -0800 Subject: [PATCH] Increase timeout to reduce test failure rate. The timeout for this test was set to 1.0s which is very low, it should be a default of 10s and be increased by a factor of 10 if ASAN is enabled. This will help reduce the falkiness of the test, especially in ASAN builds. --- .../test/tools/lldb-dap/lldbdap_testcase.py | 3 +++ .../test/API/tools/lldb-dap/launch/TestDAP_launch.py | 12 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index 288cc8cf9a48c8..23f650d2d36fdd 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -6,6 +6,9 @@ class DAPTestCaseBase(TestBase): +# set timeout based on whether ASAN was enabled or not. Increase +# timeout by a factor of 10 if ASAN is enabled. +timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1) NO_DEBUG_INFO_TESTCASE = True def create_debug_adaptor(self, lldbDAPEnv=None): diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py index 04d741c1d47201..0760d358d9c0b3 100644 --- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py +++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py @@ -44,7 +44,7 @@ def test_termination(self): self.dap_server.request_disconnect() # Wait until the underlying lldb-dap process dies. -self.dap_server.process.wait(timeout=10) + self.dap_server.process.wait(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) # Check the return code self.assertEqual(self.dap_server.process.poll(), 0) @@ -334,14 +334,14 @@ def test_commands(self): # Get output from the console. This should contain both the # "stopCommands" that were run after the first breakpoint was hit self.continue_to_breakpoints(breakpoint_ids) -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue again and hit the second breakpoint. # Get output from the console. This should contain both the # "stopCommands" that were run after the second breakpoint was hit self.continue_to_breakpoints(breakpoint_ids) -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue until the program exits @@ -402,21 +402,21 @@ def test_extra_launch_commands(self): self.verify_commands("launchCommands", output, launchCommands) # Verify the "stopCommands" here self.continue_to_next_stop() -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue and hit the second breakpoint. # Get output from the console. This should contain both the # "stopCommands" that were run after the first breakpoint was hit self.continue_to_next_stop() -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("stopCommands", output, stopCommands) # Continue until the program exits self.continue_to_exit() # Get output from the console. This should contain both the # "exitCommands" that were run after the second breakpoint was hit -output = self.get_console(timeout=1.0) +output = self.get_console(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval) self.verify_commands("exitCommands", output, exitCommands) @skipIfWindows ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][NFC] Add option to exclude third_party packages (PR #83191)
bulbazord wrote: @DavidSpickett If you haven't already, might I suggest looking into a CMake setting I implemented last year? `LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS` -- this will cause your CMake configure step to fail if your bots are missing python packages so that you know your bots are running in a reasonable state. :) https://github.com/llvm/llvm-project/pull/83191 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "XFAIL TestLocalVariables.py on Windows" (PR #83454)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Alexander M. (amordo) Changes This reverts commit 3434472ed74141848634b5eb3cd625d651e22562. Closes #43097. --- Full diff: https://github.com/llvm/llvm-project/pull/83454.diff 1 Files Affected: - (modified) lldb/test/API/lang/c/local_variables/TestLocalVariables.py (-1) ``diff diff --git a/lldb/test/API/lang/c/local_variables/TestLocalVariables.py b/lldb/test/API/lang/c/local_variables/TestLocalVariables.py index cccb8cac013ff2..686636119314ef 100644 --- a/lldb/test/API/lang/c/local_variables/TestLocalVariables.py +++ b/lldb/test/API/lang/c/local_variables/TestLocalVariables.py @@ -19,7 +19,6 @@ def setUp(self): self.source = "main.c" self.line = line_number(self.source, "// Set break point at this line.") -@skipIfWindows def test_c_local_variables(self): """Test local variable value.""" self.build() `` https://github.com/llvm/llvm-project/pull/83454 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "XFAIL TestLocalVariables.py on Windows" (PR #83454)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/83454 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Revert "XFAIL TestLocalVariables.py on Windows" (PR #83454)
https://github.com/amordo created https://github.com/llvm/llvm-project/pull/83454 This reverts commit 3434472ed74141848634b5eb3cd625d651e22562. Closes #43097. >From 05d72acd675d343ad844b93a2a18e7da9c6d7980 Mon Sep 17 00:00:00 2001 From: Alexander Mordovskiy Date: Thu, 29 Feb 2024 18:58:28 +0100 Subject: [PATCH] Revert "XFAIL TestLocalVariables.py on Windows" This reverts commit 3434472ed74141848634b5eb3cd625d651e22562. Closes #43097. --- lldb/test/API/lang/c/local_variables/TestLocalVariables.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/test/API/lang/c/local_variables/TestLocalVariables.py b/lldb/test/API/lang/c/local_variables/TestLocalVariables.py index cccb8cac013ff2..686636119314ef 100644 --- a/lldb/test/API/lang/c/local_variables/TestLocalVariables.py +++ b/lldb/test/API/lang/c/local_variables/TestLocalVariables.py @@ -19,7 +19,6 @@ def setUp(self): self.source = "main.c" self.line = line_number(self.source, "// Set break point at this line.") -@skipIfWindows def test_c_local_variables(self): """Test local variable value.""" self.build() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] a6d9b7b - [lldb] Don't cache lldb_find_python_module result
Author: Jonas Devlieghere Date: 2024-02-29T09:12:20-08:00 New Revision: a6d9b7ba2722953960b83fbacda1757349f00156 URL: https://github.com/llvm/llvm-project/commit/a6d9b7ba2722953960b83fbacda1757349f00156 DIFF: https://github.com/llvm/llvm-project/commit/a6d9b7ba2722953960b83fbacda1757349f00156.diff LOG: [lldb] Don't cache lldb_find_python_module result Don't cache lldb_find_python_module result as that requires you to do a clean build after installing the dependency. Added: Modified: lldb/cmake/modules/AddLLDB.cmake Removed: diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake index 328e883ddbe5a6..fdc4ee0c05d755 100644 --- a/lldb/cmake/modules/AddLLDB.cmake +++ b/lldb/cmake/modules/AddLLDB.cmake @@ -383,7 +383,7 @@ endfunction() function(lldb_find_python_module module) set(MODULE_FOUND PY_${module}_FOUND) - if (DEFINED ${MODULE_FOUND}) + if (${MODULE_FOUND}) return() endif() @@ -392,10 +392,10 @@ function(lldb_find_python_module module) ERROR_QUIET) if (status) -set(${MODULE_FOUND} OFF CACHE BOOL "Failed to find python module '${module}'") +set(${MODULE_FOUND} OFF PARENT_SCOPE) message(STATUS "Could NOT find Python module '${module}'") else() -set(${MODULE_FOUND} ON CACHE BOOL "Found python module '${module}'") +set(${MODULE_FOUND} ON PARENT_SCOPE) message(STATUS "Found Python module '${module}'") endif() endfunction() ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][progress] Hook up new broadcast bit and progress manager (PR #83069)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/83069 >From 59e3b1da1335261badeace24d6136d924cda6949 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Tue, 20 Feb 2024 13:56:53 -0800 Subject: [PATCH] [lldb][progress] Hook up new broadcast bit and progress manager This commit adds the functionality to broadcast events using the `Debugger::eBroadcastProgressCategory` bit (https://github.com/llvm/llvm-project/pull/81169) by keeping track of these reports with the `ProgressManager` class (https://github.com/llvm/llvm-project/pull/81319). The new bit is used in such a way that it will only broadcast the initial and final progress reports for specific progress categories that are managed by the progress manager. This commit also adds a new test to the progress report unit test that checks that only the initial/final reports are broadcasted when using the new bit. --- lldb/include/lldb/Core/Debugger.h | 10 ++- lldb/include/lldb/Core/Progress.h | 47 +++ lldb/source/Core/Debugger.cpp | 19 +++-- lldb/source/Core/Progress.cpp | 77 +- lldb/unittests/Core/ProgressReportTest.cpp | 93 +- 5 files changed, 195 insertions(+), 51 deletions(-) diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 6ba90eb6ed8fdf..b65ec1029ab24b 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -593,6 +593,7 @@ class Debugger : public std::enable_shared_from_this, friend class CommandInterpreter; friend class REPL; friend class Progress; + friend class ProgressManager; /// Report progress events. /// @@ -623,10 +624,11 @@ class Debugger : public std::enable_shared_from_this, /// debugger identifier that this progress should be delivered to. If this /// optional parameter does not have a value, the progress will be /// delivered to all debuggers. - static void ReportProgress(uint64_t progress_id, std::string title, - std::string details, uint64_t completed, - uint64_t total, - std::optional debugger_id); + static void + ReportProgress(uint64_t progress_id, std::string title, std::string details, + uint64_t completed, uint64_t total, + std::optional debugger_id, + uint32_t progress_category_bit = eBroadcastBitProgress); static void ReportDiagnosticImpl(DiagnosticEventData::Type type, std::string message, diff --git a/lldb/include/lldb/Core/Progress.h b/lldb/include/lldb/Core/Progress.h index eb4d9f9d7af08e..450c0b439910f2 100644 --- a/lldb/include/lldb/Core/Progress.h +++ b/lldb/include/lldb/Core/Progress.h @@ -9,10 +9,11 @@ #ifndef LLDB_CORE_PROGRESS_H #define LLDB_CORE_PROGRESS_H -#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" #include "llvm/ADT/StringMap.h" #include +#include #include #include @@ -97,27 +98,36 @@ class Progress { /// Used to indicate a non-deterministic progress report static constexpr uint64_t kNonDeterministicTotal = UINT64_MAX; + /// Data belonging to this Progress event. This data is used by the Debugger + /// to broadcast the event and by the ProgressManager for bookkeeping. + struct ProgressData { +/// The title of the progress activity, also used as a category. +std::string title; +/// More specific information about the current file being displayed in the +/// report. +std::string details; +/// A unique integer identifier for progress reporting. +uint64_t progress_id; +/// How much work ([0...m_total]) that has been completed. +uint64_t completed; +/// Total amount of work, use a std::nullopt in the constructor for non +/// deterministic progress. +uint64_t total; +/// The optional debugger ID to report progress to. If this has no value +/// then all debuggers will receive this event. +std::optional debugger_id; + }; + private: void ReportProgress(); static std::atomic g_id; - /// The title of the progress activity. - std::string m_title; - std::string m_details; std::mutex m_mutex; - /// A unique integer identifier for progress reporting. - const uint64_t m_id; - /// How much work ([0...m_total]) that has been completed. - uint64_t m_completed; - /// Total amount of work, use a std::nullopt in the constructor for non - /// deterministic progress. - uint64_t m_total; - /// The optional debugger ID to report progress to. If this has no value then - /// all debuggers will receive this event. - std::optional m_debugger_id; /// Set to true when progress has been reported where m_completed == m_total /// to ensure that we don't send progress updates after progress has /// completed. bool m_complete = false; + /// Data needed by
[Lldb-commits] [lldb] [lldb][ClangASTImporter] Import record layouts from origin if available (PR #83295)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/83295 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Move helpers to import record layout into ClangASTImporter (PR #83291)
@@ -517,6 +520,207 @@ bool ClangASTImporter::CompleteType(const CompilerType _type) { return false; } +template adrian-prantl wrote: Not your code, but I'm wondering if there's an opportunity here to add a small doxygen comment to the top of the functions? https://github.com/llvm/llvm-project/pull/83291 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Move helpers to import record layout into ClangASTImporter (PR #83291)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/83291 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Move helpers to import record layout into ClangASTImporter (PR #83291)
https://github.com/adrian-prantl edited https://github.com/llvm/llvm-project/pull/83291 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)
@@ -6,6 +6,7 @@ class DAPTestCaseBase(TestBase): +timeoutval = 10 * (10 if ('ASAN_OPTIONS' in os.environ) else 1) walter-erquinigo wrote: Please add a comment here mentioning what the purpose of this variable is https://github.com/llvm/llvm-project/pull/83312 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)
https://github.com/walter-erquinigo edited https://github.com/llvm/llvm-project/pull/83312 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Increase timeout to reduce test failure rate. (PR #83312)
https://github.com/walter-erquinigo approved this pull request. Other than a missing comment, this LGTM. Thanks! https://github.com/llvm/llvm-project/pull/83312 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][NFC] Add option to exclude third_party packages (PR #83191)
DavidSpickett wrote: Arm and AArch64 bots now have pexpect 4.9.0 installed. For Linaro's bots at least, we would be ok with you flipping `LLDB_TEST_USE_VENDOR_PACKAGES` to `OFF` as the next step. This saves us getting a change through zorg and should "just work" now. https://github.com/llvm/llvm-project/pull/83191 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5a0bd2a - [lldb] Add pexpect to LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS
Author: Jonas Devlieghere Date: 2024-02-29T08:08:30-08:00 New Revision: 5a0bd2a36591fe48c24de220a5f8ddef9ce6f0b1 URL: https://github.com/llvm/llvm-project/commit/5a0bd2a36591fe48c24de220a5f8ddef9ce6f0b1 DIFF: https://github.com/llvm/llvm-project/commit/5a0bd2a36591fe48c24de220a5f8ddef9ce6f0b1.diff LOG: [lldb] Add pexpect to LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS This executed Alex' idea [1] of adding pexpect to the list of "strict test requirements" as we're planning to stop vendoring it. This will ensure all the bots have the package before we toggle the default. [1] https://github.com/llvm/llvm-project/pull/83191 Added: Modified: lldb/test/CMakeLists.txt Removed: diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt index 7c31fd487f6ff8..2a9877c721e3b4 100644 --- a/lldb/test/CMakeLists.txt +++ b/lldb/test/CMakeLists.txt @@ -12,7 +12,8 @@ endif() if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS) message(STATUS "Enforcing strict test requirements for LLDB") set(useful_python_modules -psutil # Lit uses psutil to do per-test timeouts. +psutil # Lit uses psutil to do per-test timeouts. +pexpect # We no longer vendor pexpect. ) foreach(module ${useful_python_modules}) lldb_find_python_module(${module}) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 99824cf - [lldb][test] Use pexpect spawn instead of spawnu
Author: David Spickett Date: 2024-02-29T14:59:51Z New Revision: 99824cf7967922bdd9ac895c949f330bb8d6b85a URL: https://github.com/llvm/llvm-project/commit/99824cf7967922bdd9ac895c949f330bb8d6b85a DIFF: https://github.com/llvm/llvm-project/commit/99824cf7967922bdd9ac895c949f330bb8d6b85a.diff LOG: [lldb][test] Use pexpect spawn instead of spawnu This is marked deprecated from at least 4.6 onward: Deprecated: pass encoding to spawn() instead. Added: Modified: lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py lldb/test/API/terminal/TestSTTYBeforeAndAfter.py Removed: diff --git a/lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py b/lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py index d7560156e0571a..15d9feb543895a 100644 --- a/lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py +++ b/lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py @@ -56,8 +56,9 @@ def run_lldb_to_breakpoint(self, exe, source_file, line, settings_commands=None) # So that the child gets torn down after the test. import pexpect -self.child = pexpect.spawnu( -"%s %s %s" % (lldbtest_config.lldbExec, self.lldbOption, exe) +self.child = pexpect.spawn( +"%s %s %s" % (lldbtest_config.lldbExec, self.lldbOption, exe), +encoding="utf-8", ) child = self.child diff --git a/lldb/test/API/terminal/TestSTTYBeforeAndAfter.py b/lldb/test/API/terminal/TestSTTYBeforeAndAfter.py index e9b5940ff1adaf..31b960859fa2e5 100644 --- a/lldb/test/API/terminal/TestSTTYBeforeAndAfter.py +++ b/lldb/test/API/terminal/TestSTTYBeforeAndAfter.py @@ -37,7 +37,7 @@ def test_stty_dash_a_before_and_afetr_invoking_lldb_command(self): lldb_prompt = "(lldb) " # So that the child gets torn down after the test. -self.child = pexpect.spawnu("expect") +self.child = pexpect.spawn("expect", encoding="utf-8") child = self.child child.expect(expect_prompt) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][NFC] Add option to exclude third_party packages (PR #83191)
DavidSpickett wrote: > It should perhaps unset the variable first, I'll see if I can implement that. https://github.com/llvm/llvm-project/commit/ec95379df363253ffcbbda21297417e703d5ccca https://github.com/llvm/llvm-project/pull/83191 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ec95379 - [lldb][test] Clear pexpect found var before checking again
Author: David Spickett Date: 2024-02-29T14:22:23Z New Revision: ec95379df363253ffcbbda21297417e703d5ccca URL: https://github.com/llvm/llvm-project/commit/ec95379df363253ffcbbda21297417e703d5ccca DIFF: https://github.com/llvm/llvm-project/commit/ec95379df363253ffcbbda21297417e703d5ccca.diff LOG: [lldb][test] Clear pexpect found var before checking again If you run cmake without pexpect installed it errors as expected. However, if you just `pip install pexpect` and cmake again it still doesn't find it because it cached the result of the search. Unset the result before looking for pexpect. So that this works as expected: cmake ... pip3 install pexpect cmake ... Added: Modified: lldb/test/CMakeLists.txt Removed: diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt index d8cbb24b6c9b81..7c31fd487f6ff8 100644 --- a/lldb/test/CMakeLists.txt +++ b/lldb/test/CMakeLists.txt @@ -30,6 +30,7 @@ endif() # LLDB tree. However, we delay the deletion of it from the tree in case # users/buildbots don't have the package yet and need some time to install it. if (NOT LLDB_TEST_USE_VENDOR_PACKAGES) + unset(PY_pexpect_FOUND CACHE) lldb_find_python_module(pexpect) if (NOT PY_pexpect_FOUND) message(FATAL_ERROR ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][NFC] Add option to exclude third_party packages (PR #83191)
DavidSpickett wrote: FYI @labath as the x86 bot owner. https://github.com/llvm/llvm-project/pull/83191 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][NFC] Add option to exclude third_party packages (PR #83191)
DavidSpickett wrote: And a data point, AArch64 and Arm Linux are fine with pexpect-4.9.0. Still working on getting it installed on the bot containers. https://github.com/llvm/llvm-project/pull/83191 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test][NFC] Add option to exclude third_party packages (PR #83191)
DavidSpickett wrote: The way the cmake is written it seems that Py_pexpect_FOUND is set to false the first time you run cmake. Then you install pexpect and lldb_find_python_module bails early because Py_pexpect_FOUND is *still* set to false. If you remove the CMake cache it'll then find pexpect as, well, expected. https://github.com/llvm/llvm-project/pull/83191 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix test failure introduced by #83234 (PR #83406)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Sudharsan Veeravalli (svs-quic) Changes Missed adding a . in the test check --- Full diff: https://github.com/llvm/llvm-project/pull/83406.diff 1 Files Affected: - (modified) lldb/test/API/functionalities/completion/TestCompletion.py (+1-1) ``diff diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index 2f6af3cfce109d..0d6907e0c3d229 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -65,7 +65,7 @@ def do_test_variable_completion(self, command): self.complete_from_to(f"{command} fooo.dd", f"{command} fooo.dd") self.complete_from_to(f"{command} ptr_fooo->", f"{command} ptr_fooo->t") -self.complete_from_to(f"{command} ptr_fooo->t", f"{command} ptr_fooo->t.x") +self.complete_from_to(f"{command} ptr_fooo->t.", f"{command} ptr_fooo->t.x") self.complete_from_to(f"{command} ptr_fooo->dd", f"{command} ptr_fooo->dd") self.complete_from_to(f"{command} cont", f"{command} container") `` https://github.com/llvm/llvm-project/pull/83406 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix test failure introduced by #83234 (PR #83406)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/83406 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] ee297a7 - [LLDB] Fix test failure introduced by #83234 (#83406)
Author: Sudharsan Veeravalli Date: 2024-02-29T11:02:22Z New Revision: ee297a73b590ee63f0f4ec9f21c5114c106c8467 URL: https://github.com/llvm/llvm-project/commit/ee297a73b590ee63f0f4ec9f21c5114c106c8467 DIFF: https://github.com/llvm/llvm-project/commit/ee297a73b590ee63f0f4ec9f21c5114c106c8467.diff LOG: [LLDB] Fix test failure introduced by #83234 (#83406) Missed adding a . in the test check Added: Modified: lldb/test/API/functionalities/completion/TestCompletion.py Removed: diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index 2f6af3cfce109d..0d6907e0c3d229 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -65,7 +65,7 @@ def do_test_variable_completion(self, command): self.complete_from_to(f"{command} fooo.dd", f"{command} fooo.dd") self.complete_from_to(f"{command} ptr_fooo->", f"{command} ptr_fooo->t") -self.complete_from_to(f"{command} ptr_fooo->t", f"{command} ptr_fooo->t.x") +self.complete_from_to(f"{command} ptr_fooo->t.", f"{command} ptr_fooo->t.x") self.complete_from_to(f"{command} ptr_fooo->dd", f"{command} ptr_fooo->dd") self.complete_from_to(f"{command} cont", f"{command} container") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add support for inline DWARF source files. (PR #75880)
amordo wrote: @adrian-prantl, I'll be glad to help:) dwarf on Win has warnings like `objdump: Warning: DW_FORM_line_strp offset too big: 0x4008a16c` and no inlined source here is a part of `$ objdump --dwarf a.out` ([full](https://github.com/amordo/TestInlineSourceFiles.test_dwarf/blob/main/objdump_win_out.md)) ``` The File Name Table (offset 0xaf, lines 2, columns 3): Entry Dir (Unknown format content type 8193) Name 0 0objdump: Warning: DW_FORM_line_strp offset too big: 0x4008a161 (indirect line string, offset: 0x4008a161): objdump: Warning: DW_FORM_line_strp offset too big: 0x4008a14f (indirect line string, offset: 0x4008a14f): 1 1objdump: Warning: DW_FORM_line_strp offset too big: 0x4008a16c (indirect line string, offset: 0x4008a16c): objdump: Warning: DW_FORM_line_strp offset too big: 0x4008a162 (indirect line string, offset: 0x4008a162): ``` while linux has one ``` The File Name Table (offset 0xad, lines 2, columns 3): Entry Dir (Unknown format content type 8193) Name 0 0 (indirect line string, offset: 0x159): (indirect line string, offset: 0xf4): /INLINE/inlined.c 1 1 (indirect line string, offset: 0x106): void stop(); void f() { // This is inline source code. stop(); // break here } ``` you can look at Win test result there (+ added 2 .md with the objdump outputs) https://github.com/amordo/TestInlineSourceFiles.test_dwarf/tree/main ps. played replacing '/' on '\\' in paths in `inline.ll`, no effect https://github.com/llvm/llvm-project/pull/75880 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix test failure introduced by #83234 (PR #83406)
https://github.com/Michael137 approved this pull request. https://github.com/llvm/llvm-project/pull/83406 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix test failure introduced by #83234 (PR #83406)
svs-quic wrote: @Michael137 could you please help merge this one as well. https://github.com/llvm/llvm-project/pull/83406 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix test failure introduced by #83234 (PR #83406)
https://github.com/svs-quic ready_for_review https://github.com/llvm/llvm-project/pull/83406 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Fix test failure introduced by #83234 (PR #83406)
https://github.com/svs-quic created https://github.com/llvm/llvm-project/pull/83406 Missed adding a . in the test check >From 1e686b765ba8a456f6a53731a2de2f28d41f6a9c Mon Sep 17 00:00:00 2001 From: Sudharsan Veeravalli Date: Thu, 29 Feb 2024 16:20:35 +0530 Subject: [PATCH] [LLDB] Fix test failure introduced by #83234 --- lldb/test/API/functionalities/completion/TestCompletion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py index 2f6af3cfce109d..0d6907e0c3d229 100644 --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/lldb/test/API/functionalities/completion/TestCompletion.py @@ -65,7 +65,7 @@ def do_test_variable_completion(self, command): self.complete_from_to(f"{command} fooo.dd", f"{command} fooo.dd") self.complete_from_to(f"{command} ptr_fooo->", f"{command} ptr_fooo->t") -self.complete_from_to(f"{command} ptr_fooo->t", f"{command} ptr_fooo->t.x") +self.complete_from_to(f"{command} ptr_fooo->t.", f"{command} ptr_fooo->t.x") self.complete_from_to(f"{command} ptr_fooo->dd", f"{command} ptr_fooo->dd") self.complete_from_to(f"{command} cont", f"{command} container") ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits