llvm-project/lldb/source
Jonas Devlieghere 04de24e690 [lldb/IOHandler] Improve synchronization between IO handlers.
The way the IO handlers are currently managed by the debugger is wrong. The
implementation lacks proper synchronization between RunIOHandlerSync and
RunIOHandlers. The latter is meant to be run by the "main thread", while the
former is meant to be run synchronously, potentially from a different thread.

Imagine a scenario where RunIOHandlerSync is called from a different thread
than RunIOHandlers. Both functions manipulate the debugger's IOHandlerStack.
Although the push and pop operations are synchronized, the logic to activate,
deactivate and run IO handlers is not.

While investigating PR44352, I noticed some weird behavior in the Editline
implementation. One of its members (m_editor_status) was modified from another
thread. This happened because the main thread, while running RunIOHandlers
ended up execution the IOHandlerEditline created by the breakpoint callback
thread. Even worse, due to the lack of synchronization within the IO handler
implementation, both threads ended up executing the same IO handler.

Most of the time, the IO handlers don't need to run synchronously. The
exception is sourcing commands from external files, like the .lldbinit file.

I've added a (recursive) mutex to prevent another thread from messing with the
IO handlers wile another thread is running one synchronously. It has to be
recursive, because we might have to source another file when encountering a
command source in the original file.

Differential revision: https://reviews.llvm.org/D72748
2020-01-20 11:17:55 -08:00
..
API [lldb] Remove out of order OperatingSystemPython::Terminate call in SystemInitializerFull 2020-01-17 13:02:15 +01:00
Breakpoint [lldb][NFC] Migrate FileSpec::Dump to raw_ostream 2019-12-06 09:40:42 +01:00
Commands [lldb/Reproducers] Print more info for reproducer status 2020-01-15 20:25:44 -08:00
Core [lldb/IOHandler] Improve synchronization between IO handlers. 2020-01-20 11:17:55 -08:00
DataFormatters Data formatters: Look through array element typedefs 2020-01-10 11:45:24 +01:00
Expression Fix a buffer-size bug when the first DW_OP_piece is undefined 2020-01-16 16:47:59 -08:00
Host [lldb][NFC] Use static_cast instead of reinterpret_cast where possible 2020-01-07 13:03:56 +01:00
Initialization [Reproducer] Use ::rtrim() to remove trailing control characters. 2019-10-18 17:11:48 +00:00
Interpreter [lldb/Debugger] Rename ExecuteIOHandlers to RunIOHandlers (NFC) 2020-01-16 16:45:47 -08:00
Plugins [lldb] Allow loading of minidumps with no process id 2020-01-20 13:08:58 +01:00
Symbol [lldb] Mark the implicit copy constructor as deleted when a move constructor is provided. 2020-01-20 14:34:07 +01:00
Target [lldb] Remove ClangASTContext.h inclusion in Target.cpp 2020-01-16 22:43:10 -08:00
Utility [lldb/Reproducers] Print more info for reproducer status 2020-01-15 20:25:44 -08:00
CMakeLists.txt Make LLVM_APPEND_VC_REV=OFF affect clang, lld, and lldb as well. 2020-01-16 19:04:08 -05:00
lldb.cpp [CMake] Remove Apple-specific version logic. 2019-04-17 18:23:22 +00:00