[Lldb-commits] [lldb] [lldb] Fix the flaky test dwp-foreign-type-units.cpp. (PR #98237)
DavidSpickett wrote: Thanks! You've saved me some work here. We've been seeing this fail on the Linuxes too since I disabled it for Windows. https://github.com/llvm/llvm-project/pull/98237 ___ 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 flaky test dwp-foreign-type-units.cpp. (PR #98237)
https://github.com/DavidSpickett approved this pull request. https://github.com/llvm/llvm-project/pull/98237 ___ 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 flaky test dwp-foreign-type-units.cpp. (PR #98237)
DavidSpickett wrote: cI failure is unrelated: ``` Timed Out Tests (1): lldb-api :: api/multiple-debuggers/TestMultipleDebuggers.py ``` Which is the *other* flaky test on my list to look at... https://github.com/llvm/llvm-project/pull/98237 ___ 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 flaky test dwp-foreign-type-units.cpp. (PR #98237)
DavidSpickett wrote: In case we need them for future reference, some failures this aims to fix: https://github.com/llvm/llvm-project/pull/98041#issuecomment-2216892858 https://lab.llvm.org/buildbot/#/builders/59/builds/1234 https://lab.llvm.org/buildbot/#/builders/162/builds/1570 https://github.com/llvm/llvm-project/pull/98237 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 14ba847 - [lldb] Bump timeouts in TestCallWithTimeout
Author: Pavel Labath Date: 2024-07-10T09:36:26Z New Revision: 14ba847d273a0defe0f4617bcfe9e1b2163e2bbc URL: https://github.com/llvm/llvm-project/commit/14ba847d273a0defe0f4617bcfe9e1b2163e2bbc DIFF: https://github.com/llvm/llvm-project/commit/14ba847d273a0defe0f4617bcfe9e1b2163e2bbc.diff LOG: [lldb] Bump timeouts in TestCallWithTimeout this test is occasionally (~3%) failing on an emulator target. The value used by the test (one second) is quite aggressive given that we set the timeout for a single gdb packet to 60 seconds. Bumping it to five to resolve flakyness. Added: Modified: lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py Removed: diff --git a/lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py b/lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py index 2c48024c69833..de074e8ff7b09 100644 --- a/lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py +++ b/lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py @@ -27,14 +27,17 @@ def test(self): self, "stop here in main.", self.main_source_spec ) +short_time = 5000 +long_time = short_time * 1000 + # First set the timeout too short, and make sure we fail. options = lldb.SBExpressionOptions() -options.SetTimeoutInMicroSeconds(10) +options.SetTimeoutInMicroSeconds(short_time) options.SetUnwindOnError(True) frame = thread.GetFrameAtIndex(0) -value = frame.EvaluateExpression("wait_a_while(100)", options) +value = frame.EvaluateExpression(f"wait_a_while({long_time})", options) self.assertTrue(value.IsValid()) self.assertFalse(value.GetError().Success()) @@ -44,14 +47,14 @@ def test(self): result = lldb.SBCommandReturnObject() return_value = interp.HandleCommand( -"expr -t 100 -u true -- wait_a_while(100)", result +f"expr -t {short_time} -u true -- wait_a_while({long_time})", result ) self.assertEqual(return_value, lldb.eReturnStatusFailed) # Okay, now do it again with long enough time outs: -options.SetTimeoutInMicroSeconds(100) -value = frame.EvaluateExpression("wait_a_while (1000)", options) +options.SetTimeoutInMicroSeconds(long_time) +value = frame.EvaluateExpression(f"wait_a_while({short_time})", options) self.assertTrue(value.IsValid()) self.assertSuccess(value.GetError()) @@ -61,15 +64,15 @@ def test(self): result = lldb.SBCommandReturnObject() return_value = interp.HandleCommand( -"expr -t 100 -u true -- wait_a_while(1000)", result +f"expr -t {long_time} -u true -- wait_a_while({short_time})", result ) self.assertEqual(return_value, lldb.eReturnStatusSuccessFinishResult) # Finally set the one thread timeout and make sure that doesn't change # things much: -options.SetTimeoutInMicroSeconds(100) -options.SetOneThreadTimeoutInMicroSeconds(50) -value = frame.EvaluateExpression("wait_a_while (1000)", options) +options.SetTimeoutInMicroSeconds(long_time) +options.SetOneThreadTimeoutInMicroSeconds(100) +value = frame.EvaluateExpression(f"wait_a_while({short_time})", options) self.assertTrue(value.IsValid()) self.assertSuccess(value.GetError()) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix ThreadList assignment race (PR #98293)
https://github.com/labath created https://github.com/llvm/llvm-project/pull/98293 ThreadList uses the Process mutex to guard its state. This means its not possible to safely modify its process member, as the member is required to lock the mutex. Fortunately for us, we never actually need to change the process member (we always just juggle different kinds of thread lists belonging to the same process). This patch replaces the process member assignment (which is technically a race even when it assigns the same value) with an assertion. Since all this means that the class can never change its process member value (and it also must be non-null at all times), I've also changed the member type to a reference. >From 0a594fea0a5db3ebc8de74edbcd051cbac911697 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 10 Jul 2024 04:06:42 +0200 Subject: [PATCH] [lldb] Fix ThreadList assignment race ThreadList uses the Process mutex to guard its state. This means its not possible to safely modify its process member, as the member is required to lock the mutex. Fortunately for us, we never actually need to change the process member (we always just juggle different kinds of thread lists belonging to the same process). This patch replaces the process member assignment (which is technically a race even when it assigns the same value) with an assertion. Since all this means that the class can never change its process member value (and it also must be non-null at all times), I've also changed the member type to a reference. --- lldb/include/lldb/Target/ThreadList.h | 6 +- .../Python/OperatingSystemPython.cpp | 2 +- lldb/source/Target/Process.cpp| 14 ++--- lldb/source/Target/ThreadList.cpp | 59 +-- 4 files changed, 40 insertions(+), 41 deletions(-) diff --git a/lldb/include/lldb/Target/ThreadList.h b/lldb/include/lldb/Target/ThreadList.h index 6af04f8ffc376..91c4317cb8571 100644 --- a/lldb/include/lldb/Target/ThreadList.h +++ b/lldb/include/lldb/Target/ThreadList.h @@ -27,12 +27,13 @@ class ThreadList : public ThreadCollection { friend class Process; public: - ThreadList(Process *process); + ThreadList(Process &process); ThreadList(const ThreadList &rhs); ~ThreadList() override; + // Precondition: both thread lists must be belong to the same process. const ThreadList &operator=(const ThreadList &rhs); uint32_t GetSize(bool can_update = true); @@ -135,6 +136,7 @@ class ThreadList : public ThreadCollection { std::recursive_mutex &GetMutex() const override; + // Precondition: both thread lists must be belong to the same process. void Update(ThreadList &rhs); protected: @@ -143,7 +145,7 @@ class ThreadList : public ThreadCollection { void NotifySelectedThreadChanged(lldb::tid_t tid); // Classes that inherit from Process can see and modify these - Process *m_process; ///< The process that manages this thread list. + Process &m_process; ///< The process that manages this thread list. uint32_t m_stop_id; ///< The process stop ID that this thread list is valid for. lldb::tid_t diff --git a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp index 81ee7e328b6c0..e026ffefd645e 100644 --- a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -372,7 +372,7 @@ lldb::ThreadSP OperatingSystemPython::CreateThread(lldb::tid_t tid, std::vector core_used_map; if (thread_info_dict) { - ThreadList core_threads(m_process); + ThreadList core_threads(*m_process); ThreadList &thread_list = m_process->GetThreadList(); bool did_create = false; ThreadSP thread_sp( diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index dc7f6c9e86a47..b91446e1c0e49 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -460,12 +460,10 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp, m_private_state_listener_sp( Listener::MakeListener("lldb.process.internal_state_listener")), m_mod_id(), m_process_unique_id(0), m_thread_index_id(0), - m_thread_id_to_index_id_map(), m_exit_status(-1), m_exit_string(), - m_exit_status_mutex(), m_thread_mutex(), m_thread_list_real(this), - m_thread_list(this), m_thread_plans(*this), m_extended_thread_list(this), - m_extended_thread_stop_id(0), m_queue_list(this), m_queue_list_stop_id(0), - m_watchpoint_resource_list(), m_notifications(), m_image_tokens(), - m_breakpoint_site_list(), m_dynamic_checkers_up(), + m_thread_id_to_index_id_map(), m_exit_status(-1), + m_thread_list_real(*this), m_thread_list(*this), m_thread_plans(*this), + m_extended_thread_list(*this), m_extended_thread_stop_id(0), + m_queue_list(this), m_
[Lldb-commits] [lldb] [lldb] Fix ThreadList assignment race (PR #98293)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Pavel Labath (labath) Changes ThreadList uses the Process mutex to guard its state. This means its not possible to safely modify its process member, as the member is required to lock the mutex. Fortunately for us, we never actually need to change the process member (we always just juggle different kinds of thread lists belonging to the same process). This patch replaces the process member assignment (which is technically a race even when it assigns the same value) with an assertion. Since all this means that the class can never change its process member value (and it also must be non-null at all times), I've also changed the member type to a reference. --- Full diff: https://github.com/llvm/llvm-project/pull/98293.diff 4 Files Affected: - (modified) lldb/include/lldb/Target/ThreadList.h (+4-2) - (modified) lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp (+1-1) - (modified) lldb/source/Target/Process.cpp (+6-8) - (modified) lldb/source/Target/ThreadList.cpp (+29-30) ``diff diff --git a/lldb/include/lldb/Target/ThreadList.h b/lldb/include/lldb/Target/ThreadList.h index 6af04f8ffc376..91c4317cb8571 100644 --- a/lldb/include/lldb/Target/ThreadList.h +++ b/lldb/include/lldb/Target/ThreadList.h @@ -27,12 +27,13 @@ class ThreadList : public ThreadCollection { friend class Process; public: - ThreadList(Process *process); + ThreadList(Process &process); ThreadList(const ThreadList &rhs); ~ThreadList() override; + // Precondition: both thread lists must be belong to the same process. const ThreadList &operator=(const ThreadList &rhs); uint32_t GetSize(bool can_update = true); @@ -135,6 +136,7 @@ class ThreadList : public ThreadCollection { std::recursive_mutex &GetMutex() const override; + // Precondition: both thread lists must be belong to the same process. void Update(ThreadList &rhs); protected: @@ -143,7 +145,7 @@ class ThreadList : public ThreadCollection { void NotifySelectedThreadChanged(lldb::tid_t tid); // Classes that inherit from Process can see and modify these - Process *m_process; ///< The process that manages this thread list. + Process &m_process; ///< The process that manages this thread list. uint32_t m_stop_id; ///< The process stop ID that this thread list is valid for. lldb::tid_t diff --git a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp index 81ee7e328b6c0..e026ffefd645e 100644 --- a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -372,7 +372,7 @@ lldb::ThreadSP OperatingSystemPython::CreateThread(lldb::tid_t tid, std::vector core_used_map; if (thread_info_dict) { - ThreadList core_threads(m_process); + ThreadList core_threads(*m_process); ThreadList &thread_list = m_process->GetThreadList(); bool did_create = false; ThreadSP thread_sp( diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index dc7f6c9e86a47..b91446e1c0e49 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -460,12 +460,10 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp, m_private_state_listener_sp( Listener::MakeListener("lldb.process.internal_state_listener")), m_mod_id(), m_process_unique_id(0), m_thread_index_id(0), - m_thread_id_to_index_id_map(), m_exit_status(-1), m_exit_string(), - m_exit_status_mutex(), m_thread_mutex(), m_thread_list_real(this), - m_thread_list(this), m_thread_plans(*this), m_extended_thread_list(this), - m_extended_thread_stop_id(0), m_queue_list(this), m_queue_list_stop_id(0), - m_watchpoint_resource_list(), m_notifications(), m_image_tokens(), - m_breakpoint_site_list(), m_dynamic_checkers_up(), + m_thread_id_to_index_id_map(), m_exit_status(-1), + m_thread_list_real(*this), m_thread_list(*this), m_thread_plans(*this), + m_extended_thread_list(*this), m_extended_thread_stop_id(0), + m_queue_list(this), m_queue_list_stop_id(0), m_unix_signals_sp(unix_signals_sp), m_abi_sp(), m_process_input_reader(), m_stdio_communication("process.stdio"), m_stdio_communication_mutex(), m_stdin_forward(false), m_stdout_data(), m_stderr_data(), @@ -1183,8 +1181,8 @@ void Process::UpdateThreadListIfNeeded() { // mutex between the call to UpdateThreadList(...) and the // os->UpdateThreadList(...) so it doesn't change on us ThreadList &old_thread_list = m_thread_list; - ThreadList real_thread_list(this); - ThreadList new_thread_list(this); + ThreadList real_thread_list(*this); + ThreadList new_thread_list(*this); // Always update the thread list with the protocol specific thread list, /
[Lldb-commits] [lldb] [lldb] Fix ThreadList assignment race (PR #98293)
labath wrote: Previous attempt to fix this issue: https://reviews.llvm.org/D158034 https://github.com/llvm/llvm-project/pull/98293 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 08ce147 - [lldb][test] Fix lldb-test compile error
Author: David Spickett Date: 2024-07-10T10:35:28Z New Revision: 08ce14732d528ab70309f334446d39782f2f07c0 URL: https://github.com/llvm/llvm-project/commit/08ce14732d528ab70309f334446d39782f2f07c0 DIFF: https://github.com/llvm/llvm-project/commit/08ce14732d528ab70309f334446d39782f2f07c0.diff LOG: [lldb][test] Fix lldb-test compile error https://github.com/llvm/llvm-project/pull/82819 made the lookup here ambiguous. Added: Modified: lldb/tools/lldb-test/lldb-test.cpp Removed: diff --git a/lldb/tools/lldb-test/lldb-test.cpp b/lldb/tools/lldb-test/lldb-test.cpp index 30df2ddf864cd..da3822393dad1 100644 --- a/lldb/tools/lldb-test/lldb-test.cpp +++ b/lldb/tools/lldb-test/lldb-test.cpp @@ -509,8 +509,8 @@ Error opts::symbols::findFunctions(lldb_private::Module &Module) { ContextOr->IsValid() ? *ContextOr : CompilerDeclContext(); List.Clear(); -Module::LookupInfo lookup_info(ConstString(Name), getFunctionNameFlags(), - eLanguageTypeUnknown); +lldb_private::Module::LookupInfo lookup_info( +ConstString(Name), getFunctionNameFlags(), eLanguageTypeUnknown); Symfile.FindFunctions(lookup_info, ContextPtr, true, List); } outs() << formatv("Found {0} functions:\n", List.GetSize()); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/96538 >From 2b82d72874c396258378f9db2f01729e5be5bae1 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 29 Jan 2024 16:23:16 + Subject: [PATCH] [lldb] Support new libc++ __compressed_pair layout --- lldb/examples/synthetic/libcxx.py | 26 -- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 78 - .../Plugins/Language/CPlusPlus/LibCxx.h | 1 + .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 83 --- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 68 +++ .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 82 +- .../Language/CPlusPlus/LibCxxVector.cpp | 40 + .../list/TestDataFormatterGenericList.py | 3 +- .../libcxx/string/simulator/main.cpp | 1 + .../TestDataFormatterLibcxxUniquePtr.py | 2 +- 10 files changed, 253 insertions(+), 131 deletions(-) diff --git a/lldb/examples/synthetic/libcxx.py b/lldb/examples/synthetic/libcxx.py index 474aaa428fa23..060ff90100849 100644 --- a/lldb/examples/synthetic/libcxx.py +++ b/lldb/examples/synthetic/libcxx.py @@ -721,6 +721,12 @@ def _get_value_of_compressed_pair(self, pair): def update(self): logger = lldb.formatters.Logger.Logger() try: +has_compressed_pair_layout = True +alloc_valobj = self.valobj.GetChildMemberWithName("__alloc_") +size_valobj = self.valobj.GetChildMemberWithName("__size_") +if alloc_valobj.IsValid() and size_valobj.IsValid(): +has_compressed_pair_layout = False + # A deque is effectively a two-dim array, with fixed width. # 'map' contains pointers to the rows of this array. The # full memory area allocated by the deque is delimited @@ -734,9 +740,13 @@ def update(self): # variable tells which element in this NxM array is the 0th # one, and the 'size' element gives the number of elements # in the deque. -count = self._get_value_of_compressed_pair( -self.valobj.GetChildMemberWithName("__size_") -) +if has_compressed_pair_layout: +count = self._get_value_of_compressed_pair( +self.valobj.GetChildMemberWithName("__size_") +) +else: +count = size_valobj.GetValueAsUnsigned(0) + # give up now if we cant access memory reliably if self.block_size < 0: logger.write("block_size < 0") @@ -748,9 +758,13 @@ def update(self): self.map_begin = map_.GetChildMemberWithName("__begin_") map_begin = self.map_begin.GetValueAsUnsigned(0) map_end = map_.GetChildMemberWithName("__end_").GetValueAsUnsigned(0) -map_endcap = self._get_value_of_compressed_pair( -map_.GetChildMemberWithName("__end_cap_") -) + +if has_compressed_pair_layout: +map_endcap = self._get_value_of_compressed_pair( +map_.GetChildMemberWithName("__end_cap_") +) +else: +map_endcap = map_.GetChildMemberWithName("__end_cap_").GetValueAsUnsigned(0) # check consistency if not map_first <= map_begin <= map_end <= map_endcap: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 05cfa0568c25d..f23b8697792da 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -27,6 +27,7 @@ #include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" #include #include @@ -34,6 +35,31 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::formatters; +static bool isOldCompressedPairLayout(ValueObject &pair_obj) { + return isStdTemplate(pair_obj.GetTypeName(), "__compressed_pair"); +} + +static void consumeInlineNamespace(llvm::StringRef &name) { + // Delete past an inline namespace, if any: __[a-zA-Z0-9_]+:: + auto scratch = name; + if (scratch.consume_front("__") && std::isalnum(scratch[0])) { +scratch = scratch.drop_while([](char c) { return std::isalnum(c); }); +if (scratch.consume_front("::")) { + // Successfully consumed a namespace. + name = scratch; +} + } +} + +bool lldb_private::formatters::isStdTemplate(ConstString type_name, llvm::StringRef type) { + llvm::StringRef name = type_name.GetStringRef(); + // The type name may be prefixed with `std::__::`. + if (name.consume_front("std::")) +consumeInlineNamespace(name); + return name.consume_front(type) && name.starts_with("<"); +} + + lldb::ValueObjectSP lldb_private::formatters::GetChildMemberW
[Lldb-commits] [lldb] 3e06392 - [lldb][test] Fix instruction test step on Windows
Author: David Spickett Date: 2024-07-10T11:22:07Z New Revision: 3e06392c7db0eacfca94a176d430d9988b3ffbd6 URL: https://github.com/llvm/llvm-project/commit/3e06392c7db0eacfca94a176d430d9988b3ffbd6 DIFF: https://github.com/llvm/llvm-project/commit/3e06392c7db0eacfca94a176d430d9988b3ffbd6.diff LOG: [lldb][test] Fix instruction test step on Windows On Windows the function name is the full prototype including the calling convention, all we care about is that the last part is correct. This also reverts the xfail added by 07b3e2c0c68b93a3d4d89426dc7fd14cc31ca6be. Added: Modified: lldb/test/API/python_api/thread/TestThreadAPI.py Removed: diff --git a/lldb/test/API/python_api/thread/TestThreadAPI.py b/lldb/test/API/python_api/thread/TestThreadAPI.py index a74302263aa45..1898c6a2a9792 100644 --- a/lldb/test/API/python_api/thread/TestThreadAPI.py +++ b/lldb/test/API/python_api/thread/TestThreadAPI.py @@ -52,7 +52,6 @@ def test_negative_indexing(self): self.build() self.validate_negative_indexing() -@expectedFailureAll(oslist=["windows"]) def test_StepInstruction(self): """Test that StepInstruction preserves the plan stack.""" self.build() @@ -324,34 +323,40 @@ def step_instruction_in_called_function(self): self.assertGreater( call_me_bkpt.GetNumLocations(), 0, "Got at least one location in call_me" ) + +# On Windows this may be the full name "void __cdecl call_me(bool)", +# elsewhere it's just "call_me(bool)". +expected_name = r".*call_me\(bool\)$" + # Now run the expression, this will fail because we stopped at a breakpoint: self.runCmd("expr -i 0 -- call_me(true)", check=False) # Now we should be stopped in call_me: -self.assertEqual( -thread.frames[0].name, "call_me(bool)", "Stopped in call_me(bool)" +self.assertRegex( +thread.frames[0].name, expected_name, "Stopped in call_me(bool)" ) + # Now do a various API steps. These should not cause the expression context to get unshipped: thread.StepInstruction(False) -self.assertEqual( +self.assertRegex( thread.frames[0].name, -"call_me(bool)", +expected_name, "Still in call_me(bool) after StepInstruction", ) thread.StepInstruction(True) -self.assertEqual( +self.assertRegex( thread.frames[0].name, -"call_me(bool)", +expected_name, "Still in call_me(bool) after NextInstruction", ) thread.StepInto() -self.assertEqual( +self.assertRegex( thread.frames[0].name, -"call_me(bool)", +expected_name, "Still in call_me(bool) after StepInto", ) thread.StepOver(False) -self.assertEqual( +self.assertRegex( thread.frames[0].name, -"call_me(bool)", +expected_name, "Still in call_me(bool) after StepOver", ) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix printing of unsigned enum bitfields when they contain the max value (PR #96202)
DavidSpickett wrote: Clang's decision to emit DW_AT_type or not goes back to https://reviews.llvm.org/D42734 and in particular this code: ``` void DwarfUnit::constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy) { const DIType *DTy = resolve(CTy->getBaseType()); bool IsUnsigned = DTy && isUnsignedDIType(DD, DTy); if (DTy && DD->getDwarfVersion() >= 3) addType(Buffer, DTy); ``` DWARF v2 (https://dwarfstd.org/doc/dwarf-2.0.0.pdf) does have the concept of DW_AT_type but it does not mention that it may be found in enumeration types. "5.6 Enumeration Type Entries <...> Each enumerator entry has a DW_AT_name attribute, whose value is a null-terminated string containing the name of the enumeration literal as it appears in the source program. Each enumerator entry also has a DW_AT_const_value attribute, whose value is the actual numeric value of the enumerator as represented on the target system." So perhaps you could infer the type from the enumerators, but this is ambiguous if you only have positive enumerators within signed int's range. If the debugger is in C/C++ mode, it's reasonable for it to assume signed int most of the time. In DWARF v3 (https://dwarfstd.org/doc/Dwarf3.pdf) "5.8 Enumeration Type Entries" we have an explicit mention of DW_AT_type. "The enumeration type entry may also have a DW_AT_type attribute which refers to the underlying data type used to implement the enumeration. In C or C++, the underlying type will be the appropriate integral type determined by the compiler from the properties of the enumeration literal values." See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16063 for details on what g++ did for this. ``` * dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if DWARF version >= 3 or not strict DWARF. ``` If you pass `-gstrict-dwarf` to g++ then DW_AT_type is not emitted. Clang does have that option so we could do the same, let me see what `-gstrict-dwarf` things we have currently. https://github.com/llvm/llvm-project/pull/96202 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP][lldb][test] Add a layout simulator test for std::unique_ptr (PR #98330)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/98330 This is currently just a prototype. This is motivated by the upcoming refactor of libc++'s `__compressed_pair` in https://github.com/llvm/llvm-project/pull/76756 As this will require changes to numerous LLDB libc++ data-formatters (see early draft https://github.com/llvm/llvm-project/pull/96538), it would be nice to have a test-suite that will actually exercise both the old and new layout. We have a matrix bot that tests old versions of Clang (but currently those only date back to Clang-15). Having them in the test-suite will give us quicker signal on what broke. We have an existing test that exercises various layouts of `std::string` over time in `TestDataFormatterLibcxxStringSimulator.py`, but that's the only STL type we have it for. This patch proposes a new `libcxx-simulators` directory which will take the same approach. It'll be great to have a record of how the layout of libc++ types. Eventually we'll move the `std::string` simulator into this directory too. Some related discussion: * https://github.com/llvm/llvm-project/pull/97568#issuecomment-2213426804 >From a25b3c8a6a36326730d00d1060ff84181bece26e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 10 Jul 2024 15:37:45 +0100 Subject: [PATCH] [WIP][lldb][test] Add a layout simulator test for std::unique_ptr --- .../libcxx-simulators/compressed_pair.h | 89 +++ .../libcxx-simulators/unique_ptr/Makefile | 3 + ...stDataFormatterLibcxxUniquePtrSimulator.py | 32 +++ .../libcxx-simulators/unique_ptr/main.cpp | 43 + 4 files changed, 167 insertions(+) create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/compressed_pair.h create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/TestDataFormatterLibcxxUniquePtrSimulator.py create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/compressed_pair.h b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/compressed_pair.h new file mode 100644 index 0..ec978b8053646 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/compressed_pair.h @@ -0,0 +1,89 @@ +#ifndef STD_LLDB_COMPRESSED_PAIR_H +#define STD_LLDB_COMPRESSED_PAIR_H + +#include <__memory/compressed_pair.h> +#include + +namespace std { +namespace __lldb { + +#if COMPRESSED_PAIR_REV == 0 // Post-c88580c layout +struct __value_init_tag {}; +struct __default_init_tag {}; + +template ::value && !std::is_final<_Tp>::value> +struct __compressed_pair_elem { + explicit __compressed_pair_elem(__default_init_tag) {} + explicit __compressed_pair_elem(__value_init_tag) : __value_() {} + + explicit __compressed_pair_elem(_Tp __t) : __value_(__t) {} + + _Tp &__get() { return __value_; } + +private: + _Tp __value_; +}; + +template +struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp { + explicit __compressed_pair_elem(_Tp __t) : _Tp(__t) {} + explicit __compressed_pair_elem(__default_init_tag) {} + explicit __compressed_pair_elem(__value_init_tag) : _Tp() {} + + _Tp &__get() { return *this; } +}; + +template +class __compressed_pair : private __compressed_pair_elem<_T1, 0>, + private __compressed_pair_elem<_T2, 1> { +public: + using _Base1 = __compressed_pair_elem<_T1, 0>; + using _Base2 = __compressed_pair_elem<_T2, 1>; + + explicit __compressed_pair(_T1 __t1, _T2 __t2) : _Base1(__t1), _Base2(__t2) {} + explicit __compressed_pair() + : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {} + + template + explicit __compressed_pair(_U1 &&__t1, _U2 &&__t2) + : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {} + + _T1 &first() { return static_cast<_Base1 &>(*this).__get(); } +}; +#elif COMPRESSED_PAIR_REV == 1 +#define _LLDB_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ + [[__gnu__::__aligned__(alignof(T2))]] [[no_unique_address]] T1 Initializer1; \ + [[no_unique_address]] __compressed_pair_padding _LIBCPP_CONCAT3( \ + __padding1_, __LINE__, _); \ + [[no_unique_address]] T2 Initializer2; \ + [[no_unique_address]] __compressed_pair_padding _LIBCPP_CONCAT3( \ + __padding2_, __LINE__, _) + +#define _LLDB_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, \ +Initializer3) \ + [[using __gnu__: __aligned__(alignof(T2)),
[Lldb-commits] [lldb] [WIP][lldb][test] Add a layout simulator test for std::unique_ptr (PR #98330)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes This is currently just a prototype. This is motivated by the upcoming refactor of libc++'s `__compressed_pair` in https://github.com/llvm/llvm-project/pull/76756 As this will require changes to numerous LLDB libc++ data-formatters (see early draft https://github.com/llvm/llvm-project/pull/96538), it would be nice to have a test-suite that will actually exercise both the old and new layout. We have a matrix bot that tests old versions of Clang (but currently those only date back to Clang-15). Having them in the test-suite will give us quicker signal on what broke. We have an existing test that exercises various layouts of `std::string` over time in `TestDataFormatterLibcxxStringSimulator.py`, but that's the only STL type we have it for. This patch proposes a new `libcxx-simulators` directory which will take the same approach. It'll be great to have a record of how the layout of libc++ types. Eventually we'll move the `std::string` simulator into this directory too. Some related discussion: * https://github.com/llvm/llvm-project/pull/97568#issuecomment-2213426804 --- Full diff: https://github.com/llvm/llvm-project/pull/98330.diff 4 Files Affected: - (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/compressed_pair.h (+89) - (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/Makefile (+3) - (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/TestDataFormatterLibcxxUniquePtrSimulator.py (+32) - (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp (+43) ``diff diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/compressed_pair.h b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/compressed_pair.h new file mode 100644 index 0..ec978b8053646 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/compressed_pair.h @@ -0,0 +1,89 @@ +#ifndef STD_LLDB_COMPRESSED_PAIR_H +#define STD_LLDB_COMPRESSED_PAIR_H + +#include <__memory/compressed_pair.h> +#include + +namespace std { +namespace __lldb { + +#if COMPRESSED_PAIR_REV == 0 // Post-c88580c layout +struct __value_init_tag {}; +struct __default_init_tag {}; + +template ::value && !std::is_final<_Tp>::value> +struct __compressed_pair_elem { + explicit __compressed_pair_elem(__default_init_tag) {} + explicit __compressed_pair_elem(__value_init_tag) : __value_() {} + + explicit __compressed_pair_elem(_Tp __t) : __value_(__t) {} + + _Tp &__get() { return __value_; } + +private: + _Tp __value_; +}; + +template +struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp { + explicit __compressed_pair_elem(_Tp __t) : _Tp(__t) {} + explicit __compressed_pair_elem(__default_init_tag) {} + explicit __compressed_pair_elem(__value_init_tag) : _Tp() {} + + _Tp &__get() { return *this; } +}; + +template +class __compressed_pair : private __compressed_pair_elem<_T1, 0>, + private __compressed_pair_elem<_T2, 1> { +public: + using _Base1 = __compressed_pair_elem<_T1, 0>; + using _Base2 = __compressed_pair_elem<_T2, 1>; + + explicit __compressed_pair(_T1 __t1, _T2 __t2) : _Base1(__t1), _Base2(__t2) {} + explicit __compressed_pair() + : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {} + + template + explicit __compressed_pair(_U1 &&__t1, _U2 &&__t2) + : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {} + + _T1 &first() { return static_cast<_Base1 &>(*this).__get(); } +}; +#elif COMPRESSED_PAIR_REV == 1 +#define _LLDB_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ + [[__gnu__::__aligned__(alignof(T2))]] [[no_unique_address]] T1 Initializer1; \ + [[no_unique_address]] __compressed_pair_padding _LIBCPP_CONCAT3( \ + __padding1_, __LINE__, _); \ + [[no_unique_address]] T2 Initializer2; \ + [[no_unique_address]] __compressed_pair_padding _LIBCPP_CONCAT3( \ + __padding2_, __LINE__, _) + +#define _LLDB_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, \ +Initializer3) \ + [[using __gnu__: __aligned__(alignof(T2)), \ +__aligned__(alignof(T3))]] [[no_unique_address]] T1 Initializer1; \ + [[no_unique_address]] __compressed_pair_padding _LIBCPP_CONCAT3( \ + __padding1_, __LINE__, _); \ + [[no_unique_address]] T2 Initializer2; \ + [[no_unique_address]] __compressed_pair_padding _LIBCPP_CON
[Lldb-commits] [lldb] [WIP][lldb][test] Add a layout simulator test for std::unique_ptr (PR #98330)
Michael137 wrote: It's a non-trivial maintenance cost but I think the upside is quite large: * we'll have more confidence that old layouts don't break over time * faster signal when we break compatibility * trimmed down reference implementation of the various STL layouts without having to trawl through git history https://github.com/llvm/llvm-project/pull/98330 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP][lldb][test] Add a layout simulator test for std::unique_ptr (PR #98330)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r 918ac62916d48649f224f8c54837d25baff97a08...a25b3c8a6a36326730d00d1060ff84181bece26e lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/TestDataFormatterLibcxxUniquePtrSimulator.py `` View the diff from darker here. ``diff --- TestDataFormatterLibcxxUniquePtrSimulator.py2024-07-10 14:37:45.00 + +++ TestDataFormatterLibcxxUniquePtrSimulator.py2024-07-10 14:49:09.903049 + @@ -6,10 +6,11 @@ import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil import functools + class LibcxxUniquePtrDataFormatterSimulatorTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True def _run_test(self, defines): @@ -18,13 +19,16 @@ lldbutil.run_to_source_breakpoint( self, "// Break here", lldb.SBFileSpec("main.cpp") ) self.expect("frame variable var_up", substrs=["pointer ="]) self.expect("frame variable var_up", substrs=["deleter ="], matching=False) -self.expect("frame variable var_with_deleter_up", substrs=["pointer =", "deleter ="]) +self.expect( +"frame variable var_with_deleter_up", substrs=["pointer =", "deleter ="] +) -#for r in range(3): + +# for r in range(3): for r in range(1): name = "test_r%d" % r defines = ["COMPRESSED_PAIR_REV=%d" % r] f = functools.partialmethod( LibcxxUniquePtrDataFormatterSimulatorTestCase._run_test, defines `` https://github.com/llvm/llvm-project/pull/98330 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP][lldb][test] Add a layout simulator test for std::unique_ptr (PR #98330)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/98330 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/96538 >From 1b47b3f3b0735a5a127372e93775e99fd2977e6f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 29 Jan 2024 16:23:16 + Subject: [PATCH] [lldb] Support new libc++ __compressed_pair layout --- lldb/examples/synthetic/libcxx.py | 26 -- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 85 ++- .../Plugins/Language/CPlusPlus/LibCxx.h | 3 +- .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 72 +--- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 46 +++--- .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 82 +- .../Language/CPlusPlus/LibCxxVector.cpp | 40 + .../list/TestDataFormatterGenericList.py | 3 +- .../libcxx/string/simulator/main.cpp | 1 + .../TestDataFormatterLibcxxUniquePtr.py | 2 +- 10 files changed, 233 insertions(+), 127 deletions(-) diff --git a/lldb/examples/synthetic/libcxx.py b/lldb/examples/synthetic/libcxx.py index 474aaa428fa23..060ff90100849 100644 --- a/lldb/examples/synthetic/libcxx.py +++ b/lldb/examples/synthetic/libcxx.py @@ -721,6 +721,12 @@ def _get_value_of_compressed_pair(self, pair): def update(self): logger = lldb.formatters.Logger.Logger() try: +has_compressed_pair_layout = True +alloc_valobj = self.valobj.GetChildMemberWithName("__alloc_") +size_valobj = self.valobj.GetChildMemberWithName("__size_") +if alloc_valobj.IsValid() and size_valobj.IsValid(): +has_compressed_pair_layout = False + # A deque is effectively a two-dim array, with fixed width. # 'map' contains pointers to the rows of this array. The # full memory area allocated by the deque is delimited @@ -734,9 +740,13 @@ def update(self): # variable tells which element in this NxM array is the 0th # one, and the 'size' element gives the number of elements # in the deque. -count = self._get_value_of_compressed_pair( -self.valobj.GetChildMemberWithName("__size_") -) +if has_compressed_pair_layout: +count = self._get_value_of_compressed_pair( +self.valobj.GetChildMemberWithName("__size_") +) +else: +count = size_valobj.GetValueAsUnsigned(0) + # give up now if we cant access memory reliably if self.block_size < 0: logger.write("block_size < 0") @@ -748,9 +758,13 @@ def update(self): self.map_begin = map_.GetChildMemberWithName("__begin_") map_begin = self.map_begin.GetValueAsUnsigned(0) map_end = map_.GetChildMemberWithName("__end_").GetValueAsUnsigned(0) -map_endcap = self._get_value_of_compressed_pair( -map_.GetChildMemberWithName("__end_cap_") -) + +if has_compressed_pair_layout: +map_endcap = self._get_value_of_compressed_pair( +map_.GetChildMemberWithName("__end_cap_") +) +else: +map_endcap = map_.GetChildMemberWithName("__end_cap_").GetValueAsUnsigned(0) # check consistency if not map_first <= map_begin <= map_end <= map_endcap: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index feaa51a96843a..7d3b2410a7296 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -27,6 +27,7 @@ #include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" #include #include @@ -34,6 +35,32 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::formatters; +static void consumeInlineNamespace(llvm::StringRef &name) { + // Delete past an inline namespace, if any: __[a-zA-Z0-9_]+:: + auto scratch = name; + if (scratch.consume_front("__") && std::isalnum(scratch[0])) { +scratch = scratch.drop_while([](char c) { return std::isalnum(c); }); +if (scratch.consume_front("::")) { + // Successfully consumed a namespace. + name = scratch; +} + } +} + +bool lldb_private::formatters::isOldCompressedPairLayout( +ValueObject &pair_obj) { + return isStdTemplate(pair_obj.GetTypeName(), "__compressed_pair"); +} + +bool lldb_private::formatters::isStdTemplate(ConstString type_name, + llvm::StringRef type) { + llvm::StringRef name = type_name.GetStringRef(); + // The type name may be prefixed with `std::__::`. + if (name.consume_front("std::")) +consumeInlineNamespace(name); + return name.consume_front(type) && name.starts_with("<"); +} +
[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/96538 >From 7de2db47a5be90a41a211d21210429e01cda945d Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 29 Jan 2024 16:23:16 + Subject: [PATCH] [lldb] Support new libc++ __compressed_pair layout --- lldb/examples/synthetic/libcxx.py | 26 -- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 85 ++- .../Plugins/Language/CPlusPlus/LibCxx.h | 3 +- .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 72 +--- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 41 ++--- .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 82 +- .../Language/CPlusPlus/LibCxxVector.cpp | 40 + .../list/TestDataFormatterGenericList.py | 3 +- .../libcxx/string/simulator/main.cpp | 1 + .../TestDataFormatterLibcxxUniquePtr.py | 2 +- 10 files changed, 228 insertions(+), 127 deletions(-) diff --git a/lldb/examples/synthetic/libcxx.py b/lldb/examples/synthetic/libcxx.py index 474aaa428fa23..060ff90100849 100644 --- a/lldb/examples/synthetic/libcxx.py +++ b/lldb/examples/synthetic/libcxx.py @@ -721,6 +721,12 @@ def _get_value_of_compressed_pair(self, pair): def update(self): logger = lldb.formatters.Logger.Logger() try: +has_compressed_pair_layout = True +alloc_valobj = self.valobj.GetChildMemberWithName("__alloc_") +size_valobj = self.valobj.GetChildMemberWithName("__size_") +if alloc_valobj.IsValid() and size_valobj.IsValid(): +has_compressed_pair_layout = False + # A deque is effectively a two-dim array, with fixed width. # 'map' contains pointers to the rows of this array. The # full memory area allocated by the deque is delimited @@ -734,9 +740,13 @@ def update(self): # variable tells which element in this NxM array is the 0th # one, and the 'size' element gives the number of elements # in the deque. -count = self._get_value_of_compressed_pair( -self.valobj.GetChildMemberWithName("__size_") -) +if has_compressed_pair_layout: +count = self._get_value_of_compressed_pair( +self.valobj.GetChildMemberWithName("__size_") +) +else: +count = size_valobj.GetValueAsUnsigned(0) + # give up now if we cant access memory reliably if self.block_size < 0: logger.write("block_size < 0") @@ -748,9 +758,13 @@ def update(self): self.map_begin = map_.GetChildMemberWithName("__begin_") map_begin = self.map_begin.GetValueAsUnsigned(0) map_end = map_.GetChildMemberWithName("__end_").GetValueAsUnsigned(0) -map_endcap = self._get_value_of_compressed_pair( -map_.GetChildMemberWithName("__end_cap_") -) + +if has_compressed_pair_layout: +map_endcap = self._get_value_of_compressed_pair( +map_.GetChildMemberWithName("__end_cap_") +) +else: +map_endcap = map_.GetChildMemberWithName("__end_cap_").GetValueAsUnsigned(0) # check consistency if not map_first <= map_begin <= map_end <= map_endcap: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index feaa51a96843a..7d3b2410a7296 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -27,6 +27,7 @@ #include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" #include #include @@ -34,6 +35,32 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::formatters; +static void consumeInlineNamespace(llvm::StringRef &name) { + // Delete past an inline namespace, if any: __[a-zA-Z0-9_]+:: + auto scratch = name; + if (scratch.consume_front("__") && std::isalnum(scratch[0])) { +scratch = scratch.drop_while([](char c) { return std::isalnum(c); }); +if (scratch.consume_front("::")) { + // Successfully consumed a namespace. + name = scratch; +} + } +} + +bool lldb_private::formatters::isOldCompressedPairLayout( +ValueObject &pair_obj) { + return isStdTemplate(pair_obj.GetTypeName(), "__compressed_pair"); +} + +bool lldb_private::formatters::isStdTemplate(ConstString type_name, + llvm::StringRef type) { + llvm::StringRef name = type_name.GetStringRef(); + // The type name may be prefixed with `std::__::`. + if (name.consume_front("std::")) +consumeInlineNamespace(name); + return name.consume_front(type) && name.starts_with("<"); +} +
[Lldb-commits] [lldb] [WIP][lldb][test] Add a layout simulator test for std::unique_ptr (PR #98330)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/98330 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP][lldb][test] Add a layout simulator test for std::unique_ptr (PR #98330)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/98330 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [WIP][lldb][test] Add a layout simulator test for std::unique_ptr (PR #98330)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/98330 >From a25b3c8a6a36326730d00d1060ff84181bece26e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Wed, 10 Jul 2024 15:37:45 +0100 Subject: [PATCH 1/2] [WIP][lldb][test] Add a layout simulator test for std::unique_ptr --- .../libcxx-simulators/compressed_pair.h | 89 +++ .../libcxx-simulators/unique_ptr/Makefile | 3 + ...stDataFormatterLibcxxUniquePtrSimulator.py | 32 +++ .../libcxx-simulators/unique_ptr/main.cpp | 43 + 4 files changed, 167 insertions(+) create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/compressed_pair.h create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/TestDataFormatterLibcxxUniquePtrSimulator.py create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/unique_ptr/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/compressed_pair.h b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/compressed_pair.h new file mode 100644 index 0..ec978b8053646 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/compressed_pair.h @@ -0,0 +1,89 @@ +#ifndef STD_LLDB_COMPRESSED_PAIR_H +#define STD_LLDB_COMPRESSED_PAIR_H + +#include <__memory/compressed_pair.h> +#include + +namespace std { +namespace __lldb { + +#if COMPRESSED_PAIR_REV == 0 // Post-c88580c layout +struct __value_init_tag {}; +struct __default_init_tag {}; + +template ::value && !std::is_final<_Tp>::value> +struct __compressed_pair_elem { + explicit __compressed_pair_elem(__default_init_tag) {} + explicit __compressed_pair_elem(__value_init_tag) : __value_() {} + + explicit __compressed_pair_elem(_Tp __t) : __value_(__t) {} + + _Tp &__get() { return __value_; } + +private: + _Tp __value_; +}; + +template +struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp { + explicit __compressed_pair_elem(_Tp __t) : _Tp(__t) {} + explicit __compressed_pair_elem(__default_init_tag) {} + explicit __compressed_pair_elem(__value_init_tag) : _Tp() {} + + _Tp &__get() { return *this; } +}; + +template +class __compressed_pair : private __compressed_pair_elem<_T1, 0>, + private __compressed_pair_elem<_T2, 1> { +public: + using _Base1 = __compressed_pair_elem<_T1, 0>; + using _Base2 = __compressed_pair_elem<_T2, 1>; + + explicit __compressed_pair(_T1 __t1, _T2 __t2) : _Base1(__t1), _Base2(__t2) {} + explicit __compressed_pair() + : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {} + + template + explicit __compressed_pair(_U1 &&__t1, _U2 &&__t2) + : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {} + + _T1 &first() { return static_cast<_Base1 &>(*this).__get(); } +}; +#elif COMPRESSED_PAIR_REV == 1 +#define _LLDB_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ + [[__gnu__::__aligned__(alignof(T2))]] [[no_unique_address]] T1 Initializer1; \ + [[no_unique_address]] __compressed_pair_padding _LIBCPP_CONCAT3( \ + __padding1_, __LINE__, _); \ + [[no_unique_address]] T2 Initializer2; \ + [[no_unique_address]] __compressed_pair_padding _LIBCPP_CONCAT3( \ + __padding2_, __LINE__, _) + +#define _LLDB_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, \ +Initializer3) \ + [[using __gnu__: __aligned__(alignof(T2)), \ +__aligned__(alignof(T3))]] [[no_unique_address]] T1 Initializer1; \ + [[no_unique_address]] __compressed_pair_padding _LIBCPP_CONCAT3( \ + __padding1_, __LINE__, _); \ + [[no_unique_address]] T2 Initializer2; \ + [[no_unique_address]] __compressed_pair_padding _LIBCPP_CONCAT3( \ + __padding2_, __LINE__, _); \ + [[no_unique_address]] T3 Initializer3; \ + [[no_unique_address]] __compressed_pair_padding _LIBCPP_CONCAT3( \ + __padding3_, __LINE__, _) +#elif COMPRESSED_PAIR_REV == 2 +#define _LLDB_COMPRESSED_PAIR(T1, Name1, T2, Name2) \ + [[no_unique_address]] T1 Name1; \ + [[no_unique_address]] T2 Name2 + +#define _LLDB_COMPRESSED_TRIPLE(T1, Name1, T2, Name2, T3, Name3) \ + [[no_unique_address]] T1 Name1;
[Lldb-commits] [lldb] [lldb] DebugInfoD tests & fixes (but with dwp testing disabled) (PR #98344)
https://github.com/kevinfrei created https://github.com/llvm/llvm-project/pull/98344 This is all the tests and fixes I've had percolating since my first attempt at this in January. After 6 months of trying, I've given up on adding the ability to test DWP files in LLDB API tests. I've left both the tests (disabled) and the changes to Makefile.rules in place, in the hopes that someone who can configure the build bots will be able to enable the tests once a non-borked dwp tool is widely available. Other than disabling the DWP tests, this continues to be the same diff that I've tried to land and [not](https://github.com/llvm/llvm-project/pull/90622) [revert](https://github.com/llvm/llvm-project/pull/87676) [five](https://github.com/llvm/llvm-project/pull/86812) [times](https://github.com/llvm/llvm-project/pull/85693) [before](https://github.com/llvm/llvm-project/pull/96802). There are a couple of fixes that the testing exposed, and I've abandoned the DWP tests because I want to get those fixes finally upstreamed, as without them DebugInfoD is less useful. >From 6f885b0c6b255ec7066bbe2a2493608a12c531fb Mon Sep 17 00:00:00 2001 From: Kevin Frei Date: Mon, 25 Mar 2024 08:23:47 -0700 Subject: [PATCH 01/14] Trying to deal with Linux AArch64 test failures :/ --- .../SymbolVendor/ELF/SymbolVendorELF.cpp | 18 ++ .../API/debuginfod/Normal/TestDebuginfod.py | 187 + .../SplitDWARF/TestDebuginfodDWP.py | 196 ++ 3 files changed, 401 insertions(+) create mode 100644 lldb/test/API/debuginfod/Normal/TestDebuginfod.py create mode 100644 lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py diff --git a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp index b5fe35d71032a..a881218a56cef 100644 --- a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp +++ b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp @@ -44,6 +44,24 @@ llvm::StringRef SymbolVendorELF::GetPluginDescriptionStatic() { "executables."; } +// If this is needed elsewhere, it can be exported/moved. +static bool IsDwpSymbolFile(const lldb::ModuleSP &module_sp, +const FileSpec &file_spec) { + DataBufferSP dwp_file_data_sp; + lldb::offset_t dwp_file_data_offset = 0; + // Try to create an ObjectFile from the file_spec. + ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin( + module_sp, &file_spec, 0, FileSystem::Instance().GetByteSize(file_spec), + dwp_file_data_sp, dwp_file_data_offset); + // The presence of a debug_cu_index section is the key identifying feature of + // a DWP file. Make sure we don't fill in the section list on dwp_obj_file + // (by calling GetSectionList(false)) as this is invoked before we may have + // all the symbol files collected and available. + return dwp_obj_file && ObjectFileELF::classof(dwp_obj_file.get()) && + dwp_obj_file->GetSectionList(false)->FindSectionByType( + eSectionTypeDWARFDebugCuIndex, false); +} + // CreateInstance // // Platforms can register a callback to use when creating symbol vendors to diff --git a/lldb/test/API/debuginfod/Normal/TestDebuginfod.py b/lldb/test/API/debuginfod/Normal/TestDebuginfod.py new file mode 100644 index 0..a662fb9fc6e68 --- /dev/null +++ b/lldb/test/API/debuginfod/Normal/TestDebuginfod.py @@ -0,0 +1,187 @@ +import os +import shutil +import tempfile +import struct + +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.lldbtest import * + + +def getUUID(aoutuuid): +""" +Pull the 20 byte UUID out of the .note.gnu.build-id section that was dumped +to a file already, as part of the build. +""" +with open(aoutuuid, "rb") as f: +data = f.read(36) +if len(data) != 36: +return None +header = struct.unpack_from("<4I", data) +if len(header) != 4: +return None +# 4 element 'prefix', 20 bytes of uuid, 3 byte long string: 'GNU': +if header[0] != 4 or header[1] != 20 or header[2] != 3 or header[3] != 0x554E47: +return None +return data[16:].hex() + + +""" +Test support for the DebugInfoD network symbol acquisition protocol. +This one is for simple / no split-dwarf scenarios. + +For no-split-dwarf scenarios, there are 2 variations: +1 - A stripped binary with it's corresponding unstripped binary: +2 - A stripped binary with a corresponding --only-keep-debug symbols file +""" + + +@skipUnlessPlatform(["linux", "freebsd"]) +class DebugInfodTests(TestBase): +# No need to try every flavor of debug inf. +NO_DEBUG_INFO_TESTCASE = True + +def test_normal_no_symbols(self): +""" +Validate behavior with no symbols or symbol locator. +('baseline negative' behavior) +""" +test_root = self.config_test(["a.out"]) +self.try_breakpoint(False)
[Lldb-commits] [lldb] [lldb] DebugInfoD tests & fixes (but with dwp testing disabled) (PR #98344)
kevinfrei wrote: @JDevlieghere or @clayborg if one of you could please approve & land this, I *believe* this disables the tests that caused the previous diff to be reverted. https://github.com/llvm/llvm-project/pull/98344 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] DebugInfoD tests & fixes (but with dwp testing disabled) (PR #98344)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/98344 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b9496a7 - [lldb] DebugInfoD tests & fixes (but with dwp testing disabled) (#98344)
Author: Kevin Frei Date: 2024-07-10T09:28:22-07:00 New Revision: b9496a74eb4029629ca2e440c5441614e766f773 URL: https://github.com/llvm/llvm-project/commit/b9496a74eb4029629ca2e440c5441614e766f773 DIFF: https://github.com/llvm/llvm-project/commit/b9496a74eb4029629ca2e440c5441614e766f773.diff LOG: [lldb] DebugInfoD tests & fixes (but with dwp testing disabled) (#98344) This is all the tests and fixes I've had percolating since my first attempt at this in January. After 6 months of trying, I've given up on adding the ability to test DWP files in LLDB API tests. I've left both the tests (disabled) and the changes to Makefile.rules in place, in the hopes that someone who can configure the build bots will be able to enable the tests once a non-borked dwp tool is widely available. Other than disabling the DWP tests, this continues to be the same diff that I've tried to land and [not](https://github.com/llvm/llvm-project/pull/90622) [revert](https://github.com/llvm/llvm-project/pull/87676) [five](https://github.com/llvm/llvm-project/pull/86812) [times](https://github.com/llvm/llvm-project/pull/85693) [before](https://github.com/llvm/llvm-project/pull/96802). There are a couple of fixes that the testing exposed, and I've abandoned the DWP tests because I want to get those fixes finally upstreamed, as without them DebugInfoD is less useful. Added: lldb/test/API/debuginfod/Normal/Makefile lldb/test/API/debuginfod/Normal/TestDebuginfod.py lldb/test/API/debuginfod/Normal/main.c lldb/test/API/debuginfod/SplitDWARF/Makefile lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py lldb/test/API/debuginfod/SplitDWARF/main.c Modified: lldb/include/lldb/Host/Config.h.cmake lldb/packages/Python/lldbsuite/test/decorators.py lldb/packages/Python/lldbsuite/test/make/Makefile.rules lldb/source/API/SBDebugger.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolLocator/CMakeLists.txt lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp Removed: diff --git a/lldb/include/lldb/Host/Config.h.cmake b/lldb/include/lldb/Host/Config.h.cmake index 3defa454f6d42..9e538534086a2 100644 --- a/lldb/include/lldb/Host/Config.h.cmake +++ b/lldb/include/lldb/Host/Config.h.cmake @@ -33,6 +33,8 @@ #cmakedefine01 LLDB_ENABLE_LZMA +#cmakedefine01 LLVM_ENABLE_CURL + #cmakedefine01 LLDB_ENABLE_CURSES #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index ecc7b81035f11..0e8ca159efd55 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -1053,6 +1053,10 @@ def _get_bool_config_skip_if_decorator(key): return unittest.skipIf(not have, "requires " + key) +def skipIfCurlSupportMissing(func): +return _get_bool_config_skip_if_decorator("curl")(func) + + def skipIfCursesSupportMissing(func): return _get_bool_config_skip_if_decorator("curses")(func) diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index 3d562285ce9cc..d1a2de8b2478a 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../ # # GNUWin32 uname gives "windows32" or "server version windows32" while # some versions of MSYS uname return "MSYS_NT*", but most environments -# standardize on "Windows_NT", so we'll make it consistent here. +# standardize on "Windows_NT", so we'll make it consistent here. # When running tests from Visual Studio, the environment variable isn't # inherited all the way down to the process spawned for make. #-- @@ -213,6 +213,12 @@ else ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES" DSYM = $(EXE).debug endif + + ifeq "$(MAKE_DWP)" "YES" + MAKE_DWO := YES + DWP_NAME = $(EXE).dwp + DYLIB_DWP_NAME = $(DYLIB_NAME).dwp + endif endif LIMIT_DEBUG_INFO_FLAGS = @@ -361,6 +367,17 @@ ifneq "$(OS)" "Darwin" OBJCOPY ?= $(call replace_cc_with,objcopy) ARCHIVER ?= $(call replace_cc_with,ar) + # Look for llvm-dwp or gnu dwp + DWP ?= $(call replace_cc_with,llvm-dwp) + ifeq ($(wildcard $(DWP)),) + DWP = $(call replace_cc_with,dwp) + ifeq ($(wildcard $(DWP)),) + DWP = $(shell command -v llvm-dwp 2> /dev/null) + ifeq ($(wildcard $(DWP)),) + DWP = $(shell command -v dwp 2> /dev/null) + endif + endif + endif override AR = $(ARCHIVER) endif @@ -531,
[Lldb-commits] [lldb] [lldb] DebugInfoD tests & fixes (but with dwp testing disabled) (PR #98344)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/98344 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/96538 >From 125e24426cd897292f8839fbc4c6465ce915ac05 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 29 Jan 2024 16:23:16 + Subject: [PATCH] [lldb] Support new libc++ __compressed_pair layout --- lldb/examples/synthetic/libcxx.py | 26 ++- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 85 ++--- .../Plugins/Language/CPlusPlus/LibCxx.h | 3 +- .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 72 +--- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 41 +++-- .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 166 +++--- .../Language/CPlusPlus/LibCxxVector.cpp | 40 +++-- .../list/TestDataFormatterGenericList.py | 3 +- .../libcxx/string/simulator/main.cpp | 1 + .../TestDataFormatterLibcxxUniquePtr.py | 2 +- 10 files changed, 289 insertions(+), 150 deletions(-) diff --git a/lldb/examples/synthetic/libcxx.py b/lldb/examples/synthetic/libcxx.py index 474aaa428fa23..060ff90100849 100644 --- a/lldb/examples/synthetic/libcxx.py +++ b/lldb/examples/synthetic/libcxx.py @@ -721,6 +721,12 @@ def _get_value_of_compressed_pair(self, pair): def update(self): logger = lldb.formatters.Logger.Logger() try: +has_compressed_pair_layout = True +alloc_valobj = self.valobj.GetChildMemberWithName("__alloc_") +size_valobj = self.valobj.GetChildMemberWithName("__size_") +if alloc_valobj.IsValid() and size_valobj.IsValid(): +has_compressed_pair_layout = False + # A deque is effectively a two-dim array, with fixed width. # 'map' contains pointers to the rows of this array. The # full memory area allocated by the deque is delimited @@ -734,9 +740,13 @@ def update(self): # variable tells which element in this NxM array is the 0th # one, and the 'size' element gives the number of elements # in the deque. -count = self._get_value_of_compressed_pair( -self.valobj.GetChildMemberWithName("__size_") -) +if has_compressed_pair_layout: +count = self._get_value_of_compressed_pair( +self.valobj.GetChildMemberWithName("__size_") +) +else: +count = size_valobj.GetValueAsUnsigned(0) + # give up now if we cant access memory reliably if self.block_size < 0: logger.write("block_size < 0") @@ -748,9 +758,13 @@ def update(self): self.map_begin = map_.GetChildMemberWithName("__begin_") map_begin = self.map_begin.GetValueAsUnsigned(0) map_end = map_.GetChildMemberWithName("__end_").GetValueAsUnsigned(0) -map_endcap = self._get_value_of_compressed_pair( -map_.GetChildMemberWithName("__end_cap_") -) + +if has_compressed_pair_layout: +map_endcap = self._get_value_of_compressed_pair( +map_.GetChildMemberWithName("__end_cap_") +) +else: +map_endcap = map_.GetChildMemberWithName("__end_cap_").GetValueAsUnsigned(0) # check consistency if not map_first <= map_begin <= map_end <= map_endcap: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index feaa51a96843a..7d3b2410a7296 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -27,6 +27,7 @@ #include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" #include #include @@ -34,6 +35,32 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::formatters; +static void consumeInlineNamespace(llvm::StringRef &name) { + // Delete past an inline namespace, if any: __[a-zA-Z0-9_]+:: + auto scratch = name; + if (scratch.consume_front("__") && std::isalnum(scratch[0])) { +scratch = scratch.drop_while([](char c) { return std::isalnum(c); }); +if (scratch.consume_front("::")) { + // Successfully consumed a namespace. + name = scratch; +} + } +} + +bool lldb_private::formatters::isOldCompressedPairLayout( +ValueObject &pair_obj) { + return isStdTemplate(pair_obj.GetTypeName(), "__compressed_pair"); +} + +bool lldb_private::formatters::isStdTemplate(ConstString type_name, + llvm::StringRef type) { + llvm::StringRef name = type_name.GetStringRef(); + // The type name may be prefixed with `std::__::`. + if (name.consume_front("std::")) +consumeInlineNamespace(name); + return name.consume_front(type) && name.starts_with("<"); +} + lldb::ValueObjectS
[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/96538 >From 231e0ddc5834ac7fe8e4860c79504f6ce8666db5 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 29 Jan 2024 16:23:16 + Subject: [PATCH] [lldb] Support new libc++ __compressed_pair layout --- lldb/examples/synthetic/libcxx.py | 26 ++- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 85 ++--- .../Plugins/Language/CPlusPlus/LibCxx.h | 3 +- .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 72 +--- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 41 +++-- .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 166 +++--- .../Language/CPlusPlus/LibCxxVector.cpp | 38 ++-- .../list/TestDataFormatterGenericList.py | 2 +- .../libcxx/string/simulator/main.cpp | 1 + 9 files changed, 283 insertions(+), 151 deletions(-) diff --git a/lldb/examples/synthetic/libcxx.py b/lldb/examples/synthetic/libcxx.py index 474aaa428fa23..060ff90100849 100644 --- a/lldb/examples/synthetic/libcxx.py +++ b/lldb/examples/synthetic/libcxx.py @@ -721,6 +721,12 @@ def _get_value_of_compressed_pair(self, pair): def update(self): logger = lldb.formatters.Logger.Logger() try: +has_compressed_pair_layout = True +alloc_valobj = self.valobj.GetChildMemberWithName("__alloc_") +size_valobj = self.valobj.GetChildMemberWithName("__size_") +if alloc_valobj.IsValid() and size_valobj.IsValid(): +has_compressed_pair_layout = False + # A deque is effectively a two-dim array, with fixed width. # 'map' contains pointers to the rows of this array. The # full memory area allocated by the deque is delimited @@ -734,9 +740,13 @@ def update(self): # variable tells which element in this NxM array is the 0th # one, and the 'size' element gives the number of elements # in the deque. -count = self._get_value_of_compressed_pair( -self.valobj.GetChildMemberWithName("__size_") -) +if has_compressed_pair_layout: +count = self._get_value_of_compressed_pair( +self.valobj.GetChildMemberWithName("__size_") +) +else: +count = size_valobj.GetValueAsUnsigned(0) + # give up now if we cant access memory reliably if self.block_size < 0: logger.write("block_size < 0") @@ -748,9 +758,13 @@ def update(self): self.map_begin = map_.GetChildMemberWithName("__begin_") map_begin = self.map_begin.GetValueAsUnsigned(0) map_end = map_.GetChildMemberWithName("__end_").GetValueAsUnsigned(0) -map_endcap = self._get_value_of_compressed_pair( -map_.GetChildMemberWithName("__end_cap_") -) + +if has_compressed_pair_layout: +map_endcap = self._get_value_of_compressed_pair( +map_.GetChildMemberWithName("__end_cap_") +) +else: +map_endcap = map_.GetChildMemberWithName("__end_cap_").GetValueAsUnsigned(0) # check consistency if not map_first <= map_begin <= map_end <= map_endcap: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index feaa51a96843a..7d3b2410a7296 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -27,6 +27,7 @@ #include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" #include #include @@ -34,6 +35,32 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::formatters; +static void consumeInlineNamespace(llvm::StringRef &name) { + // Delete past an inline namespace, if any: __[a-zA-Z0-9_]+:: + auto scratch = name; + if (scratch.consume_front("__") && std::isalnum(scratch[0])) { +scratch = scratch.drop_while([](char c) { return std::isalnum(c); }); +if (scratch.consume_front("::")) { + // Successfully consumed a namespace. + name = scratch; +} + } +} + +bool lldb_private::formatters::isOldCompressedPairLayout( +ValueObject &pair_obj) { + return isStdTemplate(pair_obj.GetTypeName(), "__compressed_pair"); +} + +bool lldb_private::formatters::isStdTemplate(ConstString type_name, + llvm::StringRef type) { + llvm::StringRef name = type_name.GetStringRef(); + // The type name may be prefixed with `std::__::`. + if (name.consume_front("std::")) +consumeInlineNamespace(name); + return name.consume_front(type) && name.starts_with("<"); +} + lldb::ValueObjectSP lldb_private::formatters::GetChildMemberWithName( V
[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/96538 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)
https://github.com/Michael137 ready_for_review https://github.com/llvm/llvm-project/pull/96538 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Support new libc++ __compressed_pair layout (PR #96538)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes This patch is in preparation for the `__compressed_pair` refactor in https://github.com/llvm/llvm-project/pull/76756. This is mostly reviewable now. With the new layout we no longer need to unwrap the `__compressed_pair`. Instead, we just need to look for child members. E.g., to get to the underlying pointer of `std::unique_ptr` we no longer do, ``` GetFirstValueOfCXXCompressedPair(GetChildMemberWithName("__ptr_")) ``` but instead do ``` GetChildMemberWithName("__ptr_") ``` We need to be slightly careful because previously the `__compressed_pair` had a member called `__value_`, whereas now `__value_` might be a member of the class that used to hold the `__compressed_pair`. So before unwrapping the pair, we added checks for `isOldCompressedLayout` (not sure yet whether folding this check into `GetFirstValueOfCXXCompressedPair` is better). --- Patch is 26.60 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/96538.diff 9 Files Affected: - (modified) lldb/examples/synthetic/libcxx.py (+20-6) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp (+63-22) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxx.h (+2-1) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp (+43-29) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp (+31-10) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp (+103-63) - (modified) lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp (+19-19) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py (+1-1) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/simulator/main.cpp (+1) ``diff diff --git a/lldb/examples/synthetic/libcxx.py b/lldb/examples/synthetic/libcxx.py index 474aaa428fa23..060ff90100849 100644 --- a/lldb/examples/synthetic/libcxx.py +++ b/lldb/examples/synthetic/libcxx.py @@ -721,6 +721,12 @@ def _get_value_of_compressed_pair(self, pair): def update(self): logger = lldb.formatters.Logger.Logger() try: +has_compressed_pair_layout = True +alloc_valobj = self.valobj.GetChildMemberWithName("__alloc_") +size_valobj = self.valobj.GetChildMemberWithName("__size_") +if alloc_valobj.IsValid() and size_valobj.IsValid(): +has_compressed_pair_layout = False + # A deque is effectively a two-dim array, with fixed width. # 'map' contains pointers to the rows of this array. The # full memory area allocated by the deque is delimited @@ -734,9 +740,13 @@ def update(self): # variable tells which element in this NxM array is the 0th # one, and the 'size' element gives the number of elements # in the deque. -count = self._get_value_of_compressed_pair( -self.valobj.GetChildMemberWithName("__size_") -) +if has_compressed_pair_layout: +count = self._get_value_of_compressed_pair( +self.valobj.GetChildMemberWithName("__size_") +) +else: +count = size_valobj.GetValueAsUnsigned(0) + # give up now if we cant access memory reliably if self.block_size < 0: logger.write("block_size < 0") @@ -748,9 +758,13 @@ def update(self): self.map_begin = map_.GetChildMemberWithName("__begin_") map_begin = self.map_begin.GetValueAsUnsigned(0) map_end = map_.GetChildMemberWithName("__end_").GetValueAsUnsigned(0) -map_endcap = self._get_value_of_compressed_pair( -map_.GetChildMemberWithName("__end_cap_") -) + +if has_compressed_pair_layout: +map_endcap = self._get_value_of_compressed_pair( +map_.GetChildMemberWithName("__end_cap_") +) +else: +map_endcap = map_.GetChildMemberWithName("__end_cap_").GetValueAsUnsigned(0) # check consistency if not map_first <= map_begin <= map_end <= map_endcap: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index feaa51a96843a..7d3b2410a7296 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -27,6 +27,7 @@ #include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h" #include "Plugins/TypeSystem/Clang/TypeSystemClang.h" #include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" #include #include @@ -34,6 +35,32 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::formatters; +static void consumeInlineNamespace(llvm::S
[Lldb-commits] [lldb] [lldb] DebugInfoD tests & fixes (but with dwp testing disabled) (PR #98344)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `lldb-arm-ubuntu` running on `linaro-lldb-arm-ubuntu` while building `lldb` at step 6 "test". Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/616 Here is the relevant piece of the build log for the reference: ``` Step 6 (test) failure: build (failure) ... PASS: lldb-api :: commands/watchpoints/watchpoint_commands/condition/TestWatchpointConditionCmd.py (260 of 2751) PASS: lldb-api :: commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py (261 of 2751) UNSUPPORTED: lldb-api :: commands/watchpoints/watchpoint_count/TestWatchpointCount.py (262 of 2751) PASS: lldb-api :: commands/watchpoints/watchpoint_disable/TestWatchpointDisable.py (263 of 2751) PASS: lldb-api :: commands/watchpoints/watchpoint_events/TestWatchpointEvents.py (264 of 2751) UNSUPPORTED: lldb-api :: commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py (265 of 2751) PASS: lldb-api :: commands/watchpoints/watchpoint_on_vectors/TestValueOfVectorVariable.py (266 of 2751) PASS: lldb-api :: debuginfod/Normal/TestDebuginfod.py (267 of 2751) PASS: lldb-api :: commands/watchpoints/watchpoint_size/TestWatchpointSizes.py (268 of 2751) UNRESOLVED: lldb-api :: debuginfod/SplitDWARF/TestDebuginfodDWP.py (269 of 2751) TEST 'lldb-api :: debuginfod/SplitDWARF/TestDebuginfodDWP.py' FAILED Script: -- /usr/bin/python3.8 /home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/local/bin/llvm-ar --env OBJCOPY=/usr/bin/llvm-objcopy --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --arch armv8l --build-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/dsymutil --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib /home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/debuginfod/SplitDWARF -p TestDebuginfodDWP.py -- Exit Code: 1 Command Output (stdout): -- lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision b9496a74eb4029629ca2e440c5441614e766f773) clang revision b9496a74eb4029629ca2e440c5441614e766f773 llvm revision b9496a74eb4029629ca2e440c5441614e766f773 Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 'debugserver', 'objc'] -- Command Output (stderr): -- UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_debuginfod_both_okd_symfiles_from_service (TestDebuginfodDWP.DebugInfodDWPTests) (requires curl) UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_debuginfod_both_symfiles_from_service (TestDebuginfodDWP.DebugInfodDWPTests) (requires curl) UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_debuginfod_dwp_from_service (TestDebuginfodDWP.DebugInfodDWPTests) (requires curl) FAIL: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_normal_stripped (TestDebuginfodDWP.DebugInfodDWPTests) UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_normal_stripped_only_dwp (TestDebuginfodDWP.DebugInfodDWPTests) (requires one of linux_freebsd_but_old_dwp_tools_on_build_bots_are_broken) UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/bin/clang-arm) :: test_normal_stripped_split_with_dwp (TestDebuginfodDWP.DebugInfodDWPTests) (requires one of linux_freebsd_but_old_dwp_tools_on_build_bots_are_broken) == ERROR: test_normal_stripped (TestDebuginfodDWP.DebugInfodDWPTests) Validate behavior with a stripped binary, no symbols or symbol locator. -- Error when building test subject. Build Command: make VPATH=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/debuginfod/SplitDWARF -C /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/debuginfod/SplitDWARF/TestDebuginfodDWP.test_normal_stripped -I /home/tcwg-buil
[Lldb-commits] [lldb] Missed disabling the baseline test for DWP stuff (PR #98351)
https://github.com/kevinfrei created https://github.com/llvm/llvm-project/pull/98351 This should disable the failing test on the ubuntu build bots @JDevlieghere (I forgot to disable the 'baseline' test, as it tests the debugger's basic handling of DWP files, but again, the API infrastructure doesn't quite support DWP generation) https://github.com/llvm/llvm-project/pull/98344#issuecomment-2221000566 >From 9840146580768d72eed4ec43941751d5a3859f9c Mon Sep 17 00:00:00 2001 From: Kevin Frei Date: Wed, 10 Jul 2024 10:02:47 -0700 Subject: [PATCH] Missed disabling the baseline test for DWP stuff --- lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py b/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py index 129f402c6a124..437c83a820fb7 100644 --- a/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py +++ b/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py @@ -25,7 +25,7 @@ class DebugInfodDWPTests(TestBase): # No need to try every flavor of debug inf. NO_DEBUG_INFO_TESTCASE = True -@skipUnlessPlatform(["linux", "freebsd"]) + @skipUnlessPlatform(["linux_freebsd_but_old_dwp_tools_on_build_bots_are_broken"]) def test_normal_stripped(self): """ Validate behavior with a stripped binary, no symbols or symbol locator. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Missed disabling the baseline test for DWP stuff (PR #98351)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Kevin Frei (kevinfrei) Changes This should disable the failing test on the ubuntu build bots @JDevlieghere (I forgot to disable the 'baseline' test, as it tests the debugger's basic handling of DWP files, but again, the API infrastructure doesn't quite support DWP generation) https://github.com/llvm/llvm-project/pull/98344#issuecomment-2221000566 --- Full diff: https://github.com/llvm/llvm-project/pull/98351.diff 1 Files Affected: - (modified) lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py (+1-1) ``diff diff --git a/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py b/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py index 129f402c6a124..437c83a820fb7 100644 --- a/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py +++ b/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py @@ -25,7 +25,7 @@ class DebugInfodDWPTests(TestBase): # No need to try every flavor of debug inf. NO_DEBUG_INFO_TESTCASE = True -@skipUnlessPlatform(["linux", "freebsd"]) + @skipUnlessPlatform(["linux_freebsd_but_old_dwp_tools_on_build_bots_are_broken"]) def test_normal_stripped(self): """ Validate behavior with a stripped binary, no symbols or symbol locator. `` https://github.com/llvm/llvm-project/pull/98351 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] DebugInfoD tests & fixes (but with dwp testing disabled) (PR #98344)
kevinfrei wrote: "fixed forward" with [PR98351](https://github.com/llvm/llvm-project/pull/98351/commits) if someone can approve & land that (it just disabled the baseline test for DWP stuff, as well: I missed it because the dwp tests run on all the machines I have access to :/ ) https://github.com/llvm/llvm-project/pull/98344 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix ThreadList assignment race (PR #98293)
https://github.com/JDevlieghere approved this pull request. LGTM. As a nice to have, maybe add a short explanation to the first mutex explaining that these operations are only allowed between thread lists belonging to the same process. Your current comment makes it sound as if that only applies *if* the processes are the same, but per the assertion, the requirement is stricter than that. https://github.com/llvm/llvm-project/pull/98293 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix ThreadList assignment race (PR #98293)
https://github.com/JDevlieghere edited https://github.com/llvm/llvm-project/pull/98293 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)
https://github.com/bulbazord approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #98361)
https://github.com/ZequanWu created https://github.com/llvm/llvm-project/pull/98361 This is a reapply of https://github.com/llvm/llvm-project/pull/92328 and https://github.com/llvm/llvm-project/pull/93839. It now passes the [test](https://github.com/llvm/llvm-project/commit/de3f1b6d68ab8a0e827db84b328803857a4f60df), which crashes with the original reverted changes. >From 37b6878b9125c314c75053f7d5b0ba520111e9a3 Mon Sep 17 00:00:00 2001 From: Zequan Wu Date: Tue, 9 Jul 2024 15:28:19 -0700 Subject: [PATCH] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. --- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 279 -- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 67 +++-- .../SymbolFile/DWARF/SymbolFileDWARF.h| 15 +- .../DWARF/SymbolFileDWARFDebugMap.h | 9 + .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp | 2 +- .../SymbolFile/DWARF/SymbolFileDWARFDwo.h | 3 +- .../SymbolFile/DWARF/UniqueDWARFASTType.cpp | 117 .../SymbolFile/DWARF/UniqueDWARFASTType.h | 36 +-- .../delayed-definition-die-searching.test | 36 +++ .../x86/simple-template-names-context.cpp | 4 +- 10 files changed, 301 insertions(+), 267 deletions(-) create mode 100644 lldb/test/Shell/SymbolFile/DWARF/delayed-definition-die-searching.test diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 8e297141f4e13..7b93f6941ddda 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1603,41 +1603,74 @@ DWARFASTParserClang::GetCPlusPlusQualifiedName(const DWARFDIE &die) { TypeSP DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, - const DWARFDIE &decl_die, + const DWARFDIE &die, ParsedDWARFTypeAttributes &attrs) { CompilerType clang_type; - const dw_tag_t tag = decl_die.Tag(); - SymbolFileDWARF *dwarf = decl_die.GetDWARF(); - LanguageType cu_language = SymbolFileDWARF::GetLanguage(*decl_die.GetCU()); + const dw_tag_t tag = die.Tag(); + SymbolFileDWARF *dwarf = die.GetDWARF(); + LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU()); Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups); - // UniqueDWARFASTType is large, so don't create a local variables on the - // stack, put it on the heap. This function is often called recursively and - // clang isn't good at sharing the stack space for variables in different - // blocks. - auto unique_ast_entry_up = std::make_unique(); - ConstString unique_typename(attrs.name); Declaration unique_decl(attrs.decl); + uint64_t byte_size = attrs.byte_size.value_or(0); + if (attrs.byte_size && *attrs.byte_size == 0 && attrs.name && + !die.HasChildren() && cu_language == eLanguageTypeObjC) { +// Work around an issue with clang at the moment where forward +// declarations for objective C classes are emitted as: +// DW_TAG_structure_type [2] +// DW_AT_name( "ForwardObjcClass" ) +// DW_AT_byte_size( 0x00 ) +// DW_AT_decl_file( "..." ) +// DW_AT_decl_line( 1 ) +// +// Note that there is no DW_AT_declaration and there are no children, +// and the byte size is zero. +attrs.is_forward_declaration = true; + } if (attrs.name) { if (Language::LanguageIsCPlusPlus(cu_language)) { // For C++, we rely solely upon the one definition rule that says // only one thing can exist at a given decl context. We ignore the // file and line that things are declared on. - std::string qualified_name = GetCPlusPlusQualifiedName(decl_die); + std::string qualified_name = GetCPlusPlusQualifiedName(die); if (!qualified_name.empty()) unique_typename = ConstString(qualified_name); unique_decl.Clear(); } -if (dwarf->GetUniqueDWARFASTTypeMap().Find( -unique_typename, decl_die, unique_decl, -attrs.byte_size.value_or(-1), *unique_ast_entry_up)) { - if (TypeSP type_sp = unique_ast_entry_up->m_type_sp) { +if (UniqueDWARFASTType *unique_ast_entry_type = +dwarf->GetUniqueDWARFASTTypeMap().Find( +unique_typename, die, unique_decl, byte_size, +attrs.is_forward_declaration)) { + if (TypeSP type_sp = unique_ast_entry_type->m_type_sp) { +dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); LinkDeclContextToDIE( -GetCachedClangDeclContextForDIE(unique_ast_entry_up->m_die), -decl_die); +GetCachedClangDeclContextForDIE(unique_ast_entry_type->m_die), die); +// If the DIE being parsed in this function is a definition and the +// entry in the map is a declaration, then we need to updat
[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #98361)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Zequan Wu (ZequanWu) Changes This is a reapply of https://github.com/llvm/llvm-project/pull/92328 and https://github.com/llvm/llvm-project/pull/93839. It now passes the [test](https://github.com/llvm/llvm-project/commit/de3f1b6d68ab8a0e827db84b328803857a4f60df), which crashes with the original reverted changes. --- Patch is 36.66 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/98361.diff 10 Files Affected: - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+118-161) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+49-18) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (+8-7) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (+9) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp (+1-1) - (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h (+2-1) - (modified) lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp (+63-54) - (modified) lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h (+13-23) - (added) lldb/test/Shell/SymbolFile/DWARF/delayed-definition-die-searching.test (+36) - (modified) lldb/test/Shell/SymbolFile/DWARF/x86/simple-template-names-context.cpp (+2-2) ``diff diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 8e297141f4e13..7b93f6941ddda 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1603,41 +1603,74 @@ DWARFASTParserClang::GetCPlusPlusQualifiedName(const DWARFDIE &die) { TypeSP DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc, - const DWARFDIE &decl_die, + const DWARFDIE &die, ParsedDWARFTypeAttributes &attrs) { CompilerType clang_type; - const dw_tag_t tag = decl_die.Tag(); - SymbolFileDWARF *dwarf = decl_die.GetDWARF(); - LanguageType cu_language = SymbolFileDWARF::GetLanguage(*decl_die.GetCU()); + const dw_tag_t tag = die.Tag(); + SymbolFileDWARF *dwarf = die.GetDWARF(); + LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU()); Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups); - // UniqueDWARFASTType is large, so don't create a local variables on the - // stack, put it on the heap. This function is often called recursively and - // clang isn't good at sharing the stack space for variables in different - // blocks. - auto unique_ast_entry_up = std::make_unique(); - ConstString unique_typename(attrs.name); Declaration unique_decl(attrs.decl); + uint64_t byte_size = attrs.byte_size.value_or(0); + if (attrs.byte_size && *attrs.byte_size == 0 && attrs.name && + !die.HasChildren() && cu_language == eLanguageTypeObjC) { +// Work around an issue with clang at the moment where forward +// declarations for objective C classes are emitted as: +// DW_TAG_structure_type [2] +// DW_AT_name( "ForwardObjcClass" ) +// DW_AT_byte_size( 0x00 ) +// DW_AT_decl_file( "..." ) +// DW_AT_decl_line( 1 ) +// +// Note that there is no DW_AT_declaration and there are no children, +// and the byte size is zero. +attrs.is_forward_declaration = true; + } if (attrs.name) { if (Language::LanguageIsCPlusPlus(cu_language)) { // For C++, we rely solely upon the one definition rule that says // only one thing can exist at a given decl context. We ignore the // file and line that things are declared on. - std::string qualified_name = GetCPlusPlusQualifiedName(decl_die); + std::string qualified_name = GetCPlusPlusQualifiedName(die); if (!qualified_name.empty()) unique_typename = ConstString(qualified_name); unique_decl.Clear(); } -if (dwarf->GetUniqueDWARFASTTypeMap().Find( -unique_typename, decl_die, unique_decl, -attrs.byte_size.value_or(-1), *unique_ast_entry_up)) { - if (TypeSP type_sp = unique_ast_entry_up->m_type_sp) { +if (UniqueDWARFASTType *unique_ast_entry_type = +dwarf->GetUniqueDWARFASTTypeMap().Find( +unique_typename, die, unique_decl, byte_size, +attrs.is_forward_declaration)) { + if (TypeSP type_sp = unique_ast_entry_type->m_type_sp) { +dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); LinkDeclContextToDIE( -GetCachedClangDeclContextForDIE(unique_ast_entry_up->m_die), -decl_die); +GetCachedClangDeclContextForDIE(unique_ast_entry_type->m_die), die); +// If the DIE being parsed in this function is a definition and the +// entry in the map is a declaration, then we need
[Lldb-commits] [clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)
@@ -20,16 +20,15 @@ using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + const StringMap features = sys::getHostCPUFeatures(features); + if (features.empty()) return 1; - if (features["sse"]) + if (features->lookup("sse")) topperc wrote: Why does this need `->` instead of `.`? https://github.com/llvm/llvm-project/pull/97824 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 2fa1220 - Missed disabling the baseline test for DWP stuff (#98351)
Author: Kevin Frei Date: 2024-07-10T11:07:01-07:00 New Revision: 2fa1220a37a3f55b76a29803d8333b3a3937d53a URL: https://github.com/llvm/llvm-project/commit/2fa1220a37a3f55b76a29803d8333b3a3937d53a DIFF: https://github.com/llvm/llvm-project/commit/2fa1220a37a3f55b76a29803d8333b3a3937d53a.diff LOG: Missed disabling the baseline test for DWP stuff (#98351) This should disable the failing test on the ubuntu build bots @JDevlieghere (I forgot to disable the 'baseline' test, as it tests the debugger's basic handling of DWP files, but again, the API infrastructure doesn't quite support DWP generation) https://github.com/llvm/llvm-project/pull/98344#issuecomment-2221000566 Added: Modified: lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py Removed: diff --git a/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py b/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py index 129f402c6a124..437c83a820fb7 100644 --- a/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py +++ b/lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py @@ -25,7 +25,7 @@ class DebugInfodDWPTests(TestBase): # No need to try every flavor of debug inf. NO_DEBUG_INFO_TESTCASE = True -@skipUnlessPlatform(["linux", "freebsd"]) + @skipUnlessPlatform(["linux_freebsd_but_old_dwp_tools_on_build_bots_are_broken"]) def test_normal_stripped(self): """ Validate behavior with a stripped binary, no symbols or symbol locator. ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Missed disabling the baseline test for DWP stuff (PR #98351)
https://github.com/clayborg closed https://github.com/llvm/llvm-project/pull/98351 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Missed disabling the baseline test for DWP stuff (PR #98351)
https://github.com/clayborg approved this pull request. https://github.com/llvm/llvm-project/pull/98351 ___ 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 displaying `__float128` variables (PR #98369)
https://github.com/beetrees created https://github.com/llvm/llvm-project/pull/98369 Adds support to LLDB for displaying 128-bit IEEE 754 floats (`__float128` in Clang, `_Float128` in GCC, `f128` in Rust). As DWARF does not currently provide a systemic way to distinguish between a 128-bit IEEE 754 float and a 128-bit x87/PPC `long double` (see #98179), the type name is used to disambiguate instead. >From 42df2ac904995b02c0f9abcf1aacf54d17dd219e Mon Sep 17 00:00:00 2001 From: beetrees Date: Wed, 10 Jul 2024 18:49:45 +0100 Subject: [PATCH] [lldb] Add support for displaying `__float128` variables --- lldb/bindings/python/python-extensions.swig | 1 + lldb/docs/python_api_enums.rst| 2 ++ lldb/include/lldb/lldb-enumerations.h | 13 lldb/source/Commands/CommandObjectMemory.cpp | 2 ++ lldb/source/Core/DumpDataExtractor.cpp| 7 ++- lldb/source/Core/ValueObject.cpp | 5 +++-- lldb/source/DataFormatters/FormatManager.cpp | 1 + lldb/source/DataFormatters/VectorType.cpp | 2 ++ .../TypeSystem/Clang/TypeSystemClang.cpp | 21 +++ lldb/unittests/Core/DumpDataExtractorTest.cpp | 6 ++ lldb/unittests/Symbol/TestTypeSystemClang.cpp | 2 ++ 11 files changed, 55 insertions(+), 7 deletions(-) diff --git a/lldb/bindings/python/python-extensions.swig b/lldb/bindings/python/python-extensions.swig index 4ba1607c70909..40fa76872ee96 100644 --- a/lldb/bindings/python/python-extensions.swig +++ b/lldb/bindings/python/python-extensions.swig @@ -594,6 +594,7 @@ def is_numeric_type(basic_type): if basic_type == eBasicTypeFloat: return (True,True) if basic_type == eBasicTypeDouble: return (True,True) if basic_type == eBasicTypeLongDouble: return (True,True) +if basic_type == eBasicTypeFloat128: return (True,True) if basic_type == eBasicTypeFloatComplex: return (True,True) if basic_type == eBasicTypeDoubleComplex: return (True,True) if basic_type == eBasicTypeLongDoubleComplex: return (True,True) diff --git a/lldb/docs/python_api_enums.rst b/lldb/docs/python_api_enums.rst index b6a2497ea878e..92ddfaf7b110a 100644 --- a/lldb/docs/python_api_enums.rst +++ b/lldb/docs/python_api_enums.rst @@ -295,6 +295,7 @@ Format .. py:data:: eFormatHex .. py:data:: eFormatHexUppercase .. py:data:: eFormatFloat +.. py:data:: eFormatFloat128 .. py:data:: eFormatOctal .. py:data:: eFormatOSType .. py:data:: eFormatUnicode16 @@ -1037,6 +1038,7 @@ BasicType .. py:data:: eBasicTypeFloat .. py:data:: eBasicTypeDouble .. py:data:: eBasicTypeLongDouble +.. py:data:: eBasicTypeFloat128 .. py:data:: eBasicTypeFloatComplex .. py:data:: eBasicTypeDoubleComplex .. py:data:: eBasicTypeLongDoubleComplex diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 74ff458bf87de..d90a64bb652e6 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -170,6 +170,10 @@ enum Format { eFormatHex, eFormatHexUppercase, eFormatFloat, + eFormatFloat128, //< Disambiguate between 128-bit `long double` (which uses + //< `eFormatFloat`) and `__float128` (which uses + //< `eFormatFloat128`). If the value being formatted is not + //< 128 bits, then this is identical to `eFormatFloat`. eFormatOctal, eFormatOSType, ///< OS character codes encoded into an integer 'PICT' 'text' ///< etc... @@ -195,10 +199,10 @@ enum Format { ///< character arrays that can contain non printable ///< characters eFormatAddressInfo,///< Describe what an address points to (func + offset - ///< with file/line, symbol + offset, data, etc) - eFormatHexFloat,///< ISO C99 hex float string - eFormatInstruction, ///< Disassemble an opcode - eFormatVoid,///< Do not print this + ///< with file/line, symbol + offset, data, etc) + eFormatHexFloat, ///< ISO C99 hex float string + eFormatInstruction,///< Disassemble an opcode + eFormatVoid, ///< Do not print this eFormatUnicode8, kNumFormats }; @@ -819,6 +823,7 @@ enum BasicType { eBasicTypeFloat, eBasicTypeDouble, eBasicTypeLongDouble, + eBasicTypeFloat128, eBasicTypeFloatComplex, eBasicTypeDoubleComplex, eBasicTypeLongDoubleComplex, diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 137b1ad981073..dde27d2df0fe5 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -156,6 +156,7 @@ class OptionGroupReadMemory : public OptionGroup { case eFormatBinary: case eFormatFloat: +case eFormatFloat128: case eFormatOctal: case eFormatDecimal: case eFormatEnum: @@ -1329,6 +1330,7 @@ class CommandObjectMemoryWrite : public CommandObjectParsed {
[Lldb-commits] [lldb] [lldb] Add support for displaying `__float128` variables (PR #98369)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: None (beetrees) Changes Adds support to LLDB for displaying 128-bit IEEE 754 floats (`__float128` in Clang, `_Float128` in GCC, `f128` in Rust). As DWARF does not currently provide a systemic way to distinguish between a 128-bit IEEE 754 float and a 128-bit x87/PPC `long double` (see #98179), the type name is used to disambiguate instead. --- Full diff: https://github.com/llvm/llvm-project/pull/98369.diff 11 Files Affected: - (modified) lldb/bindings/python/python-extensions.swig (+1) - (modified) lldb/docs/python_api_enums.rst (+2) - (modified) lldb/include/lldb/lldb-enumerations.h (+9-4) - (modified) lldb/source/Commands/CommandObjectMemory.cpp (+2) - (modified) lldb/source/Core/DumpDataExtractor.cpp (+6-1) - (modified) lldb/source/Core/ValueObject.cpp (+3-2) - (modified) lldb/source/DataFormatters/FormatManager.cpp (+1) - (modified) lldb/source/DataFormatters/VectorType.cpp (+2) - (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+21) - (modified) lldb/unittests/Core/DumpDataExtractorTest.cpp (+6) - (modified) lldb/unittests/Symbol/TestTypeSystemClang.cpp (+2) ``diff diff --git a/lldb/bindings/python/python-extensions.swig b/lldb/bindings/python/python-extensions.swig index 4ba1607c70909..40fa76872ee96 100644 --- a/lldb/bindings/python/python-extensions.swig +++ b/lldb/bindings/python/python-extensions.swig @@ -594,6 +594,7 @@ def is_numeric_type(basic_type): if basic_type == eBasicTypeFloat: return (True,True) if basic_type == eBasicTypeDouble: return (True,True) if basic_type == eBasicTypeLongDouble: return (True,True) +if basic_type == eBasicTypeFloat128: return (True,True) if basic_type == eBasicTypeFloatComplex: return (True,True) if basic_type == eBasicTypeDoubleComplex: return (True,True) if basic_type == eBasicTypeLongDoubleComplex: return (True,True) diff --git a/lldb/docs/python_api_enums.rst b/lldb/docs/python_api_enums.rst index b6a2497ea878e..92ddfaf7b110a 100644 --- a/lldb/docs/python_api_enums.rst +++ b/lldb/docs/python_api_enums.rst @@ -295,6 +295,7 @@ Format .. py:data:: eFormatHex .. py:data:: eFormatHexUppercase .. py:data:: eFormatFloat +.. py:data:: eFormatFloat128 .. py:data:: eFormatOctal .. py:data:: eFormatOSType .. py:data:: eFormatUnicode16 @@ -1037,6 +1038,7 @@ BasicType .. py:data:: eBasicTypeFloat .. py:data:: eBasicTypeDouble .. py:data:: eBasicTypeLongDouble +.. py:data:: eBasicTypeFloat128 .. py:data:: eBasicTypeFloatComplex .. py:data:: eBasicTypeDoubleComplex .. py:data:: eBasicTypeLongDoubleComplex diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 74ff458bf87de..d90a64bb652e6 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -170,6 +170,10 @@ enum Format { eFormatHex, eFormatHexUppercase, eFormatFloat, + eFormatFloat128, //< Disambiguate between 128-bit `long double` (which uses + //< `eFormatFloat`) and `__float128` (which uses + //< `eFormatFloat128`). If the value being formatted is not + //< 128 bits, then this is identical to `eFormatFloat`. eFormatOctal, eFormatOSType, ///< OS character codes encoded into an integer 'PICT' 'text' ///< etc... @@ -195,10 +199,10 @@ enum Format { ///< character arrays that can contain non printable ///< characters eFormatAddressInfo,///< Describe what an address points to (func + offset - ///< with file/line, symbol + offset, data, etc) - eFormatHexFloat,///< ISO C99 hex float string - eFormatInstruction, ///< Disassemble an opcode - eFormatVoid,///< Do not print this + ///< with file/line, symbol + offset, data, etc) + eFormatHexFloat, ///< ISO C99 hex float string + eFormatInstruction,///< Disassemble an opcode + eFormatVoid, ///< Do not print this eFormatUnicode8, kNumFormats }; @@ -819,6 +823,7 @@ enum BasicType { eBasicTypeFloat, eBasicTypeDouble, eBasicTypeLongDouble, + eBasicTypeFloat128, eBasicTypeFloatComplex, eBasicTypeDoubleComplex, eBasicTypeLongDoubleComplex, diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 137b1ad981073..dde27d2df0fe5 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -156,6 +156,7 @@ class OptionGroupReadMemory : public OptionGroup { case eFormatBinary: case eFormatFloat: +case eFormatFloat128: case eFormatOctal: case eFormatDecimal: case eFormatEnum: @@ -1329,6 +1330,7 @@ class CommandObjectMemoryWrite : public CommandObjectParsed { switch (m_format_options.GetFormat()) { case kNumFormats: case eFormatFloat: // TODO: add support f
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
@@ -58,8 +58,13 @@ class ThreadPlanStepRange : public ThreadPlan { // run' plan, then just single step. bool SetNextBranchBreakpoint(); + // Whether the input stop info is caused by the next branch breakpoint. jeffreytan81 wrote: This function only checks the branch breakpoint without caring whether its site is shared by others or not. Let me add a comment. https://github.com/llvm/llvm-project/pull/90930 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r b81fcd01bde51eb8976b81a2c0c19fc0645cd2ff...aa85d4ce6981670d9e652a57caa8c73324099533 lldb/test/API/functionalities/single-thread-step/TestSingleThreadStepTimeout.py `` View the diff from darker here. ``diff --- TestSingleThreadStepTimeout.py 2024-07-10 19:55:23.00 + +++ TestSingleThreadStepTimeout.py 2024-07-10 20:00:37.677522 + @@ -119,15 +119,15 @@ self.dbg.HandleCommand( "settings set target.process.thread.single-thread-plan-timeout 2000" ) self.dbg.HandleCommand("settings set target.use-fast-stepping false") self.step_over_multi_calls_helper() - + @skipIfWindows def test_step_over_deadlock_with_inner_breakpoint_continue(self): """Test step over deadlock function with inner breakpoint will trigger the breakpoint -and later continue will finish the stepping. +and later continue will finish the stepping. """ self.dbg.HandleCommand( "settings set target.process.thread.single-thread-plan-timeout 2000" ) (target, process, self.thread, _) = lldbutil.run_to_source_breakpoint( @@ -138,36 +138,43 @@ self.assertTrue(signal_main_thread_value.IsValid()) # Change signal_main_thread global variable to 1 so that worker thread loop can # terminate and move forward to signal main thread signal_main_thread_value.SetValueFromCString("1") - + # Set breakpoint on inner function call inner_breakpoint = target.BreakpointCreateByLocation( -lldb.SBFileSpec(self.main_source), line_number("main.cpp", "// Set interrupt breakpoint here"), -0, 0, lldb.SBFileSpecList(), False +lldb.SBFileSpec(self.main_source), +line_number("main.cpp", "// Set interrupt breakpoint here"), +0, +0, +lldb.SBFileSpecList(), +False, ) # Step over will hit the inner breakpoint and stop self.thread.StepOver(lldb.eOnlyThisThread) self.assertStopReason(self.thread.GetStopReason(), lldb.eStopReasonBreakpoint) thread1 = lldbutil.get_one_thread_stopped_at_breakpoint( process, inner_breakpoint ) -self.assertTrue(thread1.IsValid(), "We are indeed stopped at inner breakpoint inside deadlock_func") - +self.assertTrue( +thread1.IsValid(), +"We are indeed stopped at inner breakpoint inside deadlock_func", +) + # Continue the process should complete the step-over process.Continue() self.assertState(process.GetState(), lldb.eStateStopped) self.assertStopReason(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete) - -self.verify_hit_correct_line("// Finish step-over from breakpoint1") - + +self.verify_hit_correct_line("// Finish step-over from breakpoint1") + @skipIfWindows def test_step_over_deadlock_with_inner_breakpoint_step(self): """Test step over deadlock function with inner breakpoint will trigger the breakpoint -and later step still works +and later step still works """ self.dbg.HandleCommand( "settings set target.process.thread.single-thread-plan-timeout 2000" ) (target, process, self.thread, _) = lldbutil.run_to_source_breakpoint( @@ -178,63 +185,70 @@ self.assertTrue(signal_main_thread_value.IsValid()) # Change signal_main_thread global variable to 1 so that worker thread loop can # terminate and move forward to signal main thread signal_main_thread_value.SetValueFromCString("1") - + # Set breakpoint on inner function call inner_breakpoint = target.BreakpointCreateByLocation( -lldb.SBFileSpec(self.main_source), line_number("main.cpp", "// Set interrupt breakpoint here"), -0, 0, lldb.SBFileSpecList(), False +lldb.SBFileSpec(self.main_source), +line_number("main.cpp", "// Set interrupt breakpoint here"), +0, +0, +lldb.SBFileSpecList(), +False, ) # Step over will hit the inner breakpoint and stop self.thread.StepOver(lldb.eOnlyThisThread) self.assertStopReason(self.thread.GetStopReason(), lldb.eStopReasonBreakpoint) thread1 = lldbutil.get_one_thread_stopped_at_breakpoint( process, inner_breakpoint ) -self.assertTrue(thread1.IsValid(), "We are indeed stopped at inner breakpoint inside deadlock_func") - +self.assertTrue( +thread1.IsValid(), +"We are i
[Lldb-commits] [lldb] [lldb] Add support for displaying `__float128` variables (PR #98369)
@@ -195,10 +199,10 @@ enum Format { ///< character arrays that can contain non printable ///< characters eFormatAddressInfo,///< Describe what an address points to (func + offset - ///< with file/line, symbol + offset, data, etc) - eFormatHexFloat,///< ISO C99 hex float string - eFormatInstruction, ///< Disassemble an opcode - eFormatVoid,///< Do not print this + ///< with file/line, symbol + offset, data, etc) + eFormatHexFloat, ///< ISO C99 hex float string + eFormatInstruction,///< Disassemble an opcode + eFormatVoid, ///< Do not print this bulbazord wrote: Can you remove the formatting changes to this part? https://github.com/llvm/llvm-project/pull/98369 ___ 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 displaying `__float128` variables (PR #98369)
https://github.com/beetrees updated https://github.com/llvm/llvm-project/pull/98369 >From 1fa7e9025310f244633dd70566f63885ec5d3314 Mon Sep 17 00:00:00 2001 From: beetrees Date: Wed, 10 Jul 2024 18:49:45 +0100 Subject: [PATCH] [lldb] Add support for displaying `__float128` variables --- lldb/bindings/python/python-extensions.swig | 1 + lldb/docs/python_api_enums.rst| 2 ++ lldb/include/lldb/lldb-enumerations.h | 5 + lldb/source/Commands/CommandObjectMemory.cpp | 2 ++ lldb/source/Core/DumpDataExtractor.cpp| 7 ++- lldb/source/Core/ValueObject.cpp | 5 +++-- lldb/source/DataFormatters/FormatManager.cpp | 1 + lldb/source/DataFormatters/VectorType.cpp | 2 ++ .../TypeSystem/Clang/TypeSystemClang.cpp | 21 +++ lldb/unittests/Core/DumpDataExtractorTest.cpp | 6 ++ lldb/unittests/Symbol/TestTypeSystemClang.cpp | 2 ++ 11 files changed, 51 insertions(+), 3 deletions(-) diff --git a/lldb/bindings/python/python-extensions.swig b/lldb/bindings/python/python-extensions.swig index 4ba1607c70909..40fa76872ee96 100644 --- a/lldb/bindings/python/python-extensions.swig +++ b/lldb/bindings/python/python-extensions.swig @@ -594,6 +594,7 @@ def is_numeric_type(basic_type): if basic_type == eBasicTypeFloat: return (True,True) if basic_type == eBasicTypeDouble: return (True,True) if basic_type == eBasicTypeLongDouble: return (True,True) +if basic_type == eBasicTypeFloat128: return (True,True) if basic_type == eBasicTypeFloatComplex: return (True,True) if basic_type == eBasicTypeDoubleComplex: return (True,True) if basic_type == eBasicTypeLongDoubleComplex: return (True,True) diff --git a/lldb/docs/python_api_enums.rst b/lldb/docs/python_api_enums.rst index b6a2497ea878e..92ddfaf7b110a 100644 --- a/lldb/docs/python_api_enums.rst +++ b/lldb/docs/python_api_enums.rst @@ -295,6 +295,7 @@ Format .. py:data:: eFormatHex .. py:data:: eFormatHexUppercase .. py:data:: eFormatFloat +.. py:data:: eFormatFloat128 .. py:data:: eFormatOctal .. py:data:: eFormatOSType .. py:data:: eFormatUnicode16 @@ -1037,6 +1038,7 @@ BasicType .. py:data:: eBasicTypeFloat .. py:data:: eBasicTypeDouble .. py:data:: eBasicTypeLongDouble +.. py:data:: eBasicTypeFloat128 .. py:data:: eBasicTypeFloatComplex .. py:data:: eBasicTypeDoubleComplex .. py:data:: eBasicTypeLongDoubleComplex diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 74ff458bf87de..0201681fcb42c 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -170,6 +170,10 @@ enum Format { eFormatHex, eFormatHexUppercase, eFormatFloat, + eFormatFloat128, //< Disambiguate between 128-bit `long double` (which uses + //< `eFormatFloat`) and `__float128` (which uses + //< `eFormatFloat128`). If the value being formatted is not + //< 128 bits, then this is identical to `eFormatFloat`. eFormatOctal, eFormatOSType, ///< OS character codes encoded into an integer 'PICT' 'text' ///< etc... @@ -819,6 +823,7 @@ enum BasicType { eBasicTypeFloat, eBasicTypeDouble, eBasicTypeLongDouble, + eBasicTypeFloat128, eBasicTypeFloatComplex, eBasicTypeDoubleComplex, eBasicTypeLongDoubleComplex, diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 137b1ad981073..dde27d2df0fe5 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -156,6 +156,7 @@ class OptionGroupReadMemory : public OptionGroup { case eFormatBinary: case eFormatFloat: +case eFormatFloat128: case eFormatOctal: case eFormatDecimal: case eFormatEnum: @@ -1329,6 +1330,7 @@ class CommandObjectMemoryWrite : public CommandObjectParsed { switch (m_format_options.GetFormat()) { case kNumFormats: case eFormatFloat: // TODO: add support for floats soon + case eFormatFloat128: case eFormatCharPrintable: case eFormatBytesWithASCII: case eFormatComplex: diff --git a/lldb/source/Core/DumpDataExtractor.cpp b/lldb/source/Core/DumpDataExtractor.cpp index 826edd7bab046..faaeb0dacc6a8 100644 --- a/lldb/source/Core/DumpDataExtractor.cpp +++ b/lldb/source/Core/DumpDataExtractor.cpp @@ -334,6 +334,8 @@ static const llvm::fltSemantics &GetFloatSemantics(const TargetSP &target_sp, return llvm::APFloat::IEEEsingle(); case 8: return llvm::APFloat::IEEEdouble(); +case 16: + return llvm::APFloat::IEEEquad(); } return llvm::APFloat::Bogus(); } @@ -652,6 +654,7 @@ lldb::offset_t lldb_private::DumpDataExtractor( } } break; +case eFormatFloat128: case eFormatFloat: { TargetSP target_sp; if (exe_scope) @@ -665,7 +668,9 @@ lldb::offset_t lldb_private::DumpDataExtractor( const unsign
[Lldb-commits] [lldb] [lldb] Add support for displaying `__float128` variables (PR #98369)
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 33af4bd7a4c42f55646fa7d2826cd41384ecdece 1fa7e9025310f244633dd70566f63885ec5d3314 --extensions cpp,h -- lldb/include/lldb/lldb-enumerations.h lldb/source/Commands/CommandObjectMemory.cpp lldb/source/Core/DumpDataExtractor.cpp lldb/source/Core/ValueObject.cpp lldb/source/DataFormatters/FormatManager.cpp lldb/source/DataFormatters/VectorType.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/unittests/Core/DumpDataExtractorTest.cpp lldb/unittests/Symbol/TestTypeSystemClang.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 0201681fcb..d90a64bb65 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -199,10 +199,10 @@ enum Format { ///< character arrays that can contain non printable ///< characters eFormatAddressInfo,///< Describe what an address points to (func + offset - ///< with file/line, symbol + offset, data, etc) - eFormatHexFloat,///< ISO C99 hex float string - eFormatInstruction, ///< Disassemble an opcode - eFormatVoid,///< Do not print this + ///< with file/line, symbol + offset, data, etc) + eFormatHexFloat, ///< ISO C99 hex float string + eFormatInstruction,///< Disassemble an opcode + eFormatVoid, ///< Do not print this eFormatUnicode8, kNumFormats }; `` https://github.com/llvm/llvm-project/pull/98369 ___ 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 displaying `__float128` variables (PR #98369)
https://github.com/beetrees updated https://github.com/llvm/llvm-project/pull/98369 >From 42df2ac904995b02c0f9abcf1aacf54d17dd219e Mon Sep 17 00:00:00 2001 From: beetrees Date: Wed, 10 Jul 2024 18:49:45 +0100 Subject: [PATCH] [lldb] Add support for displaying `__float128` variables --- lldb/bindings/python/python-extensions.swig | 1 + lldb/docs/python_api_enums.rst| 2 ++ lldb/include/lldb/lldb-enumerations.h | 13 lldb/source/Commands/CommandObjectMemory.cpp | 2 ++ lldb/source/Core/DumpDataExtractor.cpp| 7 ++- lldb/source/Core/ValueObject.cpp | 5 +++-- lldb/source/DataFormatters/FormatManager.cpp | 1 + lldb/source/DataFormatters/VectorType.cpp | 2 ++ .../TypeSystem/Clang/TypeSystemClang.cpp | 21 +++ lldb/unittests/Core/DumpDataExtractorTest.cpp | 6 ++ lldb/unittests/Symbol/TestTypeSystemClang.cpp | 2 ++ 11 files changed, 55 insertions(+), 7 deletions(-) diff --git a/lldb/bindings/python/python-extensions.swig b/lldb/bindings/python/python-extensions.swig index 4ba1607c70909..40fa76872ee96 100644 --- a/lldb/bindings/python/python-extensions.swig +++ b/lldb/bindings/python/python-extensions.swig @@ -594,6 +594,7 @@ def is_numeric_type(basic_type): if basic_type == eBasicTypeFloat: return (True,True) if basic_type == eBasicTypeDouble: return (True,True) if basic_type == eBasicTypeLongDouble: return (True,True) +if basic_type == eBasicTypeFloat128: return (True,True) if basic_type == eBasicTypeFloatComplex: return (True,True) if basic_type == eBasicTypeDoubleComplex: return (True,True) if basic_type == eBasicTypeLongDoubleComplex: return (True,True) diff --git a/lldb/docs/python_api_enums.rst b/lldb/docs/python_api_enums.rst index b6a2497ea878e..92ddfaf7b110a 100644 --- a/lldb/docs/python_api_enums.rst +++ b/lldb/docs/python_api_enums.rst @@ -295,6 +295,7 @@ Format .. py:data:: eFormatHex .. py:data:: eFormatHexUppercase .. py:data:: eFormatFloat +.. py:data:: eFormatFloat128 .. py:data:: eFormatOctal .. py:data:: eFormatOSType .. py:data:: eFormatUnicode16 @@ -1037,6 +1038,7 @@ BasicType .. py:data:: eBasicTypeFloat .. py:data:: eBasicTypeDouble .. py:data:: eBasicTypeLongDouble +.. py:data:: eBasicTypeFloat128 .. py:data:: eBasicTypeFloatComplex .. py:data:: eBasicTypeDoubleComplex .. py:data:: eBasicTypeLongDoubleComplex diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index 74ff458bf87de..d90a64bb652e6 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -170,6 +170,10 @@ enum Format { eFormatHex, eFormatHexUppercase, eFormatFloat, + eFormatFloat128, //< Disambiguate between 128-bit `long double` (which uses + //< `eFormatFloat`) and `__float128` (which uses + //< `eFormatFloat128`). If the value being formatted is not + //< 128 bits, then this is identical to `eFormatFloat`. eFormatOctal, eFormatOSType, ///< OS character codes encoded into an integer 'PICT' 'text' ///< etc... @@ -195,10 +199,10 @@ enum Format { ///< character arrays that can contain non printable ///< characters eFormatAddressInfo,///< Describe what an address points to (func + offset - ///< with file/line, symbol + offset, data, etc) - eFormatHexFloat,///< ISO C99 hex float string - eFormatInstruction, ///< Disassemble an opcode - eFormatVoid,///< Do not print this + ///< with file/line, symbol + offset, data, etc) + eFormatHexFloat, ///< ISO C99 hex float string + eFormatInstruction,///< Disassemble an opcode + eFormatVoid, ///< Do not print this eFormatUnicode8, kNumFormats }; @@ -819,6 +823,7 @@ enum BasicType { eBasicTypeFloat, eBasicTypeDouble, eBasicTypeLongDouble, + eBasicTypeFloat128, eBasicTypeFloatComplex, eBasicTypeDoubleComplex, eBasicTypeLongDoubleComplex, diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 137b1ad981073..dde27d2df0fe5 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -156,6 +156,7 @@ class OptionGroupReadMemory : public OptionGroup { case eFormatBinary: case eFormatFloat: +case eFormatFloat128: case eFormatOctal: case eFormatDecimal: case eFormatEnum: @@ -1329,6 +1330,7 @@ class CommandObjectMemoryWrite : public CommandObjectParsed { switch (m_format_options.GetFormat()) { case kNumFormats: case eFormatFloat: // TODO: add support for floats soon + case eFormatFloat128: case eFormatCharPrintable: case eFormatBytesWithASCII: case eFormatComplex: diff --git a/lldb/source/Core/DumpDataExtractor.cpp b/lldb/sourc
[Lldb-commits] [lldb] [lldb] Add support for displaying `__float128` variables (PR #98369)
@@ -195,10 +199,10 @@ enum Format { ///< character arrays that can contain non printable ///< characters eFormatAddressInfo,///< Describe what an address points to (func + offset - ///< with file/line, symbol + offset, data, etc) - eFormatHexFloat,///< ISO C99 hex float string - eFormatInstruction, ///< Disassemble an opcode - eFormatVoid,///< Do not print this + ///< with file/line, symbol + offset, data, etc) + eFormatHexFloat, ///< ISO C99 hex float string + eFormatInstruction,///< Disassemble an opcode + eFormatVoid, ///< Do not print this beetrees wrote: Unfortunately `git clang-format` made those changes, and CI will complain if I remove them. https://github.com/llvm/llvm-project/pull/98369 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Don't crash on malformed filesets (PR #98388)
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/98388 The memory read can fail for a malformed fileset. Handle it gracefully instead of passing a nullptr to the std::string constructor. rdar://131477833 >From 30f9ae1d2a086e7cf6ef713cc1e7ca91490169e5 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 10 Jul 2024 14:11:15 -0700 Subject: [PATCH] [lldb] Don't crash on malformed filesets The memory read can fail for a malformed fileset. Handle it gracefully instead of passing a nullptr to the std::string constructor. rdar://131477833 --- .../Mach-O-Fileset/ObjectContainerMachOFileset.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp b/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp index 2dc71d85777ca..76141f7976413 100644 --- a/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp +++ b/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp @@ -159,9 +159,9 @@ ParseFileset(DataExtractor &data, mach_header header, fileset_entry_command entry; data.CopyData(load_cmd_offset, sizeof(fileset_entry_command), &entry); lldb::offset_t entry_id_offset = load_cmd_offset + entry.entry_id.offset; - const char *id = data.GetCStr(&entry_id_offset); - entries.emplace_back(entry.vmaddr + slide, entry.fileoff, - std::string(id)); + if (const char *id = data.GetCStr(&entry_id_offset)) +entries.emplace_back(entry.vmaddr + slide, entry.fileoff, + std::string(id)); } offset = load_cmd_offset + lc.cmdsize; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Don't crash on malformed filesets (PR #98388)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) Changes The memory read can fail for a malformed fileset. Handle it gracefully instead of passing a nullptr to the std::string constructor. rdar://131477833 --- Full diff: https://github.com/llvm/llvm-project/pull/98388.diff 1 Files Affected: - (modified) lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp (+3-3) ``diff diff --git a/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp b/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp index 2dc71d85777ca..76141f7976413 100644 --- a/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp +++ b/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp @@ -159,9 +159,9 @@ ParseFileset(DataExtractor &data, mach_header header, fileset_entry_command entry; data.CopyData(load_cmd_offset, sizeof(fileset_entry_command), &entry); lldb::offset_t entry_id_offset = load_cmd_offset + entry.entry_id.offset; - const char *id = data.GetCStr(&entry_id_offset); - entries.emplace_back(entry.vmaddr + slide, entry.fileoff, - std::string(id)); + if (const char *id = data.GetCStr(&entry_id_offset)) +entries.emplace_back(entry.vmaddr + slide, entry.fileoff, + std::string(id)); } offset = load_cmd_offset + lc.cmdsize; `` https://github.com/llvm/llvm-project/pull/98388 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Don't crash on malformed filesets (PR #98388)
https://github.com/jasonmolenda approved this pull request. LGTM. We'll skip any fileset entries that we can't read the filename of. https://github.com/llvm/llvm-project/pull/98388 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Don't crash on malformed filesets (PR #98388)
https://github.com/JDevlieghere closed https://github.com/llvm/llvm-project/pull/98388 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 919caa8 - [lldb] Don't crash on malformed filesets (#98388)
Author: Jonas Devlieghere Date: 2024-07-10T14:16:56-07:00 New Revision: 919caa89ee3323228ccb1dd065d86805b34b9b6a URL: https://github.com/llvm/llvm-project/commit/919caa89ee3323228ccb1dd065d86805b34b9b6a DIFF: https://github.com/llvm/llvm-project/commit/919caa89ee3323228ccb1dd065d86805b34b9b6a.diff LOG: [lldb] Don't crash on malformed filesets (#98388) The memory read can fail for a malformed fileset. Handle it gracefully instead of passing a nullptr to the std::string constructor. rdar://131477833 Added: Modified: lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp Removed: diff --git a/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp b/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp index 2dc71d85777ca..76141f7976413 100644 --- a/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp +++ b/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp @@ -159,9 +159,9 @@ ParseFileset(DataExtractor &data, mach_header header, fileset_entry_command entry; data.CopyData(load_cmd_offset, sizeof(fileset_entry_command), &entry); lldb::offset_t entry_id_offset = load_cmd_offset + entry.entry_id.offset; - const char *id = data.GetCStr(&entry_id_offset); - entries.emplace_back(entry.vmaddr + slide, entry.fileoff, - std::string(id)); + if (const char *id = data.GetCStr(&entry_id_offset)) +entries.emplace_back(entry.vmaddr + slide, entry.fileoff, + std::string(id)); } offset = load_cmd_offset + lc.cmdsize; ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Support remote run of Shell tests (PR #95986)
dzhidzhoev wrote: Created RFC https://discourse.llvm.org/t/rfc-lldb-support-remote-run-of-shell-tests/80072, hope it fosters the discussion. https://github.com/llvm/llvm-project/pull/95986 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [lld] [lldb] [llvm] [BOLT] Match blocks with calls as anchors (PR #96596)
https://github.com/shawbyoung closed https://github.com/llvm/llvm-project/pull/96596 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
Jlalond wrote: > > None of the SB API methods return any STL types/containers, like the > > std::optionals returned in this PR. I worry if this will make the bridging > > to other languages more complicated, but it's never something I've thought > > about before. @jimingham @bulbazord @clayborg @JDevlieghere may have a more > > informed opinion on whether this is important or not. > > Yeah, we've been discussing introducing an `SBOptional` type at some point to > be easier to bridge it with python but we should refrain from using the STL > as return types / arguments for now. > > Besides that, I've also noticed that your classes are named `CoreDumpOption`. > On Apple platform, we call these "corefiles" so to be consistent accros > various platform, lets just drop the "Dump" part from the class / method > names and call it `CoreOption` @clayborg actually mentioned this when I started work originally that we should avoid STL types. It seems I forgot while figuring out SWIG. As for `CoreOptions` vs `CoreDumpOptions`, the primary flavors I know of are Window's Kernel/Minidump and the ELF Coredumps. I think `CoreDumpOptions` is less ambiguous for that reason https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
https://github.com/Jlalond unassigned https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
https://github.com/Jlalond unassigned https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
https://github.com/Jlalond unassigned https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)
walter-erquinigo wrote: This is a very benign change, so I'll be merging it. Happy to make change post-merge if anyone provides any feedback. https://github.com/llvm/llvm-project/pull/97871 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Support throw and catch exception breakpoints for dynamica… (PR #97871)
https://github.com/walter-erquinigo closed https://github.com/llvm/llvm-project/pull/97871 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 541f22e - [lldb-dap] Support throw and catch exception breakpoints for dynamica… (#97871)
Author: Walter Erquinigo Date: 2024-07-10T19:05:38-04:00 New Revision: 541f22ee361a8b3029ac898db29d3e9184fb1671 URL: https://github.com/llvm/llvm-project/commit/541f22ee361a8b3029ac898db29d3e9184fb1671 DIFF: https://github.com/llvm/llvm-project/commit/541f22ee361a8b3029ac898db29d3e9184fb1671.diff LOG: [lldb-dap] Support throw and catch exception breakpoints for dynamica… (#97871) …lly registered languages First of all, this is done to support exceptions for the Mojo language, but it's done in a way that will benefit any other plugin language. 1. I added a new lldb-dap CLI argument (not DAP field) called `pre-init-commands`. These commands are executed before DAP initialization. The other `init-commands` are executed after DAP initialization. It's worth mentioning that the debug adapter returns to VSCode the list of supported exception breakpoints during DAP initialization, which means that I need to register the Mojo plugin before that initialization step, hence the need for `pre-init-commands`. In general, language plugins should be registered in that step, as they affect the capabilities of the debugger. 2. I added a set of APIs for lldb-dap to query information of each language related to exception breakpoints. E.g. whether a language supports throw or catch breakpoints, how the throw keyword is called in each particular language, etc. 3. I'm realizing that the Swift support for exception breakpoints in lldb-dap should have been implemented in this way, instead of hardcoding it. Added: Modified: lldb/include/lldb/API/SBLanguageRuntime.h lldb/include/lldb/Target/Language.h lldb/source/API/SBLanguageRuntime.cpp lldb/tools/lldb-dap/DAP.cpp lldb/tools/lldb-dap/DAP.h lldb/tools/lldb-dap/Options.td lldb/tools/lldb-dap/lldb-dap.cpp Removed: diff --git a/lldb/include/lldb/API/SBLanguageRuntime.h b/lldb/include/lldb/API/SBLanguageRuntime.h index 38aac05d490c1..011015ec46463 100644 --- a/lldb/include/lldb/API/SBLanguageRuntime.h +++ b/lldb/include/lldb/API/SBLanguageRuntime.h @@ -18,6 +18,32 @@ class SBLanguageRuntime { static lldb::LanguageType GetLanguageTypeFromString(const char *string); static const char *GetNameForLanguageType(lldb::LanguageType language); + + /// Returns whether the given language is any version of C++. + static bool LanguageIsCPlusPlus(lldb::LanguageType language); + + /// Returns whether the given language is Obj-C or Obj-C++. + static bool LanguageIsObjC(lldb::LanguageType language); + + /// Returns whether the given language is any version of C, C++ or Obj-C. + static bool LanguageIsCFamily(lldb::LanguageType language); + + /// Returns whether the given language supports exception breakpoints on + /// throw statements. + static bool SupportsExceptionBreakpointsOnThrow(lldb::LanguageType language); + + /// Returns whether the given language supports exception breakpoints on + /// catch statements. + static bool SupportsExceptionBreakpointsOnCatch(lldb::LanguageType language); + + /// Returns the keyword used for throw statements in the given language, e.g. + /// Python uses \b raise. Returns \b nullptr if the language is not supported. + static const char *GetThrowKeywordForLanguage(lldb::LanguageType language); + + /// Returns the keyword used for catch statements in the given language, e.g. + /// Python uses \b except. Returns \b nullptr if the language is not + /// supported. + static const char *GetCatchKeywordForLanguage(lldb::LanguageType language); }; } // namespace lldb diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h index 83bf7635e369a..41d8eeef469ea 100644 --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -371,6 +371,14 @@ class Language : public PluginInterface { /// a corresponding LanguageRuntime plugin. virtual bool SupportsExceptionBreakpointsOnCatch() const { return false; } + /// Returns the keyword used for throw statements in this language, e.g. + /// Python uses \b raise. Defaults to \b throw. + virtual llvm::StringRef GetThrowKeyword() const { return "throw"; } + + /// Returns the keyword used for catch statements in this language, e.g. + /// Python uses \b except. Defaults to \b catch. + virtual llvm::StringRef GetCatchKeyword() const { return "catch"; } + protected: // Classes that inherit from Language can see and modify these diff --git a/lldb/source/API/SBLanguageRuntime.cpp b/lldb/source/API/SBLanguageRuntime.cpp index d571f282fce03..958652ab6f136 100644 --- a/lldb/source/API/SBLanguageRuntime.cpp +++ b/lldb/source/API/SBLanguageRuntime.cpp @@ -26,3 +26,43 @@ SBLanguageRuntime::GetNameForLanguageType(lldb::LanguageType language) { return Language::GetNameForLanguageType(language); } + +bool SBLanguageRuntime::LanguageIsCPlusPlus(lldb::LanguageType language) { + return Language::Languag
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
jimingham wrote: I prefer CoreDumpOptions, because CoreOptions could mean "options for reading in core files" or "options for writing core files", but CoreDumpOptions - reading the Dump as a verb - resolves the ambiguity. Or you could use CoreFileWritingOptions if you want to be really explicit. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][man][nfc] Don't register a markdown parser when building man packages (PR #98420)
https://github.com/alanzhao1 created https://github.com/llvm/llvm-project/pull/98420 This reduces Sphinx dependencies for building lldb man pages as lldb man pages don't use markdown. >From fab10fb2efe8265d1b403a650dbd2d3348f29b73 Mon Sep 17 00:00:00 2001 From: Alan Zhao Date: Wed, 10 Jul 2024 15:56:39 -0700 Subject: [PATCH] [lldb][man][nfc] Don't register a markdown parser when building man pages This reduces Sphinx dependencies for building lldb man pages as lldb man pages don't use markdown. --- lldb/docs/conf.py | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lldb/docs/conf.py b/lldb/docs/conf.py index 27a1cd7c3c31a..805a6dc19ac81 100644 --- a/lldb/docs/conf.py +++ b/lldb/docs/conf.py @@ -89,9 +89,13 @@ # The suffix of source filenames. source_suffix = { ".rst": "restructuredtext", -".md": "markdown", } +# Man pages do not use markdown pages, so we don't need to register a markdown +# parser. +if not building_man_page: + source_suffix[".md"] = "markdown" + # The encoding of source files. # source_encoding = 'utf-8-sig' ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][man][nfc] Don't register a markdown parser when building man packages (PR #98420)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Alan Zhao (alanzhao1) Changes This reduces Sphinx dependencies for building lldb man pages as lldb man pages don't use markdown. --- Full diff: https://github.com/llvm/llvm-project/pull/98420.diff 1 Files Affected: - (modified) lldb/docs/conf.py (+5-1) ``diff diff --git a/lldb/docs/conf.py b/lldb/docs/conf.py index 27a1cd7c3c31a..805a6dc19ac81 100644 --- a/lldb/docs/conf.py +++ b/lldb/docs/conf.py @@ -89,9 +89,13 @@ # The suffix of source filenames. source_suffix = { ".rst": "restructuredtext", -".md": "markdown", } +# Man pages do not use markdown pages, so we don't need to register a markdown +# parser. +if not building_man_page: + source_suffix[".md"] = "markdown" + # The encoding of source files. # source_encoding = 'utf-8-sig' `` https://github.com/llvm/llvm-project/pull/98420 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][man][nfc] Don't register a markdown parser when building man packages (PR #98420)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/98420 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][man][nfc] Don't register a markdown parser when building man packages (PR #98420)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r 131eb30584333b61888735b4fefe53dd25b741e0...fab10fb2efe8265d1b403a650dbd2d3348f29b73 lldb/docs/conf.py `` View the diff from darker here. ``diff --- conf.py 2024-07-10 22:56:39.00 + +++ conf.py 2024-07-11 00:19:37.080545 + @@ -92,11 +92,11 @@ } # Man pages do not use markdown pages, so we don't need to register a markdown # parser. if not building_man_page: - source_suffix[".md"] = "markdown" +source_suffix[".md"] = "markdown" # The encoding of source files. # source_encoding = 'utf-8-sig' # The master toctree document. `` https://github.com/llvm/llvm-project/pull/98420 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][man][nfc] Don't register a markdown parser when building man packages (PR #98420)
https://github.com/alanzhao1 updated https://github.com/llvm/llvm-project/pull/98420 >From fab10fb2efe8265d1b403a650dbd2d3348f29b73 Mon Sep 17 00:00:00 2001 From: Alan Zhao Date: Wed, 10 Jul 2024 15:56:39 -0700 Subject: [PATCH 1/2] [lldb][man][nfc] Don't register a markdown parser when building man pages This reduces Sphinx dependencies for building lldb man pages as lldb man pages don't use markdown. --- lldb/docs/conf.py | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lldb/docs/conf.py b/lldb/docs/conf.py index 27a1cd7c3c31a..805a6dc19ac81 100644 --- a/lldb/docs/conf.py +++ b/lldb/docs/conf.py @@ -89,9 +89,13 @@ # The suffix of source filenames. source_suffix = { ".rst": "restructuredtext", -".md": "markdown", } +# Man pages do not use markdown pages, so we don't need to register a markdown +# parser. +if not building_man_page: + source_suffix[".md"] = "markdown" + # The encoding of source files. # source_encoding = 'utf-8-sig' >From f89c189303a4a22e9087b190612b7d483238b703 Mon Sep 17 00:00:00 2001 From: Alan Zhao Date: Wed, 10 Jul 2024 17:30:44 -0700 Subject: [PATCH 2/2] fix formatting --- lldb/docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/docs/conf.py b/lldb/docs/conf.py index 805a6dc19ac81..233cdf7501934 100644 --- a/lldb/docs/conf.py +++ b/lldb/docs/conf.py @@ -94,7 +94,7 @@ # Man pages do not use markdown pages, so we don't need to register a markdown # parser. if not building_man_page: - source_suffix[".md"] = "markdown" +source_suffix[".md"] = "markdown" # The encoding of source files. # source_encoding = 'utf-8-sig' ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
cmtice wrote: > > BTW, I have verified that this stripped down version passes all the frame > > variable tests in LLDB. > > That's cool. Just to confirm, have you looked at replacing `target variable` > as well? It uses the same language as "frame var" under the hood, which but > it has a somewhat different starting point (it basically ignores the local > scope and looks only at globals), which means it may need some special > handling in the new parser. > No, I have not looked at 'target variable' at this time. > > I agree with Jim re the DIL language: We should only have a single language > > definition, and it can be a superset of the languages it supports. So there > > may be parts of it that belong to particular languages, but that does not > > mean it supports those languages exclusively. > > This direction makes sense to me, but I think that's all the more reason to > be conservative/cautious about adding new features to the language. We can't > just put every possible feature of every language into it, as we'd end up > with a unmaintainable mess. https://github.com/llvm/llvm-project/pull/95738 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
@@ -0,0 +1,446 @@ +//===-- DILAST.h *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_DIL_AST_H_ +#define LLDB_DIL_AST_H_ + +#include +#include +#include +#include +#include + +#include "lldb/Core/ValueObject.h" +#include "lldb/Symbol/Type.h" +#include "lldb/Symbol/TypeList.h" +#include "lldb/Target/LanguageRuntime.h" +#include "lldb/Utility/ConstString.h" +#include "clang/Basic/SourceLocation.h" +#include "clang/Basic/TokenKinds.h" +#include "llvm/ADT/APFloat.h" +#include "llvm/ADT/APInt.h" + +namespace lldb_private { + +/// Struct to hold information about member fields. Used by the parser for the +/// Data Inspection Language (DIL). +struct DILMemberInfo { + std::optional name; + CompilerType type; + bool is_bitfield; + uint32_t bitfield_size_in_bits; cmtice wrote: Some bitfields have an undefined size, e.g. result of a ternary operation. So I'd rather keep these two fields separate. https://github.com/llvm/llvm-project/pull/95738 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
@@ -0,0 +1,446 @@ +//===-- DILAST.h *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_DIL_AST_H_ +#define LLDB_DIL_AST_H_ + +#include +#include +#include +#include +#include + +#include "lldb/Core/ValueObject.h" +#include "lldb/Symbol/Type.h" +#include "lldb/Symbol/TypeList.h" +#include "lldb/Target/LanguageRuntime.h" +#include "lldb/Utility/ConstString.h" +#include "clang/Basic/SourceLocation.h" +#include "clang/Basic/TokenKinds.h" +#include "llvm/ADT/APFloat.h" +#include "llvm/ADT/APInt.h" + +namespace lldb_private { + +/// Struct to hold information about member fields. Used by the parser for the +/// Data Inspection Language (DIL). +struct DILMemberInfo { + std::optional name; + CompilerType type; + bool is_bitfield; + uint32_t bitfield_size_in_bits; + bool is_synthetic; + bool is_dynamic; + lldb::ValueObjectSP val_obj_sp; + + explicit operator bool() const { return type.IsValid(); } cmtice wrote: Could you please elaborate? I don't quite understand what you are suggesting here. https://github.com/llvm/llvm-project/pull/95738 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
@@ -0,0 +1,446 @@ +//===-- DILAST.h *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_DIL_AST_H_ +#define LLDB_DIL_AST_H_ + +#include +#include +#include +#include +#include + +#include "lldb/Core/ValueObject.h" +#include "lldb/Symbol/Type.h" +#include "lldb/Symbol/TypeList.h" +#include "lldb/Target/LanguageRuntime.h" +#include "lldb/Utility/ConstString.h" +#include "clang/Basic/SourceLocation.h" +#include "clang/Basic/TokenKinds.h" +#include "llvm/ADT/APFloat.h" +#include "llvm/ADT/APInt.h" + +namespace lldb_private { + +/// Struct to hold information about member fields. Used by the parser for the +/// Data Inspection Language (DIL). +struct DILMemberInfo { + std::optional name; + CompilerType type; + bool is_bitfield; + uint32_t bitfield_size_in_bits; + bool is_synthetic; + bool is_dynamic; + lldb::ValueObjectSP val_obj_sp; + + explicit operator bool() const { return type.IsValid(); } +}; + +/// This determines if the type is a shared, unique or weak pointer, either +/// from stdlibc++ or libc+++. +bool IsSmartPtrType(CompilerType type); + +/// Finds the member field with the given name and type, stores the child index +/// corresponding to the field in the idx vector and returns a DILMemberInfo +/// struct with appropriate information about the field. +DILMemberInfo GetFieldWithNameIndexPath(lldb::ValueObjectSP lhs_val_sp, +CompilerType type, +const std::string &name, +std::vector *idx, +CompilerType empty_type, +bool use_synthetic, bool is_dynamic); + +std::tuple> +GetMemberInfo(lldb::ValueObjectSP lhs_val_sp, CompilerType type, + const std::string &name, bool use_synthetic); + +/// Get the appropriate ValueObjectSP, consulting the use_dynamic and +/// use_synthetic options passed, acquiring the process & target locks if +/// appropriate. +lldb::ValueObjectSP +DILGetSPWithLock(lldb::ValueObjectSP valobj_sp, + lldb::DynamicValueType use_dynamic = lldb::eNoDynamicValues, + bool use_synthetic = false); + +/// The various types DIL AST nodes (used by the DIL parser). +enum class DILNodeKind { + kDILErrorNode, + kLiteralNode, + kIdentifierNode, + kBuiltinFunctionCallNode, + kCStyleCastNode, + kMemberOfNode, + kArraySubscriptNode, + kUnaryOpNode, + kSmartPtrToPtrDecay +}; + +/// The C-Style casts allowed by DIL. +enum class CStyleCastKind { + kArithmetic, + kEnumeration, + kPointer, + kNullptr, + kReference, +}; + +/// The Unary operators recognized by DIL. +enum class UnaryOpKind { + AddrOf, // "&" + Deref, // "*" + Minus, // "-" +}; + +/// Given a string representing a type, returns the CompilerType corresponding +/// to the named type, if it exists. +CompilerType +ResolveTypeByName(const std::string &name, + std::shared_ptr ctx_scope); + +/// Quick lookup to check if a type name already exists in a +/// name-to-CompilerType map the DIL parser keeps of previously found +/// name/type pairs. +bool IsContextVar(const std::string &name); + +/// Checks to see if the CompilerType is a Smart Pointer (shared, unique, weak) +/// or not. Only applicable for C++, which is why this is here and not part of +/// the CompilerType class. cmtice wrote: When we go to dereference a pointer we need to know whether or not it's a smart pointer, because if it's a smart pointer we need to get at the pointer inside before we can dereference it. So we use IsSmartPtrType to determine whether or not to insert this layer of unwrapping (converting the smart ptr into a normal ptr). https://github.com/llvm/llvm-project/pull/95738 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix a bug for PT_TLS segments getting loaded when they shouldn't. (PR #98432)
https://github.com/clayborg created https://github.com/llvm/llvm-project/pull/98432 PT_LOAD and PT_TLS segments are top level sections in the ObjectFileELF section list. The two segments can often have the same program header p_vaddr and p_paddr values and this can cause section load list issues in LLDB if we load the PT_TLS segments. What happens is the SectionLoadList::m_addr_to_sect, when a library is loaded, will first map one of the sections named "PT_LOAD[0]" with the load address that matches the p_vaddr entry from the program header. Then the "PT_TLS[0]" would come along and try to load this section at the same address. This would cause the "PT_LOAD[0]" section to be unloaded as the SectionLoadList::m_addr_to_sect would replace the value for the matching p_vaddr with the last section to be seen. The sizes of the PT_TLS and PT_LOAD that have the same p_vaddr value don't need to have the same byte size, so this could cause lookups to fail for an addresses in the "PT_LOAD[0]" section or any of its children if the offset is greater than the offset size of the PT_TLS segment. It could also cause us to incorrectly attribute addresses from the "PT_LOAD[0]" to the "PT_TLS[0]" segment when doing lookups for offset that are less than the size of the PT_TLS segment. This fix stops us from loading PT_TLS segments in the section load lists and will prevent the bugs that resulted from this. No addresses the the DWARF refer to TLS data with a "file address" in any way. They all have TLS DWARF location expressions to locate these variables. We also don't have any support for having actual thread specific sections and having those sections resolve to something different for each thread, so there currently is no point in loading thread specific sections. Both the ObjectFileMachO and ObjectFileCOFF both ignore thread specific sections at the moment, so this brings the ObjectFileELF to parity with those plug-ins. I added a test into an existing test to verify that things work as expected. Prior to this fix with a real binary, the output of "target dump section-load-list" would look like this for the old LLDB: ``` // (lldb) target dump section-load-list // addr = 0x, section = 0x55d46ab8c510: 0xfffd container[0x-0x0628) r-- 0x 0x0628 0x a.out.PT_LOAD[0] // addr = 0x1000, section = 0x55d46ab8b0c0: 0xfffc container[0x1000-0x1185) r-x 0x1000 0x0185 0x a.out.PT_LOAD[1] // addr = 0x2000, section = 0x55d46ac040f0: 0xfffb container[0x2000-0x20cc) r-- 0x2000 0x00cc 0x a.out.PT_LOAD[2] // addr = 0x3db0, section = 0x55d46ab7cef0: 0xfff6 container[0x3db0-0x3db4) r-- 0x2db0 0x 0x a.out.PT_TLS[0] ``` And this for the fixed LLDB: ``` // (lldb) target dump section-load-list // addr = 0x, section = 0x105f0a9a8: 0xfffd container[0x-0x0628) r-- 0x 0x0628 0x a.out.PT_LOAD[0] // addr = 0x1000, section = 0x105f0adb8: 0xfffc container[0x1000-0x1185) r-x 0x1000 0x0185 0x a.out.PT_LOAD[1] // addr = 0x2000, section = 0x105f0af48: 0xfffb container[0x2000-0x20cc) r-- 0x2000 0x00cc 0x a.out.PT_LOAD[2] // addr = 0x3db0, section = 0x105f0b078: 0xfffa container[0x3db0-0x4028) rw- 0x2db0 0x0274 0x a.out.PT_LOAD[3] ``` We can see that previously the "PT_LOAD[3]" segment would be removed from the section load list, and after the fix it remains and there is on PT_TLS in the loaded sections. >From ede6fc3939cbdf3a5744ff5e6919551a4b5dd438 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Wed, 10 Jul 2024 21:49:04 -0700 Subject: [PATCH] Fix a bug for PT_TLS segments getting loaded when they shouldn't. PT_LOAD and PT_TLS segments are top level sections in the ObjectFileELF section list. The two segments can often have the same program header p_vaddr and p_paddr values and this can cause section load list issues in LLDB if we load the PT_TLS segments. What happens is the SectionLoadList::m_addr_to_sect, when a library is loaded, will first map one of the sections named "PT_LOAD[0]" with the load address that matches the p_vaddr entry from the program header. Then the "PT_TLS[0]" would come along and try to load this section at the same address. This would cause the "PT_LOAD[0]" section to be unloaded as the SectionLoadList::m_addr_to_sect would replace the value for the matching p_vaddr with the last section to be seen. The sizes of the PT_TLS and PT_LOAD that have the same p_vaddr value
[Lldb-commits] [lldb] [lldb] Fix a bug for PT_TLS segments getting loaded when they shouldn't. (PR #98432)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Greg Clayton (clayborg) Changes PT_LOAD and PT_TLS segments are top level sections in the ObjectFileELF section list. The two segments can often have the same program header p_vaddr and p_paddr values and this can cause section load list issues in LLDB if we load the PT_TLS segments. What happens is the SectionLoadList::m_addr_to_sect, when a library is loaded, will first map one of the sections named "PT_LOAD[0]" with the load address that matches the p_vaddr entry from the program header. Then the "PT_TLS[0]" would come along and try to load this section at the same address. This would cause the "PT_LOAD[0]" section to be unloaded as the SectionLoadList::m_addr_to_sect would replace the value for the matching p_vaddr with the last section to be seen. The sizes of the PT_TLS and PT_LOAD that have the same p_vaddr value don't need to have the same byte size, so this could cause lookups to fail for an addresses in the "PT_LOAD[0]" section or any of its children if the offset is greater than the offset size of the PT_TLS segment. It could also cause us to incorrectly attribute addresses from the "PT_LOAD[0]" to the "PT_TLS[0]" segment when doing lookups for offset that are less than the size of the PT_TLS segment. This fix stops us from loading PT_TLS segments in the section load lists and will prevent the bugs that resulted from this. No addresses the the DWARF refer to TLS data with a "file address" in any way. They all have TLS DWARF location expressions to locate these variables. We also don't have any support for having actual thread specific sections and having those sections resolve to something different for each thread, so there currently is no point in loading thread specific sections. Both the ObjectFileMachO and ObjectFileCOFF both ignore thread specific sections at the moment, so this brings the ObjectFileELF to parity with those plug-ins. I added a test into an existing test to verify that things work as expected. Prior to this fix with a real binary, the output of "target dump section-load-list" would look like this for the old LLDB: ``` // (lldb) target dump section-load-list // addr = 0x, section = 0x55d46ab8c510: 0xfffd container[0x-0x0628) r-- 0x 0x0628 0x a.out.PT_LOAD[0] // addr = 0x1000, section = 0x55d46ab8b0c0: 0xfffc container[0x1000-0x1185) r-x 0x1000 0x0185 0x a.out.PT_LOAD[1] // addr = 0x2000, section = 0x55d46ac040f0: 0xfffb container[0x2000-0x20cc) r-- 0x2000 0x00cc 0x a.out.PT_LOAD[2] // addr = 0x3db0, section = 0x55d46ab7cef0: 0xfff6 container[0x3db0-0x3db4) r-- 0x2db0 0x 0x a.out.PT_TLS[0] ``` And this for the fixed LLDB: ``` // (lldb) target dump section-load-list // addr = 0x, section = 0x105f0a9a8: 0xfffd container[0x-0x0628) r-- 0x 0x0628 0x a.out.PT_LOAD[0] // addr = 0x1000, section = 0x105f0adb8: 0xfffc container[0x1000-0x1185) r-x 0x1000 0x0185 0x a.out.PT_LOAD[1] // addr = 0x2000, section = 0x105f0af48: 0xfffb container[0x2000-0x20cc) r-- 0x2000 0x00cc 0x a.out.PT_LOAD[2] // addr = 0x3db0, section = 0x105f0b078: 0xfffa container[0x3db0-0x4028) rw- 0x2db0 0x0274 0x a.out.PT_LOAD[3] ``` We can see that previously the "PT_LOAD[3]" segment would be removed from the section load list, and after the fix it remains and there is on PT_TLS in the loaded sections. --- Full diff: https://github.com/llvm/llvm-project/pull/98432.diff 2 Files Affected: - (modified) lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (+14) - (modified) lldb/test/Shell/ObjectFile/ELF/PT_TLS-overlap-PT_LOAD.yaml (+24-1) ``diff diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index 5c6b475044be5..51bd34e95c77d 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -717,6 +717,20 @@ bool ObjectFileELF::SetLoadAddress(Target &target, lldb::addr_t value, // Iterate through the object file sections to find all of the sections // that have SHF_ALLOC in their flag bits. SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx)); + +// PT_TLS segments can have the same p_vaddr and p_paddr as other +// PT_LOAD segments so we shouldn't load them. If we do load them, then +// the Sectio
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
https://github.com/clayborg edited https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,67 @@ +//===-- SBCoreDumpOptions.cpp ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/API/SBCoreDumpOptions.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Symbol/CoreDumpOptions.h" +#include "lldb/Utility/Instrumentation.h" + +#include "Utils.h" + +using namespace lldb; + +SBCoreDumpOptions::SBCoreDumpOptions(const char *filePath) { + LLDB_INSTRUMENT_VA(this, filePath); + lldb_private::FileSpec fspec(filePath); + lldb_private::FileSystem::Instance().Resolve(fspec); + m_opaque_up = std::make_unique(fspec); +} + +SBCoreDumpOptions::SBCoreDumpOptions(const SBCoreDumpOptions &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); + + m_opaque_up = clone(rhs.m_opaque_up); +} + +const SBCoreDumpOptions & +SBCoreDumpOptions::operator=(const SBCoreDumpOptions &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); + + if (this != &rhs) +m_opaque_up = clone(rhs.m_opaque_up); + return *this; +} + +void SBCoreDumpOptions::SetCoreDumpPluginName(const char *name) { + m_opaque_up->SetCoreDumpPluginName(name); +} + +void SBCoreDumpOptions::SetCoreDumpStyle(lldb::SaveCoreStyle style) { + m_opaque_up->SetCoreDumpStyle(style); +} + +const std::optional +SBCoreDumpOptions::GetCoreDumpPluginName() const { + const auto &name = m_opaque_up->GetCoreDumpPluginName(); clayborg wrote: We don't want to return std::optional or any STL across library boundaries in our pubic API. We have two options here: 1) Have the `lldb_private::CoreDumpOptions::GetCoreDumpPluginName()` return an optional like it already is and return a NULL by doing: ``` name = m_opaque_up->GetCoreDumpPluginName(); if (name.has_value()) return name->data(); return NULL; ``` 2) change `lldb_private::CoreDumpOptions::GetCoreDumpPluginName()` to return a "const char *" and do the work in that accessor. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
https://github.com/clayborg requested changes to this pull request. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -55,8 +56,7 @@ typedef ObjectFile *(*ObjectFileCreateMemoryInstance)( const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t offset); typedef bool (*ObjectFileSaveCore)(const lldb::ProcessSP &process_sp, - const FileSpec &outfile, - lldb::SaveCoreStyle &core_style, + lldb_private::CoreDumpOptions &core_options, clayborg wrote: make const: `const lldb_private::CoreDumpOptions &core_options` https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,59 @@ +//===-- SBCoreDumpOptions.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBCOREDUMPOPTIONS_H +#define LLDB_API_SBCOREDUMPOPTIONS_H + +#include "lldb/API/SBDefines.h" +#include "lldb/Symbol/CoreDumpOptions.h" + +namespace lldb { + +class LLDB_API SBCoreDumpOptions { +public: + SBCoreDumpOptions(const char *filePath); + SBCoreDumpOptions(const lldb::SBCoreDumpOptions &rhs); + ~SBCoreDumpOptions() = default; + + const SBCoreDumpOptions &operator=(const lldb::SBCoreDumpOptions &rhs); + + /// Set the Core dump plugin name. + /// + /// \param plugin Name of the object file plugin. + void SetCoreDumpPluginName(const char *plugin); + + /// Get the Core dump plugin name, if set. + /// + /// \return The name of the plugin, or nullopt if not set. + const std::optional GetCoreDumpPluginName() const; + + /// Set the Core dump style. + /// + /// \param style The style of the core dump. + void SetCoreDumpStyle(lldb::SaveCoreStyle style); + + /// Get the Core dump style, if set. + /// + /// \return The core dump style, or nullopt if not set. + const std::optional GetCoreDumpStyle() const; + + /// Get the output file path + /// + /// \return The output file path. + const char *GetOutputFile() const; clayborg wrote: Return a `lldb::SBFileSpec` here instead of a `const char *`. We also need a way to set this output file value as well, so add an accessor: ``` void SetOutputFile(lldb::SBFileSpec &file); ``` https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,59 @@ +//===-- SBCoreDumpOptions.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBCOREDUMPOPTIONS_H +#define LLDB_API_SBCOREDUMPOPTIONS_H + +#include "lldb/API/SBDefines.h" +#include "lldb/Symbol/CoreDumpOptions.h" + +namespace lldb { + +class LLDB_API SBCoreDumpOptions { +public: + SBCoreDumpOptions(const char *filePath); + SBCoreDumpOptions(const lldb::SBCoreDumpOptions &rhs); + ~SBCoreDumpOptions() = default; + + const SBCoreDumpOptions &operator=(const lldb::SBCoreDumpOptions &rhs); + + /// Set the Core dump plugin name. + /// + /// \param plugin Name of the object file plugin. + void SetCoreDumpPluginName(const char *plugin); + + /// Get the Core dump plugin name, if set. + /// + /// \return The name of the plugin, or nullopt if not set. + const std::optional GetCoreDumpPluginName() const; + + /// Set the Core dump style. + /// + /// \param style The style of the core dump. + void SetCoreDumpStyle(lldb::SaveCoreStyle style); + + /// Get the Core dump style, if set. + /// + /// \return The core dump style, or nullopt if not set. + const std::optional GetCoreDumpStyle() const; clayborg wrote: return `lldb::SaveCoreStyle` with no optional. `lldb_private::CoreDumpOptions::GetCoreDumpStyle()` should return a good default value for this, and that will be returned as the result of this function. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -56,18 +56,18 @@ size_t ObjectFileMinidump::GetModuleSpecifications( } bool ObjectFileMinidump::SaveCore(const lldb::ProcessSP &process_sp, - const lldb_private::FileSpec &outfile, - lldb::SaveCoreStyle &core_style, + lldb_private::CoreDumpOptions &core_options, lldb_private::Status &error) { // Set default core style if it isn't set. - if (core_style == SaveCoreStyle::eSaveCoreUnspecified) -core_style = SaveCoreStyle::eSaveCoreStackOnly; + if (core_options.GetCoreDumpStyle() == SaveCoreStyle::eSaveCoreUnspecified) +core_options.SetCoreDumpStyle(SaveCoreStyle::eSaveCoreStackOnly); clayborg wrote: We should move this code into the `PluginManager::SaveCore` function and set this correctly prior to call each instance.save_core, that way each plug-in won't do things differently. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -191,9 +191,7 @@ class PluginManager { GetObjectFileCreateMemoryCallbackForPluginName(llvm::StringRef name); static Status SaveCore(const lldb::ProcessSP &process_sp, - const FileSpec &outfile, - lldb::SaveCoreStyle &core_style, - llvm::StringRef plugin_name); + lldb_private::CoreDumpOptions &core_options); clayborg wrote: change to const: `const lldb_private::CoreDumpOptions &core_options` https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,67 @@ +//===-- SBCoreDumpOptions.cpp ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/API/SBCoreDumpOptions.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Symbol/CoreDumpOptions.h" +#include "lldb/Utility/Instrumentation.h" + +#include "Utils.h" + +using namespace lldb; + +SBCoreDumpOptions::SBCoreDumpOptions(const char *filePath) { + LLDB_INSTRUMENT_VA(this, filePath); + lldb_private::FileSpec fspec(filePath); + lldb_private::FileSystem::Instance().Resolve(fspec); + m_opaque_up = std::make_unique(fspec); +} + +SBCoreDumpOptions::SBCoreDumpOptions(const SBCoreDumpOptions &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); + + m_opaque_up = clone(rhs.m_opaque_up); +} + +const SBCoreDumpOptions & +SBCoreDumpOptions::operator=(const SBCoreDumpOptions &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); + + if (this != &rhs) +m_opaque_up = clone(rhs.m_opaque_up); + return *this; +} + +void SBCoreDumpOptions::SetCoreDumpPluginName(const char *name) { + m_opaque_up->SetCoreDumpPluginName(name); +} + +void SBCoreDumpOptions::SetCoreDumpStyle(lldb::SaveCoreStyle style) { + m_opaque_up->SetCoreDumpStyle(style); +} + +const std::optional +SBCoreDumpOptions::GetCoreDumpPluginName() const { + const auto &name = m_opaque_up->GetCoreDumpPluginName(); + if (name->empty()) +return std::nullopt; + return name->data(); +} + +const char *SBCoreDumpOptions::GetOutputFile() const { + return m_opaque_up->GetOutputFile().GetFilename().AsCString(); +} + +const std::optional clayborg wrote: remove `std::optional` from here and from `lldb_private::CoreDumpOptions::GetCoreDumpStyle()` and have them both return a valid `lldb::SaveCoreStyle`. `lldb_private::CoreDumpOptions::GetCoreDumpStyle()` will check if its optional value has a value and return it if it has one, else it can return `lldb::eSaveCoreUnspecified` https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -1304,9 +1304,11 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed { FileSpec output_file(command.GetArgumentAtIndex(0)); FileSystem::Instance().Resolve(output_file); SaveCoreStyle corefile_style = m_options.m_requested_save_core_style; -Status error = -PluginManager::SaveCore(process_sp, output_file, corefile_style, -m_options.m_requested_plugin_name); +CoreDumpOptions core_dump_options(output_file); +core_dump_options.SetCoreDumpPluginName( +m_options.m_requested_plugin_name); +core_dump_options.SetCoreDumpStyle(corefile_style); +Status error = PluginManager::SaveCore(process_sp, core_dump_options); clayborg wrote: We need to remove the instance variables `m_requested_plugin_name` and `m_requested_save_core_style` and replace with with `lldb_private::CoreDumpOptions m_options;`. Then in the code that used to fill in the old ivars, we will just call the accessor instead. We can also call the accessor to set the output file as well on the `m_options;` ivar. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,42 @@ +//===-- CoreDumpOptions.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H +#define LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H + +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" + +#include +#include + +namespace lldb_private { + +class CoreDumpOptions { +public: + CoreDumpOptions(const lldb_private::FileSpec &fspec) + : m_core_dump_file(std::move(fspec)){}; + ~CoreDumpOptions() = default; + + void SetCoreDumpPluginName(llvm::StringRef name); + std::optional GetCoreDumpPluginName() const; + + void SetCoreDumpStyle(lldb::SaveCoreStyle style); + lldb::SaveCoreStyle GetCoreDumpStyle() const; + + const lldb_private::FileSpec &GetOutputFile() const; clayborg wrote: Add an accessor for SetOutputFile() as well. Why? Because we want to use this in the "process save-core" command and fill this structure in as options and arguments are parsed. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -1222,7 +1223,17 @@ lldb::SBError SBProcess::SaveCore(const char *file_name) { lldb::SBError SBProcess::SaveCore(const char *file_name, const char *flavor, SaveCoreStyle core_style) { - LLDB_INSTRUMENT_VA(this, file_name, flavor, core_style); + SBCoreDumpOptions options(file_name); clayborg wrote: I would default construct the SBCoreDumpOptions and then call: ``` options.SetOutputFile(file_name); ``` If a user wants to make a command line tool that uses this API, they will need to default construct a `SBCoreDumpOptions` object and fill things in as needed. If we require a filename up front, then that ruins the ability to use the `SBCoreDumpOptions` class effectively. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,42 @@ +//===-- CoreDumpOptions.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H +#define LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H + +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" + +#include +#include + +namespace lldb_private { + +class CoreDumpOptions { +public: + CoreDumpOptions(const lldb_private::FileSpec &fspec) + : m_core_dump_file(std::move(fspec)){}; + ~CoreDumpOptions() = default; + + void SetCoreDumpPluginName(llvm::StringRef name); + std::optional GetCoreDumpPluginName() const; + + void SetCoreDumpStyle(lldb::SaveCoreStyle style); + lldb::SaveCoreStyle GetCoreDumpStyle() const; + + const lldb_private::FileSpec &GetOutputFile() const; + +private: + std::optional m_core_dump_plugin_name; + const lldb_private::FileSpec m_core_dump_file; clayborg wrote: Remove `const` and change `m_core_dump_file ` to `m_file`. This is a CoreDumpOptions class so no need to repeat the name here in the instance variable. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,59 @@ +//===-- SBCoreDumpOptions.h -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_API_SBCOREDUMPOPTIONS_H +#define LLDB_API_SBCOREDUMPOPTIONS_H + +#include "lldb/API/SBDefines.h" +#include "lldb/Symbol/CoreDumpOptions.h" + +namespace lldb { + +class LLDB_API SBCoreDumpOptions { +public: + SBCoreDumpOptions(const char *filePath); + SBCoreDumpOptions(const lldb::SBCoreDumpOptions &rhs); + ~SBCoreDumpOptions() = default; + + const SBCoreDumpOptions &operator=(const lldb::SBCoreDumpOptions &rhs); + + /// Set the Core dump plugin name. + /// + /// \param plugin Name of the object file plugin. + void SetCoreDumpPluginName(const char *plugin); + + /// Get the Core dump plugin name, if set. + /// + /// \return The name of the plugin, or nullopt if not set. + const std::optional GetCoreDumpPluginName() const; clayborg wrote: Jason is right: no std::optional in the public API. The std::optional should only be used in the internal lldb_private::CoreDumpOptions and the accessors for lldb_private::CoreDumpOptions should not return std::optional either, it should use it to return something like: ``` return m_optional.value_or(); ``` The std::optional stuff is there just so we know when a user has set an option value in a command or on via the API. If the value hasn't been set, then we return a good default value. This function should return `NULL` if there is no value. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,42 @@ +//===-- CoreDumpOptions.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H +#define LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H + +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" + +#include +#include + +namespace lldb_private { + +class CoreDumpOptions { +public: + CoreDumpOptions(const lldb_private::FileSpec &fspec) + : m_core_dump_file(std::move(fspec)){}; + ~CoreDumpOptions() = default; + + void SetCoreDumpPluginName(llvm::StringRef name); + std::optional GetCoreDumpPluginName() const; clayborg wrote: return an `std::optional` to match how it is stored in the instance variable. https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,42 @@ +//===-- CoreDumpOptions.h ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H +#define LLDB_SOURCE_PLUGINS_OBJECTFILE_COREDUMPOPTIONS_H + +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" + +#include +#include + +namespace lldb_private { + +class CoreDumpOptions { +public: + CoreDumpOptions(const lldb_private::FileSpec &fspec) + : m_core_dump_file(std::move(fspec)){}; + ~CoreDumpOptions() = default; + + void SetCoreDumpPluginName(llvm::StringRef name); + std::optional GetCoreDumpPluginName() const; + + void SetCoreDumpStyle(lldb::SaveCoreStyle style); + lldb::SaveCoreStyle GetCoreDumpStyle() const; + + const lldb_private::FileSpec &GetOutputFile() const; + +private: + std::optional m_core_dump_plugin_name; + const lldb_private::FileSpec m_core_dump_file; + lldb::SaveCoreStyle m_core_dump_style = lldb::eSaveCoreUnspecified; clayborg wrote: This should be `std::optional< lldb::SaveCoreStyle>`. And the accessor should return a `lldb::eSaveCoreUnspecified` if the optional has no value. Rename from `m_core_dump_style` to m_style` https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBCoreDumpOptions Object, and SBProcess::SaveCore() overload (PR #98403)
@@ -0,0 +1,67 @@ +//===-- SBCoreDumpOptions.cpp ---*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/API/SBCoreDumpOptions.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Symbol/CoreDumpOptions.h" +#include "lldb/Utility/Instrumentation.h" + +#include "Utils.h" + +using namespace lldb; + +SBCoreDumpOptions::SBCoreDumpOptions(const char *filePath) { + LLDB_INSTRUMENT_VA(this, filePath); + lldb_private::FileSpec fspec(filePath); + lldb_private::FileSystem::Instance().Resolve(fspec); + m_opaque_up = std::make_unique(fspec); +} + +SBCoreDumpOptions::SBCoreDumpOptions(const SBCoreDumpOptions &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); + + m_opaque_up = clone(rhs.m_opaque_up); +} + +const SBCoreDumpOptions & +SBCoreDumpOptions::operator=(const SBCoreDumpOptions &rhs) { + LLDB_INSTRUMENT_VA(this, rhs); + + if (this != &rhs) +m_opaque_up = clone(rhs.m_opaque_up); + return *this; +} + +void SBCoreDumpOptions::SetCoreDumpPluginName(const char *name) { + m_opaque_up->SetCoreDumpPluginName(name); +} + +void SBCoreDumpOptions::SetCoreDumpStyle(lldb::SaveCoreStyle style) { + m_opaque_up->SetCoreDumpStyle(style); +} + +const std::optional +SBCoreDumpOptions::GetCoreDumpPluginName() const { + const auto &name = m_opaque_up->GetCoreDumpPluginName(); + if (name->empty()) +return std::nullopt; + return name->data(); +} + +const char *SBCoreDumpOptions::GetOutputFile() const { + return m_opaque_up->GetOutputFile().GetFilename().AsCString(); +} clayborg wrote: Return a SBFileSpec object here. Also remove the "const" as it doesn't mean anything because it just means you can't change the `m_opaque_up` value, but it will still allow you to call a non const function on the pointer contained in `m_opaque_up`... You will need to add the `SBCoreDumpOptions` as friend class in SBFileSpec.h so that you can call the constructor that uses a `lldb_private::FileSpec`. Then this code becomes: ``` lldb::SBFileSpec SBCoreDumpOptions::GetOutputFile() { return lldb::SBFileSpec(m_opaque_up->GetOutputFile()); } ``` https://github.com/llvm/llvm-project/pull/98403 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB] Add AST node classes, functions, etc. for Data Inspection Lang… (PR #95738)
@@ -0,0 +1,468 @@ +//===-- DILAST.cpp ===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "lldb/Core/DILAST.h" +#include "lldb/API/SBType.h" +#include "lldb/Core/ValueObjectRegister.h" +#include "lldb/Core/ValueObjectVariable.h" +#include "lldb/Symbol/TypeList.h" +#include "lldb/Symbol/VariableList.h" +#include "lldb/Target/LanguageRuntime.h" +#include "lldb/Target/RegisterContext.h" +#include "llvm/ADT/StringRef.h" + +#include + +namespace lldb_private { + +lldb::ValueObjectSP DILGetSPWithLock(lldb::ValueObjectSP in_valobj_sp, + lldb::DynamicValueType use_dynamic, + bool use_synthetic) { + Process::StopLocker stop_locker; + std::unique_lock lock; + Status error; + + if (!in_valobj_sp) { +error.SetErrorString("invalid value object"); +return in_valobj_sp; + } + + lldb::ValueObjectSP value_sp = in_valobj_sp; + + Target *target = value_sp->GetTargetSP().get(); + // If this ValueObject holds an error, then it is valuable for that. + if (value_sp->GetError().Fail()) +return value_sp; + + if (!target) +return lldb::ValueObjectSP(); + + lock = std::unique_lock(target->GetAPIMutex()); + + lldb::ProcessSP process_sp(value_sp->GetProcessSP()); + if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock())) { +// We don't allow people to play around with ValueObject if the process +// is running. If you want to look at values, pause the process, then +// look. +error.SetErrorString("process must be stopped."); +return lldb::ValueObjectSP(); + } + + if (use_dynamic != lldb::eNoDynamicValues) { +lldb::ValueObjectSP dynamic_sp = value_sp->GetDynamicValue(use_dynamic); +if (dynamic_sp) + value_sp = dynamic_sp; + } + + if (use_synthetic) { +lldb::ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue(); +if (synthetic_sp) + value_sp = synthetic_sp; + } + + if (!value_sp) +error.SetErrorString("invalid value object"); + + return value_sp; +} + +CompilerType DILASTNode::result_type_deref() const { + auto type = result_type(); + return type.IsReferenceType() ? type.GetNonReferenceType() : type; +} + +static std::unordered_map context_args; + +bool IsContextVar(const std::string &name) { + return context_args.find(name) != context_args.end(); +} cmtice wrote: When you say it needs to be scoped, you mean put inside a dil namespace? This is used by the stripped down parser when it's handling identifiers. https://github.com/llvm/llvm-project/pull/95738 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits