On Mon, May 11, 2026 at 06:04:51PM +0100, Alex Bennée wrote: > QEMU makes heavy use of C Macros which can be confusing to humans and > seems almost impossible for AI agents to follow. In the past I've > dealt with this by compiling with V=1 and manually copying and pasting > the gcc command line and appending -E to run the pre-processor step. > > With the modern build system we now have a compile_commands.json so we > can automate the process with a script. > > There is some trickiness involved in following the line markers so we > know where in the source file we are. To handle this we implement a > PreprocessorState object to track where in the include chain we are. > This allows us to show the including location when we dump the > expanded macro. > > Signed-off-by: Alex Bennée <[email protected]> > --- > scripts/expand-macro.py | 272 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 272 insertions(+) > create mode 100755 scripts/expand-macro.py > > diff --git a/scripts/expand-macro.py b/scripts/expand-macro.py > new file mode 100755 > index 00000000000..581f20b9897 > --- /dev/null > +++ b/scripts/expand-macro.py > @@ -0,0 +1,272 @@ > +#!/usr/bin/env python3 > +# > +# Automate the expansion of QEMU macros based on compile_commands.json. > +# > +# This script runs the C preprocessor over a file to expand macros > +# in a specified line range, using the compilation flags defined in > +# compile_commands.json. > +# > +# Copyright (c) Linaro 2026
SPDX-License-Identifier needed With regards, Daniel -- |: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
