[DTrace-devel] [PATCH 06/61] Clean up dtrace::: arg handling and testing

Kris Van Hees kris.van.hees at oracle.com
Mon Jul 11 16:54:25 UTC 2022


On Fri, Jul 08, 2022 at 10:44:50AM -0400, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> Currently, the dtrace provider trampoline sets probe arguments to the
> values being passed in some function call.  However:
> 
> *)  The BEGIN and END probes have no arguments defined.  This
>     point is documented explicitly.  The probe arguments are
>     certainly not the arguments passed into internal functions
>     BEGIN_probe() and END_probe() -- no such arguments are passed!
> 
> *)  The ERROR probe does have defined arguments, but they are
>     set up in clause code, not in the trampoline.
> 
> Therefore, do not copy probe args in the dtrace-provider trampoline.
> Just zero the BEGIN and END probe arguments.
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>

... and I will push to dev (since I have it on my pre-push branch already).

>Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com> ---
>  libdtrace/dt_prov_dtrace.c              | 7 +++++--
>  test/unittest/variables/bvar/tst.arg0.d | 7 ++++---
>  test/unittest/variables/bvar/tst.arg1.d | 7 ++++---
>  test/unittest/variables/bvar/tst.arg2.d | 7 ++++---
>  test/unittest/variables/bvar/tst.arg3.d | 7 ++++---
>  test/unittest/variables/bvar/tst.arg4.d | 7 ++++---
>  test/unittest/variables/bvar/tst.arg5.d | 7 ++++---
>  test/unittest/variables/bvar/tst.arg6.d | 7 ++++---
>  test/unittest/variables/bvar/tst.arg7.d | 7 ++++---
>  test/unittest/variables/bvar/tst.arg8.d | 7 ++++---
>  test/unittest/variables/bvar/tst.arg9.d | 7 ++++---
>  11 files changed, 45 insertions(+), 32 deletions(-)
> 
> diff --git a/libdtrace/dt_prov_dtrace.c b/libdtrace/dt_prov_dtrace.c
> index a7fc2cf5..82f80680 100644
> --- a/libdtrace/dt_prov_dtrace.c
> +++ b/libdtrace/dt_prov_dtrace.c
> @@ -80,7 +80,7 @@ static void trampoline(dt_pcb_t *pcb)
>  {
>  	dt_irlist_t	*dlp = &pcb->pcb_ir;
>  	dt_activity_t	act = DT_ACTIVITY_ACTIVE;
> -	uint32_t	key = 0;
> +	uint32_t	i, key = 0;
>  
>  	/*
>  	 * The ERROR probe isn't really a trace event that a BPF program is
> @@ -156,7 +156,10 @@ static void trampoline(dt_pcb_t *pcb)
>  	emit(dlp, BPF_CALL_HELPER(BPF_FUNC_map_update_elem));
>  
>  	dt_cg_tramp_copy_regs(pcb, BPF_REG_8);
> -	dt_cg_tramp_copy_args_from_regs(pcb, BPF_REG_8);
> +
> +	/* zero the probe args */
> +	for (i = 0; i < ARRAY_SIZE(((dt_mstate_t *)0)->argv); i++)
> +		emit(dlp, BPF_STORE_IMM(BPF_DW, BPF_REG_7, DMST_ARG(i), 0));
>  
>  	dt_cg_tramp_epilogue_advance(pcb, act);
>  }
> diff --git a/test/unittest/variables/bvar/tst.arg0.d b/test/unittest/variables/bvar/tst.arg0.d
> index a745db0d..b17ca252 100644
> --- a/test/unittest/variables/bvar/tst.arg0.d
> +++ b/test/unittest/variables/bvar/tst.arg0.d
> @@ -1,12 +1,13 @@
>  /*
>   * Oracle Linux DTrace.
> - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
>   * Licensed under the Universal Permissive License v 1.0 as shown at
>   * http://oss.oracle.com/licenses/upl.
>   */
>  
>  /*
> - * ASSERTION: The 'arg0' variable can be accessed and is not -1.
> + * ASSERTION: The 'arg0' variable can be accessed.  (This implementation
> + * sets the arg to 0, so check this undocumented behavior as well.)
>   *
>   * SECTION: Variables/Built-in Variables/arg0
>   */
> @@ -15,7 +16,7 @@
>  
>  BEGIN {
>  	trace(arg0);
> -	exit(arg0 != -1 ? 0 : 1);
> +	exit(arg0 == 0 ? 0 : 1);
>  }
>  
>  ERROR {
> diff --git a/test/unittest/variables/bvar/tst.arg1.d b/test/unittest/variables/bvar/tst.arg1.d
> index 7d2cd65a..7eb71d1a 100644
> --- a/test/unittest/variables/bvar/tst.arg1.d
> +++ b/test/unittest/variables/bvar/tst.arg1.d
> @@ -1,12 +1,13 @@
>  /*
>   * Oracle Linux DTrace.
> - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
>   * Licensed under the Universal Permissive License v 1.0 as shown at
>   * http://oss.oracle.com/licenses/upl.
>   */
>  
>  /*
> - * ASSERTION: The 'arg1' variable can be accessed and is not -1.
> + * ASSERTION: The 'arg1' variable can be accessed.  (This implementation
> + * sets the arg to 0, so check this undocumented behavior as well.)
>   *
>   * SECTION: Variables/Built-in Variables/arg1
>   */
> @@ -15,7 +16,7 @@
>  
>  BEGIN {
>  	trace(arg1);
> -	exit(arg1 != -1 ? 0 : 1);
> +	exit(arg1 == 0 ? 0 : 1);
>  }
>  
>  ERROR {
> diff --git a/test/unittest/variables/bvar/tst.arg2.d b/test/unittest/variables/bvar/tst.arg2.d
> index 08cf98aa..62ef3347 100644
> --- a/test/unittest/variables/bvar/tst.arg2.d
> +++ b/test/unittest/variables/bvar/tst.arg2.d
> @@ -1,12 +1,13 @@
>  /*
>   * Oracle Linux DTrace.
> - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
>   * Licensed under the Universal Permissive License v 1.0 as shown at
>   * http://oss.oracle.com/licenses/upl.
>   */
>  
>  /*
> - * ASSERTION: The 'arg2' variable can be accessed and is not -1.
> + * ASSERTION: The 'arg2' variable can be accessed.  (This implementation
> + * sets the arg to 0, so check this undocumented behavior as well.)
>   *
>   * SECTION: Variables/Built-in Variables/arg2
>   */
> @@ -15,7 +16,7 @@
>  
>  BEGIN {
>  	trace(arg2);
> -	exit(arg2 != -1 ? 0 : 1);
> +	exit(arg2 == 0 ? 0 : 1);
>  }
>  
>  ERROR {
> diff --git a/test/unittest/variables/bvar/tst.arg3.d b/test/unittest/variables/bvar/tst.arg3.d
> index a7eea667..9d628f8a 100644
> --- a/test/unittest/variables/bvar/tst.arg3.d
> +++ b/test/unittest/variables/bvar/tst.arg3.d
> @@ -1,12 +1,13 @@
>  /*
>   * Oracle Linux DTrace.
> - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
>   * Licensed under the Universal Permissive License v 1.0 as shown at
>   * http://oss.oracle.com/licenses/upl.
>   */
>  
>  /*
> - * ASSERTION: The 'arg3' variable can be accessed and is not -1.
> + * ASSERTION: The 'arg3' variable can be accessed.  (This implementation
> + * sets the arg to 0, so check this undocumented behavior as well.)
>   *
>   * SECTION: Variables/Built-in Variables/arg3
>   */
> @@ -15,7 +16,7 @@
>  
>  BEGIN {
>  	trace(arg3);
> -	exit(arg3 != -1 ? 0 : 1);
> +	exit(arg3 == 0 ? 0 : 1);
>  }
>  
>  ERROR {
> diff --git a/test/unittest/variables/bvar/tst.arg4.d b/test/unittest/variables/bvar/tst.arg4.d
> index defc09ce..898252aa 100644
> --- a/test/unittest/variables/bvar/tst.arg4.d
> +++ b/test/unittest/variables/bvar/tst.arg4.d
> @@ -1,12 +1,13 @@
>  /*
>   * Oracle Linux DTrace.
> - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
>   * Licensed under the Universal Permissive License v 1.0 as shown at
>   * http://oss.oracle.com/licenses/upl.
>   */
>  
>  /*
> - * ASSERTION: The 'arg4' variable can be accessed and is not -1.
> + * ASSERTION: The 'arg4' variable can be accessed.  (This implementation
> + * sets the arg to 0, so check this undocumented behavior as well.)
>   *
>   * SECTION: Variables/Built-in Variables/arg4
>   */
> @@ -15,7 +16,7 @@
>  
>  BEGIN {
>  	trace(arg4);
> -	exit(arg4 != -1 ? 0 : 1);
> +	exit(arg4 == 0 ? 0 : 1);
>  }
>  
>  ERROR {
> diff --git a/test/unittest/variables/bvar/tst.arg5.d b/test/unittest/variables/bvar/tst.arg5.d
> index 48ae3f12..d166372b 100644
> --- a/test/unittest/variables/bvar/tst.arg5.d
> +++ b/test/unittest/variables/bvar/tst.arg5.d
> @@ -1,12 +1,13 @@
>  /*
>   * Oracle Linux DTrace.
> - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
>   * Licensed under the Universal Permissive License v 1.0 as shown at
>   * http://oss.oracle.com/licenses/upl.
>   */
>  
>  /*
> - * ASSERTION: The 'arg5' variable can be accessed and is not -1.
> + * ASSERTION: The 'arg5' variable can be accessed.  (This implementation
> + * sets the arg to 0, so check this undocumented behavior as well.)
>   *
>   * SECTION: Variables/Built-in Variables/arg5
>   */
> @@ -15,7 +16,7 @@
>  
>  BEGIN {
>  	trace(arg5);
> -	exit(arg5 != -1 ? 0 : 1);
> +	exit(arg5 == 0 ? 0 : 1);
>  }
>  
>  ERROR {
> diff --git a/test/unittest/variables/bvar/tst.arg6.d b/test/unittest/variables/bvar/tst.arg6.d
> index cd77dff3..2dd4282a 100644
> --- a/test/unittest/variables/bvar/tst.arg6.d
> +++ b/test/unittest/variables/bvar/tst.arg6.d
> @@ -1,12 +1,13 @@
>  /*
>   * Oracle Linux DTrace.
> - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
>   * Licensed under the Universal Permissive License v 1.0 as shown at
>   * http://oss.oracle.com/licenses/upl.
>   */
>  
>  /*
> - * ASSERTION: The 'arg6' variable can be accessed and is not -1.
> + * ASSERTION: The 'arg6' variable can be accessed.  (This implementation
> + * sets the arg to 0, so check this undocumented behavior as well.)
>   *
>   * SECTION: Variables/Built-in Variables/arg6
>   */
> @@ -15,7 +16,7 @@
>  
>  BEGIN {
>  	trace(arg6);
> -	exit(arg6 != -1 ? 0 : 1);
> +	exit(arg6 == 0 ? 0 : 1);
>  }
>  
>  ERROR {
> diff --git a/test/unittest/variables/bvar/tst.arg7.d b/test/unittest/variables/bvar/tst.arg7.d
> index 314fdb1f..0ccc6ed7 100644
> --- a/test/unittest/variables/bvar/tst.arg7.d
> +++ b/test/unittest/variables/bvar/tst.arg7.d
> @@ -1,12 +1,13 @@
>  /*
>   * Oracle Linux DTrace.
> - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
>   * Licensed under the Universal Permissive License v 1.0 as shown at
>   * http://oss.oracle.com/licenses/upl.
>   */
>  
>  /*
> - * ASSERTION: The 'arg7' variable can be accessed and is not -1.
> + * ASSERTION: The 'arg7' variable can be accessed.  (This implementation
> + * sets the arg to 0, so check this undocumented behavior as well.)
>   *
>   * SECTION: Variables/Built-in Variables/arg7
>   */
> @@ -15,7 +16,7 @@
>  
>  BEGIN {
>  	trace(arg7);
> -	exit(arg7 != -1 ? 0 : 1);
> +	exit(arg7 == 0 ? 0 : 1);
>  }
>  
>  ERROR {
> diff --git a/test/unittest/variables/bvar/tst.arg8.d b/test/unittest/variables/bvar/tst.arg8.d
> index dc03db3b..be876e01 100644
> --- a/test/unittest/variables/bvar/tst.arg8.d
> +++ b/test/unittest/variables/bvar/tst.arg8.d
> @@ -1,12 +1,13 @@
>  /*
>   * Oracle Linux DTrace.
> - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
>   * Licensed under the Universal Permissive License v 1.0 as shown at
>   * http://oss.oracle.com/licenses/upl.
>   */
>  
>  /*
> - * ASSERTION: The 'arg8' variable can be accessed and is not -1.
> + * ASSERTION: The 'arg8' variable can be accessed.  (This implementation
> + * sets the arg to 0, so check this undocumented behavior as well.)
>   *
>   * SECTION: Variables/Built-in Variables/arg8
>   */
> @@ -15,7 +16,7 @@
>  
>  BEGIN {
>  	trace(arg8);
> -	exit(arg8 != -1 ? 0 : 1);
> +	exit(arg8 == 0 ? 0 : 1);
>  }
>  
>  ERROR {
> diff --git a/test/unittest/variables/bvar/tst.arg9.d b/test/unittest/variables/bvar/tst.arg9.d
> index 4456bba0..39217765 100644
> --- a/test/unittest/variables/bvar/tst.arg9.d
> +++ b/test/unittest/variables/bvar/tst.arg9.d
> @@ -1,12 +1,13 @@
>  /*
>   * Oracle Linux DTrace.
> - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
>   * Licensed under the Universal Permissive License v 1.0 as shown at
>   * http://oss.oracle.com/licenses/upl.
>   */
>  
>  /*
> - * ASSERTION: The 'arg9' variable can be accessed and is not -1.
> + * ASSERTION: The 'arg9' variable can be accessed.  (This implementation
> + * sets the arg to 0, so check this undocumented behavior as well.)
>   *
>   * SECTION: Variables/Built-in Variables/arg9
>   */
> @@ -15,7 +16,7 @@
>  
>  BEGIN {
>  	trace(arg9);
> -	exit(arg9 != -1 ? 0 : 1);
> +	exit(arg9 == 0 ? 0 : 1);
>  }
>  
>  ERROR {
> -- 
> 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