Print this page
4719 Common patchset for jdk1.7 support preparation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/dtrace/test/tst/common/java_api/src/TestFunctionLookup.java
+++ new/usr/src/cmd/dtrace/test/tst/common/java_api/src/TestFunctionLookup.java
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 import org.opensolaris.os.dtrace.*;
28 28
29 29 /**
30 30 * Regression for bug 6413280 lookupKernelFunction() and
31 31 * lookupUserFunction() truncate last character.
32 32 */
33 33 public class TestFunctionLookup {
34 34 static final String kernelLookupProgram = "sdt:::callout-start { " +
35 35 "@[((callout_t *)arg0)->c_func] = count(); }";
36 36 static final String userLookupProgram = "pid$target::f2:entry { " +
37 37 "@[arg0] = count(); }";
38 38
39 39 public static void
40 40 main(String[] args)
41 41 {
42 42 if (args.length != 1) {
43 43 System.err.println("usage: java TestFunctionLookup <command>");
44 44 System.exit(1);
45 45 }
46 46 String cmd = args[0];
47 47
48 48 Consumer consumer = new LocalConsumer();
↓ open down ↓ |
48 lines elided |
↑ open up ↑ |
49 49 try {
50 50 consumer.open();
51 51 consumer.compile(kernelLookupProgram);
52 52 consumer.enable();
53 53 consumer.go();
54 54 Aggregate a;
55 55 Number address;
56 56 String f;
57 57 boolean done = false;
58 58 for (int i = 0; (i < 20) && !done; ++i) {
59 - Thread.currentThread().sleep(100);
59 + Thread.sleep(100);
60 60 a = consumer.getAggregate();
61 61 for (Aggregation agg : a.getAggregations()) {
62 62 for (Tuple tuple : agg.asMap().keySet()) {
63 63 address = (Number)tuple.get(0).getValue();
64 64 if (address instanceof Integer) {
65 65 int addr = (Integer)address;
66 66 f = consumer.lookupKernelFunction(addr);
67 67 } else {
68 68 long addr = (Long)address;
69 69 f = consumer.lookupKernelFunction(addr);
70 70 }
71 71 if (f.equals("genunix`cv_wakeup")) {
72 72 System.out.println(f);
73 73 done = true;
74 74 }
75 75 }
76 76 }
77 77 }
78 78 consumer.close();
79 79 } catch (Exception e) {
80 80 e.printStackTrace();
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
81 81 System.exit(1);
82 82 }
83 83
84 84 consumer = new LocalConsumer();
85 85 try {
86 86 consumer.open();
87 87 int pid = consumer.createProcess(cmd);
88 88 consumer.compile(userLookupProgram);
89 89 consumer.enable();
90 90 consumer.go();
91 - Thread.currentThread().sleep(500);
91 + Thread.sleep(500);
92 92 Aggregate a = consumer.getAggregate();
93 93 Number address;
94 94 String f;
95 95 for (Aggregation agg : a.getAggregations()) {
96 96 for (Tuple tuple : agg.asMap().keySet()) {
97 97 address = (Number)tuple.get(0).getValue();
98 98 if (address instanceof Integer) {
99 99 int addr = (Integer)address;
100 100 f = consumer.lookupUserFunction(pid, addr);
101 101 } else {
102 102 long addr = (Long)address;
103 103 f = consumer.lookupUserFunction(pid, addr);
104 104 }
105 105 System.out.println(f);
106 106 }
107 107 }
108 108 consumer.close();
109 109 } catch (Exception e) {
110 110 e.printStackTrace();
111 111 System.exit(1);
112 112 }
113 113 }
114 114 }
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX