From ea2e6226e713e89589dc27f0d81a0538f7178ae9 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Wed, 21 May 2025 19:43:20 -0700 Subject: [PATCH 1/2] Fix a bug where using "thread backtrace unique" would switch you to always using the "frame-format-unique" even when you weren't doing the unique backtrace mode. --- .../Commands/CommandObjectThreadUtil.cpp | 2 ++ .../thread/num_threads/TestNumThreads.py | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lldb/source/Commands/CommandObjectThreadUtil.cpp b/lldb/source/Commands/CommandObjectThreadUtil.cpp index cdc5946547f47..a451de137d702 100644 --- a/lldb/source/Commands/CommandObjectThreadUtil.cpp +++ b/lldb/source/Commands/CommandObjectThreadUtil.cpp @@ -37,6 +37,8 @@ void CommandObjectIterateOverThreads::DoExecute(Args &command, result.SetStatus(m_success_return); bool all_threads = false; + m_unique_stacks = false; + if (command.GetArgumentCount() == 0) { Thread *thread = m_exe_ctx.GetThreadPtr(); if (thread) diff --git a/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py b/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py index ee9b14f15b6e9..40bc2a175c2f9 100644 --- a/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py +++ b/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py @@ -132,10 +132,26 @@ def is_thread3(thread): # Construct our expected back trace string expect_string = "10 thread(s)%s" % (expect_threads) + # There was a bug where if you used 'thread backtrace unique' + # we would switch all future backtraces to use the + # "frame-format-unique" not the "frame-format". Make + # sure we don't do that... + setting_data = self.dbg.GetSetting("frame-format-unique") + setting_str = setting_data.GetStringValue(1000) + setting_str = "UNIQUE: " + setting_str + lldb.SBDebugger.SetInternalVariable("frame-format-unique", setting_str, self.dbg.GetInstanceName()) # Now that we are stopped, we should have 10 threads waiting in the # thread3 function. All of these threads should show as one stack. self.expect( "thread backtrace unique", "Backtrace with unique stack shown correctly", - substrs=[expect_string, "main.cpp:%d" % self.thread3_before_lock_line], + substrs=[expect_string, "UNIQUE:", "main.cpp:%d" % self.thread3_before_lock_line], + ) + # Make sure setting the unique flag in the command isn't + # persistent: + self.expect( + "thread backtrace", + "Backtrace unique is not sticky", + substrs=["UNIQUE:"], + matching=False ) From f5ebdd42375e9cf7abe69b2f997971214dae97da Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Thu, 22 May 2025 10:34:00 -0700 Subject: [PATCH 2/2] Darkening --- .../thread/num_threads/TestNumThreads.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py b/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py index 40bc2a175c2f9..2f7d64bacfea9 100644 --- a/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py +++ b/lldb/test/API/functionalities/thread/num_threads/TestNumThreads.py @@ -139,13 +139,19 @@ def is_thread3(thread): setting_data = self.dbg.GetSetting("frame-format-unique") setting_str = setting_data.GetStringValue(1000) setting_str = "UNIQUE: " + setting_str - lldb.SBDebugger.SetInternalVariable("frame-format-unique", setting_str, self.dbg.GetInstanceName()) + lldb.SBDebugger.SetInternalVariable( + "frame-format-unique", setting_str, self.dbg.GetInstanceName() + ) # Now that we are stopped, we should have 10 threads waiting in the # thread3 function. All of these threads should show as one stack. self.expect( "thread backtrace unique", "Backtrace with unique stack shown correctly", - substrs=[expect_string, "UNIQUE:", "main.cpp:%d" % self.thread3_before_lock_line], + substrs=[ + expect_string, + "UNIQUE:", + "main.cpp:%d" % self.thread3_before_lock_line, + ], ) # Make sure setting the unique flag in the command isn't # persistent: @@ -153,5 +159,5 @@ def is_thread3(thread): "thread backtrace", "Backtrace unique is not sticky", substrs=["UNIQUE:"], - matching=False + matching=False, )