PageRenderTime 927ms CodeModel.GetById 74ms RepoModel.GetById 1ms app.codeStats 0ms

/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 108 lines | 64 code | 14 blank | 30 comment | 5 complexity | 6e0765ab9f1803d5b87c3783c90ad7a8 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 2006 Sun Microsystems, Inc. All rights reserved.
  23. # Use is subject to license terms.
  24. #
  25. #ident "%Z%%M% %I% %E% SMI"
  26. # Rebuilding an object file containing DOF changes slightly when the object
  27. # files containing the probes have already been modified. This tests that
  28. # case by generating the DOF object, removing it, and building it again.
  29. if [ $# != 1 ]; then
  30. echo expected one argument: '<'dtrace-path'>'
  31. exit 2
  32. fi
  33. dtrace=$1
  34. DIR=/var/tmp/dtest.$$
  35. mkdir $DIR
  36. cd $DIR
  37. cat > test.c <<EOF
  38. #include <unistd.h>
  39. #include <sys/sdt.h>
  40. static void
  41. foo(void)
  42. {
  43. DTRACE_PROBE(test_prov, probe1);
  44. DTRACE_PROBE(test_prov, probe2);
  45. }
  46. int
  47. main(int argc, char **argv)
  48. {
  49. DTRACE_PROBE(test_prov, probe1);
  50. DTRACE_PROBE(test_prov, probe2);
  51. foo();
  52. }
  53. EOF
  54. cat > prov.d <<EOF
  55. provider test_prov {
  56. probe probe1();
  57. probe probe2();
  58. };
  59. EOF
  60. cc -c test.c
  61. if [ $? -ne 0 ]; then
  62. print -u2 "failed to compile test.c"
  63. exit 1
  64. fi
  65. $dtrace -G -s prov.d test.o
  66. if [ $? -ne 0 ]; then
  67. print -u2 "failed to create initial DOF"
  68. exit 1
  69. fi
  70. rm -f prov.o
  71. $dtrace -G -s prov.d test.o
  72. if [ $? -ne 0 ]; then
  73. print -u2 "failed to create final DOF"
  74. exit 1
  75. fi
  76. cc -o test test.o prov.o
  77. if [ $? -ne 0 ]; then
  78. print -u2 "failed to link final executable"
  79. exit 1
  80. fi
  81. script()
  82. {
  83. $dtrace -c ./test -qs /dev/stdin <<EOF
  84. test_prov\$target:::
  85. {
  86. printf("%s:%s:%s\n", probemod, probefunc, probename);
  87. }
  88. EOF
  89. }
  90. script
  91. status=$?
  92. cd /
  93. /bin/rm -rf $DIR
  94. exit $status