[DTrace-devel] [PATCH CORRECTED] Implement normalize() and denormalize()

Eugene Loh eugene.loh at oracle.com
Fri Jan 15 12:17:40 PST 2021


Actually, I have another question here.  For dt_cg_[de]normalize(), you 
introduce an argc to count the number of arguments and check if it's the 
expected value.

At least for denormalize(), however, that doesn't make sense.  If the 
number of arguments is wrong, you'll never get to this new 
dt_cg_denormalize() code.  You will already have failed with PROTO_LEN.  
In fact, you've added new tests to check just that.

For normalize(), I guess(?) the new argc code is okay.  The case of "too 
few args" seems to be caught by the new code, even if I do not 
understand why PROTO_LEN hasn't complained.


On 01/14/2021 09:04 AM, Kris Van Hees wrote:
> diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> @@ -609,33 +609,36 @@ dt_cg_act_commit(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
>   static void
>   dt_cg_act_denormalize(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
>   {
> -	dt_node_t *anp;
> -	dt_ident_t *aid;
> -	char n[DT_TYPE_NAMELEN];
> +	dt_node_t	*anp;
> +	int		argc = 0;
> +	char		n[DT_TYPE_NAMELEN];
> +	dt_ident_t	*aid;
> +
> +	/* Count the arguments. */
> +	for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
> +		argc++;
> +
> +	if (argc != 1)
> +		dnerror(dnp, D_NORMALIZE_PROTO,
> +		    "%s( ) prototype mismatch: %d args passed, %d expected\n",
> +		    dnp->dn_ident->di_name, argc, 1);
>   
> @@ -730,6 +733,43 @@ dt_cg_act_jstack(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
>   static void
>   dt_cg_act_normalize(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
>   {
> +	dt_node_t	*anp, *normal;
> +	int		argc = 0;
> +	char		n[DT_TYPE_NAMELEN];
> +	dt_ident_t	*aid;
> +
> +	/* Count the arguments. */
> +	for (anp = dnp->dn_args; anp != NULL; anp = anp->dn_list)
> +		argc++;
> +
> +	if (argc != 2)
> +		dnerror(dnp, D_NORMALIZE_PROTO,
> +		    "%s( ) prototype mismatch: %d args passed, %d expected\n",
> +		    dnp->dn_ident->di_name, argc, 2);
> +
> diff --git a/test/unittest/aggs/err.D_NORMALIZE_PROTO.bad.d ...
> deleted file mode 100644
> diff --git a/test/unittest/aggs/err.D_NORMALIZE_PROTO.norm_too_few_args.d ...
> new file mode 100644
> diff --git a/test/unittest/aggs/err.D_PROTO_LEN.denorm_too_few_args.d ...
> new file mode 100644
> diff --git a/test/unittest/aggs/err.D_PROTO_LEN.denorm_too_many_args.d ...
> new file mode 100644
> diff --git a/test/unittest/aggs/err.D_PROTO_LEN.norm_too_many_args.d ...
> new file mode 100644



More information about the DTrace-devel mailing list