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