[DTrace-devel] [PATCH] Add test for default value of string type TLS variables

Eugene Loh eugene.loh at oracle.com
Fri Mar 4 21:15:33 UTC 2022


Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
s/unknosn/unknown/
s/THis/This/
Prepend "test:" to the subject line???

On 3/4/22 4:00 PM, Kris Van Hees via DTrace-devel wrote:
> The default value of any unknosn TLS variable is 0.  This means that
> a TLS variable of type string will contain NULL.  THis test verifies
> that by detecting the invalid address fault on address 0x0.
>
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
>   test/unittest/variables/tvar/tst.init-str.d | 28 +++++++++++++++++++++
>   1 file changed, 28 insertions(+)
>   create mode 100644 test/unittest/variables/tvar/tst.init-str.d
>
> diff --git a/test/unittest/variables/tvar/tst.init-str.d b/test/unittest/variables/tvar/tst.init-str.d
> new file mode 100644
> index 00000000..47d3eab6
> --- /dev/null
> +++ b/test/unittest/variables/tvar/tst.init-str.d
> @@ -0,0 +1,28 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 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: Thread-local string variables are initialized to 0.  Trying to
> + *	      trace() it will result in a 'invalid address 0x0' fault.
> + *
> + * SECTION: Variables/Thread-Local Variables
> + */
> +
> +#pragma D option quiet
> +
> +self string x;
> +
> +BEGIN
> +{
> +	trace(self->x);
> +	exit(1);
> +}
> +
> +ERROR
> +{
> +	exit(arg4 != 1 || arg5 != 0);
> +}



More information about the DTrace-devel mailing list