annotate src/share/vm/prims/forte.cpp @ 1349:547cbe6dacc5

6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly Reviewed-by: kvn
author never
date Thu, 01 Apr 2010 16:06:57 -0700
parents d1605aabd0a1
children cff162798819
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
196
d1605aabd0a1 6719955: Update copyright year
xdono
parents: 107
diff changeset
2 * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_forte.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
28 // These name match the names reported by the forte quality kit
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
29 enum {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
30 ticks_no_Java_frame = 0,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
31 ticks_no_class_load = -1,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
32 ticks_GC_active = -2,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
33 ticks_unknown_not_Java = -3,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
34 ticks_not_walkable_not_Java = -4,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
35 ticks_unknown_Java = -5,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
36 ticks_not_walkable_Java = -6,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
37 ticks_unknown_state = -7,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
38 ticks_thread_exit = -8,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
39 ticks_deopt = -9,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
40 ticks_safepoint = -10
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
41 };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 //-------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // Native interfaces for use by Forte tools.
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 #ifndef IA64
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 class vframeStreamForte : public vframeStreamCommon {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // constructor that starts with sender of frame fr (top_frame)
a61af66fc99e Initial load
duke
parents:
diff changeset
53 vframeStreamForte(JavaThread *jt, frame fr, bool stop_at_java_call_stub);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 void forte_next();
a61af66fc99e Initial load
duke
parents:
diff changeset
55 };
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
58 static bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, nmethod* nm);
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
59 static bool is_decipherable_interpreted_frame(JavaThread* thread,
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
60 frame* fr,
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
61 methodOop* method_p,
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
62 int* bci_p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
67 vframeStreamForte::vframeStreamForte(JavaThread *jt,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
68 frame fr,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
69 bool stop_at_java_call_stub) : vframeStreamCommon(jt) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 _stop_at_java_call_stub = stop_at_java_call_stub;
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
72 _frame = fr;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
73
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
74 // We must always have a valid frame to start filling
0
a61af66fc99e Initial load
duke
parents:
diff changeset
75
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
76 bool filled_in = fill_from_frame();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
77
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
78 assert(filled_in, "invariant");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // Solaris SPARC Compiler1 needs an additional check on the grandparent
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // of the top_frame when the parent of the top_frame is interpreted and
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // the grandparent is compiled. However, in this method we do not know
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // the relationship of the current _frame relative to the top_frame so
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // we implement a more broad sanity check. When the previous callee is
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // interpreted and the current sender is compiled, we verify that the
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // current sender is also walkable. If it is not walkable, then we mark
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // the current vframeStream as at the end.
a61af66fc99e Initial load
duke
parents:
diff changeset
91 void vframeStreamForte::forte_next() {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // handle frames with inlining
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if (_mode == compiled_mode &&
a61af66fc99e Initial load
duke
parents:
diff changeset
94 vframeStreamCommon::fill_in_compiled_inlined_sender()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // handle general case
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 int loop_count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 int loop_max = MaxJavaStackTraceDepth * 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 do {
a61af66fc99e Initial load
duke
parents:
diff changeset
105
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
106 loop_count++;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
107
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
108 // By the time we get here we should never see unsafe but better
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
109 // safe then segv'd
0
a61af66fc99e Initial load
duke
parents:
diff changeset
110
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
111 if (loop_count > loop_max || !_frame.safe_for_sender(_thread)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
112 _mode = at_end_mode;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
116 _frame = _frame.sender(&_reg_map);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 } while (!fill_from_frame());
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
121 // Determine if 'fr' is a decipherable compiled frame. We are already
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
122 // assured that fr is for a java nmethod.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
123
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
124 static bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, nmethod* nm) {
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
125 assert(nm->is_java_method(), "invariant");
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
126
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
127 if (thread->has_last_Java_frame() && thread->last_Java_pc() == fr->pc()) {
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
128 // We're stopped at a call into the JVM so look for a PcDesc with
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
129 // the actual pc reported by the frame.
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
130 PcDesc* pc_desc = nm->pc_desc_at(fr->pc());
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
131
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
132 // Did we find a useful PcDesc?
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
133 if (pc_desc != NULL &&
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
134 pc_desc->scope_decode_offset() != DebugInformationRecorder::serialized_null) {
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
135 return true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
138
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
139 // We're at some random pc in the nmethod so search for the PcDesc
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
140 // whose pc is greater than the current PC. It's done this way
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
141 // because the extra PcDescs that are recorded for improved debug
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
142 // info record the end of the region covered by the ScopeDesc
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
143 // instead of the beginning.
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
144 PcDesc* pc_desc = nm->pc_desc_near(fr->pc() + 1);
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
145
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
146 // Now do we have a useful PcDesc?
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
147 if (pc_desc == NULL ||
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
148 pc_desc->scope_decode_offset() == DebugInformationRecorder::serialized_null) {
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
149 // No debug information available for this pc
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
150 // vframeStream would explode if we try and walk the frames.
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
151 return false;
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
152 }
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
153
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
154 // This PcDesc is useful however we must adjust the frame's pc
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
155 // so that the vframeStream lookups will use this same pc
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
156 fr->set_pc(pc_desc->real_pc(nm));
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
157 return true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
160
0
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // Determine if 'fr' is a walkable interpreted frame. Returns false
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // if it is not. *method_p, and *bci_p are not set when false is
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // returned. *method_p is non-NULL if frame was executing a Java
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // method. *bci_p is != -1 if a valid BCI in the Java method could
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // be found.
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // Note: this method returns true when a valid Java method is found
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // even if a valid BCI cannot be found.
a61af66fc99e Initial load
duke
parents:
diff changeset
168
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
169 static bool is_decipherable_interpreted_frame(JavaThread* thread,
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
170 frame* fr,
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
171 methodOop* method_p,
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
172 int* bci_p) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
173 assert(fr->is_interpreted_frame(), "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // top frame is an interpreted frame
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // check if it is walkable (i.e. valid methodOop and valid bci)
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
177
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
178 // Because we may be racing a gc thread the method and/or bci
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
179 // of a valid interpreter frame may look bad causing us to
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
180 // fail the is_interpreted_frame_valid test. If the thread
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
181 // is in any of the following states we are assured that the
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
182 // frame is in fact valid and we must have hit the race.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
183
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
184 JavaThreadState state = thread->thread_state();
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
185 bool known_valid = (state == _thread_in_native ||
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
186 state == _thread_in_vm ||
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
187 state == _thread_blocked );
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
188
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
189 if (known_valid || fr->is_interpreted_frame_valid(thread)) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
190
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
191 // The frame code should completely validate the frame so that
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
192 // references to methodOop and bci are completely safe to access
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
193 // If they aren't the frame code should be fixed not this
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
194 // code. However since gc isn't locked out the values could be
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
195 // stale. This is a race we can never completely win since we can't
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
196 // lock out gc so do one last check after retrieving their values
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
197 // from the frame for additional safety
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
198
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
199 methodOop method = fr->interpreter_frame_method();
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
200
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
201 // We've at least found a method.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
202 // NOTE: there is something to be said for the approach that
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
203 // if we don't find a valid bci then the method is not likely
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
204 // a valid method. Then again we may have caught an interpreter
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
205 // frame in the middle of construction and the bci field is
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
206 // not yet valid.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
207
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
208 *method_p = method;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
209
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
210 // See if gc may have invalidated method since we validated frame
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
211
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
212 if (!Universe::heap()->is_valid_method(method)) return false;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
213
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
214 intptr_t bcx = fr->interpreter_frame_bcx();
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
215
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
216 int bci = method->validate_bci_from_bcx(bcx);
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
217
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
218 // note: bci is set to -1 if not a valid bci
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
219 *bci_p = bci;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
220 return true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
222
0
a61af66fc99e Initial load
duke
parents:
diff changeset
223 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225
a61af66fc99e Initial load
duke
parents:
diff changeset
226
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
227 // Determine if 'fr' can be used to find an initial Java frame.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
228 // Return false if it can not find a fully decipherable Java frame
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
229 // (in other words a frame that isn't safe to use in a vframe stream).
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
230 // Obviously if it can't even find a Java frame false will also be returned.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
231 //
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
232 // If we find a Java frame decipherable or not then by definition we have
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
233 // identified a method and that will be returned to the caller via method_p.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
234 // If we can determine a bci that is returned also. (Hmm is it possible
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
235 // to return a method and bci and still return false? )
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
236 //
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
237 // The initial Java frame we find (if any) is return via initial_frame_p.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
238 //
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
239
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
240 static bool find_initial_Java_frame(JavaThread* thread,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
241 frame* fr,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
242 frame* initial_frame_p,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
243 methodOop* method_p,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
244 int* bci_p) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
245
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
246 // It is possible that for a frame containing an nmethod
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
247 // we can capture the method but no bci. If we get no
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
248 // bci the frame isn't walkable but the method is usable.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
249 // Therefore we init the returned methodOop to NULL so the
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
250 // caller can make the distinction.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
251
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
252 *method_p = NULL;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
253
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
254 // On the initial call to this method the frame we get may not be
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
255 // recognizable to us. This should only happen if we are in a JRT_LEAF
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
256 // or something called by a JRT_LEAF method.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
257
0
a61af66fc99e Initial load
duke
parents:
diff changeset
258
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
259
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
260 frame candidate = *fr;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
261
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
262 // If the starting frame we were given has no codeBlob associated with
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
263 // it see if we can find such a frame because only frames with codeBlobs
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
264 // are possible Java frames.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
265
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
266 if (fr->cb() == NULL) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
267
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
268 // See if we can find a useful frame
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
269 int loop_count;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
270 int loop_max = MaxJavaStackTraceDepth * 2;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
271 RegisterMap map(thread, false);
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
272
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
273 for (loop_count = 0; loop_count < loop_max; loop_count++) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
274 if (!candidate.safe_for_sender(thread)) return false;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
275 candidate = candidate.sender(&map);
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
276 if (candidate.cb() != NULL) break;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
277 }
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
278 if (candidate.cb() == NULL) return false;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
281 // We have a frame known to be in the codeCache
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
282 // We will hopefully be able to figure out something to do with it.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
283 int loop_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
284 int loop_max = MaxJavaStackTraceDepth * 2;
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
285 RegisterMap map(thread, false);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 for (loop_count = 0; loop_count < loop_max; loop_count++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
288
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
289 if (candidate.is_first_frame()) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
290 // If initial frame is frame from StubGenerator and there is no
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
291 // previous anchor, there are no java frames associated with a method
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
292 return false;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
293 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
294
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
295 if (candidate.is_interpreted_frame()) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
296 if (is_decipherable_interpreted_frame(thread, &candidate, method_p, bci_p)) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
297 *initial_frame_p = candidate;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
298 return true;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
299 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
300
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
301 // Hopefully we got some data
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
302 return false;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
304
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
305 if (candidate.cb()->is_nmethod()) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
306
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
307 nmethod* nm = (nmethod*) candidate.cb();
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
308 *method_p = nm->method();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
309
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
310 // If the frame isn't fully decipherable then the default
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
311 // value for the bci is a signal that we don't have a bci.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
312 // If we have a decipherable frame this bci value will
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
313 // not be used.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
314
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
315 *bci_p = -1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
316
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
317 *initial_frame_p = candidate;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
318
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
319 // Native wrapper code is trivial to decode by vframeStream
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
320
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
321 if (nm->is_native_method()) return true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
322
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
323 // If it isn't decipherable then we have found a pc that doesn't
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
324 // have a PCDesc that can get us a bci however we did find
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
325 // a method
0
a61af66fc99e Initial load
duke
parents:
diff changeset
326
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
327 if (!is_decipherable_compiled_frame(thread, &candidate, nm)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
328 return false;
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
329 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
330
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
331 // is_decipherable_compiled_frame may modify candidate's pc
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
332 *initial_frame_p = candidate;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
333
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
334 assert(nm->pc_desc_at(candidate.pc()) != NULL, "if it's decipherable then pc must be valid");
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
335
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
336 return true;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
337 }
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
338
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
339 // Must be some stub frame that we don't care about
0
a61af66fc99e Initial load
duke
parents:
diff changeset
340
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
341 if (!candidate.safe_for_sender(thread)) return false;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
342 candidate = candidate.sender(&map);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
343
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
344 // If it isn't in the code cache something is wrong
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
345 // since once we find a frame in the code cache they
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
346 // all should be there.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
347
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
348 if (candidate.cb() == NULL) return false;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
349
0
a61af66fc99e Initial load
duke
parents:
diff changeset
350 }
a61af66fc99e Initial load
duke
parents:
diff changeset
351
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
352 return false;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
353
0
a61af66fc99e Initial load
duke
parents:
diff changeset
354 }
a61af66fc99e Initial load
duke
parents:
diff changeset
355
a61af66fc99e Initial load
duke
parents:
diff changeset
356
a61af66fc99e Initial load
duke
parents:
diff changeset
357 // call frame copied from old .h file and renamed
a61af66fc99e Initial load
duke
parents:
diff changeset
358 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 jint lineno; // line number in the source file
a61af66fc99e Initial load
duke
parents:
diff changeset
360 jmethodID method_id; // method executed in this frame
a61af66fc99e Initial load
duke
parents:
diff changeset
361 } ASGCT_CallFrame;
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363 // call trace copied from old .h file and renamed
a61af66fc99e Initial load
duke
parents:
diff changeset
364 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
365 JNIEnv *env_id; // Env where trace was recorded
a61af66fc99e Initial load
duke
parents:
diff changeset
366 jint num_frames; // number of frames in this trace
a61af66fc99e Initial load
duke
parents:
diff changeset
367 ASGCT_CallFrame *frames; // frames
a61af66fc99e Initial load
duke
parents:
diff changeset
368 } ASGCT_CallTrace;
a61af66fc99e Initial load
duke
parents:
diff changeset
369
a61af66fc99e Initial load
duke
parents:
diff changeset
370 static void forte_fill_call_trace_given_top(JavaThread* thd,
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
371 ASGCT_CallTrace* trace,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
372 int depth,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
373 frame top_frame) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
374 NoHandleMark nhm;
a61af66fc99e Initial load
duke
parents:
diff changeset
375
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
376 frame initial_Java_frame;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
377 methodOop method;
a61af66fc99e Initial load
duke
parents:
diff changeset
378 int bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
379 int count;
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
382 assert(trace->frames != NULL, "trace->frames must be non-NULL");
a61af66fc99e Initial load
duke
parents:
diff changeset
383
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
384 bool fully_decipherable = find_initial_Java_frame(thd, &top_frame, &initial_Java_frame, &method, &bci);
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
385
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
386 // The frame might not be walkable but still recovered a method
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
387 // (e.g. an nmethod with no scope info for the pc
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
388
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
389 if (method == NULL) return;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
390
a61af66fc99e Initial load
duke
parents:
diff changeset
391 CollectedHeap* ch = Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
392
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
393 // The method is not stored GC safe so see if GC became active
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
394 // after we entered AsyncGetCallTrace() and before we try to
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
395 // use the methodOop.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
396 // Yes, there is still a window after this check and before
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
397 // we use methodOop below, but we can't lock out GC so that
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
398 // has to be an acceptable risk.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
399 if (!ch->is_valid_method(method)) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
400 trace->num_frames = ticks_GC_active; // -2
0
a61af66fc99e Initial load
duke
parents:
diff changeset
401 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
402 }
a61af66fc99e Initial load
duke
parents:
diff changeset
403
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
404 // We got a Java frame however it isn't fully decipherable
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
405 // so it won't necessarily be safe to use it for the
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
406 // initial frame in the vframe stream.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
407
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
408 if (!fully_decipherable) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
409 // Take whatever method the top-frame decoder managed to scrape up.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
410 // We look further at the top frame only if non-safepoint
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
411 // debugging information is available.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
412 count++;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
413 trace->num_frames = count;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
414 trace->frames[0].method_id = method->find_jmethod_id_or_null();
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
415 if (!method->is_native()) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
416 trace->frames[0].lineno = bci;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
417 } else {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
418 trace->frames[0].lineno = -3;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
419 }
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
420
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
421 if (!initial_Java_frame.safe_for_sender(thd)) return;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
422
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
423 RegisterMap map(thd, false);
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
424 initial_Java_frame = initial_Java_frame.sender(&map);
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
425 }
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
426
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
427 vframeStreamForte st(thd, initial_Java_frame, false);
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
428
0
a61af66fc99e Initial load
duke
parents:
diff changeset
429 for (; !st.at_end() && count < depth; st.forte_next(), count++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
430 bci = st.bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
431 method = st.method();
a61af66fc99e Initial load
duke
parents:
diff changeset
432
a61af66fc99e Initial load
duke
parents:
diff changeset
433 // The method is not stored GC safe so see if GC became active
a61af66fc99e Initial load
duke
parents:
diff changeset
434 // after we entered AsyncGetCallTrace() and before we try to
a61af66fc99e Initial load
duke
parents:
diff changeset
435 // use the methodOop.
a61af66fc99e Initial load
duke
parents:
diff changeset
436 // Yes, there is still a window after this check and before
a61af66fc99e Initial load
duke
parents:
diff changeset
437 // we use methodOop below, but we can't lock out GC so that
a61af66fc99e Initial load
duke
parents:
diff changeset
438 // has to be an acceptable risk.
a61af66fc99e Initial load
duke
parents:
diff changeset
439 if (!ch->is_valid_method(method)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
440 // we throw away everything we've gathered in this sample since
a61af66fc99e Initial load
duke
parents:
diff changeset
441 // none of it is safe
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
442 trace->num_frames = ticks_GC_active; // -2
0
a61af66fc99e Initial load
duke
parents:
diff changeset
443 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
444 }
a61af66fc99e Initial load
duke
parents:
diff changeset
445
a61af66fc99e Initial load
duke
parents:
diff changeset
446 trace->frames[count].method_id = method->find_jmethod_id_or_null();
a61af66fc99e Initial load
duke
parents:
diff changeset
447 if (!method->is_native()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
448 trace->frames[count].lineno = bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
449 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
450 trace->frames[count].lineno = -3;
a61af66fc99e Initial load
duke
parents:
diff changeset
451 }
a61af66fc99e Initial load
duke
parents:
diff changeset
452 }
a61af66fc99e Initial load
duke
parents:
diff changeset
453 trace->num_frames = count;
a61af66fc99e Initial load
duke
parents:
diff changeset
454 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
455 }
a61af66fc99e Initial load
duke
parents:
diff changeset
456
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 // Forte Analyzer AsyncGetCallTrace() entry point. Currently supported
a61af66fc99e Initial load
duke
parents:
diff changeset
459 // on Linux X86, Solaris SPARC and Solaris X86.
a61af66fc99e Initial load
duke
parents:
diff changeset
460 //
a61af66fc99e Initial load
duke
parents:
diff changeset
461 // Async-safe version of GetCallTrace being called from a signal handler
a61af66fc99e Initial load
duke
parents:
diff changeset
462 // when a LWP gets interrupted by SIGPROF but the stack traces are filled
a61af66fc99e Initial load
duke
parents:
diff changeset
463 // with different content (see below).
a61af66fc99e Initial load
duke
parents:
diff changeset
464 //
a61af66fc99e Initial load
duke
parents:
diff changeset
465 // This function must only be called when JVM/TI
a61af66fc99e Initial load
duke
parents:
diff changeset
466 // CLASS_LOAD events have been enabled since agent startup. The enabled
a61af66fc99e Initial load
duke
parents:
diff changeset
467 // event will cause the jmethodIDs to be allocated at class load time.
a61af66fc99e Initial load
duke
parents:
diff changeset
468 // The jmethodIDs cannot be allocated in a signal handler because locks
a61af66fc99e Initial load
duke
parents:
diff changeset
469 // cannot be grabbed in a signal handler safely.
a61af66fc99e Initial load
duke
parents:
diff changeset
470 //
a61af66fc99e Initial load
duke
parents:
diff changeset
471 // void (*AsyncGetCallTrace)(ASGCT_CallTrace *trace, jint depth, void* ucontext)
a61af66fc99e Initial load
duke
parents:
diff changeset
472 //
a61af66fc99e Initial load
duke
parents:
diff changeset
473 // Called by the profiler to obtain the current method call stack trace for
a61af66fc99e Initial load
duke
parents:
diff changeset
474 // a given thread. The thread is identified by the env_id field in the
a61af66fc99e Initial load
duke
parents:
diff changeset
475 // ASGCT_CallTrace structure. The profiler agent should allocate a ASGCT_CallTrace
a61af66fc99e Initial load
duke
parents:
diff changeset
476 // structure with enough memory for the requested stack depth. The VM fills in
a61af66fc99e Initial load
duke
parents:
diff changeset
477 // the frames buffer and the num_frames field.
a61af66fc99e Initial load
duke
parents:
diff changeset
478 //
a61af66fc99e Initial load
duke
parents:
diff changeset
479 // Arguments:
a61af66fc99e Initial load
duke
parents:
diff changeset
480 //
a61af66fc99e Initial load
duke
parents:
diff changeset
481 // trace - trace data structure to be filled by the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
482 // depth - depth of the call stack trace.
a61af66fc99e Initial load
duke
parents:
diff changeset
483 // ucontext - ucontext_t of the LWP
a61af66fc99e Initial load
duke
parents:
diff changeset
484 //
a61af66fc99e Initial load
duke
parents:
diff changeset
485 // ASGCT_CallTrace:
a61af66fc99e Initial load
duke
parents:
diff changeset
486 // typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
487 // JNIEnv *env_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
488 // jint num_frames;
a61af66fc99e Initial load
duke
parents:
diff changeset
489 // ASGCT_CallFrame *frames;
a61af66fc99e Initial load
duke
parents:
diff changeset
490 // } ASGCT_CallTrace;
a61af66fc99e Initial load
duke
parents:
diff changeset
491 //
a61af66fc99e Initial load
duke
parents:
diff changeset
492 // Fields:
a61af66fc99e Initial load
duke
parents:
diff changeset
493 // env_id - ID of thread which executed this trace.
a61af66fc99e Initial load
duke
parents:
diff changeset
494 // num_frames - number of frames in the trace.
a61af66fc99e Initial load
duke
parents:
diff changeset
495 // (< 0 indicates the frame is not walkable).
a61af66fc99e Initial load
duke
parents:
diff changeset
496 // frames - the ASGCT_CallFrames that make up this trace. Callee followed by callers.
a61af66fc99e Initial load
duke
parents:
diff changeset
497 //
a61af66fc99e Initial load
duke
parents:
diff changeset
498 // ASGCT_CallFrame:
a61af66fc99e Initial load
duke
parents:
diff changeset
499 // typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
500 // jint lineno;
a61af66fc99e Initial load
duke
parents:
diff changeset
501 // jmethodID method_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
502 // } ASGCT_CallFrame;
a61af66fc99e Initial load
duke
parents:
diff changeset
503 //
a61af66fc99e Initial load
duke
parents:
diff changeset
504 // Fields:
a61af66fc99e Initial load
duke
parents:
diff changeset
505 // 1) For Java frame (interpreted and compiled),
a61af66fc99e Initial load
duke
parents:
diff changeset
506 // lineno - bci of the method being executed or -1 if bci is not available
a61af66fc99e Initial load
duke
parents:
diff changeset
507 // method_id - jmethodID of the method being executed
a61af66fc99e Initial load
duke
parents:
diff changeset
508 // 2) For native method
a61af66fc99e Initial load
duke
parents:
diff changeset
509 // lineno - (-3)
a61af66fc99e Initial load
duke
parents:
diff changeset
510 // method_id - jmethodID of the method being executed
a61af66fc99e Initial load
duke
parents:
diff changeset
511
a61af66fc99e Initial load
duke
parents:
diff changeset
512 extern "C" {
a61af66fc99e Initial load
duke
parents:
diff changeset
513 void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) {
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
514
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
515 // This is if'd out because we no longer use thread suspension.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
516 // However if someone wanted to backport this to a 5.0 jvm then this
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
517 // code would be important.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
518 #if 0
0
a61af66fc99e Initial load
duke
parents:
diff changeset
519 if (SafepointSynchronize::is_synchronizing()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
520 // The safepoint mechanism is trying to synchronize all the threads.
a61af66fc99e Initial load
duke
parents:
diff changeset
521 // Since this can involve thread suspension, it is not safe for us
a61af66fc99e Initial load
duke
parents:
diff changeset
522 // to be here. We can reduce the deadlock risk window by quickly
a61af66fc99e Initial load
duke
parents:
diff changeset
523 // returning to the SIGPROF handler. However, it is still possible
a61af66fc99e Initial load
duke
parents:
diff changeset
524 // for VMThread to catch us here or in the SIGPROF handler. If we
a61af66fc99e Initial load
duke
parents:
diff changeset
525 // are suspended while holding a resource and another thread blocks
a61af66fc99e Initial load
duke
parents:
diff changeset
526 // on that resource in the SIGPROF handler, then we will have a
a61af66fc99e Initial load
duke
parents:
diff changeset
527 // three-thread deadlock (VMThread, this thread, the other thread).
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
528 trace->num_frames = ticks_safepoint; // -10
0
a61af66fc99e Initial load
duke
parents:
diff changeset
529 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
530 }
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
531 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
532
a61af66fc99e Initial load
duke
parents:
diff changeset
533 JavaThread* thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
534
a61af66fc99e Initial load
duke
parents:
diff changeset
535 if (trace->env_id == NULL ||
a61af66fc99e Initial load
duke
parents:
diff changeset
536 (thread = JavaThread::thread_from_jni_environment(trace->env_id)) == NULL ||
a61af66fc99e Initial load
duke
parents:
diff changeset
537 thread->is_exiting()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
538
a61af66fc99e Initial load
duke
parents:
diff changeset
539 // bad env_id, thread has exited or thread is exiting
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
540 trace->num_frames = ticks_thread_exit; // -8
0
a61af66fc99e Initial load
duke
parents:
diff changeset
541 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
542 }
a61af66fc99e Initial load
duke
parents:
diff changeset
543
a61af66fc99e Initial load
duke
parents:
diff changeset
544 if (thread->in_deopt_handler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
545 // thread is in the deoptimization handler so return no frames
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
546 trace->num_frames = ticks_deopt; // -9
0
a61af66fc99e Initial load
duke
parents:
diff changeset
547 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
548 }
a61af66fc99e Initial load
duke
parents:
diff changeset
549
a61af66fc99e Initial load
duke
parents:
diff changeset
550 assert(JavaThread::current() == thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
551 "AsyncGetCallTrace must be called by the current interrupted thread");
a61af66fc99e Initial load
duke
parents:
diff changeset
552
a61af66fc99e Initial load
duke
parents:
diff changeset
553 if (!JvmtiExport::should_post_class_load()) {
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
554 trace->num_frames = ticks_no_class_load; // -1
0
a61af66fc99e Initial load
duke
parents:
diff changeset
555 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
556 }
a61af66fc99e Initial load
duke
parents:
diff changeset
557
a61af66fc99e Initial load
duke
parents:
diff changeset
558 if (Universe::heap()->is_gc_active()) {
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
559 trace->num_frames = ticks_GC_active; // -2
0
a61af66fc99e Initial load
duke
parents:
diff changeset
560 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
561 }
a61af66fc99e Initial load
duke
parents:
diff changeset
562
a61af66fc99e Initial load
duke
parents:
diff changeset
563 switch (thread->thread_state()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
564 case _thread_new:
a61af66fc99e Initial load
duke
parents:
diff changeset
565 case _thread_uninitialized:
a61af66fc99e Initial load
duke
parents:
diff changeset
566 case _thread_new_trans:
a61af66fc99e Initial load
duke
parents:
diff changeset
567 // We found the thread on the threads list above, but it is too
a61af66fc99e Initial load
duke
parents:
diff changeset
568 // young to be useful so return that there are no Java frames.
a61af66fc99e Initial load
duke
parents:
diff changeset
569 trace->num_frames = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
570 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
571 case _thread_in_native:
a61af66fc99e Initial load
duke
parents:
diff changeset
572 case _thread_in_native_trans:
a61af66fc99e Initial load
duke
parents:
diff changeset
573 case _thread_blocked:
a61af66fc99e Initial load
duke
parents:
diff changeset
574 case _thread_blocked_trans:
a61af66fc99e Initial load
duke
parents:
diff changeset
575 case _thread_in_vm:
a61af66fc99e Initial load
duke
parents:
diff changeset
576 case _thread_in_vm_trans:
a61af66fc99e Initial load
duke
parents:
diff changeset
577 {
a61af66fc99e Initial load
duke
parents:
diff changeset
578 frame fr;
a61af66fc99e Initial load
duke
parents:
diff changeset
579
a61af66fc99e Initial load
duke
parents:
diff changeset
580 // param isInJava == false - indicate we aren't in Java code
a61af66fc99e Initial load
duke
parents:
diff changeset
581 if (!thread->pd_get_top_frame_for_signal_handler(&fr, ucontext, false)) {
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
582 trace->num_frames = ticks_unknown_not_Java; // -3 unknown frame
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
583 } else {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
584 if (!thread->has_last_Java_frame()) {
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
585 trace->num_frames = 0; // No Java frames
0
a61af66fc99e Initial load
duke
parents:
diff changeset
586 } else {
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
587 trace->num_frames = ticks_not_walkable_not_Java; // -4 non walkable frame by default
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
588 forte_fill_call_trace_given_top(thread, trace, depth, fr);
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
589
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
590 // This assert would seem to be valid but it is not.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
591 // It would be valid if we weren't possibly racing a gc
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
592 // thread. A gc thread can make a valid interpreted frame
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
593 // look invalid. It's a small window but it does happen.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
594 // The assert is left here commented out as a reminder.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
595 // assert(trace->num_frames != ticks_not_walkable_not_Java, "should always be walkable");
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
596
0
a61af66fc99e Initial load
duke
parents:
diff changeset
597 }
a61af66fc99e Initial load
duke
parents:
diff changeset
598 }
a61af66fc99e Initial load
duke
parents:
diff changeset
599 }
a61af66fc99e Initial load
duke
parents:
diff changeset
600 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
601 case _thread_in_Java:
a61af66fc99e Initial load
duke
parents:
diff changeset
602 case _thread_in_Java_trans:
a61af66fc99e Initial load
duke
parents:
diff changeset
603 {
a61af66fc99e Initial load
duke
parents:
diff changeset
604 frame fr;
a61af66fc99e Initial load
duke
parents:
diff changeset
605
a61af66fc99e Initial load
duke
parents:
diff changeset
606 // param isInJava == true - indicate we are in Java code
a61af66fc99e Initial load
duke
parents:
diff changeset
607 if (!thread->pd_get_top_frame_for_signal_handler(&fr, ucontext, true)) {
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
608 trace->num_frames = ticks_unknown_Java; // -5 unknown frame
0
a61af66fc99e Initial load
duke
parents:
diff changeset
609 } else {
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
610 trace->num_frames = ticks_not_walkable_Java; // -6, non walkable frame by default
0
a61af66fc99e Initial load
duke
parents:
diff changeset
611 forte_fill_call_trace_given_top(thread, trace, depth, fr);
a61af66fc99e Initial load
duke
parents:
diff changeset
612 }
a61af66fc99e Initial load
duke
parents:
diff changeset
613 }
a61af66fc99e Initial load
duke
parents:
diff changeset
614 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
615 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
616 // Unknown thread state
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
617 trace->num_frames = ticks_unknown_state; // -7
0
a61af66fc99e Initial load
duke
parents:
diff changeset
618 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
619 }
a61af66fc99e Initial load
duke
parents:
diff changeset
620 }
a61af66fc99e Initial load
duke
parents:
diff changeset
621
a61af66fc99e Initial load
duke
parents:
diff changeset
622
a61af66fc99e Initial load
duke
parents:
diff changeset
623 #ifndef _WINDOWS
a61af66fc99e Initial load
duke
parents:
diff changeset
624 // Support for the Forte(TM) Peformance Tools collector.
a61af66fc99e Initial load
duke
parents:
diff changeset
625 //
a61af66fc99e Initial load
duke
parents:
diff changeset
626 // The method prototype is derived from libcollector.h. For more
a61af66fc99e Initial load
duke
parents:
diff changeset
627 // information, please see the libcollect man page.
a61af66fc99e Initial load
duke
parents:
diff changeset
628
a61af66fc99e Initial load
duke
parents:
diff changeset
629 // Method to let libcollector know about a dynamically loaded function.
a61af66fc99e Initial load
duke
parents:
diff changeset
630 // Because it is weakly bound, the calls become NOP's when the library
a61af66fc99e Initial load
duke
parents:
diff changeset
631 // isn't present.
a61af66fc99e Initial load
duke
parents:
diff changeset
632 void collector_func_load(char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
633 void* null_argument_1,
a61af66fc99e Initial load
duke
parents:
diff changeset
634 void* null_argument_2,
a61af66fc99e Initial load
duke
parents:
diff changeset
635 void *vaddr,
a61af66fc99e Initial load
duke
parents:
diff changeset
636 int size,
a61af66fc99e Initial load
duke
parents:
diff changeset
637 int zero_argument,
a61af66fc99e Initial load
duke
parents:
diff changeset
638 void* null_argument_3);
a61af66fc99e Initial load
duke
parents:
diff changeset
639 #pragma weak collector_func_load
a61af66fc99e Initial load
duke
parents:
diff changeset
640 #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \
a61af66fc99e Initial load
duke
parents:
diff changeset
641 ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),0 : 0 )
a61af66fc99e Initial load
duke
parents:
diff changeset
642 #endif // !_WINDOWS
a61af66fc99e Initial load
duke
parents:
diff changeset
643
a61af66fc99e Initial load
duke
parents:
diff changeset
644 } // end extern "C"
a61af66fc99e Initial load
duke
parents:
diff changeset
645 #endif // !IA64
a61af66fc99e Initial load
duke
parents:
diff changeset
646
a61af66fc99e Initial load
duke
parents:
diff changeset
647 void Forte::register_stub(const char* name, address start, address end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
648 #if !defined(_WINDOWS) && !defined(IA64)
a61af66fc99e Initial load
duke
parents:
diff changeset
649 assert(pointer_delta(end, start, sizeof(jbyte)) < INT_MAX,
a61af66fc99e Initial load
duke
parents:
diff changeset
650 "Code size exceeds maximum range")
a61af66fc99e Initial load
duke
parents:
diff changeset
651
a61af66fc99e Initial load
duke
parents:
diff changeset
652 collector_func_load((char*)name, NULL, NULL, start,
a61af66fc99e Initial load
duke
parents:
diff changeset
653 pointer_delta(end, start, sizeof(jbyte)), 0, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
654 #endif // !_WINDOWS && !IA64
a61af66fc99e Initial load
duke
parents:
diff changeset
655 }