author | trims |
Thu, 27 May 2010 19:08:38 -0700 | |
changeset 5547 | f4b087cbb361 |
parent 670 | ddf3e9583f2f |
child 7397 | 5b173b4ca846 |
permissions | -rw-r--r-- |
363
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
1 |
/* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
2 |
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. |
363
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
4 |
* |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
8 |
* |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
13 |
* accompanied this code). |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
14 |
* |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
18 |
* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
21 |
* questions. |
363
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
22 |
* |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
23 |
*/ |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
24 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
25 |
#include "incls/_precompiled.incl" |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
26 |
#include "incls/_dtraceJSDT_solaris.cpp.incl" |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
27 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
28 |
#ifdef HAVE_DTRACE_H |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
29 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
30 |
#include <sys/types.h> |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
31 |
#include <sys/stat.h> |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
32 |
#include <fcntl.h> |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
33 |
#include <unistd.h> |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
34 |
#include <dtrace.h> |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
35 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
36 |
static const char* devname = "/dev/dtrace/helper"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
37 |
static const char* olddevname = "/devices/pseudo/dtrace@0:helper"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
38 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
39 |
static const char* string_sig = "uintptr_t"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
40 |
static const char* int_sig = "long"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
41 |
static const char* long_sig = "long long"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
42 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
43 |
static void printDOFHelper(dof_helper_t* helper); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
44 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
45 |
static int dofhelper_open() { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
46 |
int fd; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
47 |
if ((fd = open64(devname, O_RDWR)) < 0) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
48 |
// Optimize next calls |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
49 |
devname = olddevname; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
50 |
if ((fd = open64(devname, O_RDWR)) < 0) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
51 |
return -1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
52 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
53 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
54 |
return fd; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
55 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
56 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
57 |
static jint dof_register(jstring module, uint8_t* dof, void* modaddr) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
58 |
int probe; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
59 |
dof_helper_t dh; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
60 |
int fd; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
61 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
62 |
memset(&dh, 0, sizeof(dh)); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
63 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
64 |
char* module_name = java_lang_String::as_utf8_string( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
65 |
JNIHandles::resolve_non_null(module)); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
66 |
jio_snprintf(dh.dofhp_mod, sizeof(dh.dofhp_mod), "%s", module_name); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
67 |
dh.dofhp_dof = (uint64_t)dof; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
68 |
dh.dofhp_addr = (uint64_t)modaddr; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
69 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
70 |
fd = dofhelper_open(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
71 |
if (fd < 0) |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
72 |
return -1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
73 |
probe = ioctl(fd, DTRACEHIOC_ADDDOF, &dh); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
74 |
close(fd); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
75 |
if (PrintDTraceDOF) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
76 |
printDOFHelper(&dh); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
77 |
tty->print_cr("DOF helper id = %d", probe); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
78 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
79 |
return probe; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
80 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
81 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
82 |
int DTraceJSDT::pd_activate( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
83 |
void* moduleBaseAddress, jstring module, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
84 |
jint providers_count, JVM_DTraceProvider* providers) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
85 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
86 |
// We need sections: |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
87 |
// (1) STRTAB |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
88 |
// ( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
89 |
// (2) PROVIDER |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
90 |
// (3) PROBES |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
91 |
// (4) PROBOFFS |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
92 |
// (5) PROBARGS |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
93 |
// ) * Number of Providers |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
94 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
95 |
// Type of sections we create |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
96 |
enum { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
97 |
STRTAB = 0, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
98 |
PROVIDERS = 1, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
99 |
PROBES = 2, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
100 |
PROBE_OFFSETS = 3, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
101 |
ARG_OFFSETS = 4, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
102 |
NUM_SECTIONS = 5 |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
103 |
}; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
104 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
105 |
static int alignment_for[NUM_SECTIONS] = { 1, 4, 8, 4, 1 }; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
106 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
107 |
ResourceMark rm; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
108 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
109 |
uint32_t num_sections = 1 + 4 * providers_count; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
110 |
uint32_t offset = sizeof(dof_hdr_t) + (num_sections * sizeof(dof_sec_t)); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
111 |
uint32_t* secoffs = NEW_RESOURCE_ARRAY(uint32_t, num_sections); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
112 |
uint32_t* secsize = NEW_RESOURCE_ARRAY(uint32_t, num_sections); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
113 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
114 |
// Store offsets of all strings here in such order: |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
115 |
// zero-string (always 0) |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
116 |
// provider1-name |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
117 |
// probe1-function |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
118 |
// probe1-name |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
119 |
// arg-1 |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
120 |
// arg-2 |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
121 |
// ... |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
122 |
// probe2-function |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
123 |
// probe2-name |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
124 |
// arg-1 |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
125 |
// arg-2 |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
126 |
// provider2-name |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
127 |
// ... |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
128 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
129 |
uint32_t strcount = 0; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
130 |
// Count the number of strings we'll need |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
131 |
for(int prvc = 0; prvc < providers_count; ++prvc) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
132 |
JVM_DTraceProvider* provider = &providers[prvc]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
133 |
// Provider name |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
134 |
++strcount; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
135 |
for(int prbc = 0; prbc < provider->probe_count; ++prbc) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
136 |
JVM_DTraceProbe* p = &(provider->probes[prbc]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
137 |
symbolOop sig = JNIHandles::resolve_jmethod_id(p->method)->signature(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
138 |
// function + name + one per argument |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
139 |
strcount += 2 + ArgumentCount(sig).size(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
140 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
141 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
142 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
143 |
// Create place for string offsets |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
144 |
uint32_t* stroffs = NEW_RESOURCE_ARRAY(uint32_t, strcount + 1); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
145 |
uint32_t string_index = 0; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
146 |
uint32_t curstr = 0; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
147 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
148 |
// First we need an empty string: "" |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
149 |
stroffs[curstr++] = string_index; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
150 |
string_index += strlen("") + 1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
151 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
152 |
for(int prvc = 0; prvc < providers_count; ++prvc) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
153 |
JVM_DTraceProvider* provider = &providers[prvc]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
154 |
char* provider_name = java_lang_String::as_utf8_string( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
155 |
JNIHandles::resolve_non_null(provider->name)); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
156 |
stroffs[curstr++] = string_index; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
157 |
string_index += strlen(provider_name) + 1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
158 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
159 |
// All probes |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
160 |
for(int prbc = 0; prbc < provider->probe_count; ++prbc) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
161 |
JVM_DTraceProbe* p = &(provider->probes[prbc]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
162 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
163 |
char* function = java_lang_String::as_utf8_string( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
164 |
JNIHandles::resolve_non_null(p->function)); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
165 |
stroffs[curstr++] = string_index; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
166 |
string_index += strlen(function) + 1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
167 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
168 |
char* name = java_lang_String::as_utf8_string( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
169 |
JNIHandles::resolve_non_null(p->name)); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
170 |
stroffs[curstr++] = string_index; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
171 |
string_index += strlen(name) + 1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
172 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
173 |
symbolOop sig = JNIHandles::resolve_jmethod_id(p->method)->signature(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
174 |
SignatureStream ss(sig); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
175 |
for ( ; !ss.at_return_type(); ss.next()) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
176 |
BasicType bt = ss.type(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
177 |
const char* t = NULL; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
178 |
if (bt == T_OBJECT && |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
179 |
ss.as_symbol_or_null() == vmSymbols::java_lang_String()) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
180 |
t = string_sig; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
181 |
} else if (bt == T_LONG) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
182 |
t = long_sig; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
183 |
} else { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
184 |
t = int_sig; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
185 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
186 |
stroffs[curstr++] = string_index; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
187 |
string_index += strlen(t) + 1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
188 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
189 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
190 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
191 |
secoffs[STRTAB] = offset; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
192 |
secsize[STRTAB] = string_index; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
193 |
offset += string_index; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
194 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
195 |
// Calculate the size of the rest |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
196 |
for(int prvc = 0; prvc < providers_count; ++prvc) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
197 |
JVM_DTraceProvider* provider = &providers[prvc]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
198 |
size_t provider_sec = PROVIDERS + prvc * 4; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
199 |
size_t probe_sec = PROBES + prvc * 4; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
200 |
size_t probeoffs_sec = PROBE_OFFSETS + prvc * 4; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
201 |
size_t argoffs_sec = ARG_OFFSETS + prvc * 4; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
202 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
203 |
// Allocate space for the provider data struction |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
204 |
secoffs[provider_sec] = align_size_up(offset, alignment_for[PROVIDERS]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
205 |
secsize[provider_sec] = sizeof(dof_provider_t); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
206 |
offset = secoffs[provider_sec] + secsize[provider_sec]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
207 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
208 |
// Allocate space for all the probes |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
209 |
secoffs[probe_sec] = align_size_up(offset, alignment_for[PROBES]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
210 |
secsize[probe_sec] = sizeof(dof_probe_t) * provider->probe_count; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
211 |
offset = secoffs[probe_sec] + secsize[probe_sec]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
212 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
213 |
// Allocate space for the probe offsets |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
214 |
secoffs[probeoffs_sec] = align_size_up(offset, alignment_for[PROBE_OFFSETS]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
215 |
secsize[probeoffs_sec] = sizeof(uint32_t) * provider->probe_count; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
216 |
offset = secoffs[probeoffs_sec] + secsize[probeoffs_sec]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
217 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
218 |
// We need number of arguments argoffs |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
219 |
uint32_t argscount = 0; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
220 |
for(int prbc = 0; prbc < provider->probe_count; ++prbc) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
221 |
JVM_DTraceProbe* p = &(provider->probes[prbc]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
222 |
symbolOop sig = JNIHandles::resolve_jmethod_id(p->method)->signature(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
223 |
argscount += ArgumentCount(sig).size(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
224 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
225 |
secoffs[argoffs_sec] = align_size_up(offset, alignment_for[ARG_OFFSETS]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
226 |
secsize[argoffs_sec] = sizeof(uint8_t) * argscount; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
227 |
offset = secoffs[argoffs_sec] + secsize[argoffs_sec]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
228 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
229 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
230 |
uint32_t size = offset; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
231 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
232 |
uint8_t* dof = NEW_RESOURCE_ARRAY(uint8_t, size); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
233 |
if (!dof) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
234 |
return -1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
235 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
236 |
memset((void*)dof, 0, size); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
237 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
238 |
// Fill memory with proper values |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
239 |
dof_hdr_t* hdr = (dof_hdr_t*)dof; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
240 |
hdr->dofh_ident[DOF_ID_MAG0] = DOF_MAG_MAG0; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
241 |
hdr->dofh_ident[DOF_ID_MAG1] = DOF_MAG_MAG1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
242 |
hdr->dofh_ident[DOF_ID_MAG2] = DOF_MAG_MAG2; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
243 |
hdr->dofh_ident[DOF_ID_MAG3] = DOF_MAG_MAG3; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
244 |
hdr->dofh_ident[DOF_ID_MODEL] = DOF_MODEL_NATIVE; // No variants |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
245 |
hdr->dofh_ident[DOF_ID_ENCODING] = DOF_ENCODE_NATIVE; // No variants |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
246 |
hdr->dofh_ident[DOF_ID_VERSION] = DOF_VERSION_1; // No variants |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
247 |
hdr->dofh_ident[DOF_ID_DIFVERS] = DIF_VERSION_2; // No variants |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
248 |
// all other fields of ident to zero |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
249 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
250 |
hdr->dofh_flags = 0; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
251 |
hdr->dofh_hdrsize = sizeof(dof_hdr_t); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
252 |
hdr->dofh_secsize = sizeof(dof_sec_t); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
253 |
hdr->dofh_secnum = num_sections; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
254 |
hdr->dofh_secoff = sizeof(dof_hdr_t); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
255 |
hdr->dofh_loadsz = size; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
256 |
hdr->dofh_filesz = size; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
257 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
258 |
// First section: STRTAB |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
259 |
dof_sec_t* sec = (dof_sec_t*)(dof + sizeof(dof_hdr_t)); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
260 |
sec->dofs_type = DOF_SECT_STRTAB; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
261 |
sec->dofs_align = alignment_for[STRTAB]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
262 |
sec->dofs_flags = DOF_SECF_LOAD; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
263 |
sec->dofs_entsize = 0; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
264 |
sec->dofs_offset = secoffs[STRTAB]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
265 |
sec->dofs_size = secsize[STRTAB]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
266 |
// Make data for this section |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
267 |
char* str = (char*)(dof + sec->dofs_offset); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
268 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
269 |
*str = 0; str += 1; // "" |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
270 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
271 |
// Run through all strings again |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
272 |
for(int prvc = 0; prvc < providers_count; ++prvc) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
273 |
JVM_DTraceProvider* provider = &providers[prvc]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
274 |
char* provider_name = java_lang_String::as_utf8_string( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
275 |
JNIHandles::resolve_non_null(provider->name)); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
276 |
strcpy(str, provider_name); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
277 |
str += strlen(provider_name) + 1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
278 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
279 |
// All probes |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
280 |
for(int prbc = 0; prbc < provider->probe_count; ++prbc) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
281 |
JVM_DTraceProbe* p = &(provider->probes[prbc]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
282 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
283 |
char* function = java_lang_String::as_utf8_string( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
284 |
JNIHandles::resolve_non_null(p->function)); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
285 |
strcpy(str, function); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
286 |
str += strlen(str) + 1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
287 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
288 |
char* name = java_lang_String::as_utf8_string( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
289 |
JNIHandles::resolve_non_null(p->name)); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
290 |
strcpy(str, name); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
291 |
str += strlen(name) + 1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
292 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
293 |
symbolOop sig = JNIHandles::resolve_jmethod_id(p->method)->signature(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
294 |
SignatureStream ss(sig); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
295 |
for ( ; !ss.at_return_type(); ss.next()) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
296 |
BasicType bt = ss.type(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
297 |
const char* t; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
298 |
if (bt == T_OBJECT && |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
299 |
ss.as_symbol_or_null() == vmSymbols::java_lang_String()) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
300 |
t = string_sig; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
301 |
} else if (bt == T_LONG) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
302 |
t = long_sig; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
303 |
} else { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
304 |
t = int_sig; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
305 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
306 |
strcpy(str, t); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
307 |
str += strlen(t) + 1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
308 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
309 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
310 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
311 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
312 |
curstr = 1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
313 |
for(int prvc = 0; prvc < providers_count; ++prvc) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
314 |
JVM_DTraceProvider* provider = &providers[prvc]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
315 |
size_t provider_sec = PROVIDERS + prvc * 4; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
316 |
size_t probe_sec = PROBES + prvc * 4; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
317 |
size_t probeoffs_sec = PROBE_OFFSETS + prvc * 4; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
318 |
size_t argoffs_sec = ARG_OFFSETS + prvc * 4; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
319 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
320 |
// PROVIDER /////////////////////////////////////////////////////////////// |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
321 |
// Section header |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
322 |
sec = (dof_sec_t*) |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
323 |
(dof + sizeof(dof_hdr_t) + sizeof(dof_sec_t) * provider_sec); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
324 |
sec->dofs_type = DOF_SECT_PROVIDER; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
325 |
sec->dofs_align = alignment_for[PROVIDERS]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
326 |
sec->dofs_flags = DOF_SECF_LOAD; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
327 |
sec->dofs_entsize = 0; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
328 |
sec->dofs_offset = secoffs[provider_sec]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
329 |
sec->dofs_size = secsize[provider_sec]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
330 |
// Make provider decriiption |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
331 |
dof_provider_t* prv = (dof_provider_t*)(dof + sec->dofs_offset); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
332 |
prv->dofpv_strtab = STRTAB; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
333 |
prv->dofpv_probes = probe_sec; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
334 |
prv->dofpv_prargs = argoffs_sec; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
335 |
prv->dofpv_proffs = probeoffs_sec; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
336 |
prv->dofpv_name = stroffs[curstr++]; // Index in string table |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
337 |
prv->dofpv_provattr = DOF_ATTR( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
338 |
provider->providerAttributes.nameStability, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
339 |
provider->providerAttributes.dataStability, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
340 |
provider->providerAttributes.dependencyClass); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
341 |
prv->dofpv_modattr = DOF_ATTR( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
342 |
provider->moduleAttributes.nameStability, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
343 |
provider->moduleAttributes.dataStability, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
344 |
provider->moduleAttributes.dependencyClass); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
345 |
prv->dofpv_funcattr = DOF_ATTR( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
346 |
provider->functionAttributes.nameStability, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
347 |
provider->functionAttributes.dataStability, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
348 |
provider->functionAttributes.dependencyClass); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
349 |
prv->dofpv_nameattr = DOF_ATTR( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
350 |
provider->nameAttributes.nameStability, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
351 |
provider->nameAttributes.dataStability, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
352 |
provider->nameAttributes.dependencyClass); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
353 |
prv->dofpv_argsattr = DOF_ATTR( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
354 |
provider->argsAttributes.nameStability, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
355 |
provider->argsAttributes.dataStability, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
356 |
provider->argsAttributes.dependencyClass); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
357 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
358 |
// PROBES ///////////////////////////////////////////////////////////////// |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
359 |
// Section header |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
360 |
sec = (dof_sec_t*) |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
361 |
(dof + sizeof(dof_hdr_t) + sizeof(dof_sec_t) * probe_sec); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
362 |
sec->dofs_type = DOF_SECT_PROBES; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
363 |
sec->dofs_align = alignment_for[PROBES]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
364 |
sec->dofs_flags = DOF_SECF_LOAD; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
365 |
sec->dofs_entsize = sizeof(dof_probe_t); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
366 |
sec->dofs_offset = secoffs[probe_sec]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
367 |
sec->dofs_size = secsize[probe_sec]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
368 |
// Make probes descriptions |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
369 |
uint32_t argsoffs = 0; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
370 |
for(int prbc = 0; prbc < provider->probe_count; ++prbc) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
371 |
JVM_DTraceProbe* probe = &(provider->probes[prbc]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
372 |
methodOop m = JNIHandles::resolve_jmethod_id(probe->method); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
373 |
int arg_count = ArgumentCount(m->signature()).size(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
374 |
assert(m->code() != NULL, "must have an nmethod"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
375 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
376 |
dof_probe_t* prb = |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
377 |
(dof_probe_t*)(dof + sec->dofs_offset + prbc * sizeof(dof_probe_t)); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
378 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
379 |
prb->dofpr_addr = (uint64_t)m->code()->entry_point(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
380 |
prb->dofpr_func = stroffs[curstr++]; // Index in string table |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
381 |
prb->dofpr_name = stroffs[curstr++]; // Index in string table |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
382 |
prb->dofpr_nargv = stroffs[curstr ]; // Index in string table |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
383 |
// We spent siglen strings here |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
384 |
curstr += arg_count; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
385 |
prb->dofpr_xargv = prb->dofpr_nargv; // Same bunch of strings |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
386 |
prb->dofpr_argidx = argsoffs; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
387 |
prb->dofpr_offidx = prbc; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
388 |
prb->dofpr_nargc = arg_count; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
389 |
prb->dofpr_xargc = arg_count; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
390 |
prb->dofpr_noffs = 1; // Number of offsets |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
391 |
// Next bunch of offsets |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
392 |
argsoffs += arg_count; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
393 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
394 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
395 |
// PROFFS ///////////////////////////////////////////////////////////////// |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
396 |
// Section header |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
397 |
sec = (dof_sec_t*) |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
398 |
(dof + sizeof(dof_hdr_t) + sizeof(dof_sec_t) * probeoffs_sec); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
399 |
sec->dofs_type = DOF_SECT_PROFFS; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
400 |
sec->dofs_align = alignment_for[PROBE_OFFSETS]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
401 |
sec->dofs_flags = DOF_SECF_LOAD; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
402 |
sec->dofs_entsize = sizeof(uint32_t); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
403 |
sec->dofs_offset = secoffs[probeoffs_sec]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
404 |
sec->dofs_size = secsize[probeoffs_sec]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
405 |
// Make offsets |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
406 |
for (int prbc = 0; prbc < provider->probe_count; ++prbc) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
407 |
uint32_t* pof = |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
408 |
(uint32_t*)(dof + sec->dofs_offset + sizeof(uint32_t) * prbc); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
409 |
JVM_DTraceProbe* probe = &(provider->probes[prbc]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
410 |
methodOop m = JNIHandles::resolve_jmethod_id(probe->method); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
411 |
*pof = m->code()->trap_offset(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
412 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
413 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
414 |
// PRARGS ///////////////////////////////////////////////////////////////// |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
415 |
// Section header |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
416 |
sec = (dof_sec_t*) |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
417 |
(dof + sizeof(dof_hdr_t) + sizeof(dof_sec_t) * argoffs_sec); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
418 |
sec->dofs_type = DOF_SECT_PRARGS; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
419 |
sec->dofs_align = alignment_for[ARG_OFFSETS]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
420 |
sec->dofs_flags = DOF_SECF_LOAD; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
421 |
sec->dofs_entsize = sizeof(uint8_t); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
422 |
sec->dofs_offset = secoffs[argoffs_sec]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
423 |
sec->dofs_size = secsize[argoffs_sec]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
424 |
// Make arguments |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
425 |
uint8_t* par = (uint8_t*)(dof + sec->dofs_offset); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
426 |
for (int prbc = 0; prbc < provider->probe_count; ++prbc) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
427 |
JVM_DTraceProbe* p = &(provider->probes[prbc]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
428 |
symbolOop sig = JNIHandles::resolve_jmethod_id(p->method)->signature(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
429 |
uint8_t count = (uint8_t)ArgumentCount(sig).size(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
430 |
for (uint8_t i = 0; i < count; ++i) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
431 |
*par++ = i; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
432 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
433 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
434 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
435 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
436 |
// Register module |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
437 |
return dof_register(module, dof, moduleBaseAddress); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
438 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
439 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
440 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
441 |
void DTraceJSDT::pd_dispose(int handle) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
442 |
int fd; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
443 |
if (handle == -1) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
444 |
return; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
445 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
446 |
fd = dofhelper_open(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
447 |
if (fd < 0) |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
448 |
return; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
449 |
ioctl(fd, DTRACEHIOC_REMOVE, handle); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
450 |
close(fd); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
451 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
452 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
453 |
jboolean DTraceJSDT::pd_is_supported() { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
454 |
int fd = dofhelper_open(); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
455 |
if (fd < 0) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
456 |
return false; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
457 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
458 |
close(fd); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
459 |
return true; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
460 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
461 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
462 |
static const char* dofSecTypeFor(uint32_t type) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
463 |
switch (type) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
464 |
case 0: return "DOF_SECT_NONE"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
465 |
case 1: return "DOF_SECT_COMMENTS"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
466 |
case 2: return "DOF_SECT_SOURCE"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
467 |
case 3: return "DOF_SECT_ECBDESC"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
468 |
case 4: return "DOF_SECT_PROBEDESC"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
469 |
case 5: return "DOF_SECT_ACTDESC"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
470 |
case 6: return "DOF_SECT_DIFOHDR"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
471 |
case 7: return "DOF_SECT_DIF"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
472 |
case 8: return "DOF_SECT_STRTAB"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
473 |
case 9: return "DOF_SECT_VARTAB"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
474 |
case 10: return "DOF_SECT_RELTAB"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
475 |
case 11: return "DOF_SECT_TYPETAB"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
476 |
case 12: return "DOF_SECT_URELHDR"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
477 |
case 13: return "DOF_SECT_KRELHDR"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
478 |
case 14: return "DOF_SECT_OPTDESC"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
479 |
case 15: return "DOF_SECT_PROVIDER"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
480 |
case 16: return "DOF_SECT_PROBES"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
481 |
case 17: return "DOF_SECT_PRARGS"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
482 |
case 18: return "DOF_SECT_PROFFS"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
483 |
case 19: return "DOF_SECT_INTTAB"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
484 |
case 20: return "DOF_SECT_UTSNAME"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
485 |
case 21: return "DOF_SECT_XLTAB"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
486 |
case 22: return "DOF_SECT_XLMEMBERS"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
487 |
case 23: return "DOF_SECT_XLIMPORT"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
488 |
case 24: return "DOF_SECT_XLEXPORT"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
489 |
case 25: return "DOF_SECT_PREXPORT"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
490 |
case 26: return "DOF_SECT_PRENOFFS"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
491 |
default: return "<unknown>"; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
492 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
493 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
494 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
495 |
static void printDOFStringTabSec(void* dof, dof_sec_t* sec) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
496 |
size_t tab = sec->dofs_offset; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
497 |
size_t limit = sec->dofs_size; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
498 |
tty->print_cr("// String Table:"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
499 |
for (size_t idx = 0; idx < limit; /*empty*/) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
500 |
char* str = ((char*)dof) + tab + idx; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
501 |
tty->print_cr("// [0x%x + 0x%x] '%s'", tab, idx, str); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
502 |
idx += strlen(str) + 1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
503 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
504 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
505 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
506 |
static void printDOFProviderSec(void* dof, dof_sec_t* sec) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
507 |
dof_provider_t* prov = (dof_provider_t*)((char*)dof + sec->dofs_offset); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
508 |
tty->print_cr("// dof_provider_t {"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
509 |
tty->print_cr("// dofpv_strtab = %d", prov->dofpv_strtab); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
510 |
tty->print_cr("// dofpv_probes = %d", prov->dofpv_probes); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
511 |
tty->print_cr("// dofpv_prargs = %d", prov->dofpv_prargs); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
512 |
tty->print_cr("// dofpv_proffs = %d", prov->dofpv_proffs); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
513 |
tty->print_cr("// dofpv_name = 0x%x", prov->dofpv_name); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
514 |
tty->print_cr("// dofpv_provattr = 0x%08x", prov->dofpv_provattr); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
515 |
tty->print_cr("// dofpv_modattr = 0x%08x", prov->dofpv_modattr); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
516 |
tty->print_cr("// dofpv_funcattr = 0x%08x", prov->dofpv_funcattr); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
517 |
tty->print_cr("// dofpv_nameattr = 0x%08x", prov->dofpv_nameattr); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
518 |
tty->print_cr("// dofpv_argsattr = 0x%08x", prov->dofpv_argsattr); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
519 |
tty->print_cr("// }"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
520 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
521 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
522 |
static void printDOFProbesSec(void* dof, dof_sec_t* sec) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
523 |
size_t idx = sec->dofs_offset; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
524 |
size_t limit = idx + sec->dofs_size; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
525 |
for (size_t idx = sec->dofs_offset; idx < limit; idx += sec->dofs_entsize) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
526 |
dof_probe_t* prb = (dof_probe_t*)((char*)dof + idx); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
527 |
tty->print_cr("// dof_probe_t {"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
528 |
tty->print_cr("// dofpr_addr = 0x%016llx", prb->dofpr_addr); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
529 |
tty->print_cr("// dofpr_func = 0x%x", prb->dofpr_func); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
530 |
tty->print_cr("// dofpr_name = 0x%x", prb->dofpr_name); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
531 |
tty->print_cr("// dofpr_nargv = 0x%x", prb->dofpr_nargv); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
532 |
tty->print_cr("// dofpr_xargv = 0x%x", prb->dofpr_xargv); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
533 |
tty->print_cr("// dofpr_argidx = 0x%x", prb->dofpr_argidx); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
534 |
tty->print_cr("// dofpr_offidx = 0x%x", prb->dofpr_offidx); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
535 |
tty->print_cr("// dofpr_nargc = %d", prb->dofpr_nargc); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
536 |
tty->print_cr("// dofpr_xargc = %d", prb->dofpr_xargc); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
537 |
tty->print_cr("// dofpr_noffs = %d", prb->dofpr_noffs); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
538 |
tty->print_cr("// }"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
539 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
540 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
541 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
542 |
static void printDOFOffsetsSec(void* dof, dof_sec_t* sec) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
543 |
size_t tab = sec->dofs_offset; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
544 |
size_t limit = sec->dofs_size; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
545 |
tty->print_cr("// Offsets:"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
546 |
for (size_t idx = 0; idx < limit; idx += sec->dofs_entsize) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
547 |
uint32_t* off = (uint32_t*)((char*)dof + tab + idx); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
548 |
tty->print_cr("// [0x%x + 0x%x]: %d", tab, idx, *off); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
549 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
550 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
551 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
552 |
static void printDOFArgsSec(void* dof, dof_sec_t* sec) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
553 |
size_t tab = sec->dofs_offset; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
554 |
size_t limit = sec->dofs_size; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
555 |
tty->print_cr("// Arguments:"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
556 |
for (size_t idx = 0; idx < limit; idx += sec->dofs_entsize) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
557 |
uint8_t* arg = (uint8_t*)((char*)dof + tab + idx); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
558 |
tty->print_cr("// [0x%x + 0x%x]: %d", tab, idx, *arg); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
559 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
560 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
561 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
562 |
static void printDOFSection(void* dof, dof_sec_t* sec) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
563 |
tty->print_cr("// dof_sec_t {"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
564 |
tty->print_cr("// dofs_type = 0x%x /* %s */", |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
565 |
sec->dofs_type, dofSecTypeFor(sec->dofs_type)); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
566 |
tty->print_cr("// dofs_align = %d", sec->dofs_align); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
567 |
tty->print_cr("// dofs_flags = 0x%x", sec->dofs_flags); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
568 |
tty->print_cr("// dofs_entsize = %d", sec->dofs_entsize); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
569 |
tty->print_cr("// dofs_offset = 0x%llx", sec->dofs_offset); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
570 |
tty->print_cr("// dofs_size = %lld", sec->dofs_size); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
571 |
tty->print_cr("// }"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
572 |
switch (sec->dofs_type) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
573 |
case DOF_SECT_STRTAB: printDOFStringTabSec(dof, sec); break; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
574 |
case DOF_SECT_PROVIDER: printDOFProviderSec(dof, sec); break; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
575 |
case DOF_SECT_PROBES: printDOFProbesSec(dof, sec); break; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
576 |
case DOF_SECT_PROFFS: printDOFOffsetsSec(dof, sec); break; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
577 |
case DOF_SECT_PRARGS: printDOFArgsSec(dof, sec); break; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
578 |
default: tty->print_cr("// <section type not recognized>"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
579 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
580 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
581 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
582 |
static void printDOFHeader(dof_hdr_t* hdr) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
583 |
tty->print_cr("// dof_hdr_t {"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
584 |
tty->print_cr("// dofh_ident[DOF_ID_MAG0] = 0x%x", |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
585 |
hdr->dofh_ident[DOF_ID_MAG0]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
586 |
tty->print_cr("// dofh_ident[DOF_ID_MAG1] = 0x%x", |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
587 |
hdr->dofh_ident[DOF_ID_MAG1]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
588 |
tty->print_cr("// dofh_ident[DOF_ID_MAG2] = 0x%x", |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
589 |
hdr->dofh_ident[DOF_ID_MAG2]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
590 |
tty->print_cr("// dofh_ident[DOF_ID_MAG3] = 0x%x", |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
591 |
hdr->dofh_ident[DOF_ID_MAG3]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
592 |
tty->print_cr("// dofh_ident[DOF_ID_MODEL] = 0x%x", |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
593 |
hdr->dofh_ident[DOF_ID_MODEL]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
594 |
tty->print_cr("// dofh_ident[DOF_ID_ENCODING] = 0x%x", |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
595 |
hdr->dofh_ident[DOF_ID_ENCODING]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
596 |
tty->print_cr("// dofh_ident[DOF_ID_VERSION] = 0x%x", |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
597 |
hdr->dofh_ident[DOF_ID_VERSION]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
598 |
tty->print_cr("// dofh_ident[DOF_ID_DIFVERS] = 0x%x", |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
599 |
hdr->dofh_ident[DOF_ID_DIFVERS]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
600 |
tty->print_cr("// dofh_flags = 0x%x", hdr->dofh_flags); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
601 |
tty->print_cr("// dofh_hdrsize = %d", hdr->dofh_hdrsize); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
602 |
tty->print_cr("// dofh_secsize = %d", hdr->dofh_secsize); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
603 |
tty->print_cr("// dofh_secnum = %d", hdr->dofh_secnum); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
604 |
tty->print_cr("// dofh_secoff = %lld", hdr->dofh_secoff); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
605 |
tty->print_cr("// dofh_loadsz = %lld", hdr->dofh_loadsz); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
606 |
tty->print_cr("// dofh_filesz = %lld", hdr->dofh_filesz); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
607 |
tty->print_cr("// }"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
608 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
609 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
610 |
static void printDOF(void* dof) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
611 |
dof_hdr_t* hdr = (dof_hdr_t*)dof; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
612 |
printDOFHeader(hdr); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
613 |
for (int i = 0; i < hdr->dofh_secnum; ++i) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
614 |
dof_sec_t* sec = |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
615 |
(dof_sec_t*)((char*)dof + sizeof(dof_hdr_t) + i * sizeof(dof_sec_t)); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
616 |
tty->print_cr("// [Section #%d]", i); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
617 |
printDOFSection(dof, sec); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
618 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
619 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
620 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
621 |
/** |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
622 |
* This prints out hex data in a 'windbg' or 'xxd' form, where each line is: |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
623 |
* <hex-address>: 8 * <hex-halfword> <ascii translation> |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
624 |
* example: |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
625 |
* 0000000: 7f44 4f46 0102 0102 0000 0000 0000 0000 .DOF............ |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
626 |
* 0000010: 0000 0000 0000 0040 0000 0020 0000 0005 .......@... .... |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
627 |
* 0000020: 0000 0000 0000 0040 0000 0000 0000 015d .......@.......] |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
628 |
* ... |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
629 |
*/ |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
630 |
static void printDOFRawData(void* dof) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
631 |
size_t size = ((dof_hdr_t*)dof)->dofh_loadsz; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
632 |
size_t limit = (size + 16) / 16 * 16; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
633 |
for (size_t i = 0; i < limit; ++i) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
634 |
if (i % 16 == 0) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
635 |
tty->print("%07x:", i); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
636 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
637 |
if (i % 2 == 0) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
638 |
tty->print(" "); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
639 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
640 |
if (i < size) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
641 |
tty->print("%02x", ((unsigned char*)dof)[i]); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
642 |
} else { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
643 |
tty->print(" "); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
644 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
645 |
if ((i + 1) % 16 == 0) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
646 |
tty->print(" "); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
647 |
for (size_t j = 0; j < 16; ++j) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
648 |
size_t idx = i + j - 15; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
649 |
char c = ((char*)dof)[idx]; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
650 |
if (idx < size) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
651 |
tty->print("%c", c >= 32 && c <= 126 ? c : '.'); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
652 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
653 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
654 |
tty->print_cr(""); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
655 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
656 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
657 |
tty->print_cr(""); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
658 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
659 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
660 |
static void printDOFHelper(dof_helper_t* helper) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
661 |
tty->print_cr("// dof_helper_t {"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
662 |
tty->print_cr("// dofhp_mod = \"%s\"", helper->dofhp_mod); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
663 |
tty->print_cr("// dofhp_addr = 0x%016llx", helper->dofhp_addr); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
664 |
tty->print_cr("// dofhp_dof = 0x%016llx", helper->dofhp_dof); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
665 |
printDOF((void*)helper->dofhp_dof); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
666 |
tty->print_cr("// }"); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
667 |
printDOFRawData((void*)helper->dofhp_dof); |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
668 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
669 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
670 |
#else // ndef HAVE_DTRACE_H |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
671 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
672 |
// Get here if we're not building on at least Solaris 10 |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
673 |
int DTraceJSDT::pd_activate( |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
674 |
void* baseAddress, jstring module, |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
675 |
jint provider_count, JVM_DTraceProvider* providers) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
676 |
return -1; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
677 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
678 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
679 |
void DTraceJSDT::pd_dispose(int handle) { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
680 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
681 |
|
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
682 |
jboolean DTraceJSDT::pd_is_supported() { |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
683 |
return false; |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
684 |
} |
99d43e8a76ad
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff
changeset
|
685 |
#endif |