[DTrace-devel] [PATCH 03/14] test: Add test to check DPTR flag propagation
Kris Van Hees
kris.van.hees at oracle.com
Sat Feb 18 06:10:28 UTC 2023
On Thu, Nov 03, 2022 at 03:52:15PM -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 changes to handle the fact that I mislead you on how ALLOCA
and DPTR work.
> ---
> test/unittest/codegen/tst.DPTR.d | 25 ++++++++++++++++++++++++
> test/unittest/codegen/tst.DPTR.r | 26 +++++++++++++++++++++++++
> test/unittest/codegen/tst.DPTR.r.p | 31 ++++++++++++++++++++++++++++++
> 3 files changed, 82 insertions(+)
> create mode 100644 test/unittest/codegen/tst.DPTR.d
> create mode 100644 test/unittest/codegen/tst.DPTR.r
> create mode 100755 test/unittest/codegen/tst.DPTR.r.p
>
> diff --git a/test/unittest/codegen/tst.DPTR.d b/test/unittest/codegen/tst.DPTR.d
> new file mode 100644
> index 00000000..1256a402
> --- /dev/null
> +++ b/test/unittest/codegen/tst.DPTR.d
> @@ -0,0 +1,25 @@
> +/*
> + * 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 DPTR annotations in the parse tree.
> + */
> +
> +/* @@runtest-opts: -xtree=4 -e */
> +/* @@nosort */
> +/* @@xfail: DPTR flag is not propagated properly */
> +
> +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.DPTR.r b/test/unittest/codegen/tst.DPTR.r
> new file mode 100644
> index 00000000..78ba8984
> --- /dev/null
> +++ b/test/unittest/codegen/tst.DPTR.r
> @@ -0,0 +1,26 @@
> +OP2 =
> +VARIABLE myvar_int
> +INT {ptr}
> +OP2 = DPTR
> +VARIABLE myvar_string DPTR
> +STRING "abcde" DPTR
> +OP2 = DPTR
> +VARIABLE myvar_alloca DPTR
> +FUNC alloca DPTR
> +INT {ptr}
> +OP2 = DPTR
> +VARIABLE myvar_basename DPTR
> +FUNC basename DPTR
> +STRING "/foo/bar" DPTR
> +OP2 = DPTR
> +VARIABLE myvar_copyin DPTR
> +FUNC copyin DPTR
> +INT {ptr}
> +OP2 = DPTR
> +VARIABLE myvar_copyinstr DPTR
> +FUNC copyinstr DPTR
> +INT {ptr}
> +OP2 = DPTR
> +VARIABLE myvar_dirname DPTR
> +FUNC dirname DPTR
> +STRING "/foo/bar" DPTR
> diff --git a/test/unittest/codegen/tst.DPTR.r.p b/test/unittest/codegen/tst.DPTR.r.p
> new file mode 100755
> index 00000000..c49fb909
> --- /dev/null
> +++ b/test/unittest/codegen/tst.DPTR.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 / && /DPTR/ { print $1, $2, "DPTR"; next }
> +/^ *OP2 / { print $1, $2 ; next }
> +/^ *VARIABLE / && / myvar_/ &&
> + /DPTR/ { print $1, $3, "DPTR"; next }
> +/^ *VARIABLE / && / myvar_/ { print $1, $3 ; next }
> +/^ *FUNC / && /DPTR/ { print $1, $2, "DPTR"; next }
> +/^ *FUNC / { print $1, $2 ; next }
> +/^ *INT / && /DPTR/ { print $1, $2, "DPTR"; next }
> +/^ *INT / { print $1, $2 ; next }
> +/^ *STRING / && /DPTR/ { print $1, $2, "DPTR"; 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