Skip to content

Commit

Permalink
test: Add test to check ALLOCA flag propagation
Browse files Browse the repository at this point in the history
Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed Feb 20, 2023
1 parent 35900cb commit a7ee5e8
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/unittest/codegen/tst.ALLOCA.d
Original file line number Diff line number Diff line change
@@ -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");
}
26 changes: 26 additions & 0 deletions test/unittest/codegen/tst.ALLOCA.r
Original file line number Diff line number Diff line change
@@ -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 =
VARIABLE myvar_copyinstr
FUNC copyinstr
INT {ptr}
OP2 =
VARIABLE myvar_dirname
FUNC dirname
STRING "/foo/bar"
31 changes: 31 additions & 0 deletions test/unittest/codegen/tst.ALLOCA.r.p
Original file line number Diff line number Diff line change
@@ -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 }

0 comments on commit a7ee5e8

Please sign in to comment.