[DTrace-devel] [PATCH 02/14] test: Add test to check ALLOCA flag propagation

Kris Van Hees kris.van.hees at oracle.com
Sat Feb 18 06:09:21 UTC 2023


On Thu, Nov 03, 2022 at 03:52:14PM -0400, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>

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

... with minor change due to adjustment of how ALLOCA vs DPTR works.

> ---
>  test/unittest/codegen/tst.ALLOCA.d   | 24 +++++++++++++++++++++
>  test/unittest/codegen/tst.ALLOCA.r   | 26 +++++++++++++++++++++++
>  test/unittest/codegen/tst.ALLOCA.r.p | 31 ++++++++++++++++++++++++++++
>  3 files changed, 81 insertions(+)
>  create mode 100644 test/unittest/codegen/tst.ALLOCA.d
>  create mode 100644 test/unittest/codegen/tst.ALLOCA.r
>  create mode 100755 test/unittest/codegen/tst.ALLOCA.r.p
> 
> diff --git a/test/unittest/codegen/tst.ALLOCA.d b/test/unittest/codegen/tst.ALLOCA.d
> new file mode 100644
> index 00000000..cf4081c7
> --- /dev/null
> +++ b/test/unittest/codegen/tst.ALLOCA.d
> @@ -0,0 +1,24 @@
> +/*
> + * 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.
> + */
> +
> +/*
> + * Check the ALLOCA annotations in the parse tree.
> + */
> +
> +/* @@runtest-opts: -xtree=4 -e */
> +/* @@nosort */
> +
> +syscall::write:entry
> +{
> +  myvar_int = 4;
> +  myvar_string = "abcde";
> +  myvar_alloca = alloca(4);
> +  myvar_basename = basename("/foo/bar");
> +  myvar_copyin = copyin(arg1, 4);
> +  myvar_copyinstr = copyinstr(arg1);
> +  myvar_dirname = dirname("/foo/bar");
> +}
> diff --git a/test/unittest/codegen/tst.ALLOCA.r b/test/unittest/codegen/tst.ALLOCA.r
> new file mode 100644
> index 00000000..3249b4e5
> --- /dev/null
> +++ b/test/unittest/codegen/tst.ALLOCA.r
> @@ -0,0 +1,26 @@
> +OP2 =
> +VARIABLE myvar_int
> +INT {ptr}
> +OP2 =
> +VARIABLE myvar_string
> +STRING "abcde"
> +OP2 = ALLOCA
> +VARIABLE myvar_alloca ALLOCA
> +FUNC alloca ALLOCA
> +INT {ptr}
> +OP2 =
> +VARIABLE myvar_basename
> +FUNC basename
> +STRING "/foo/bar"
> +OP2 = ALLOCA
> +VARIABLE myvar_copyin ALLOCA
> +FUNC copyin ALLOCA
> +INT {ptr}
> +OP2 = ALLOCA
> +VARIABLE myvar_copyinstr ALLOCA
> +FUNC copyinstr ALLOCA
> +INT {ptr}
> +OP2 =
> +VARIABLE myvar_dirname
> +FUNC dirname
> +STRING "/foo/bar"
> diff --git a/test/unittest/codegen/tst.ALLOCA.r.p b/test/unittest/codegen/tst.ALLOCA.r.p
> new file mode 100755
> index 00000000..49503319
> --- /dev/null
> +++ b/test/unittest/codegen/tst.ALLOCA.r.p
> @@ -0,0 +1,31 @@
> +#!/usr/bin/awk -f
> +
> +# set flag to look for the clause
> +BEGIN { read_clause = 0 }
> +
> +# we found the beginning of the clause
> +/^ *PDESC syscall::write:entry/ {
> +    read_clause = 1;
> +    getline;
> +    getline;
> +    next;
> +}
> +
> +# if not in the clause, keep looking
> +read_clause == 0 { next }
> +
> +# if we were reading the clause but get to "Parse tree", we are done
> +/^Parse tree \(Pass 3\):$/ { exit(0); }
> +
> +# dump interesting stuff from the clause
> +/^ *OP2 /      && /ALLOCA/  { print $1, $2, "ALLOCA"; next }
> +/^ *OP2 /                   { print $1, $2          ; next }
> +/^ *VARIABLE / && / myvar_/ &&
> +                  /ALLOCA/  { print $1, $3, "ALLOCA"; next }
> +/^ *VARIABLE / && / myvar_/ { print $1, $3          ; next }
> +/^ *FUNC /     && /ALLOCA/  { print $1, $2, "ALLOCA"; next }
> +/^ *FUNC /                  { print $1, $2          ; next }
> +/^ *INT /      && /ALLOCA/  { print $1, $2, "ALLOCA"; next }
> +/^ *INT /                   { print $1, $2          ; next }
> +/^ *STRING /   && /ALLOCA/  { print $1, $2, "ALLOCA"; next }
> +/^ *STRING /                { print $1, $2          ; next }
> -- 
> 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