llvm-project/lldb/source/Plugins/Process/scripted
Med Ismail Bennani 150db43e41 [lldb/Plugin] Sort the ScriptedProcess' thread list before creating threads
With Scripted Processes, in order to create scripted threads, the blueprint
provides a dictionary that have each thread index as the key with the respective
thread instance as the pair value.

In Python, this is fine because a dictionary key can be of any type including
integer types:

```
>>> {1: "one", 2: "two", 10: "ten"}
{1: 'one', 2: 'two', 10: 'ten'}
```

However, when the python dictionary gets bridged to C++ we convert it to a
`StructuredData::Dictionary` that uses a `std::map<ConstString, ObjectSP>`
for storage.

Because `std::map` is an ordered container and ours uses the `ConstString`
type for keys, the thread indices gets converted to strings which makes the
dictionary sorted alphabetically, instead of numerically.

If the ScriptedProcess has 10 threads or more, it causes thread “10”
(and higher) to be after thread “1”, but before thread “2”.

In order to solve this, this sorts the thread info dictionary keys
numerically, before iterating over them to create ScriptedThreads.

rdar://90327854

Differential Revision: https://reviews.llvm.org/D122429

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-03-25 14:59:50 -07:00
..
CMakeLists.txt [lldb/Plugins] Add support for ScriptedThread in ScriptedProcess 2021-10-08 14:54:07 +02:00
ScriptedProcess.cpp [lldb/Plugin] Sort the ScriptedProcess' thread list before creating threads 2022-03-25 14:59:50 -07:00
ScriptedProcess.h [lldb/Plugins] Add ability to load modules to Scripted Processes 2022-03-04 13:35:28 -08:00
ScriptedThread.cpp [lldb/Plugin] Use static ScriptedInterface::ErrorWithMessage function (NFC) 2022-03-04 13:35:19 -08:00
ScriptedThread.h [lldb/Plugin] Add artificial stackframe loading in ScriptedThread 2022-02-16 11:44:07 -08:00