[trace][intel pt] Support a new kernel section in LLDB’s trace bundle schema
authorWalter Erquinigo <wallace@fb.com>
Thu, 4 Aug 2022 23:24:37 +0000 (16:24 -0700)
committerWalter Erquinigo <wallace@fb.com>
Fri, 5 Aug 2022 00:15:08 +0000 (17:15 -0700)
commit6fb744be76704f075a4edc753916e0e475d10f20
treef1179ac51a4e01e6b2c789a0df3c03a0c819de9b
parent6f4c3c0f6463880b685bfbca1932c06fd0c1f015
[trace][intel pt] Support a new kernel section in LLDB’s trace bundle schema

Add a new "kernel" section with following schema.

```
"kernel": {
  "loadAddress"?: decimal | hex string | string decimal
  # This is optional. If it's not specified, use default address 0xffffffff81000000.
  "file": string
  # path to the kernel image
}
```

Here's more details of the diff:
- If "kernel" section exist, it means current tracing mode is //KernelMode//.
- If tracing mode is //KernelMode//, the "processes" section must be empty and the "kernel" and "cpus" section must be provided. This is tested with `TestTraceLoad`.
- "kernel" section is parsed and turned into a new process with a single module which is the kernel image. The kernel process has N fake threads, one for each cpu.

Reviewed By: wallace

Differential Revision: https://reviews.llvm.org/D130805
14 files changed:
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h
lldb/test/API/commands/trace/TestTraceLoad.py
lldb/test/API/commands/trace/TestTraceSave.py
lldb/test/API/commands/trace/intelpt-kernel-trace/trace.json [new file with mode: 0644]
lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_with_process.json [new file with mode: 0644]
lldb/test/API/commands/trace/intelpt-kernel-trace/trace_kernel_wo_cpus.json [new file with mode: 0644]
lldb/test/API/commands/trace/intelpt-kernel-trace/trace_with_loadAddress.json [new file with mode: 0644]