[all-commits] [llvm/llvm-project] 12301d: [lldb/crashlog] Parse thread fields and pass it to...

Med Ismail Bennani via All-commits all-commits at lists.llvm.org
Fri Mar 25 15:00:33 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 12301d616fbcd3bbc78664221256404123a0935f
      https://github.com/llvm/llvm-project/commit/12301d616fbcd3bbc78664221256404123a0935f
  Author: Med Ismail Bennani <medismail.bennani at gmail.com>
  Date:   2022-03-25 (Fri, 25 Mar 2022)

  Changed paths:
    M lldb/examples/python/crashlog.py
    M lldb/examples/python/scripted_process/crashlog_scripted_process.py
    M lldb/examples/python/scripted_process/scripted_process.py
    M lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test

  Log Message:
  -----------
  [lldb/crashlog] Parse thread fields and pass it to crashlog scripted process

Previously, the ScriptedThread used the thread index as the thread id.

This patch parses the crashlog json to extract the actual thread "id" value,
and passes this information to the Crashlog ScriptedProcess blueprint,
to create a higher fidelity ScriptedThreaad.

It also updates the blueprint to show the thread name and thread queue.

Finally, this patch updates the interactive crashlog test to reflect
these changes.

rdar://90327854

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

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


  Commit: 29f363611dd4b9b898230cde60bacf71f9581343
      https://github.com/llvm/llvm-project/commit/29f363611dd4b9b898230cde60bacf71f9581343
  Author: Med Ismail Bennani <medismail.bennani at gmail.com>
  Date:   2022-03-25 (Fri, 25 Mar 2022)

  Changed paths:
    M lldb/include/lldb/Utility/StructuredData.h

  Log Message:
  -----------
  [lldb/Utility] Make StructuredData::Dictionary::GetKeys return an Array

This patch changes `StructuredData::Dictionary::GetKeys` return type
from an `StructuredData::ObjectSP` to a `StructuredData::ArraySP`.

The function already stored the keys in an array but implicitely upcasted
it to an `ObjectSP`, which required the user to convert it again to a
Array object to access each element.

Since we know the keys should be held by an iterable container, it makes
more sense to return the allocated ArraySP as-is.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


  Commit: 150db43e412efba0f95ebde81aabd93e7535b909
      https://github.com/llvm/llvm-project/commit/150db43e412efba0f95ebde81aabd93e7535b909
  Author: Med Ismail Bennani <medismail.bennani at gmail.com>
  Date:   2022-03-25 (Fri, 25 Mar 2022)

  Changed paths:
    M lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp

  Log Message:
  -----------
  [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 at gmail.com>


Compare: https://github.com/llvm/llvm-project/compare/afaefb671fe1...150db43e412e


More information about the All-commits mailing list