mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
a2b7d0e0bf
Add support for tracing onto the PipelineC. This is done by: 1. Creating wrapper functions for each PipelineC function with the script in `scripts/PipelineC_add_tracing.py`. These will call a special function called `wrap` which will ultimately call a method with a `_` prepended to the name 2. Conversion of all PipelineC methods in `PipelineC.cpp` to `static` and their rename with a `_` in front, in order for them to work with the wrapper function in (1) 3. Generation of 2 additional include files, one for types and one for functions, to be used by users of tracing files in order to have introspection. These steps allow the creation of a trace file with the use of the `REVNG_C_API_TRACE_PATH` environment variable. The traces can then be used in conjunction with the `revng trace run` and `revng trace inspect` commands.
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
#
|
|
# This file is distributed under the MIT License. See LICENSE.md for details.
|
|
#
|
|
|
|
from revng.cli.commands_registry import Command, CommandsRegistry, Options
|
|
from revng.cli.support import collect_files, collect_libraries, get_command, handle_asan, run
|
|
|
|
|
|
class TraceRunCommand(Command):
|
|
def __init__(self):
|
|
super().__init__(("trace", "run"), "revng-trace-run wrapper", False)
|
|
|
|
def register_arguments(self, parser):
|
|
pass
|
|
|
|
def run(self, options: Options):
|
|
cmd = get_command("revng-trace-run", options.search_prefixes)
|
|
libraries, dependencies = collect_libraries(options.search_prefixes)
|
|
asan_prefix = handle_asan(dependencies, options.search_prefixes)
|
|
pipelines = collect_files(options.search_prefixes, ["share", "revng", "pipelines"], "*.yml")
|
|
|
|
args_combined = [
|
|
*[f"-load={p}" for p in libraries],
|
|
*[f"-pipeline-path={p}" for p in pipelines],
|
|
*options.remaining_args,
|
|
]
|
|
|
|
return run([*asan_prefix, cmd, *args_combined], options)
|
|
|
|
|
|
def setup(commands_registry: CommandsRegistry):
|
|
commands_registry.register_command(TraceRunCommand())
|