/usr/src/cmd/dtrace/test/tst/sparc/usdt/tst.tailcall.ksh

https://github.com/buffygb/illumos-gate · Korn Shell · 131 lines · 84 code · 19 blank · 28 comment · 9 complexity · 20d6eebea891b8ccc7f4f54d53550beb MD5 · raw file

  1. #
  2. # CDDL HEADER START
  3. #
  4. # The contents of this file are subject to the terms of the
  5. # Common Development and Distribution License (the "License").
  6. # You may not use this file except in compliance with the License.
  7. #
  8. # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  9. # or http://www.opensolaris.org/os/licensing.
  10. # See the License for the specific language governing permissions
  11. # and limitations under the License.
  12. #
  13. # When distributing Covered Code, include this CDDL HEADER in each
  14. # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15. # If applicable, add the following below this CDDL HEADER, with the
  16. # fields enclosed by brackets "[]" replaced with your own identifying
  17. # information: Portions Copyright [yyyy] [name of copyright owner]
  18. #
  19. # CDDL HEADER END
  20. #
  21. #
  22. # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
  23. # Use is subject to license terms.
  24. #
  25. #
  26. # ASSERTION: Make sure USDT probes work as tail-calls on SPARC.
  27. #
  28. if [ $# != 1 ]; then
  29. echo expected one argument: '<'dtrace-path'>'
  30. exit 2
  31. fi
  32. dtrace=$1
  33. DIR=/var/tmp/dtest.$$
  34. mkdir $DIR
  35. cd $DIR
  36. cat > test.s <<EOF
  37. #include <sys/asm_linkage.h>
  38. DGDEF(__fsr_init_value)
  39. .word 0
  40. ENTRY(test)
  41. save %sp, -SA(MINFRAME + 4), %sp
  42. mov 9, %i0
  43. mov 19, %i1
  44. mov 2006, %i2
  45. call __dtrace_test___fire
  46. restore
  47. SET_SIZE(test)
  48. ENTRY(main)
  49. save %sp, -SA(MINFRAME + 4), %sp
  50. 1:
  51. call test
  52. nop
  53. ba 1b
  54. nop
  55. ret
  56. restore %g0, %g0, %o0
  57. SET_SIZE(main)
  58. EOF
  59. cat > prov.d <<EOF
  60. provider test {
  61. probe fire(int, int, int);
  62. };
  63. EOF
  64. /usr/ccs/bin/as -xregsym=no -P -D_ASM -o test.o test.s
  65. if [ $? -ne 0 ]; then
  66. print -u2 "failed to compile test.s"
  67. exit 1
  68. fi
  69. $dtrace -G -32 -s prov.d test.o
  70. if [ $? -ne 0 ]; then
  71. print -u2 "failed to create DOF"
  72. exit 1
  73. fi
  74. gcc -o test test.o prov.o
  75. if [ $? -ne 0 ]; then
  76. print -u2 "failed to link final executable"
  77. exit 1
  78. fi
  79. $dtrace -c ./test -s /dev/stdin <<EOF
  80. test\$target:::fire
  81. /arg0 == 9 && arg1 == 19 && arg2 == 2006/
  82. {
  83. printf("%d/%d/%d", arg0, arg1, arg2);
  84. exit(0);
  85. }
  86. test\$target:::fire
  87. {
  88. printf("%d/%d/%d", arg0, arg1, arg2);
  89. exit(1);
  90. }
  91. BEGIN
  92. {
  93. /*
  94. * Let's just do this for 5 seconds.
  95. */
  96. timeout = timestamp + 5000000000;
  97. }
  98. profile:::tick-4
  99. /timestamp > timeout/
  100. {
  101. trace("test timed out");
  102. exit(1);
  103. }
  104. EOF
  105. status=$?
  106. cd /
  107. /usr/bin/rm -rf $DIR
  108. exit $status