Updates drpt2ir and drpttracer and adds a new module syscall_pt_trace that provides an API for syscall's kernel PT tracing:
(1) Updates drpttracer extension. Adds drpttracer_create_tracer() and drpttracer_destroy_tracer(). In the original implementation, the client will get a tracer by calling drpttracer_start_tracing() and destroy the tracer when calling drpttracer_end_tracing(). If the client traces multiple times, the tracer's creation and destruction will cause a big overhead. Currently, the client can use drpttracer_create_tracer() to get a tracer and use drpttracer_start_tracing() and drpttracer_end_tracing() to start and stop a tracing processes, then use drpttracer_destory_tracer() to destroy the tracer. In the future implementation, multiple traces can share one tracer, and the overhead is reduced to an acceptable level.
(2) Adds the syscall_pt_trace module for dr$sim to record syscall's kernel PT trace. This module wraps a PT tracer as a class and provides APIs for thread-local syscall tracing. Also, it provides APIs to check the currently tracing syscall's sysnum and last recorded syscall's id. In this PR, syscall_pt_trace will create a trace handle for each syscall, making the decoding process simple for the decoder. In the current implementation, syscall_pt_trace module can cause significant overhead. A pending optimization can reduce the overhead caused by pttracer initialization. The optimization method is the module use one pttracer handle for all syscalls in one thread and dumps the PT segments into one file. This method needs to upgrade drpt2ir to support decoding PT fragments. We will merge the optimized code after we finish implementing drpt2ir's patch.
(3) Updates dr$sim to support kernel tracing. In the current implementation, every monitored thread will create a tracer during the thread start, and dr$sim will start the syscall kernel tracing in the pre-syscall callback and stop the syscall kernel tracing at post-syscall callbacks. And every syscall will dump the PT data and metadata to files. Also, before the process end, dr$sim will use the 'perf record --kcore' command to copy out kcore and kallsyms used in the PT post processer.
(4) Updates drpt2ir. The current implementation supports using the metadata file to initiate an instance of pt2ir_config_t and replaces some c pointer parameters with c++ reference parameters.
(5) Updates drpt2trace. Adds a new option to support directly reading metadata files to initialize pt2ir_config_t. In the current implementation, drpt2trace will first use a metadata file to init the instance of pt2ir_config_t. Then if the user specifies some options, it will overwrite the corresponding field in the instance of pt2ir_config_t.
(6) Add a new test for dr$sim to check that the kernel PT output is correct. Defines a new macro for kernel feature check and adds a simple test for dr$sim. The macro will run dr$sim to generate kernel PT and drpt2trace to check whether the generated kernel PT can be decoded.
Issue: #5505