[Lldb-commits] [lldb] [lldb] Add additional assertions to TestVTableValue.test_overwrite_vtable (PR #118719)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/118719 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 15de77d - [lldb] (Prepare to) speed up dwarf indexing (#118657)
Author: Pavel Labath Date: 2024-12-05T10:38:29+01:00 New Revision: 15de77db91c199f9431e81d0b85bb6984d1c5296 URL: https://github.com/llvm/llvm-project/commit/15de77db91c199f9431e81d0b85bb6984d1c5296 DIFF: https://github.com/llvm/llvm-project/commit/15de77db91c199f9431e81d0b85bb6984d1c5296.diff LOG: [lldb] (Prepare to) speed up dwarf indexing (#118657) Indexing a single DWARF unit is a fairly small task, which means the overhead of enqueueing a task for each unit is not negligible (mainly because introduces a lot of synchronization points for queue management, memory allocation etc.). This is particularly true if the binary was built with type units, as these are usually very small. This essentially brings us back to the state before https://reviews.llvm.org/D78337, but the new implementation is built on the llvm ThreadPool, and I've added a small improvement -- we now construct one "index set" per thread instead of one per unit, which should lower the memory usage (fewer small allocations) and make the subsequent merge step faster. On its own this patch doesn't actually change the performance characteristics because we still have one choke point -- progress reporting. I'm leaving that for a separate patch, but I've tried that simply removing the progress reporting gives us about a 30-60% speed boost. Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp index 0be19ab29ef082..5b325e30bef430 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -23,6 +23,7 @@ #include "lldb/Utility/Timer.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/ThreadPool.h" +#include #include using namespace lldb_private; @@ -81,44 +82,53 @@ void ManualDWARFIndex::Index() { Progress progress("Manually indexing DWARF", module_desc.GetData(), total_progress); - std::vector sets(units_to_index.size()); - - // Keep memory down by clearing DIEs for any units if indexing - // caused us to load the unit's DIEs. - std::vector> clear_cu_dies( - units_to_index.size()); - auto parser_fn = [&](size_t cu_idx) { -IndexUnit(*units_to_index[cu_idx], dwp_dwarf, sets[cu_idx]); -progress.Increment(); - }; - - auto extract_fn = [&](size_t cu_idx) { -clear_cu_dies[cu_idx] = units_to_index[cu_idx]->ExtractDIEsScoped(); -progress.Increment(); - }; - // Share one thread pool across operations to avoid the overhead of // recreating the threads. llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool()); + const size_t num_threads = Debugger::GetThreadPool().getMaxConcurrency(); + + // Run a function for each compile unit in parallel using as many threads as + // are available. This is significantly faster than submiting a new task for + // each unit. + auto for_each_unit = [&](auto &&fn) { +std::atomic next_cu_idx = 0; +auto wrapper = [&fn, &next_cu_idx, &units_to_index, +&progress](size_t worker_id) { + size_t cu_idx; + while ((cu_idx = next_cu_idx.fetch_add(1, std::memory_order_relaxed)) < + units_to_index.size()) { +fn(worker_id, cu_idx, units_to_index[cu_idx]); +progress.Increment(); + } +}; - // Create a task runner that extracts dies for each DWARF unit in a - // separate thread. - // First figure out which units didn't have their DIEs already - // parsed and remember this. If no DIEs were parsed prior to this index - // function call, we are going to want to clear the CU dies after we are - // done indexing to make sure we don't pull in all DWARF dies, but we need - // to wait until all units have been indexed in case a DIE in one - // unit refers to another and the indexes accesses those DIEs. - for (size_t i = 0; i < units_to_index.size(); ++i) -task_group.async(extract_fn, i); - task_group.wait(); +for (size_t i = 0; i < num_threads; ++i) + task_group.async(wrapper, i); - // Now create a task runner that can index each DWARF unit in a - // separate thread so we can index quickly. - for (size_t i = 0; i < units_to_index.size(); ++i) -task_group.async(parser_fn, i); - task_group.wait(); +task_group.wait(); + }; + // Extract dies for all DWARFs unit in parallel. Figure out which units + // didn't have their DIEs already parsed and remember this. If no DIEs were + // parsed prior to this index function call, we are going to want to clear the + // CU dies after we are done indexing to make sure we don't pull in all DWARF + // dies, but we need to wait until all units have been indexed in case a DIE + // in one unit refers to another and the indexes accesses those DIEs. + std::v
[Lldb-commits] [lldb] [lldb] (Prepare to) speed up dwarf indexing (PR #118657)
https://github.com/labath closed https://github.com/llvm/llvm-project/pull/118657 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix the SocketTest failure on unsupported hosts (PR #118673)
dzhidzhoev wrote: Hmm, on my machine it fails with the same error after the commit is applied ``` Script: -- /home/parallels/llvm-build-release/tools/lldb/unittests/Host/./HostTests --gtest_filter=SocketTest.TCPListen0MultiListenerGetListeningConnectionURI -- /home/parallels/llvm-project/lldb/unittests/Host/SocketTest.cpp:289: Failure Value of: sock.get()->GetListeningConnectionURI() Expected: has 2 elements and there exists some permutation of elements such that: - element #0 is equal to "connection://[::1]:35725", and - element #1 is equal to "connection://[127.0.0.1]:35725" Actual: { "connection://[127.0.0.1]:35725" }, which has 1 element /home/parallels/llvm-project/lldb/unittests/Host/SocketTest.cpp:289 Value of: sock.get()->GetListeningConnectionURI() Expected: has 2 elements and there exists some permutation of elements such that: - element #0 is equal to "connection://[::1]:35725", and - element #1 is equal to "connection://[127.0.0.1]:35725" Actual: { "connection://[127.0.0.1]:35725" }, which has 1 element ``` https://github.com/llvm/llvm-project/pull/118673 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][Process/Utility] Introduce NativeRegisterContextDBReg class (PR #118043)
https://github.com/wangleiat edited https://github.com/llvm/llvm-project/pull/118043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #115331)
@@ -88,9 +89,10 @@ Expected llvm::localCache(const Twine &CacheNameRef, AddBuffer(std::move(AddBuffer)), TempFile(std::move(TempFile)), ModuleName(ModuleName), Task(Task) {} - ~CacheStream() { -// TODO: Manually commit rather than using non-trivial destructor, -// allowing to replace report_fatal_errors with a return Error. + Error commit() override { +if (Committed) + return Error::success(); anjenner wrote: Fair enough. My thinking was that commit() would be idempotent and calling it a second time would be harmless. But I understand the potential for confusion so I'll make it fail instead. After commit() has been called, the OS member will have been reset() and I think will cause the any calling code to do a pure virtual function call if it tries to write to it. I'll have a think about how we could better there and make a testcase. Probably setting OS to a raw_fd_ostream with an fd of zero instead of a default-constructed raw_pwrite_ostream would give a better error message. https://github.com/llvm/llvm-project/pull/115331 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
kuilpd wrote: So, is this patch worth pursuing or is it too much code for a too specific use case? https://github.com/llvm/llvm-project/pull/115005 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix the SocketTest failure on unsupported hosts (PR #118673)
@@ -116,6 +116,24 @@ bool lldb_private::HostSupportsIPv6() { return CheckIPSupport("IPv6", "[::1]:0"); } +bool lldb_private::HostSupportsLocalhostToIPv4() { + if (!HostSupportsIPv4()) +return false; + + auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, AF_INET, + SOCK_STREAM, IPPROTO_TCP); + return !addresses.empty(); +} + +bool lldb_private::HostSupportsLocalhostToIPv6() { + if (!HostSupportsIPv6()) +return false; + + auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, AF_INET6, + SOCK_STREAM, IPPROTO_TCP); ashgti wrote: Thanks for the suggestion! I tried this on my mac by commenting out the `::1 localhost` line in my hosts file, but I wonder if I had some caching or something happening. Applied this suggestion. https://github.com/llvm/llvm-project/pull/118673 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix the SocketTest failure on unsupported hosts (PR #118673)
https://github.com/ashgti updated https://github.com/llvm/llvm-project/pull/118673 >From becab1c1b0a3a9237637909212f7ea7586b82321 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Wed, 4 Dec 2024 09:39:12 -0800 Subject: [PATCH 1/2] [lldb] Fix the SocketTest::TCPListen0MultiListenerGetListeningConnectionURI failure on unsupported hosts. This failure https://lab.llvm.org/buildbot/#/builders/195/builds/1909 happened due to the host not having a `localhost` /etc/hosts entry for an ipv6 address. To fix this, I added a helper to validate if the host has an /etc/hosts entry for both ipv4 and ipv6, otherwise we skip the test. --- lldb/unittests/Host/SocketTest.cpp | 2 +- .../Host/SocketTestUtilities.cpp | 18 ++ .../TestingSupport/Host/SocketTestUtilities.h | 5 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lldb/unittests/Host/SocketTest.cpp b/lldb/unittests/Host/SocketTest.cpp index 689ef4019c618c..9cbf3e26b0883f 100644 --- a/lldb/unittests/Host/SocketTest.cpp +++ b/lldb/unittests/Host/SocketTest.cpp @@ -271,7 +271,7 @@ TEST_P(SocketTest, TCPListen0GetListeningConnectionURI) { } TEST_F(SocketTest, TCPListen0MultiListenerGetListeningConnectionURI) { - if (!HostSupportsIPv6() || !HostSupportsIPv4()) + if (!HostSupportsLocalhostToIPv4() || !HostSupportsLocalhostToIPv6()) return; llvm::Expected> sock = diff --git a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp index eb5bda0fabc770..86349351b0c3a4 100644 --- a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp +++ b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp @@ -116,6 +116,24 @@ bool lldb_private::HostSupportsIPv6() { return CheckIPSupport("IPv6", "[::1]:0"); } +bool lldb_private::HostSupportsLocalhostToIPv4() { + if (!HostSupportsIPv4()) +return false; + + auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, AF_INET, + SOCK_STREAM, IPPROTO_TCP); + return !addresses.empty(); +} + +bool lldb_private::HostSupportsLocalhostToIPv6() { + if (!HostSupportsIPv6()) +return false; + + auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, AF_INET6, + SOCK_STREAM, IPPROTO_TCP); + return !addresses.empty(); +} + llvm::Expected lldb_private::GetLocalhostIP() { if (HostSupportsIPv4()) return "127.0.0.1"; diff --git a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h index efd17428ceefb6..e5bab163cf82eb 100644 --- a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h +++ b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h @@ -43,6 +43,11 @@ void CreateDomainConnectedSockets(llvm::StringRef path, bool HostSupportsIPv6(); bool HostSupportsIPv4(); +/// Returns true if the name `localhost` maps to a loopback IPv4 address. +bool HostSupportsLocalhostToIPv4(); +/// Returns true if the name `localhost` maps to a loopback IPv6 address. +bool HostSupportsLocalhostToIPv6(); + /// Return an IP for localhost based on host support. /// /// This will return either "127.0.0.1" if IPv4 is detected, or "[::1]" if IPv6 >From 47803e31fa247d3058aa2c64d785cd7b71b027a0 Mon Sep 17 00:00:00 2001 From: John Harrison Date: Thu, 5 Dec 2024 08:53:38 -0800 Subject: [PATCH 2/2] Applying suggestions from reviewers. --- .../Host/SocketTestUtilities.cpp | 18 -- 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp index 86349351b0c3a4..80545b8c533a03 100644 --- a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp +++ b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp @@ -120,18 +120,24 @@ bool lldb_private::HostSupportsLocalhostToIPv4() { if (!HostSupportsIPv4()) return false; - auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, AF_INET, - SOCK_STREAM, IPPROTO_TCP); - return !addresses.empty(); + auto addresses = SocketAddress::GetAddressInfo( + "localhost", nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); + return std::find_if(addresses.begin(), addresses.end(), + [](SocketAddress &addr) { +return addr.GetFamily() == AF_INET; + }) != addresses.end(); } bool lldb_private::HostSupportsLocalhostToIPv6() { if (!HostSupportsIPv6()) return false; - auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, AF_INET6, - SOCK_STREAM, IPPROTO_TCP); - return !addresses.empty(); + auto addresses = SocketAddress::GetAddressInfo( + "localhost", nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
[Lldb-commits] [lldb] [lldb] Fix the SocketTest failure on unsupported hosts (PR #118673)
https://github.com/ashgti closed https://github.com/llvm/llvm-project/pull/118673 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 0964328 - [lldb] Fix the SocketTest failure on unsupported hosts (#118673)
Author: John Harrison Date: 2024-12-05T09:08:17-08:00 New Revision: 0964328c2960159f66ad232bb2257fbabab3c0ec URL: https://github.com/llvm/llvm-project/commit/0964328c2960159f66ad232bb2257fbabab3c0ec DIFF: https://github.com/llvm/llvm-project/commit/0964328c2960159f66ad232bb2257fbabab3c0ec.diff LOG: [lldb] Fix the SocketTest failure on unsupported hosts (#118673) The test `SocketTest::TCPListen0MultiListenerGetListeningConnectionURI` is failing on hosts that do not map `localhost` to both an ipv4 and ipv6 address. For example this build https://lab.llvm.org/buildbot/#/builders/195/builds/1909. To fix this, I added a helper to validate if the host has an /etc/hosts entry for both ipv4 and ipv6, otherwise we skip the test. Added: Modified: lldb/unittests/Host/SocketTest.cpp lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp lldb/unittests/TestingSupport/Host/SocketTestUtilities.h Removed: diff --git a/lldb/unittests/Host/SocketTest.cpp b/lldb/unittests/Host/SocketTest.cpp index 689ef4019c618c..9cbf3e26b0883f 100644 --- a/lldb/unittests/Host/SocketTest.cpp +++ b/lldb/unittests/Host/SocketTest.cpp @@ -271,7 +271,7 @@ TEST_P(SocketTest, TCPListen0GetListeningConnectionURI) { } TEST_F(SocketTest, TCPListen0MultiListenerGetListeningConnectionURI) { - if (!HostSupportsIPv6() || !HostSupportsIPv4()) + if (!HostSupportsLocalhostToIPv4() || !HostSupportsLocalhostToIPv6()) return; llvm::Expected> sock = diff --git a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp index eb5bda0fabc770..80545b8c533a03 100644 --- a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp +++ b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.cpp @@ -116,6 +116,30 @@ bool lldb_private::HostSupportsIPv6() { return CheckIPSupport("IPv6", "[::1]:0"); } +bool lldb_private::HostSupportsLocalhostToIPv4() { + if (!HostSupportsIPv4()) +return false; + + auto addresses = SocketAddress::GetAddressInfo( + "localhost", nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); + return std::find_if(addresses.begin(), addresses.end(), + [](SocketAddress &addr) { +return addr.GetFamily() == AF_INET; + }) != addresses.end(); +} + +bool lldb_private::HostSupportsLocalhostToIPv6() { + if (!HostSupportsIPv6()) +return false; + + auto addresses = SocketAddress::GetAddressInfo( + "localhost", nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); + return std::find_if(addresses.begin(), addresses.end(), + [](SocketAddress &addr) { +return addr.GetFamily() == AF_INET6; + }) != addresses.end(); +} + llvm::Expected lldb_private::GetLocalhostIP() { if (HostSupportsIPv4()) return "127.0.0.1"; diff --git a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h index efd17428ceefb6..e5bab163cf82eb 100644 --- a/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h +++ b/lldb/unittests/TestingSupport/Host/SocketTestUtilities.h @@ -43,6 +43,11 @@ void CreateDomainConnectedSockets(llvm::StringRef path, bool HostSupportsIPv6(); bool HostSupportsIPv4(); +/// Returns true if the name `localhost` maps to a loopback IPv4 address. +bool HostSupportsLocalhostToIPv4(); +/// Returns true if the name `localhost` maps to a loopback IPv6 address. +bool HostSupportsLocalhostToIPv6(); + /// Return an IP for localhost based on host support. /// /// This will return either "127.0.0.1" if IPv4 is detected, or "[::1]" if IPv6 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
https://github.com/medismailben approved this pull request. Nice! LGTM! https://github.com/llvm/llvm-project/pull/118814 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
jimingham wrote: I wonder if "member" might be a better name than "child". The base classes of an SBValue representing a C++ object are also children of the value, but you won't be able to look them up in this array. https://github.com/llvm/llvm-project/pull/118814 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/118814 None >From 639fc6d87345c8d68a822032917102a4225df355 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 4 Dec 2024 14:37:24 -0800 Subject: [PATCH] [lldb] Add lookup by name to SBValue.child --- lldb/bindings/interface/SBValueExtensions.i| 6 -- lldb/test/API/python_api/value/TestValueAPI.py | 8 +++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lldb/bindings/interface/SBValueExtensions.i b/lldb/bindings/interface/SBValueExtensions.i index bee9c27775d453..f743b8b9bc786f 100644 --- a/lldb/bindings/interface/SBValueExtensions.i +++ b/lldb/bindings/interface/SBValueExtensions.i @@ -7,7 +7,7 @@ STRING_EXTENSION_OUTSIDE(SBValue) return self.GetDynamicValue (eDynamicCanRunTarget) class children_access(object): -'''A helper object that will lazily hand out thread for a process when supplied an index.''' +'''A helper object that will lazily hand out child values when supplied an index or name.''' def __init__(self, sbvalue): self.sbvalue = sbvalue @@ -23,6 +23,8 @@ STRING_EXTENSION_OUTSIDE(SBValue) if -count <= key < count: key %= count return self.sbvalue.GetChildAtIndex(key) +elif isinstance(key, str): +return self.sbvalue.GetChildMemberWithName(key) return None def get_child_access_object(self): @@ -49,7 +51,7 @@ STRING_EXTENSION_OUTSIDE(SBValue) return self.GetNumChildren() children = property(get_value_child_list, None, doc='''A read only property that returns a list() of lldb.SBValue objects for the children of the value.''') -child = property(get_child_access_object, None, doc='''A read only property that returns an object that can access children of a variable by index (child_value = value.children[12]).''') +child = property(get_child_access_object, None, doc='''A read only property that returns an object that can access children of a variable by index or by name.''') name = property(GetName, None, doc='''A read only property that returns the name of this value as a string.''') type = property(GetType, None, doc='''A read only property that returns a lldb.SBType object that represents the type for this value.''') size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this value.''') diff --git a/lldb/test/API/python_api/value/TestValueAPI.py b/lldb/test/API/python_api/value/TestValueAPI.py index 512100912d6fe7..eb6dbfe6362a43 100644 --- a/lldb/test/API/python_api/value/TestValueAPI.py +++ b/lldb/test/API/python_api/value/TestValueAPI.py @@ -140,10 +140,8 @@ def test(self): val_i = target.EvaluateExpression("i") val_s = target.EvaluateExpression("s") val_a = target.EvaluateExpression("a") -self.assertTrue( -val_s.GetChildMemberWithName("a").GetAddress().IsValid(), VALID_VARIABLE -) -self.assertTrue(val_s.GetChildMemberWithName("a").AddressOf(), VALID_VARIABLE) +self.assertTrue(val_s.child["a"].GetAddress().IsValid(), VALID_VARIABLE) +self.assertTrue(val_s.child["a"].AddressOf(), VALID_VARIABLE) self.assertTrue(val_a.Cast(val_i.GetType()).AddressOf(), VALID_VARIABLE) # Test some other cases of the Cast API. We allow casts from one struct type @@ -210,7 +208,7 @@ def test(self): weird_cast = f_var.Cast(val_s.GetType()) self.assertSuccess(weird_cast.GetError(), "Can cast from a larger to a smaller") self.assertEqual( -weird_cast.GetChildMemberWithName("a").GetValueAsSigned(0), +weird_cast.child["a"].GetValueAsSigned(0), 33, "Got the right value", ) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Dave Lee (kastiglione) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/118814.diff 2 Files Affected: - (modified) lldb/bindings/interface/SBValueExtensions.i (+4-2) - (modified) lldb/test/API/python_api/value/TestValueAPI.py (+3-5) ``diff diff --git a/lldb/bindings/interface/SBValueExtensions.i b/lldb/bindings/interface/SBValueExtensions.i index bee9c27775d453..f743b8b9bc786f 100644 --- a/lldb/bindings/interface/SBValueExtensions.i +++ b/lldb/bindings/interface/SBValueExtensions.i @@ -7,7 +7,7 @@ STRING_EXTENSION_OUTSIDE(SBValue) return self.GetDynamicValue (eDynamicCanRunTarget) class children_access(object): -'''A helper object that will lazily hand out thread for a process when supplied an index.''' +'''A helper object that will lazily hand out child values when supplied an index or name.''' def __init__(self, sbvalue): self.sbvalue = sbvalue @@ -23,6 +23,8 @@ STRING_EXTENSION_OUTSIDE(SBValue) if -count <= key < count: key %= count return self.sbvalue.GetChildAtIndex(key) +elif isinstance(key, str): +return self.sbvalue.GetChildMemberWithName(key) return None def get_child_access_object(self): @@ -49,7 +51,7 @@ STRING_EXTENSION_OUTSIDE(SBValue) return self.GetNumChildren() children = property(get_value_child_list, None, doc='''A read only property that returns a list() of lldb.SBValue objects for the children of the value.''') -child = property(get_child_access_object, None, doc='''A read only property that returns an object that can access children of a variable by index (child_value = value.children[12]).''') +child = property(get_child_access_object, None, doc='''A read only property that returns an object that can access children of a variable by index or by name.''') name = property(GetName, None, doc='''A read only property that returns the name of this value as a string.''') type = property(GetType, None, doc='''A read only property that returns a lldb.SBType object that represents the type for this value.''') size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this value.''') diff --git a/lldb/test/API/python_api/value/TestValueAPI.py b/lldb/test/API/python_api/value/TestValueAPI.py index 512100912d6fe7..eb6dbfe6362a43 100644 --- a/lldb/test/API/python_api/value/TestValueAPI.py +++ b/lldb/test/API/python_api/value/TestValueAPI.py @@ -140,10 +140,8 @@ def test(self): val_i = target.EvaluateExpression("i") val_s = target.EvaluateExpression("s") val_a = target.EvaluateExpression("a") -self.assertTrue( -val_s.GetChildMemberWithName("a").GetAddress().IsValid(), VALID_VARIABLE -) -self.assertTrue(val_s.GetChildMemberWithName("a").AddressOf(), VALID_VARIABLE) +self.assertTrue(val_s.child["a"].GetAddress().IsValid(), VALID_VARIABLE) +self.assertTrue(val_s.child["a"].AddressOf(), VALID_VARIABLE) self.assertTrue(val_a.Cast(val_i.GetType()).AddressOf(), VALID_VARIABLE) # Test some other cases of the Cast API. We allow casts from one struct type @@ -210,7 +208,7 @@ def test(self): weird_cast = f_var.Cast(val_s.GetType()) self.assertSuccess(weird_cast.GetError(), "Can cast from a larger to a smaller") self.assertEqual( -weird_cast.GetChildMemberWithName("a").GetValueAsSigned(0), +weird_cast.child["a"].GetValueAsSigned(0), 33, "Got the right value", ) `` https://github.com/llvm/llvm-project/pull/118814 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #115331)
@@ -131,11 +138,22 @@ Expected llvm::localCache(const Twine &CacheNameRef, }); if (E) - report_fatal_error(Twine("Failed to rename temporary file ") + - TempFile.TmpName + " to " + ObjectPathName + ": " + - toString(std::move(E)) + "\n"); + return E; AddBuffer(Task, ModuleName, std::move(*MBOrErr)); +return Error::success(); + } + + ~CacheStream() { +// In Debug builds, try to track down places where commit() was not +// called before destruction. +assert(Committed); anjenner wrote: The advantage of explicit commit is that it allows proper error handling rather than aborting the entire process if the cache write fails - usually an undesirable behavior. My aim here was to quietly fall back to the previous behavior in if commit() was not called in release mode but help developers track down such places in debug mode (which worked perfectly - I found just such a case that way). I was thinking of leaving it there to help people who have code that uses localCache in branches that have not yet landed in mainline LLVM. However, I agree that it would be annoying to switch from release to debug to track down an unrelated problem and have to fix a missing commit() at that point. I think on balance explicitly failing here is the better plan - I'll modify my patch to do this but I could probably be talked into allowing the commit() to be optional if anyone has strong feelings about this. https://github.com/llvm/llvm-project/pull/115331 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #115331)
https://github.com/anjenner updated https://github.com/llvm/llvm-project/pull/115331 >From 3fdba46d41ad9668a114766fe892af497f121cd5 Mon Sep 17 00:00:00 2001 From: Andrew Jenner Date: Thu, 7 Nov 2024 10:47:42 -0500 Subject: [PATCH 1/3] Modify the localCache API to require an explicit commit on CachedFileStream. CachedFileStream has previously performed the commit step in its destructor, but this means its only recourse for error handling is report_fatal_error. Modify this to add an explicit commit() method, and call this in the appropriate places with appropriate error handling for the location. Currently the destructor of CacheStream gives an assert failure in Debug builds if commit() was not called. This will help track down any remaining uses of the API that assume the old destructior behaviour. In Release builds we fall back to the previous behaviour and call report_fatal_error if the commit fails. --- lldb/source/Core/DataFileCache.cpp | 5 llvm/include/llvm/Support/Caching.h | 1 + llvm/lib/Debuginfod/Debuginfod.cpp | 9 +++ llvm/lib/LTO/LTOBackend.cpp | 3 +++ llvm/lib/Support/Caching.cpp| 40 + llvm/tools/gold/gold-plugin.cpp | 4 ++- llvm/tools/llvm-lto2/llvm-lto2.cpp | 4 ++- 7 files changed, 53 insertions(+), 13 deletions(-) diff --git a/lldb/source/Core/DataFileCache.cpp b/lldb/source/Core/DataFileCache.cpp index ef0e07a8b03420..91092697112317 100644 --- a/lldb/source/Core/DataFileCache.cpp +++ b/lldb/source/Core/DataFileCache.cpp @@ -132,6 +132,11 @@ bool DataFileCache::SetCachedData(llvm::StringRef key, if (file_or_err) { llvm::CachedFileStream *cfs = file_or_err->get(); cfs->OS->write((const char *)data.data(), data.size()); +if (llvm::Error err = cfs->commit()) { + Log *log = GetLog(LLDBLog::Modules); + LLDB_LOG_ERROR(log, std::move(err), + "failed to commit to the cache for key: {0}"); +} return true; } else { Log *log = GetLog(LLDBLog::Modules); diff --git a/llvm/include/llvm/Support/Caching.h b/llvm/include/llvm/Support/Caching.h index cf45145619d95b..120bcd9da02ede 100644 --- a/llvm/include/llvm/Support/Caching.h +++ b/llvm/include/llvm/Support/Caching.h @@ -30,6 +30,7 @@ class CachedFileStream { CachedFileStream(std::unique_ptr OS, std::string OSPath = "") : OS(std::move(OS)), ObjectPathName(OSPath) {} + virtual Error commit() { return Error::success(); } std::unique_ptr OS; std::string ObjectPathName; virtual ~CachedFileStream() = default; diff --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp index 4c785117ae8ef7..6ff889d3a8cad2 100644 --- a/llvm/lib/Debuginfod/Debuginfod.cpp +++ b/llvm/lib/Debuginfod/Debuginfod.cpp @@ -188,6 +188,7 @@ class StreamedHTTPResponseHandler : public HTTPResponseHandler { public: StreamedHTTPResponseHandler(CreateStreamFn CreateStream, HTTPClient &Client) : CreateStream(CreateStream), Client(Client) {} + Error commit(); virtual ~StreamedHTTPResponseHandler() = default; Error handleBodyChunk(StringRef BodyChunk) override; @@ -210,6 +211,12 @@ Error StreamedHTTPResponseHandler::handleBodyChunk(StringRef BodyChunk) { return Error::success(); } +Error StreamedHTTPResponseHandler::commit() { + if (FileStream) +return FileStream->commit(); + return Error::success(); +} + // An over-accepting simplification of the HTTP RFC 7230 spec. static bool isHeader(StringRef S) { StringRef Name; @@ -298,6 +305,8 @@ Expected getCachedOrDownloadArtifact( Error Err = Client.perform(Request, Handler); if (Err) return std::move(Err); + if (Err = Handler.commit()) +return std::move(Err); unsigned Code = Client.responseCode(); if (Code && Code != 200) diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index bdf4ff8960bc82..4bfa8751a43643 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -434,6 +434,9 @@ static void codegen(const Config &Conf, TargetMachine *TM, if (DwoOut) DwoOut->keep(); + + if (Error Err = Stream->commit()) +report_fatal_error(std::move(Err)); } static void splitCodeGen(const Config &C, TargetMachine *TM, diff --git a/llvm/lib/Support/Caching.cpp b/llvm/lib/Support/Caching.cpp index 66e540efaca972..2ecdf53701030d 100644 --- a/llvm/lib/Support/Caching.cpp +++ b/llvm/lib/Support/Caching.cpp @@ -80,6 +80,7 @@ Expected llvm::localCache(const Twine &CacheNameRef, sys::fs::TempFile TempFile; std::string ModuleName; unsigned Task; + bool Committed = false; CacheStream(std::unique_ptr OS, AddBufferFn AddBuffer, sys::fs::TempFile TempFile, std::string EntryPath, @@ -88,9 +89,10 @@ Expected llvm::localCache(const Twine &CacheNameRef, AddBuffer(std::move(AddBuffer)), TempFile(std::move(TempFile)),
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
https://github.com/kastiglione edited https://github.com/llvm/llvm-project/pull/118814 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix the SocketTest failure on unsupported hosts (PR #118673)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/118673 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][Process/Utility] Introduce NativeRegisterContextDBReg class (PR #118043)
https://github.com/DavidSpickett commented: I was looking at the Arm (32 bit) code and it's also very similar, so if I find the time I'll migrate this to this base class too. See if you can move the use of pac_bits, then I'll test this for you on AArch64. https://github.com/llvm/llvm-project/pull/118043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][Process/Utility] Introduce NativeRegisterContextDBReg class (PR #118043)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/118043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][Process/Utility] Introduce NativeRegisterContextDBReg class (PR #118043)
@@ -234,9 +234,9 @@ class NativeRegisterContextLinux_arm64 size_t GetFPMRBufferSize() { return sizeof(m_fpmr_reg); } - llvm::Error ReadHardwareDebugInfo() override; + Status ReadHardwareDebugInfo() override; DavidSpickett wrote: @labath I seem to remember you saying we want to move to or away from Status, if I didn't imagine that, which is it? https://github.com/llvm/llvm-project/pull/118043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][Process/Utility] Introduce NativeRegisterContextDBReg class (PR #118043)
@@ -274,7 +161,7 @@ uint32_t NativeRegisterContextDBReg_arm64::SetHardwareWatchpoint( } // Setup control value - control_value = g_enable_bit | g_pac_bits | GetSizeBits(size); + control_value = m_hw_dbg_enable_bit | g_pac_bits | GetSizeBits(size); DavidSpickett wrote: Perhaps you can also move this sort of thing into a method to be overridden. Then this code can also move to the base class. https://github.com/llvm/llvm-project/pull/118043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][Process/Utility] Introduce NativeRegisterContextDBReg class (PR #118043)
https://github.com/DavidSpickett edited https://github.com/llvm/llvm-project/pull/118043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
medismailben wrote: > or, should we allow base classes to be looked up by name as well? I'd prefer the latter so they can used interchangeably. I like the fact that the subscript can be either an int or a string. https://github.com/llvm/llvm-project/pull/118814 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
kastiglione wrote: @jimingham are you proposing a new property named `member`? In which case `child` would be used for index based access, and `member` would be used for name based access? https://github.com/llvm/llvm-project/pull/118814 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
kastiglione wrote: or, should we allow base classes to be looked up by name as well? https://github.com/llvm/llvm-project/pull/118814 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add additional assertions to TestVTableValue.test_overwrite_vtable (PR #118719)
https://github.com/bulbazord closed https://github.com/llvm/llvm-project/pull/118719 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] abb6919 - [lldb] Add additional assertions to TestVTableValue.test_overwrite_vtable (#118719)
Author: Alex Langford Date: 2024-12-05T10:38:23-08:00 New Revision: abb6919a63c7ef017bb4f9c86057adcdb8129964 URL: https://github.com/llvm/llvm-project/commit/abb6919a63c7ef017bb4f9c86057adcdb8129964 DIFF: https://github.com/llvm/llvm-project/commit/abb6919a63c7ef017bb4f9c86057adcdb8129964.diff LOG: [lldb] Add additional assertions to TestVTableValue.test_overwrite_vtable (#118719) If this test fails, you're likely going to see something like "Assertion Error: A != B" which doesn't really give much explanation for why this failed. Instead of ignoring the error, we should assert that it succeeded. This will lead to a better error message, for example: `AssertionError: 'memory write failed for 0x102d7c018' is not success` Added: Modified: lldb/test/API/functionalities/vtable/TestVTableValue.py Removed: diff --git a/lldb/test/API/functionalities/vtable/TestVTableValue.py b/lldb/test/API/functionalities/vtable/TestVTableValue.py index bfc910614afa9e..f0076ea28f7599 100644 --- a/lldb/test/API/functionalities/vtable/TestVTableValue.py +++ b/lldb/test/API/functionalities/vtable/TestVTableValue.py @@ -2,7 +2,6 @@ Make sure the getting a variable path works and doesn't crash. """ - import lldb import lldbsuite.test.lldbutil as lldbutil from lldbsuite.test.decorators import * @@ -142,7 +141,12 @@ def test_overwrite_vtable(self): "\x01\x01\x01\x01\x01\x01\x01\x01" if is_64bit else "\x01\x01\x01\x01" ) error = lldb.SBError() -process.WriteMemory(vtable_addr, data, error) +bytes_written = process.WriteMemory(vtable_addr, data, error) + +self.assertSuccess(error) +self.assertGreater( +bytes_written, 0, "Failed to overwrite first entry in vtable" +) scribbled_child = vtable.GetChildAtIndex(0) self.assertEqual( ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/118814 >From 639fc6d87345c8d68a822032917102a4225df355 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 4 Dec 2024 14:37:24 -0800 Subject: [PATCH 1/3] [lldb] Add lookup by name to SBValue.child --- lldb/bindings/interface/SBValueExtensions.i| 6 -- lldb/test/API/python_api/value/TestValueAPI.py | 8 +++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lldb/bindings/interface/SBValueExtensions.i b/lldb/bindings/interface/SBValueExtensions.i index bee9c27775d453..f743b8b9bc786f 100644 --- a/lldb/bindings/interface/SBValueExtensions.i +++ b/lldb/bindings/interface/SBValueExtensions.i @@ -7,7 +7,7 @@ STRING_EXTENSION_OUTSIDE(SBValue) return self.GetDynamicValue (eDynamicCanRunTarget) class children_access(object): -'''A helper object that will lazily hand out thread for a process when supplied an index.''' +'''A helper object that will lazily hand out child values when supplied an index or name.''' def __init__(self, sbvalue): self.sbvalue = sbvalue @@ -23,6 +23,8 @@ STRING_EXTENSION_OUTSIDE(SBValue) if -count <= key < count: key %= count return self.sbvalue.GetChildAtIndex(key) +elif isinstance(key, str): +return self.sbvalue.GetChildMemberWithName(key) return None def get_child_access_object(self): @@ -49,7 +51,7 @@ STRING_EXTENSION_OUTSIDE(SBValue) return self.GetNumChildren() children = property(get_value_child_list, None, doc='''A read only property that returns a list() of lldb.SBValue objects for the children of the value.''') -child = property(get_child_access_object, None, doc='''A read only property that returns an object that can access children of a variable by index (child_value = value.children[12]).''') +child = property(get_child_access_object, None, doc='''A read only property that returns an object that can access children of a variable by index or by name.''') name = property(GetName, None, doc='''A read only property that returns the name of this value as a string.''') type = property(GetType, None, doc='''A read only property that returns a lldb.SBType object that represents the type for this value.''') size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this value.''') diff --git a/lldb/test/API/python_api/value/TestValueAPI.py b/lldb/test/API/python_api/value/TestValueAPI.py index 512100912d6fe7..eb6dbfe6362a43 100644 --- a/lldb/test/API/python_api/value/TestValueAPI.py +++ b/lldb/test/API/python_api/value/TestValueAPI.py @@ -140,10 +140,8 @@ def test(self): val_i = target.EvaluateExpression("i") val_s = target.EvaluateExpression("s") val_a = target.EvaluateExpression("a") -self.assertTrue( -val_s.GetChildMemberWithName("a").GetAddress().IsValid(), VALID_VARIABLE -) -self.assertTrue(val_s.GetChildMemberWithName("a").AddressOf(), VALID_VARIABLE) +self.assertTrue(val_s.child["a"].GetAddress().IsValid(), VALID_VARIABLE) +self.assertTrue(val_s.child["a"].AddressOf(), VALID_VARIABLE) self.assertTrue(val_a.Cast(val_i.GetType()).AddressOf(), VALID_VARIABLE) # Test some other cases of the Cast API. We allow casts from one struct type @@ -210,7 +208,7 @@ def test(self): weird_cast = f_var.Cast(val_s.GetType()) self.assertSuccess(weird_cast.GetError(), "Can cast from a larger to a smaller") self.assertEqual( -weird_cast.GetChildMemberWithName("a").GetValueAsSigned(0), +weird_cast.child["a"].GetValueAsSigned(0), 33, "Got the right value", ) >From c6f926b0e451f87af8c14baed3de55f4cb4240d5 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 5 Dec 2024 13:04:20 -0800 Subject: [PATCH 2/3] Support base class children --- lldb/bindings/interface/SBValueExtensions.i | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lldb/bindings/interface/SBValueExtensions.i b/lldb/bindings/interface/SBValueExtensions.i index f743b8b9bc786f..c813de6c65c5c6 100644 --- a/lldb/bindings/interface/SBValueExtensions.i +++ b/lldb/bindings/interface/SBValueExtensions.i @@ -24,7 +24,12 @@ STRING_EXTENSION_OUTSIDE(SBValue) key %= count return self.sbvalue.GetChildAtIndex(key) elif isinstance(key, str): -return self.sbvalue.GetChildMemberWithName(key) +if child := self.sbvalue.GetChildMemberWithName(key) +return child +# Support base classes, which are children but not members. +for child in self.sbvalue
[Lldb-commits] [lldb] [lldb-dap] Add attach & corefile templates (PR #118894)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/118894 None >From 0863b603d0bdf53e977f707d58083cf505fa0f29 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 5 Dec 2024 14:46:42 -0800 Subject: [PATCH] [lldb-dap] Add attach & corefile templates --- lldb/tools/lldb-dap/package-lock.json | 4 ++-- lldb/tools/lldb-dap/package.json | 26 -- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lldb/tools/lldb-dap/package-lock.json b/lldb/tools/lldb-dap/package-lock.json index 8663659715590a..d1cb6d00ecf566 100644 --- a/lldb/tools/lldb-dap/package-lock.json +++ b/lldb/tools/lldb-dap/package-lock.json @@ -1,12 +1,12 @@ { "name": "lldb-dap", - "version": "0.2.6", + "version": "0.2.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lldb-dap", - "version": "0.2.6", + "version": "0.2.8", "license": "Apache 2.0 License with LLVM exceptions", "devDependencies": { "@types/node": "^18.11.18", diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json index 6079edb5a2189a..bbe65e1f73fd8c 100644 --- a/lldb/tools/lldb-dap/package.json +++ b/lldb/tools/lldb-dap/package.json @@ -1,7 +1,7 @@ { "name": "lldb-dap", "displayName": "LLDB DAP", - "version": "0.2.7", + "version": "0.2.8", "publisher": "llvm-vs-code-extensions", "homepage": "https://lldb.llvm.org";, "description": "LLDB debugging from VSCode", @@ -141,7 +141,7 @@ "debuggers": [ { "type": "lldb-dap", -"label": "Native LLDB Debugger", +"label": "LLDB DAP Debugger", "program": "./bin/lldb-dap", "windows": { "program": "./bin/lldb-dap.exe" @@ -508,6 +508,28 @@ "env": [], "cwd": "^\"\\${workspaceRoot}\"" } + }, + { +"label": "LLDB: Attach", +"description": "", +"body": { + "type": "lldb-dap", + "request": "attach", + "name": "${2:Attach}", + "program": "${1:}", + "waitFor": true +} + }, + { +"label": "LLDB: Load Coredump", +"description": "", +"body": { + "type": "lldb-dap", + "request": "attach", + "name": "${2:Core}", + "program": "${1:}", + "coreFile": "${1:}.core" +} } ] } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add attach & corefile templates (PR #118894)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes --- Full diff: https://github.com/llvm/llvm-project/pull/118894.diff 2 Files Affected: - (modified) lldb/tools/lldb-dap/package-lock.json (+2-2) - (modified) lldb/tools/lldb-dap/package.json (+24-2) ``diff diff --git a/lldb/tools/lldb-dap/package-lock.json b/lldb/tools/lldb-dap/package-lock.json index 8663659715590a..d1cb6d00ecf566 100644 --- a/lldb/tools/lldb-dap/package-lock.json +++ b/lldb/tools/lldb-dap/package-lock.json @@ -1,12 +1,12 @@ { "name": "lldb-dap", - "version": "0.2.6", + "version": "0.2.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lldb-dap", - "version": "0.2.6", + "version": "0.2.8", "license": "Apache 2.0 License with LLVM exceptions", "devDependencies": { "@types/node": "^18.11.18", diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json index 6079edb5a2189a..bbe65e1f73fd8c 100644 --- a/lldb/tools/lldb-dap/package.json +++ b/lldb/tools/lldb-dap/package.json @@ -1,7 +1,7 @@ { "name": "lldb-dap", "displayName": "LLDB DAP", - "version": "0.2.7", + "version": "0.2.8", "publisher": "llvm-vs-code-extensions", "homepage": "https://lldb.llvm.org";, "description": "LLDB debugging from VSCode", @@ -141,7 +141,7 @@ "debuggers": [ { "type": "lldb-dap", -"label": "Native LLDB Debugger", +"label": "LLDB DAP Debugger", "program": "./bin/lldb-dap", "windows": { "program": "./bin/lldb-dap.exe" @@ -508,6 +508,28 @@ "env": [], "cwd": "^\"\\${workspaceRoot}\"" } + }, + { +"label": "LLDB: Attach", +"description": "", +"body": { + "type": "lldb-dap", + "request": "attach", + "name": "${2:Attach}", + "program": "${1:}", + "waitFor": true +} + }, + { +"label": "LLDB: Load Coredump", +"description": "", +"body": { + "type": "lldb-dap", + "request": "attach", + "name": "${2:Core}", + "program": "${1:}", + "coreFile": "${1:}.core" +} } ] } `` https://github.com/llvm/llvm-project/pull/118894 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][Process/Utility] Introduce NativeRegisterContextDBReg class (PR #118043)
@@ -274,7 +161,7 @@ uint32_t NativeRegisterContextDBReg_arm64::SetHardwareWatchpoint( } // Setup control value - control_value = g_enable_bit | g_pac_bits | GetSizeBits(size); + control_value = m_hw_dbg_enable_bit | g_pac_bits | GetSizeBits(size); wangleiat wrote: I have made updates based on [this](https://github.com/llvm/llvm-project/pull/118770#discussion_r1871170826) feedback. https://github.com/llvm/llvm-project/pull/118043 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][Process/Utility] Introduce NativeRegisterContextDBReg class (PR #118043)
https://github.com/wangleiat updated https://github.com/llvm/llvm-project/pull/118043 >From a7cba7ef089a6f2004b1879d30675652729370e5 Mon Sep 17 00:00:00 2001 From: wanglei Date: Fri, 29 Nov 2024 10:43:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?= =?UTF-8?q?itial=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5-bogner --- ...NativeRegisterContextLinux_loongarch64.cpp | 484 ++ .../NativeRegisterContextLinux_loongarch64.h | 60 +++ .../GDBRemoteCommunicationServerCommon.cpp| 3 +- lldb/source/Target/Process.cpp| 3 +- 4 files changed, 548 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp index f4d1bb297049da..1f73bd0467962d 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp @@ -11,7 +11,9 @@ #include "NativeRegisterContextLinux_loongarch64.h" #include "lldb/Host/HostInfo.h" +#include "lldb/Host/linux/Ptrace.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" @@ -32,6 +34,19 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::process_linux; +// CTRL_PLV3_ENABLE, used to enable breakpoint/watchpoint +constexpr uint32_t g_enable_bit = 0x10; + +// Returns appropriate control register bits for the specified size +// size encoded: +// case 1 : 0b11 +// case 2 : 0b10 +// case 4 : 0b01 +// case 8 : 0b00 +static inline uint64_t GetSizeBits(int size) { + return (3 - llvm::Log2_32(size)) << 10; +} + std::unique_ptr NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux( const ArchSpec &target_arch, NativeThreadLinux &native_thread) { @@ -61,6 +76,8 @@ NativeRegisterContextLinux_loongarch64::NativeRegisterContextLinux_loongarch64( NativeRegisterContextLinux(native_thread) { ::memset(&m_fpr, 0, sizeof(m_fpr)); ::memset(&m_gpr, 0, sizeof(m_gpr)); + ::memset(&m_hwp_regs, 0, sizeof(m_hwp_regs)); + ::memset(&m_hbp_regs, 0, sizeof(m_hbp_regs)); m_gpr_is_valid = false; m_fpu_is_valid = false; @@ -337,4 +354,471 @@ NativeRegisterContextLinux_loongarch64::GetExpeditedRegisters( return expedited_reg_nums; } +uint32_t +NativeRegisterContextLinux_loongarch64::NumSupportedHardwareBreakpoints() { + Log *log = GetLog(LLDBLog::Breakpoints); + + // Read hardware breakpoint and watchpoint information. + Status error = ReadHardwareDebugInfo(); + + if (error.Fail()) { +LLDB_LOG(log, "failed to read debug registers"); +return 0; + } + + LLDB_LOG(log, "{0}", m_max_hbp_supported); + return m_max_hbp_supported; +} + +uint32_t +NativeRegisterContextLinux_loongarch64::SetHardwareBreakpoint(lldb::addr_t addr, + size_t size) { + Log *log = GetLog(LLDBLog::Breakpoints); + LLDB_LOG(log, "addr: {0:x}, size: {1:x}", addr, size); + + // Read hardware breakpoint and watchpoint information. + Status error = ReadHardwareDebugInfo(); + if (error.Fail()) { +LLDB_LOG(log, "unable to set breakpoint: failed to read debug registers"); +return LLDB_INVALID_INDEX32; + } + + uint32_t bp_index = 0; + + // Check if size has a valid hardware breakpoint length. + if (size != 4) +return LLDB_INVALID_INDEX32; // Invalid size for a LoongArch hardware + // breakpoint + + // Check 4-byte alignment for hardware breakpoint target address. + if (addr & 0x03) +return LLDB_INVALID_INDEX32; // Invalid address, should be 4-byte aligned. + + // Iterate over stored breakpoints and find a free bp_index + bp_index = LLDB_INVALID_INDEX32; + for (uint32_t i = 0; i < m_max_hbp_supported; i++) { +if (!BreakpointIsEnabled(i)) + bp_index = i; // Mark last free slot +else if (m_hbp_regs[i].address == addr) + return LLDB_INVALID_INDEX32; // We do not support duplicate breakpoints. + } + + if (bp_index == LLDB_INVALID_INDEX32) +return LLDB_INVALID_INDEX32; + + // Update breakpoint in local cache + m_hbp_regs[bp_index].address = addr; + m_hbp_regs[bp_index].control = g_enable_bit; + + // PTRACE call to set corresponding hardware breakpoint register. + error = WriteHardwareDebugRegs(eDREGTypeBREAK); + + if (error.Fail()) { +m_hbp_regs[bp_index].address = 0; +m_hbp_regs[bp_index].control = 0; + +LLDB_LOG(log, "unable to set breakpoint: failed to write debug registers"); +return LLDB_INVALID_INDEX32; + } + + return bp_index; +} +bool NativeRegisterContextLinux_loongarch64::ClearHardwareBreakpoint( +uint32_t hw_idx) { + Log *log = GetLog(LLDBLog::Breakpoin
[Lldb-commits] [lldb] [lldb] (Prepare to) speed up dwarf indexing (PR #118657)
labath wrote: > Makes sense, LGTM. > > If the amount of work here is so small, and the granularity was too fine for > creating separate tasks, I'd argue that it's too fine for progress reporting > as well. I think that's what you're saying too. There's probably multiple > ways of dealing with that, so I'm looking forward to the PR that addresses > that. It is, and there are. I have a prototype which deals with that by updating progress after every X bytes of DWARF have been indexed. The thing I like about that is that it should give a relatively constant rate of updates regardless of whether you're using type units (many small units) or not (fewer large units). The part I don't like is that does gives a wildly different rate for split vs. non-split DWARF (as in the former case, the main DWARF unit is just a handful of bytes). I'm still thinking about alternatives... https://github.com/llvm/llvm-project/pull/118657 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] (Prepare to) speed up dwarf indexing (PR #118657)
https://github.com/labath updated https://github.com/llvm/llvm-project/pull/118657 >From 6a9384e47441117cff7b2903b4ad8bdfd11f06b4 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 2 Dec 2024 12:44:24 + Subject: [PATCH 1/2] [lldb] (Prepare to) speed up dwarf indexing Indexing a single DWARF unit is a fairly small task, which means the overhead of enqueueing a task for each unit is not negligible (mainly because introduces a lot of synchronization points for queue management, memory allocation etc.). This is particularly true for if the binary was built with type units, as these are usually very small. This essentially brings us back to the state before https://reviews.llvm.org/D78337, but the new implementation is built on the llvm ThreadPool, and I've added a small improvement -- we now construct one "index set" per thread instead of one per unit, which should lower the memory usage (fewer small allocations) and make the subsequent merge step faster. On its own this patch doesn't actually change the performance characteristics because we still have one choke point -- progress reporting. I'm leaving that for a separate patch, but I've tried that simply removing the progress reporting gives us about a 30-60% speed boost. --- .../SymbolFile/DWARF/ManualDWARFIndex.cpp | 73 +++ 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp index 0be19ab29ef082..03a031626ab154 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -23,6 +23,7 @@ #include "lldb/Utility/Timer.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/ThreadPool.h" +#include #include using namespace lldb_private; @@ -81,44 +82,54 @@ void ManualDWARFIndex::Index() { Progress progress("Manually indexing DWARF", module_desc.GetData(), total_progress); - std::vector sets(units_to_index.size()); - - // Keep memory down by clearing DIEs for any units if indexing - // caused us to load the unit's DIEs. - std::vector> clear_cu_dies( - units_to_index.size()); - auto parser_fn = [&](size_t cu_idx) { -IndexUnit(*units_to_index[cu_idx], dwp_dwarf, sets[cu_idx]); -progress.Increment(); - }; - - auto extract_fn = [&](size_t cu_idx) { -clear_cu_dies[cu_idx] = units_to_index[cu_idx]->ExtractDIEsScoped(); -progress.Increment(); - }; // Share one thread pool across operations to avoid the overhead of // recreating the threads. llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool()); + const size_t num_threads = Debugger::GetThreadPool().getMaxConcurrency(); + + // Run a function for each compile unit in parallel using as many threads as + // are available. This is significantly faster than submiting a new task for + // each unit. + auto for_each_unit = [&](auto &&fn) { +std::atomic next_cu_idx = 0; +auto wrapper = [&fn, &next_cu_idx, &units_to_index, +&progress](size_t worker_id) { + size_t cu_idx; + while ((cu_idx = next_cu_idx.fetch_add(1, std::memory_order_relaxed)) < + units_to_index.size()) { +fn(worker_id, cu_idx, units_to_index[cu_idx]); +progress.Increment(); + } +}; - // Create a task runner that extracts dies for each DWARF unit in a - // separate thread. - // First figure out which units didn't have their DIEs already - // parsed and remember this. If no DIEs were parsed prior to this index - // function call, we are going to want to clear the CU dies after we are - // done indexing to make sure we don't pull in all DWARF dies, but we need - // to wait until all units have been indexed in case a DIE in one - // unit refers to another and the indexes accesses those DIEs. - for (size_t i = 0; i < units_to_index.size(); ++i) -task_group.async(extract_fn, i); - task_group.wait(); +for (size_t i = 0; i < num_threads; ++i) + task_group.async(wrapper, i); - // Now create a task runner that can index each DWARF unit in a - // separate thread so we can index quickly. - for (size_t i = 0; i < units_to_index.size(); ++i) -task_group.async(parser_fn, i); - task_group.wait(); +task_group.wait(); + }; + // Extract dies for all DWARFs unit in parallel. Figure out which units + // didn't have their DIEs already parsed and remember this. If no DIEs were + // parsed prior to this index function call, we are going to want to clear the + // CU dies after we are done indexing to make sure we don't pull in all DWARF + // dies, but we need to wait until all units have been indexed in case a DIE + // in one unit refers to another and the indexes accesses those DIEs. + std::vector> clear_cu_dies( + units_to_index.size()); + for_each_unit([&clear_cu_dies](size_t, size_t idx, DWARFUnit *unit) { +cle
[Lldb-commits] [lldb] [lldb] Fix the SocketTest failure on unsupported hosts (PR #118673)
@@ -116,6 +116,24 @@ bool lldb_private::HostSupportsIPv6() { return CheckIPSupport("IPv6", "[::1]:0"); } +bool lldb_private::HostSupportsLocalhostToIPv4() { + if (!HostSupportsIPv4()) +return false; + + auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, AF_INET, + SOCK_STREAM, IPPROTO_TCP); + return !addresses.empty(); +} + +bool lldb_private::HostSupportsLocalhostToIPv6() { + if (!HostSupportsIPv6()) +return false; + + auto addresses = SocketAddress::GetAddressInfo("localhost", nullptr, AF_INET6, + SOCK_STREAM, IPPROTO_TCP); dzhidzhoev wrote: I've got ``` llvm-project git:(becab1c1b0a3) cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 ubuntu-linux-22-04-desktop # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ``` For some reason, `getaddrinfo("localhost", AF_UNSPEC, ...)` returns only one address (IPv4 `127.0.0.1`), but `getaddrinfo("localhost", AF_INET6, ...)` returns an address as well (IPv6 `::1`). I think it's probably an oddity in getaddrinfo implementation (my gai.conf is empty). This check seems to work the way expected: ``` auto addresses = SocketAddress::GetAddressInfo( "localhost", nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP); return std::find_if(addresses.begin(), addresses.end(), [](SocketAddress &addr) { return addr.GetFamily() == AF_INET6; }) != addresses.end(); ``` https://github.com/llvm/llvm-project/pull/118673 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
kastiglione wrote: I updated the PR to support look up of base class children by name. https://github.com/llvm/llvm-project/pull/118814 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add a compiler/interpreter of LLDB data formatter bytecode to lldb/examples (PR #113398)
https://github.com/adrian-prantl updated https://github.com/llvm/llvm-project/pull/113398 >From ca04cd4dbdba506ddc1f4816922819d0bfe3f1eb Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 22 Oct 2024 16:29:50 -0700 Subject: [PATCH] Add a compiler/interpreter of LLDB data formatter bytecode to examples --- lldb/docs/index.rst | 1 + lldb/docs/resources/formatterbytecode.rst | 238 lldb/examples/python/formatter_bytecode.py| 520 ++ .../Inputs/FormatterBytecode/MyOptional.cpp | 23 + .../Inputs/FormatterBytecode/formatter.py | 167 ++ .../ScriptInterpreter/Python/bytecode.test| 16 + 6 files changed, 965 insertions(+) create mode 100644 lldb/docs/resources/formatterbytecode.rst create mode 100644 lldb/examples/python/formatter_bytecode.py create mode 100644 lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/MyOptional.cpp create mode 100644 lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/formatter.py create mode 100644 lldb/test/Shell/ScriptInterpreter/Python/bytecode.test diff --git a/lldb/docs/index.rst b/lldb/docs/index.rst index fb22bdecad37e7..5686a33e94c938 100644 --- a/lldb/docs/index.rst +++ b/lldb/docs/index.rst @@ -164,6 +164,7 @@ interesting areas to contribute to lldb. resources/fuzzing resources/sbapi resources/dataformatters + resources/formatterbytecode resources/extensions resources/lldbgdbremote resources/lldbplatformpackets diff --git a/lldb/docs/resources/formatterbytecode.rst b/lldb/docs/resources/formatterbytecode.rst new file mode 100644 index 00..ed714bcd59e3f8 --- /dev/null +++ b/lldb/docs/resources/formatterbytecode.rst @@ -0,0 +1,238 @@ +Formatter Bytecode +== + +Background +-- + +LLDB provides very rich customization options to display data types (see :doc:`/use/variable/`). To use custom data formatters, developers need to edit the global `~/.lldbinit` file to make sure they are found and loaded. In addition to this rather manual workflow, developers or library authors can ship ship data formatters with their code in a format that allows LLDB automatically find them and run them securely. + +An end-to-end example of such a workflow is the Swift `DebugDescription` macro (see https://www.swift.org/blog/announcing-swift-6/#debugging ) that translates Swift string interpolation into LLDB summary strings, and puts them into a `.lldbsummaries` section, where LLDB can find them. + +This document describes a minimal bytecode tailored to running LLDB formatters. It defines a human-readable assembler representation for the language, an efficient binary encoding, a virtual machine for evaluating it, and format for embedding formatters into binary containers. + +Goals +~ + +Provide an efficient and secure encoding for data formatters that can be used as a compilation target from user-friendly representations (such as DIL, Swift DebugDescription, or NatVis). + +Non-goals +~ + +While humans could write the assembler syntax, making it user-friendly is not a goal. It is meant to be used as a compilation target for higher-level, language-specific affordances. + +Design of the virtual machine +- + +The LLDB formatter virtual machine uses a stack-based bytecode, comparable with DWARF expressions, but with higher-level data types and functions. + +The virtual machine has two stacks, a data and a control stack. The control stack is kept separate to make it easier to reason about the security aspects of the virtual machine. + +Data types +~~ + +All objects on the data stack must have one of the following data types. These data types are "host" data types, in LLDB parlance. + +* *String* (UTF-8) +* *Int* (64 bit) +* *UInt* (64 bit) +* *Object* (Basically an `SBValue`) +* *Type* (Basically an `SBType`) +* *Selector* (One of the predefine functions) + +*Object* and *Type* are opaque, they can only be used as a parameters of `call`. + +Instruction set +--- + +Stack operations + + +These instructions manipulate the data stack directly. + + == === + OpcodeMnemonicStack effect + -- --- + 0x00 `dup` `(x -> x x)` + 0x01 `drop` `(x y -> x)` + 0x02 `pick` `(x ... UInt -> x ... x)` + 0x03 `over` `(x y -> x y x)` + 0x04 `swap` `(x y -> y x)` + 0x05 `rot` `(x y z -> z x y)` +=== == === + +Control flow + + +These manipulate the control stack and program counter. Both `if` and `ifelse` expect a `UInt` at the top of the data stack to represent the condition. + + == + OpcodeMnemonicDescription + --
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/118814 >From 639fc6d87345c8d68a822032917102a4225df355 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Wed, 4 Dec 2024 14:37:24 -0800 Subject: [PATCH 1/2] [lldb] Add lookup by name to SBValue.child --- lldb/bindings/interface/SBValueExtensions.i| 6 -- lldb/test/API/python_api/value/TestValueAPI.py | 8 +++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lldb/bindings/interface/SBValueExtensions.i b/lldb/bindings/interface/SBValueExtensions.i index bee9c27775d453..f743b8b9bc786f 100644 --- a/lldb/bindings/interface/SBValueExtensions.i +++ b/lldb/bindings/interface/SBValueExtensions.i @@ -7,7 +7,7 @@ STRING_EXTENSION_OUTSIDE(SBValue) return self.GetDynamicValue (eDynamicCanRunTarget) class children_access(object): -'''A helper object that will lazily hand out thread for a process when supplied an index.''' +'''A helper object that will lazily hand out child values when supplied an index or name.''' def __init__(self, sbvalue): self.sbvalue = sbvalue @@ -23,6 +23,8 @@ STRING_EXTENSION_OUTSIDE(SBValue) if -count <= key < count: key %= count return self.sbvalue.GetChildAtIndex(key) +elif isinstance(key, str): +return self.sbvalue.GetChildMemberWithName(key) return None def get_child_access_object(self): @@ -49,7 +51,7 @@ STRING_EXTENSION_OUTSIDE(SBValue) return self.GetNumChildren() children = property(get_value_child_list, None, doc='''A read only property that returns a list() of lldb.SBValue objects for the children of the value.''') -child = property(get_child_access_object, None, doc='''A read only property that returns an object that can access children of a variable by index (child_value = value.children[12]).''') +child = property(get_child_access_object, None, doc='''A read only property that returns an object that can access children of a variable by index or by name.''') name = property(GetName, None, doc='''A read only property that returns the name of this value as a string.''') type = property(GetType, None, doc='''A read only property that returns a lldb.SBType object that represents the type for this value.''') size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this value.''') diff --git a/lldb/test/API/python_api/value/TestValueAPI.py b/lldb/test/API/python_api/value/TestValueAPI.py index 512100912d6fe7..eb6dbfe6362a43 100644 --- a/lldb/test/API/python_api/value/TestValueAPI.py +++ b/lldb/test/API/python_api/value/TestValueAPI.py @@ -140,10 +140,8 @@ def test(self): val_i = target.EvaluateExpression("i") val_s = target.EvaluateExpression("s") val_a = target.EvaluateExpression("a") -self.assertTrue( -val_s.GetChildMemberWithName("a").GetAddress().IsValid(), VALID_VARIABLE -) -self.assertTrue(val_s.GetChildMemberWithName("a").AddressOf(), VALID_VARIABLE) +self.assertTrue(val_s.child["a"].GetAddress().IsValid(), VALID_VARIABLE) +self.assertTrue(val_s.child["a"].AddressOf(), VALID_VARIABLE) self.assertTrue(val_a.Cast(val_i.GetType()).AddressOf(), VALID_VARIABLE) # Test some other cases of the Cast API. We allow casts from one struct type @@ -210,7 +208,7 @@ def test(self): weird_cast = f_var.Cast(val_s.GetType()) self.assertSuccess(weird_cast.GetError(), "Can cast from a larger to a smaller") self.assertEqual( -weird_cast.GetChildMemberWithName("a").GetValueAsSigned(0), +weird_cast.child["a"].GetValueAsSigned(0), 33, "Got the right value", ) >From c6f926b0e451f87af8c14baed3de55f4cb4240d5 Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Thu, 5 Dec 2024 13:04:20 -0800 Subject: [PATCH 2/2] Support base class children --- lldb/bindings/interface/SBValueExtensions.i | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lldb/bindings/interface/SBValueExtensions.i b/lldb/bindings/interface/SBValueExtensions.i index f743b8b9bc786f..c813de6c65c5c6 100644 --- a/lldb/bindings/interface/SBValueExtensions.i +++ b/lldb/bindings/interface/SBValueExtensions.i @@ -24,7 +24,12 @@ STRING_EXTENSION_OUTSIDE(SBValue) key %= count return self.sbvalue.GetChildAtIndex(key) elif isinstance(key, str): -return self.sbvalue.GetChildMemberWithName(key) +if child := self.sbvalue.GetChildMemberWithName(key) +return child +# Support base classes, which are children but not members. +for child in self.sbvalue
[Lldb-commits] [lldb] [lldb-dap] Add attach & corefile templates (PR #118894)
https://github.com/ashgti approved this pull request. https://github.com/llvm/llvm-project/pull/118894 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][NFC] Make the target's SectionLoadList private. (PR #113278)
https://github.com/clayborg updated https://github.com/llvm/llvm-project/pull/113278 >From dab763afbe46a59020ae10530c062e9420f45605 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Tue, 22 Oct 2024 01:16:40 -0700 Subject: [PATCH 1/3] Make the target's SectionLoadList private. Lots of code around LLDB was directly accessing the target's section load list. This NFC patch makes the section load list private to the Target class can access it, but everyone else now uses accessor functions. This allows us to control the resolving of addresses and will allow for functionality in LLDB which can lazily resolve addresses in JIT plug-ins with a future patch. --- lldb/include/lldb/Target/Target.h | 15 --- lldb/source/API/SBBreakpoint.cpp | 4 ++-- .../Breakpoint/BreakpointLocationList.cpp | 3 +-- .../Commands/CommandObjectDisassemble.cpp | 6 +++--- lldb/source/Commands/CommandObjectRegister.cpp | 4 ++-- lldb/source/Commands/CommandObjectSource.cpp | 9 - lldb/source/Commands/CommandObjectTarget.cpp | 15 +++ lldb/source/Core/Address.cpp | 8 +++- lldb/source/Core/Disassembler.cpp | 6 +- lldb/source/Core/DumpDataExtractor.cpp | 10 -- lldb/source/Core/FormatEntity.cpp | 2 +- lldb/source/Core/Section.cpp | 4 ++-- lldb/source/Core/Value.cpp | 5 ++--- .../DataFormatters/CXXFunctionPointer.cpp | 5 ++--- lldb/source/Expression/ObjectFileJIT.cpp | 4 ++-- .../Architecture/Mips/ArchitectureMips.cpp | 3 +-- .../Disassembler/LLVMC/DisassemblerLLVMC.cpp | 6 +++--- .../MacOSX-DYLD/DynamicLoaderMacOS.cpp | 2 +- .../Static/DynamicLoaderStatic.cpp | 4 ++-- .../TSan/InstrumentationRuntimeTSan.cpp| 9 +++-- .../Plugins/JITLoader/GDB/JITLoaderGDB.cpp | 2 +- .../CPlusPlus/CPPLanguageRuntime.cpp | 18 -- .../Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 3 +-- .../ObjectFile/Mach-O/ObjectFileMachO.cpp | 10 +- .../ObjectFile/PECOFF/ObjectFilePECOFF.cpp | 2 +- .../Placeholder/ObjectFilePlaceholder.cpp | 3 +-- .../Process/minidump/ProcessMinidump.cpp | 4 ++-- .../Trace/intel-pt/TraceIntelPTBundleSaver.cpp | 2 +- lldb/source/Symbol/ObjectFile.cpp | 3 +-- lldb/source/Target/ProcessTrace.cpp| 2 +- lldb/source/Target/Target.cpp | 14 ++ lldb/source/Target/ThreadPlanStepInRange.cpp | 3 +-- lldb/source/Target/ThreadPlanTracer.cpp| 3 +-- 33 files changed, 96 insertions(+), 97 deletions(-) diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 0d1943450d622b..717490dc475ce4 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -1151,9 +1151,14 @@ class Target : public std::enable_shared_from_this, Address &pointer_addr, bool force_live_memory = false); - SectionLoadList &GetSectionLoadList() { -return m_section_load_history.GetCurrentSectionLoadList(); - } + + bool SectionLoadListIsEmpty() const; + + lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP §ion_sp); + + void ClearSectionLoadList(); + + void DumpSectionLoadList(Stream &s); static Target *GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr); @@ -1666,6 +1671,10 @@ class Target : public std::enable_shared_from_this, Target(const Target &) = delete; const Target &operator=(const Target &) = delete; + + SectionLoadList &GetSectionLoadList() { +return m_section_load_history.GetCurrentSectionLoadList(); + } }; } // namespace lldb_private diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp index b2ed034d19983c..87fadbcec4f26b 100644 --- a/lldb/source/API/SBBreakpoint.cpp +++ b/lldb/source/API/SBBreakpoint.cpp @@ -137,7 +137,7 @@ SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) { bkpt_sp->GetTarget().GetAPIMutex()); Address address; Target &target = bkpt_sp->GetTarget(); - if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) { + if (!target.ResolveLoadAddress(vm_addr, address)) { address.SetRawAddress(vm_addr); } sb_bp_location.SetLocation(bkpt_sp->FindLocationByAddress(address)); @@ -157,7 +157,7 @@ break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) { bkpt_sp->GetTarget().GetAPIMutex()); Address address; Target &target = bkpt_sp->GetTarget(); -if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) { +if (!target.ResolveLoadAddress(vm_addr, address)) { address.SetRawAddress(vm_addr); } break_id = bkpt_sp->FindLocationIDByAddress(address); diff --gi
[Lldb-commits] [lldb] [lldb][NFC] Make the target's SectionLoadList private. (PR #113278)
https://github.com/jeffreytan81 approved this pull request. https://github.com/llvm/llvm-project/pull/113278 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
jimingham wrote: I think you have to do lookup by name just of the members (and maybe a separate lookup by name of the base classes?) https://github.com/llvm/llvm-project/pull/118814 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
jimingham wrote: Unfortunately, this is legal C++: ``` class Foo { public: int m_intvar = 10; }; class Bar : Foo { public: int Foo = 100; }; int main() { Bar myBar; return myBar.Foo; } ``` So the lookup by name of Foo wouldn't be unique here. https://github.com/llvm/llvm-project/pull/118814 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
jimingham wrote: The other way to do it would be to use "::Foo" to refer to the base class, and "Foo" the member. Maybe even nicer would be to allow just "Foo" if there's no ambiguity, and only require the :: if there is. https://github.com/llvm/llvm-project/pull/118814 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 244b207 - [lldb-dap] Add attach & corefile templates (#118894)
Author: Jonas Devlieghere Date: 2024-12-05T16:20:11-08:00 New Revision: 244b207d3c2e5a2a72cd4470829ac39c653c406a URL: https://github.com/llvm/llvm-project/commit/244b207d3c2e5a2a72cd4470829ac39c653c406a DIFF: https://github.com/llvm/llvm-project/commit/244b207d3c2e5a2a72cd4470829ac39c653c406a.diff LOG: [lldb-dap] Add attach & corefile templates (#118894) Added: Modified: lldb/tools/lldb-dap/package-lock.json lldb/tools/lldb-dap/package.json Removed: diff --git a/lldb/tools/lldb-dap/package-lock.json b/lldb/tools/lldb-dap/package-lock.json index 8663659715590a..d1cb6d00ecf566 100644 --- a/lldb/tools/lldb-dap/package-lock.json +++ b/lldb/tools/lldb-dap/package-lock.json @@ -1,12 +1,12 @@ { "name": "lldb-dap", - "version": "0.2.6", + "version": "0.2.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lldb-dap", - "version": "0.2.6", + "version": "0.2.8", "license": "Apache 2.0 License with LLVM exceptions", "devDependencies": { "@types/node": "^18.11.18", diff --git a/lldb/tools/lldb-dap/package.json b/lldb/tools/lldb-dap/package.json index 6079edb5a2189a..bbe65e1f73fd8c 100644 --- a/lldb/tools/lldb-dap/package.json +++ b/lldb/tools/lldb-dap/package.json @@ -1,7 +1,7 @@ { "name": "lldb-dap", "displayName": "LLDB DAP", - "version": "0.2.7", + "version": "0.2.8", "publisher": "llvm-vs-code-extensions", "homepage": "https://lldb.llvm.org";, "description": "LLDB debugging from VSCode", @@ -141,7 +141,7 @@ "debuggers": [ { "type": "lldb-dap", -"label": "Native LLDB Debugger", +"label": "LLDB DAP Debugger", "program": "./bin/lldb-dap", "windows": { "program": "./bin/lldb-dap.exe" @@ -508,6 +508,28 @@ "env": [], "cwd": "^\"\\${workspaceRoot}\"" } + }, + { +"label": "LLDB: Attach", +"description": "", +"body": { + "type": "lldb-dap", + "request": "attach", + "name": "${2:Attach}", + "program": "${1:}", + "waitFor": true +} + }, + { +"label": "LLDB: Load Coredump", +"description": "", +"body": { + "type": "lldb-dap", + "request": "attach", + "name": "${2:Core}", + "program": "${1:}", + "coreFile": "${1:}.core" +} } ] } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add attach & corefile templates (PR #118894)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/118894 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)
jimingham wrote: If we ever come across a language that allows numbers for ivar names, overloading `child` for by name access will make us sad, but I think such a language would make us sadder, so I'm not much concerned... https://github.com/llvm/llvm-project/pull/118814 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits