[DTrace-devel] [PATCH v2 1/4] Rename _DTRACE_VERSION
Kris Van Hees
kris.van.hees at oracle.com
Tue Mar 18 19:29:12 UTC 2025
On Thu, Feb 27, 2025 at 02:01:54PM -0500, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
>
> There are many DTrace version numbers (for version, API version,
> package version, etc.). Meanwhile, _DTRACE_VERSION is not a
> version number at all. It's a preprocessor macro in USDT .h header
> files. Prior to commit e2fb0ecd9
> ("Ensure multiple passes through dtrace -G work."), it was perhaps
> not even set. With that commit, it was always set to 1, with
> the rationale:
>
> Also add an explicit define for _DTRACE__VERSION in the generated
__ -> _ (will fix when I merge)
> header file from 'dtrace -h' invocations. This seems silly, but
> it is there to give people a skeleton to work with if they want to
> pre-generate header files and select whether to actually compile
> on the probes at a later time.
>
> Rename to _DTRACE_USE_USDT for better clarity. Define it only once
> per file. Place the definition inside an #ifndef test so that a
> developer could set the value without manually changing the file.
>
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
> libdtrace/dt_program.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/libdtrace/dt_program.c b/libdtrace/dt_program.c
> index 23b91fb2e..cfb7a5fc3 100644
> --- a/libdtrace/dt_program.c
> +++ b/libdtrace/dt_program.c
> @@ -505,13 +505,12 @@ dt_header_provider(dtrace_hdl_t *dtp, dt_provider_t *pvp, FILE *out)
> info.dthi_pfname = alloca(strlen(pvp->desc.dtvd_name) + 1 + i);
> dt_header_fmt_func(info.dthi_pfname, pvp->desc.dtvd_name);
>
> - if (fprintf(out, "#define _DTRACE_VERSION 1\n\n"
> - "#if _DTRACE_VERSION\n\n") < 0)
> + if (fprintf(out, "#if _DTRACE_USE_USDT\n\n") < 0)
> return dt_set_errno(dtp, errno);
>
> if (dt_idhash_iter(pvp->pv_probes, dt_header_probe, &info) != 0)
> return -1; /* dt_errno is set for us */
> - if (fprintf(out, "\n\n") < 0)
> + if (fprintf(out, "\n") < 0)
> return dt_set_errno(dtp, errno);
> if (dt_idhash_iter(pvp->pv_probes, dt_header_decl, &info) != 0)
> return -1; /* dt_errno is set for us */
> @@ -560,6 +559,11 @@ dtrace_program_header(dtrace_hdl_t *dtp, FILE *out, const char *fname)
> "#endif\n\n") < 0)
> return -1;
>
> + if (fprintf(out, "#ifndef _DTRACE_USE_USDT\n"
> + "# define _DTRACE_USE_USDT 1\n"
> + "#endif\n\n") < 0)
> + return -1;
> +
> while ((pvp = dt_htab_next(dtp->dt_provs, &it)) != NULL) {
> if (dt_header_provider(dtp, pvp, out) != 0) {
> dt_htab_next_destroy(it);
> --
> 2.43.5
>
More information about the DTrace-devel
mailing list