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.
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.
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]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 import org.opensolaris.os.dtrace.*;
30 * Regression for bug 6413280 lookupKernelFunction() and
31 * lookupUserFunction() truncate last character.
33 public class TestFunctionLookup {
34 static final String kernelLookupProgram = "sdt:::callout-start { " +
35 "@[((callout_t *)arg0)->c_func] = count(); }";
36 static final String userLookupProgram = "pid$target::f2:entry { " +
37 "@[arg0] = count(); }";
42 if (args.length != 1) {
43 System.err.println("usage: java TestFunctionLookup <command>");
48 Consumer consumer = new LocalConsumer();
51 consumer.compile(kernelLookupProgram);
58 for (int i = 0; (i < 20) && !done; ++i) {
59 Thread.currentThread().sleep(100);
60 a = consumer.getAggregate();
61 for (Aggregation agg : a.getAggregations()) {
62 for (Tuple tuple : agg.asMap().keySet()) {
63 address = (Number)tuple.get(0).getValue();
64 if (address instanceof Integer) {
65 int addr = (Integer)address;
66 f = consumer.lookupKernelFunction(addr);
68 long addr = (Long)address;
69 f = consumer.lookupKernelFunction(addr);
71 if (f.equals("genunix`cv_wakeup")) {
72 System.out.println(f);
79 } catch (Exception e) {
84 consumer = new LocalConsumer();
87 int pid = consumer.createProcess(cmd);
88 consumer.compile(userLookupProgram);
91 Thread.currentThread().sleep(500);
92 Aggregate a = consumer.getAggregate();
95 for (Aggregation agg : a.getAggregations()) {
96 for (Tuple tuple : agg.asMap().keySet()) {
97 address = (Number)tuple.get(0).getValue();
98 if (address instanceof Integer) {
99 int addr = (Integer)address;
100 f = consumer.lookupUserFunction(pid, addr);
102 long addr = (Long)address;
103 f = consumer.lookupUserFunction(pid, addr);
105 System.out.println(f);
109 } catch (Exception e) {