[DTrace-devel] [PATCH 2/2] bpf: generate bpf_asm_helpers.h and use it

Eugene Loh eugene.loh at oracle.com
Sat Feb 3 06:59:35 UTC 2024


Reviewed-by: Eugene Loh <eugene.loh at oracle.com>

Why is "All rights reserved." dropped in the bpf/*.S?

The awk script can be approached in a number of different ways. FWIW I 
mention some possible alternatives below.  I recognize they are arguably 
less robust, but there are no guarantees about the format of the 
bpf_helper_defs.h header anyhow.  E.g., if lines are wrapped, the script 
will fail.  The patch has a suitable awk script.  Feel free to ignore 
the alternatives below.

On 2/2/24 11:50, Kris Van Hees via DTrace-devel wrote:

> diff --git a/include/mkHelpers b/include/mkHelpers
> +$1 == "static" && /=/ && /[ \t]+[1-9][0-9]*[ \t]*;/ {

"/^static / {"
happens to work just fine

> +	match($0, /[ \t]+[1-9][0-9]*[ \t]*;/);
> +	id = substr($0, RSTART, RLENGTH - 1);
> +	gsub(/[ \t]+/,"", id);

These lines can be replaced with simply
id = strtonum($NF);

> +	match($0, /\([ \t]*\*[ \t]*bpf_[_A-Za-z0-9]+/);
> +	fn = substr($0, RSTART + 1, RLENGTH - 1);
> +	sub(/[ \t]*\*[ \t]*bpf_/, "", fn);
> +
> +	print "#define BPF_FUNC_"fn " " id;
> +}
> +
> +END {
> +	print "\n#endif /* _BPF_ASM_HELPERS_H */";
> +}



More information about the DTrace-devel mailing list