[DTrace-devel] [PATCH] Better diagnosibility for D scripts relying on dt_cg_arglist()

Kris Van Hees kris.van.hees at oracle.com
Wed Apr 20 20:54:53 UTC 2022


Now that associative arrays are implemented, this is no longer relevant.

On Wed, Feb 10, 2021 at 02:24:58PM -0500, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> The function dt_cg_arglist() is not yet implemented properly.
> Currently, D scripts that rely on its functionality fail,
> emitting multiple opaque lines of BPF verifier output.  E.g.,
> 
>     # dtrace -n 'BEGIN {d_path(&(curthread->fs->pwd));}'
>     ...10 lines...
>     BPF: jump out of range from insn 115 to 191
>     ...4 lines...
> 
>     # dtrace -n 'BEGIN {a[1] = 3;}'
>     dtrace: description 'BEGIN ' matched 1 probe
>     BPF: call to invalid destination
>     ...4 lines...
> 
> Insert dnerror() calls at dt_cg_arglist()'s call sites to report
> clearly what the problem is.  A model is how aggregation tuples
> are currently being handled:
>     # dtrace -n 'BEGIN {@a[1] = count();}'
>     dtrace: ...: indexing is not supported yet: @a
> 
> With the fix,
>     # dtrace -n 'BEGIN {d_path(&(curthread->fs->pwd));}'
>     dtrace: ...: functions are not yet supported: d_path
> 
>     # dtrace -n 'BEGIN {a[1] = 3;}'
>     dtrace: ...: arrays are not yet supported: a
> 
> The DT_TOK_IDENT / DT_NODE_VAR / DT_IDENT_ARRAY code path that
> calls dt_cg_assoc_op() -> dt_cg_arglist() remains uninstrumented.
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
>  libdtrace/dt_cg.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> index 9f2a427b..f87d416e 100644
> --- a/libdtrace/dt_cg.c
> +++ b/libdtrace/dt_cg.c
> @@ -2399,8 +2399,14 @@ dt_cg_asgn_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
>  	if (dnp->dn_left->dn_kind == DT_NODE_VAR) {
>  		idp = dt_ident_resolve(dnp->dn_left->dn_ident);
>  
> -		if (idp->di_kind == DT_IDENT_ARRAY)
> +		if (idp->di_kind == DT_IDENT_ARRAY) {
> +			/* FIXME */
> +			dnerror(dnp, D_UNKNOWN,
> +			        "arrays are not yet supported: %s\n",
> +			        idp->di_name);
> +
>  			dt_cg_arglist(idp, dnp->dn_left->dn_args, dlp, drp);
> +		}
>  
>  		dt_cg_store_var(dnp, dlp, drp, idp);
>  	} else {
> @@ -3085,6 +3091,10 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
>  				    dt_idkind_name(idp->di_kind), idp->di_name);
>  			}
>  
> +			/* FIXME */
> +			dnerror(dnp, D_UNKNOWN,
> +			        "functions are not yet supported: %s\n",
> +			        idp->di_name);
>  			dt_cg_arglist(dnp->dn_ident, dnp->dn_args, dlp, drp);
>  
>  			if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
> -- 
> 2.18.4
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list