[DTrace-devel] [PATCH 4/4] Do not register handlers when not executing probe clauses

Eugene Loh eugene.loh at oracle.com
Wed Jun 10 09:14:34 PDT 2020


This raises a question I've been curious about.  Why do we even compile 
clauses if, say, we're in "list" mode?  In that case, we only care about 
the probe descriptions, and the clauses don't matter.


On 06/10/2020 08:23 AM, Kris Van Hees wrote:
> The various handlers that are used by consumers only apply to the
> execution of probe clauses.  For operating modes that do not execute
> clauses there is no need to register handlers.  Even worse, if e.g.
> the error handler is being registered with the default error clause
> and -xnolibs is used (which is common with the -h option to generate
> a header file), an error will occur because bpf_get_bvar() cannot be
> found.
>
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
>   cmd/dtrace.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/cmd/dtrace.c b/cmd/dtrace.c
> index cef86ef2..17d5692a 100644
> --- a/cmd/dtrace.c
> +++ b/cmd/dtrace.c
> @@ -1337,7 +1337,11 @@ main(int argc, char *argv[])
>   	for (i = 0; i < g_cmdc; i++)
>   		g_cmdv[i].dc_func(&g_cmdv[i]);
>   
> -	if (g_mode != DMODE_LIST) {
> +	/*
> +	 * We only need to register handler if we are going to execute probe
> +	 * clauses.
> +	 */
> +	if (g_mode == DMODE_EXEC) {
>   		if (dtrace_handle_err(g_dtp, &errhandler, NULL) == -1)
>   			dfatal("failed to establish error handler");
>   




More information about the DTrace-devel mailing list