llvm-project/lldb/source/Core
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
..
Address.cpp [lldb][NFC] Move Address and AddressRange functions out of Stream and let them take raw_ostream 2019-12-05 14:41:33 +01:00
AddressRange.cpp [lldb][NFC] Move Address and AddressRange functions out of Stream and let them take raw_ostream 2019-12-05 14:41:33 +01:00
AddressResolver.cpp [NFC] Remove ASCII lines from comments 2019-04-10 20:48:55 +00:00
AddressResolverFileLine.cpp [lldb] NFC: refactor CompileUnit::ResolveSymbolContext 2019-11-28 21:37:31 +01:00
AddressResolverName.cpp Modernize the rest of the Find.* API (NFC) 2019-10-17 19:56:40 +00:00
CMakeLists.txt [lldb/CMake] Fix variable naming in FindLibEdit 2020-01-02 13:39:57 -08:00
Communication.cpp [Logging] Replace Log::Printf with LLDB_LOG macro (NFC) 2019-07-24 17:56:10 +00:00
CoreProperties.td [lldb] Don't process symlinks deep inside DWARFUnit 2020-01-20 13:05:00 +01:00
Debugger.cpp [lldb/IOHandler] Improve synchronization between IO handlers. 2020-01-20 11:17:55 -08:00
Disassembler.cpp Run all threads when extending a next range over a call. 2019-12-16 17:45:21 -08:00
DumpDataExtractor.cpp [lldb][NFC] Move Address and AddressRange functions out of Stream and let them take raw_ostream 2019-12-05 14:41:33 +01:00
DumpRegisterValue.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DynamicLoader.cpp [NFC] Remove ASCII lines from comments 2019-04-10 20:48:55 +00:00
EmulateInstruction.cpp Fix a "memset clearing an object of non-trivial type" warning in EmulateInstruction 2019-03-19 15:05:55 +00:00
FileLineResolver.cpp [lldb] Remove FileSpec->CompileUnit inheritance 2019-11-29 11:44:45 +01:00
FileSpecList.cpp [lldb][NFC] Migrate FileSpec::Dump to raw_ostream 2019-12-06 09:40:42 +01:00
FormatEntity.cpp [lldb] Fix an unused variable warning 2019-12-20 16:51:25 +01:00
Highlighter.cpp [NFC] Remove lldb_utility namespace. 2019-08-21 00:50:46 +00:00
IOHandler.cpp [lldb/Core] Add missing include 2019-12-12 09:55:11 -08:00
IOHandlerCursesGUI.cpp [lldb/CMake] Rename LLDB_DISABLE_CURSES to LLDB_ENABLE_CURSES 2019-12-12 09:13:31 -08:00
Mangled.cpp [LLDB] Fix handling for the clang name mangling extension for block invocations 2019-11-06 14:20:00 -08:00
Module.cpp [lldb/ScriptInterpreter] Remove can_reload which is always true (NFC) 2019-12-22 21:36:03 -08:00
ModuleChild.cpp Delete unnecessary copy ctors/copy assignment operators 2019-05-15 11:23:54 +00:00
ModuleList.cpp [lldb] Don't process symlinks deep inside DWARFUnit 2020-01-20 13:05:00 +01:00
Opcode.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
PluginManager.cpp [lldb] Fix ARM32 inferior calls 2019-12-21 11:12:17 +01:00
RichManglingContext.cpp [NFC] Remove ASCII lines from comments 2019-04-10 20:48:55 +00:00
SearchFilter.cpp [lldb] NFC: less nesting in SearchFilter.cpp 2019-12-06 08:38:33 +01:00
Section.cpp [lldb/DWARF] Move location list sections into DWARFContext 2020-01-14 15:19:29 +01:00
SourceManager.cpp [lldb] s/FileSpec::Equal/FileSpec::Match 2019-12-04 10:42:32 +01:00
StreamAsynchronousIO.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
StreamFile.cpp [LLDB] Remove dead code from StreamFile 2019-11-13 15:08:51 -08:00
UserSettingsController.cpp Pass ConstString by value (NFC) 2019-03-06 21:22:25 +00:00
Value.cpp ValueObject: Upstream early-exit from swift-lldb. (NFC) 2019-11-05 10:53:57 -08:00
ValueObject.cpp [lldb/CMake] Rename LLDB_DISABLE_PYTHON to LLDB_ENABLE_PYTHON 2019-12-13 13:41:11 -08:00
ValueObjectCast.cpp Remove unused and undocumented data_offset parameter (NFC) 2019-08-08 19:22:32 +00:00
ValueObjectChild.cpp Remove unused and undocumented data_offset parameter (NFC) 2019-08-08 19:22:32 +00:00
ValueObjectConstResult.cpp Remove unused and undocumented data_offset parameter (NFC) 2019-08-08 19:22:32 +00:00
ValueObjectConstResultCast.cpp Pass ConstString by value (NFC) 2019-03-06 21:22:25 +00:00
ValueObjectConstResultChild.cpp Pass ConstString by value (NFC) 2019-03-06 21:22:25 +00:00
ValueObjectConstResultImpl.cpp [lldb] NFC modernize codebase with modernize-use-nullptr 2019-05-23 11:14:47 +00:00
ValueObjectDynamicValue.cpp Remove unused and undocumented data_offset parameter (NFC) 2019-08-08 19:22:32 +00:00
ValueObjectList.cpp Delete unnecessary copy ctors/copy assignment operators 2019-05-15 11:23:54 +00:00
ValueObjectMemory.cpp Remove unused and undocumented data_offset parameter (NFC) 2019-08-08 19:22:32 +00:00
ValueObjectRegister.cpp [Symbol] Use llvm::Expected when getting TypeSystems 2019-07-30 22:12:34 +00:00
ValueObjectSyntheticFilter.cpp [lldb][NFC] Remove ThreadSafeSTLVector and ThreadSafeSTLMap and their use in ValueObjectSynthetic 2019-12-03 09:18:44 +01:00
ValueObjectVariable.cpp ValueObject: Fix a crash related to children address type computation 2019-10-25 17:49:06 +00:00