mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
This patch adds a plugin API function that allows diverting the program counter during execution. A potential use case for this functionality is to skip over parts of the code, e.g., by hooking into a specific instruction and setting the PC to the next instruction in the callback. Link: https://lists.nongnu.org/archive/html/qemu-devel/2025-08/msg00656.html Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Florian Hofhammer <florian.hofhammer@epfl.ch> Link: https://lore.kernel.org/qemu-devel/20260305-setpc-v5-v7-4-4c3adba52403@epfl.ch Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
#
|
|
# Extract QEMU Plugin API symbols from a header file
|
|
#
|
|
# Copyright 2024 Linaro Ltd
|
|
#
|
|
# Author: Pierrick Bouvier <pierrick.bouvier@linaro.org>
|
|
#
|
|
# This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
# See the COPYING file in the top-level directory.
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
import argparse
|
|
import re
|
|
|
|
def extract_symbols(plugin_header):
|
|
with open(plugin_header) as file:
|
|
content = file.read()
|
|
# Remove QEMU_PLUGIN_API macro definition.
|
|
content = content.replace('#define QEMU_PLUGIN_API', '')
|
|
expected = content.count('QEMU_PLUGIN_API')
|
|
# Find last word between QEMU_PLUGIN_API and ( to get the function name,
|
|
# matching on several lines. Discard attributes, if any.
|
|
# We use *? non-greedy quantifier.
|
|
syms = re.findall(
|
|
r'QEMU_PLUGIN_API\s+(?:__attribute__\(\(\S+\)\))?.*?(\w+)\s*\(',
|
|
content,
|
|
re.DOTALL,
|
|
)
|
|
syms.sort()
|
|
# Ensure we found as many symbols as API markers.
|
|
assert len(syms) == expected
|
|
return syms
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(description='Extract QEMU plugin symbols')
|
|
parser.add_argument('plugin_header', help='Path to QEMU plugin header.')
|
|
args = parser.parse_args()
|
|
|
|
syms = extract_symbols(args.plugin_header)
|
|
|
|
print('{')
|
|
for s in syms:
|
|
print(" {};".format(s))
|
|
print('};')
|
|
|
|
if __name__ == '__main__':
|
|
main()
|