[all-commits] [llvm/llvm-project] f838fa: New ThreadPlanSingleThreadTimeout to resolve poten...
jeffreytan81 via All-commits
all-commits at lists.llvm.org
Mon Aug 5 17:27:01 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f838fa820f9271008617c345c477122d9e29a05c
https://github.com/llvm/llvm-project/commit/f838fa820f9271008617c345c477122d9e29a05c
Author: jeffreytan81 <jeffreytan at meta.com>
Date: 2024-08-05 (Mon, 05 Aug 2024)
Changed paths:
M lldb/include/lldb/Target/Process.h
M lldb/include/lldb/Target/StopInfo.h
M lldb/include/lldb/Target/Thread.h
M lldb/include/lldb/Target/ThreadPlan.h
A lldb/include/lldb/Target/ThreadPlanSingleThreadTimeout.h
M lldb/include/lldb/Target/ThreadPlanStepOut.h
M lldb/include/lldb/Target/ThreadPlanStepOverRange.h
M lldb/include/lldb/Target/ThreadPlanStepRange.h
A lldb/include/lldb/Target/TimeoutResumeAll.h
M lldb/include/lldb/lldb-enumerations.h
M lldb/source/API/SBThread.cpp
M lldb/source/Interpreter/CommandInterpreter.cpp
M lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
M lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
M lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
M lldb/source/Target/CMakeLists.txt
M lldb/source/Target/Process.cpp
M lldb/source/Target/StopInfo.cpp
M lldb/source/Target/TargetProperties.td
M lldb/source/Target/Thread.cpp
M lldb/source/Target/ThreadPlan.cpp
A lldb/source/Target/ThreadPlanSingleThreadTimeout.cpp
M lldb/source/Target/ThreadPlanStepInRange.cpp
M lldb/source/Target/ThreadPlanStepOverRange.cpp
M lldb/source/Target/ThreadPlanStepRange.cpp
A lldb/test/API/functionalities/single-thread-step/Makefile
A lldb/test/API/functionalities/single-thread-step/TestSingleThreadStepTimeout.py
A lldb/test/API/functionalities/single-thread-step/main.cpp
M lldb/tools/lldb-dap/JSONUtils.cpp
M lldb/tools/lldb-dap/LLDBUtils.cpp
Log Message:
-----------
New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (#90930)
This PR introduces a new `ThreadPlanSingleThreadTimeout` that will be
used to address potential deadlock during single-thread stepping.
While debugging a target with a non-trivial number of threads (around
5000 threads in one example target), we noticed that a simple step over
can take as long as 10 seconds. Enabling single-thread stepping mode
significantly reduces the stepping time to around 3 seconds. However,
this can introduce deadlock if we try to step over a method that depends
on other threads to release a lock.
To address this issue, we introduce a new
`ThreadPlanSingleThreadTimeout` that can be controlled by the
`target.process.thread.single-thread-plan-timeout` setting during
single-thread stepping mode. The concept involves counting the elapsed
time since the last internal stop to detect overall stepping progress.
Once a timeout occurs, we assume the target is not making progress due
to a potential deadlock, as mentioned above. We then send a new async
interrupt, resume all threads, and `ThreadPlanSingleThreadTimeout`
completes its task.
To support this design, the major changes made in this PR are:
1. `ThreadPlanSingleThreadTimeout` is popped during every internal stop
and reset (re-pushed) to the top of the stack (as a leaf node) during
resume. This is achieved by always returning `true` from
`ThreadPlanSingleThreadTimeout::DoPlanExplainsStop()` and
`ThreadPlanSingleThreadTimeout::MischiefManaged()`.
2. A new thread-specific async interrupt stop is introduced, which can
be detected/consumed by `ThreadPlanSingleThreadTimeout`.
3. The clearing of branch breakpoints in the range thread plan has been
moved from `DoPlanExplainsStop()` to `ShouldStop()`, as it is not
guaranteed that it will be called.
The detailed design is discussed in the RFC below:
[https://discourse.llvm.org/t/improve-single-thread-stepping/74599](https://discourse.llvm.org/t/improve-single-thread-stepping/74599)
---------
Co-authored-by: jeffreytan81 <jeffreytan at fb.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list