]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - sim/common/local.mk
sim: common: add $LINENO rewriting support to genmloop scripts
authorMike Frysinger <vapier@gentoo.org>
Wed, 20 Dec 2023 01:04:34 +0000 (20:04 -0500)
committerMike Frysinger <vapier@gentoo.org>
Fri, 22 Dec 2023 01:16:26 +0000 (20:16 -0500)
commitc0e97c852595b9516d54688643c08918a446f36c
tree3cca7534f3ba674f35d97439f6543c7647cc6571
parent10df3b929c72245bf363c11d6236637b4dc43cbc
sim: common: add $LINENO rewriting support to genmloop scripts

The generated mloop files can trigger compile time warnings.  It can
be difficult to see/understand where the original code is coming from
as all the diagnostics point to the generated output.  Using #line
pragmas, we can point people to the original source files.

Unfortunately, this code is written in POSIX shell, and that lacks
support for line number tracking.  The $LINENO variable, even when
available, can just be plain wrong.  For example, when using dash
and subshells, $LINENO can end up having negative values.  Add a
wrapper script that will uses awk to rewrite the $LINENO variable
to the right value to avoid all that.

Basically lineno.sh takes an input script, rewrites all uses of
$LINENO into the actual line number (and $0 into the original file
name), and then executes the temporary script.

This commit doesn't actually add #line pragmas to any files.  That
comes next.
sim/Makefile.in
sim/common/genmloop.sh
sim/common/lineno.sh [new file with mode: 0755]
sim/common/local.mk