Author: Pavel Labath Date: 2021-09-21T10:01:00+02:00 New Revision: 791b6ebc86680168d634103b67a92a354c075cc4
URL: https://github.com/llvm/llvm-project/commit/791b6ebc86680168d634103b67a92a354c075cc4 DIFF: https://github.com/llvm/llvm-project/commit/791b6ebc86680168d634103b67a92a354c075cc4.diff LOG: [lldb] Speculative fix to TestGuiExpandThreadsTree This test relies on being able to unwind from an arbitrary place inside libc. While I am not sure this is the cause of the observed flakyness, it is known that we are not able to unwind correctly from some places in (linux) libc. This patch adds additional synchronization to ensure that the inferior is in the main function (instead of pthread guts) when lldb tries to unwind it. At the very least, it should make the test runs more predictable/repeatable. Added: lldb/test/API/commands/gui/expand-threads-tree/main.cpp Modified: lldb/test/API/commands/gui/expand-threads-tree/Makefile lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py Removed: lldb/test/API/commands/gui/expand-threads-tree/main.c ################################################################################ diff --git a/lldb/test/API/commands/gui/expand-threads-tree/Makefile b/lldb/test/API/commands/gui/expand-threads-tree/Makefile index 0c11fbdd8669c..566938ca0cc4e 100644 --- a/lldb/test/API/commands/gui/expand-threads-tree/Makefile +++ b/lldb/test/API/commands/gui/expand-threads-tree/Makefile @@ -1,3 +1,3 @@ -C_SOURCES := main.c +CXX_SOURCES := main.cpp ENABLE_THREADS := YES include Makefile.rules diff --git a/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py b/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py index c3ec4b285ecd0..9eed5b0ef6c39 100644 --- a/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py +++ b/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py @@ -22,7 +22,7 @@ def test_gui(self): self.build() self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100,500)) - self.expect("breakpoint set -r thread_start_routine", substrs=["Breakpoint 1", "address ="]) + self.expect("breakpoint set -n break_here", substrs=["Breakpoint 1", "address ="]) self.expect("run", substrs=["stop reason ="]) escape_key = chr(27).encode() @@ -33,7 +33,7 @@ def test_gui(self): self.child.expect_exact("Threads") # The thread running thread_start_routine should be expanded. - self.child.expect_exact("frame #0: thread_start_routine") + self.child.expect_exact("frame #0: break_here") # Exit GUI. self.child.send(escape_key) diff --git a/lldb/test/API/commands/gui/expand-threads-tree/main.c b/lldb/test/API/commands/gui/expand-threads-tree/main.c deleted file mode 100644 index 32e6d17c799a6..0000000000000 --- a/lldb/test/API/commands/gui/expand-threads-tree/main.c +++ /dev/null @@ -1,10 +0,0 @@ -#include <pthread.h> - -void *thread_start_routine(void *arg) { return NULL; } - -int main() { - pthread_t thread; - pthread_create(&thread, NULL, thread_start_routine, NULL); - pthread_join(thread, NULL); - return 0; -} diff --git a/lldb/test/API/commands/gui/expand-threads-tree/main.cpp b/lldb/test/API/commands/gui/expand-threads-tree/main.cpp new file mode 100644 index 0000000000000..5a7cbb78563c0 --- /dev/null +++ b/lldb/test/API/commands/gui/expand-threads-tree/main.cpp @@ -0,0 +1,24 @@ +#include "pseudo_barrier.h" +#include <thread> + + +pseudo_barrier_t barrier_before; +pseudo_barrier_t barrier_after; + +void break_here() {} + +void thread_func() { + pseudo_barrier_wait(barrier_before); + break_here(); + pseudo_barrier_wait(barrier_after); +} + +int main() { + pseudo_barrier_init(barrier_before, 2); + pseudo_barrier_init(barrier_after, 2); + std::thread thread(thread_func); + pseudo_barrier_wait(barrier_before); + pseudo_barrier_wait(barrier_after); + thread.join(); + return 0; +} _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits