annotate src/share/vm/prims/forte.cpp @ 23961:0cdf9eb633c4

8159515: Improve indy validation Reviewed-by: jrose, hseigel, vlivanov, bmoloden, ctornqvi, mschoene
author coleenp
date Wed, 29 Jun 2016 11:52:27 -0400
parents e8260b6328fb
children dd9cc155639c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17467
55fb97c4c58d 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 11146
diff changeset
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. 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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1489
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1489
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1489
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "code/debugInfoRec.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "code/pcDesc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "gc_interface/collectedHeap.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/space.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "memory/universe.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "oops/oop.inline2.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "prims/forte.hpp"
11146
e619a2766bcc 8016131: nsk/sysdict/vm/stress/chain tests crash the VM in 'entry_frame_is_first()'
rbackman
parents: 10973
diff changeset
34 #include "runtime/javaCalls.hpp"
20197
ce8f6bb717c9 8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents: 17795
diff changeset
35 #include "runtime/thread.inline.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #include "runtime/vframe.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 #include "runtime/vframeArray.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
38
10354
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
39 // call frame copied from old .h file and renamed
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
40 typedef struct {
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
41 jint lineno; // line number in the source file
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
42 jmethodID method_id; // method executed in this frame
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
43 } ASGCT_CallFrame;
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
44
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
45 // call trace copied from old .h file and renamed
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
46 typedef struct {
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
47 JNIEnv *env_id; // Env where trace was recorded
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
48 jint num_frames; // number of frames in this trace
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
49 ASGCT_CallFrame *frames; // frames
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
50 } ASGCT_CallTrace;
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
51
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
52 // 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
53 enum {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
54 ticks_no_Java_frame = 0,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
55 ticks_no_class_load = -1,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
56 ticks_GC_active = -2,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
57 ticks_unknown_not_Java = -3,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
58 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
59 ticks_unknown_Java = -5,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
60 ticks_not_walkable_Java = -6,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
61 ticks_unknown_state = -7,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
62 ticks_thread_exit = -8,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
63 ticks_deopt = -9,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
64 ticks_safepoint = -10
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
65 };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
66
10354
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
67 #if INCLUDE_JVMTI
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
68
0
a61af66fc99e Initial load
duke
parents:
diff changeset
69 //-------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // Native interfaces for use by Forte tools.
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73
14403
75ef1a499665 8019973: PPC64 (part 11): Fix IA64 preprocessor conditionals on AIX.
goetz
parents: 10973
diff changeset
74 #if !defined(IA64) && !defined(PPC64)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 class vframeStreamForte : public vframeStreamCommon {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // constructor that starts with sender of frame fr (top_frame)
a61af66fc99e Initial load
duke
parents:
diff changeset
79 vframeStreamForte(JavaThread *jt, frame fr, bool stop_at_java_call_stub);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 void forte_next();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 };
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
84 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
85 static bool is_decipherable_interpreted_frame(JavaThread* thread,
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
86 frame* fr,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3960
diff changeset
87 Method** method_p,
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
88 int* bci_p);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
93 vframeStreamForte::vframeStreamForte(JavaThread *jt,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
94 frame fr,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
95 bool stop_at_java_call_stub) : vframeStreamCommon(jt) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 _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
98 _frame = fr;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
99
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
100 // We must always have a valid frame to start filling
0
a61af66fc99e Initial load
duke
parents:
diff changeset
101
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
102 bool filled_in = fill_from_frame();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
103
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
104 assert(filled_in, "invariant");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Solaris SPARC Compiler1 needs an additional check on the grandparent
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // of the top_frame when the parent of the top_frame is interpreted and
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // the grandparent is compiled. However, in this method we do not know
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // the relationship of the current _frame relative to the top_frame so
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // we implement a more broad sanity check. When the previous callee is
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // interpreted and the current sender is compiled, we verify that the
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // current sender is also walkable. If it is not walkable, then we mark
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // the current vframeStream as at the end.
a61af66fc99e Initial load
duke
parents:
diff changeset
117 void vframeStreamForte::forte_next() {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // handle frames with inlining
a61af66fc99e Initial load
duke
parents:
diff changeset
119 if (_mode == compiled_mode &&
a61af66fc99e Initial load
duke
parents:
diff changeset
120 vframeStreamCommon::fill_in_compiled_inlined_sender()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // handle general case
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 int loop_count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 int loop_max = MaxJavaStackTraceDepth * 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 do {
a61af66fc99e Initial load
duke
parents:
diff changeset
131
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
132 loop_count++;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
133
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
134 // 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
135 // safe then segv'd
0
a61af66fc99e Initial load
duke
parents:
diff changeset
136
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
137 if (loop_count > loop_max || !_frame.safe_for_sender(_thread)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
138 _mode = at_end_mode;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
142 _frame = _frame.sender(&_reg_map);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 } while (!fill_from_frame());
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
147 // 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
148 // 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
149
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
150 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
151 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
152
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
153 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
154 // 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
155 // the actual pc reported by the frame.
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
156 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
157
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
158 // 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
159 if (pc_desc != NULL &&
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
160 pc_desc->scope_decode_offset() != DebugInformationRecorder::serialized_null) {
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
161 return true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
164
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
165 // 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
166 // 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
167 // 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
168 // 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
169 // instead of the beginning.
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
170 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
171
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
172 // Now do we have a useful PcDesc?
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
173 if (pc_desc == NULL ||
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
174 pc_desc->scope_decode_offset() == DebugInformationRecorder::serialized_null) {
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
175 // No debug information is available for this PC.
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
176 //
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
177 // vframeStreamCommon::fill_from_frame() will decode the frame depending
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
178 // on the state of the thread.
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
179 //
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
180 // Case #1: If the thread is in Java (state == _thread_in_Java), then
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
181 // the vframeStreamCommon object will be filled as if the frame were a native
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
182 // compiled frame. Therefore, no debug information is needed.
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
183 //
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
184 // Case #2: If the thread is in any other state, then two steps will be performed:
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
185 // - if asserts are enabled, found_bad_method_frame() will be called and
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
186 // the assert in found_bad_method_frame() will be triggered;
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
187 // - if asserts are disabled, the vframeStreamCommon object will be filled
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
188 // as if it were a native compiled frame.
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
189 //
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
190 // Case (2) is similar to the way interpreter frames are processed in
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
191 // vframeStreamCommon::fill_from_interpreter_frame in case no valid BCI
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
192 // was found for an interpreted frame. If asserts are enabled, the assert
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
193 // in found_bad_method_frame() will be triggered. If asserts are disabled,
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
194 // the vframeStreamCommon object will be filled afterwards as if the
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
195 // interpreter were at the point of entering into the method.
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
196 return false;
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
197 }
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
198
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
199 // 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
200 // 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
201 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
202 return true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
205
0
a61af66fc99e Initial load
duke
parents:
diff changeset
206 // Determine if 'fr' is a walkable interpreted frame. Returns false
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // if it is not. *method_p, and *bci_p are not set when false is
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // returned. *method_p is non-NULL if frame was executing a Java
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // method. *bci_p is != -1 if a valid BCI in the Java method could
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // be found.
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // Note: this method returns true when a valid Java method is found
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // even if a valid BCI cannot be found.
a61af66fc99e Initial load
duke
parents:
diff changeset
213
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
214 static bool is_decipherable_interpreted_frame(JavaThread* thread,
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
215 frame* fr,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3960
diff changeset
216 Method** method_p,
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
217 int* bci_p) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
218 assert(fr->is_interpreted_frame(), "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // top frame is an interpreted frame
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3960
diff changeset
221 // check if it is walkable (i.e. valid Method* and valid bci)
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
222
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
223 // 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
224 // 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
225 // 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
226 // 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
227 // 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
228
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
229 JavaThreadState state = thread->thread_state();
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
230 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
231 state == _thread_in_vm ||
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
232 state == _thread_blocked );
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
233
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
234 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
235
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
236 // The frame code should completely validate the frame so that
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3960
diff changeset
237 // references to Method* and bci are completely safe to access
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
238 // 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
239 // 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
240 // 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
241 // 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
242 // 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
243
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3960
diff changeset
244 Method* method = fr->interpreter_frame_method();
107
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 // 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
247 // 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
248 // 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
249 // 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
250 // 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
251 // not yet valid.
7176
59c790074993 8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents: 6725
diff changeset
252 if (!method->is_valid_method()) return false;
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
253 *method_p = method; // If the Method* found is invalid, it is
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
254 // ignored by forte_fill_call_trace_given_top().
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
255 // So set method_p only if the Method is valid.
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
256
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
257 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
258
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
259 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
260
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
261 // 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
262 *bci_p = bci;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
263 return true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
265
0
a61af66fc99e Initial load
duke
parents:
diff changeset
266 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
270 // Determine if a Java frame can be found starting with the frame 'fr'.
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
271 //
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
272 // Check the return value of find_initial_Java_frame and the value of
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
273 // 'method_p' to decide on how use the results returned by this method.
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
274 //
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
275 // If 'method_p' is not NULL, an initial Java frame has been found and
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
276 // the stack can be walked starting from that initial frame. In this case,
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
277 // 'method_p' points to the Method that the initial frame belongs to and
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
278 // the initial Java frame is returned in initial_frame_p.
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
279 //
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
280 // find_initial_Java_frame() returns true if a Method has been found (i.e.,
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
281 // 'method_p' is not NULL) and the initial frame that belongs to that Method
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
282 // is decipherable.
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
283 //
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
284 // A frame is considered to be decipherable:
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
285 //
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
286 // - if the frame is a compiled frame and a PCDesc is available;
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
287 //
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
288 // - if the frame is an interpreter frame that is valid or the thread is
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
289 // state (_thread_in_native || state == _thread_in_vm || state == _thread_blocked).
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
290 //
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
291 // Note that find_initial_Java_frame() can return false even if an initial
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
292 // Java method was found (e.g., there is no PCDesc available for the method).
0
a61af66fc99e Initial load
duke
parents:
diff changeset
293 //
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
294 // If 'method_p' is NULL, it was not possible to find a Java frame when
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
295 // walking the stack starting from 'fr'. In this case find_initial_Java_frame
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
296 // returns false.
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
297
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
298 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
299 frame* fr,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
300 frame* initial_frame_p,
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3960
diff changeset
301 Method** method_p,
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
302 int* bci_p) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
303
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
304 // 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
305 // 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
306 // bci the frame isn't walkable but the method is usable.
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3960
diff changeset
307 // Therefore we init the returned Method* to NULL so the
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
308 // caller can make the distinction.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
309
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
310 *method_p = NULL;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
311
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
312 // 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
313 // 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
314 // 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
315
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
316 frame candidate = *fr;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
317
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
318 // 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
319 // 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
320 // are possible Java frames.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
321
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
322 if (fr->cb() == NULL) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
323
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
324 // 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
325 int loop_count;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
326 int loop_max = MaxJavaStackTraceDepth * 2;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
327 RegisterMap map(thread, false);
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
328
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
329 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
330 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
331 candidate = candidate.sender(&map);
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
332 if (candidate.cb() != NULL) break;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
333 }
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
334 if (candidate.cb() == NULL) return false;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
337 // 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
338 // We will hopefully be able to figure out something to do with it.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
339 int loop_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
340 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
341 RegisterMap map(thread, false);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
342
a61af66fc99e Initial load
duke
parents:
diff changeset
343 for (loop_count = 0; loop_count < loop_max; loop_count++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344
11146
e619a2766bcc 8016131: nsk/sysdict/vm/stress/chain tests crash the VM in 'entry_frame_is_first()'
rbackman
parents: 10973
diff changeset
345 if (candidate.is_entry_frame()) {
e619a2766bcc 8016131: nsk/sysdict/vm/stress/chain tests crash the VM in 'entry_frame_is_first()'
rbackman
parents: 10973
diff changeset
346 // jcw is NULL if the java call wrapper couldn't be found
e619a2766bcc 8016131: nsk/sysdict/vm/stress/chain tests crash the VM in 'entry_frame_is_first()'
rbackman
parents: 10973
diff changeset
347 JavaCallWrapper *jcw = candidate.entry_frame_call_wrapper_if_safe(thread);
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
348 // 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
349 // previous anchor, there are no java frames associated with a method
11146
e619a2766bcc 8016131: nsk/sysdict/vm/stress/chain tests crash the VM in 'entry_frame_is_first()'
rbackman
parents: 10973
diff changeset
350 if (jcw == NULL || jcw->is_first_frame()) {
e619a2766bcc 8016131: nsk/sysdict/vm/stress/chain tests crash the VM in 'entry_frame_is_first()'
rbackman
parents: 10973
diff changeset
351 return false;
e619a2766bcc 8016131: nsk/sysdict/vm/stress/chain tests crash the VM in 'entry_frame_is_first()'
rbackman
parents: 10973
diff changeset
352 }
107
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
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
355 if (candidate.is_interpreted_frame()) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
356 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
357 *initial_frame_p = candidate;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
358 return true;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
359 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
360
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
361 // Hopefully we got some data
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
362 return false;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
363 }
a61af66fc99e Initial load
duke
parents:
diff changeset
364
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
365 if (candidate.cb()->is_nmethod()) {
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
366
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
367 nmethod* nm = (nmethod*) candidate.cb();
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
368 *method_p = nm->method();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
369
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
370 // If the frame is not decipherable, then the value of -1
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
371 // for the BCI is used to signal that no BCI is available.
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
372 // Furthermore, the method returns false in this case.
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
373 //
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
374 // If a decipherable frame is available, the BCI value will
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
375 // not be used.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
376
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
377 *bci_p = -1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
378
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
379 *initial_frame_p = candidate;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
380
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
381 // 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
382
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
383 if (nm->is_native_method()) return true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
384
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
385 // If the frame is not decipherable, then a PC was found
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
386 // that does not have a PCDesc from which a BCI can be obtained.
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
387 // Nevertheless, a Method was found.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
388
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
389 if (!is_decipherable_compiled_frame(thread, &candidate, nm)) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
390 return false;
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
391 }
0
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 // 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
394 *initial_frame_p = candidate;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
395
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
396 assert(nm->pc_desc_at(candidate.pc()) != NULL, "debug information must be available if the frame is decipherable");
1349
547cbe6dacc5 6936709: AsyncGetCallTrace doesn't handle inexact stack walking properly
never
parents: 196
diff changeset
397
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
398 return true;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
399 }
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
400
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
401 // Must be some stub frame that we don't care about
0
a61af66fc99e Initial load
duke
parents:
diff changeset
402
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
403 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
404 candidate = candidate.sender(&map);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
405
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
406 // 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
407 // 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
408 // all should be there.
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
409
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
410 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
411
0
a61af66fc99e Initial load
duke
parents:
diff changeset
412 }
a61af66fc99e Initial load
duke
parents:
diff changeset
413
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
414 return false;
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
415
0
a61af66fc99e Initial load
duke
parents:
diff changeset
416 }
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 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
419 ASGCT_CallTrace* trace,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
420 int depth,
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
421 frame top_frame) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
422 NoHandleMark nhm;
a61af66fc99e Initial load
duke
parents:
diff changeset
423
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
424 frame initial_Java_frame;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3960
diff changeset
425 Method* method;
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
426 int bci = -1; // assume BCI is not available for method
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
427 // update with correct information if available
0
a61af66fc99e Initial load
duke
parents:
diff changeset
428 int count;
a61af66fc99e Initial load
duke
parents:
diff changeset
429
a61af66fc99e Initial load
duke
parents:
diff changeset
430 count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
431 assert(trace->frames != NULL, "trace->frames must be non-NULL");
a61af66fc99e Initial load
duke
parents:
diff changeset
432
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
433 // Walk the stack starting from 'top_frame' and search for an initial Java frame.
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
434 find_initial_Java_frame(thd, &top_frame, &initial_Java_frame, &method, &bci);
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
435
23050
e8260b6328fb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 20197
diff changeset
436 // Check if a Java Method has been found.
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
437 if (method == NULL) return;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
438
7176
59c790074993 8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents: 6725
diff changeset
439 if (!method->is_valid_method()) {
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
440 trace->num_frames = ticks_GC_active; // -2
0
a61af66fc99e Initial load
duke
parents:
diff changeset
441 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
442 }
a61af66fc99e Initial load
duke
parents:
diff changeset
443
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
444 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
445
0
a61af66fc99e Initial load
duke
parents:
diff changeset
446 for (; !st.at_end() && count < depth; st.forte_next(), count++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
447 bci = st.bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
448 method = st.method();
a61af66fc99e Initial load
duke
parents:
diff changeset
449
7176
59c790074993 8003635: NPG: AsynchGetCallTrace broken by Method* virtual call
coleenp
parents: 6725
diff changeset
450 if (!method->is_valid_method()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
451 // we throw away everything we've gathered in this sample since
a61af66fc99e Initial load
duke
parents:
diff changeset
452 // 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
453 trace->num_frames = ticks_GC_active; // -2
0
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 trace->frames[count].method_id = method->find_jmethod_id_or_null();
a61af66fc99e Initial load
duke
parents:
diff changeset
458 if (!method->is_native()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
459 trace->frames[count].lineno = bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
460 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
461 trace->frames[count].lineno = -3;
a61af66fc99e Initial load
duke
parents:
diff changeset
462 }
a61af66fc99e Initial load
duke
parents:
diff changeset
463 }
a61af66fc99e Initial load
duke
parents:
diff changeset
464 trace->num_frames = count;
a61af66fc99e Initial load
duke
parents:
diff changeset
465 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
466 }
a61af66fc99e Initial load
duke
parents:
diff changeset
467
a61af66fc99e Initial load
duke
parents:
diff changeset
468
a61af66fc99e Initial load
duke
parents:
diff changeset
469 // Forte Analyzer AsyncGetCallTrace() entry point. Currently supported
a61af66fc99e Initial load
duke
parents:
diff changeset
470 // on Linux X86, Solaris SPARC and Solaris X86.
a61af66fc99e Initial load
duke
parents:
diff changeset
471 //
a61af66fc99e Initial load
duke
parents:
diff changeset
472 // Async-safe version of GetCallTrace being called from a signal handler
a61af66fc99e Initial load
duke
parents:
diff changeset
473 // when a LWP gets interrupted by SIGPROF but the stack traces are filled
a61af66fc99e Initial load
duke
parents:
diff changeset
474 // with different content (see below).
a61af66fc99e Initial load
duke
parents:
diff changeset
475 //
a61af66fc99e Initial load
duke
parents:
diff changeset
476 // This function must only be called when JVM/TI
a61af66fc99e Initial load
duke
parents:
diff changeset
477 // CLASS_LOAD events have been enabled since agent startup. The enabled
a61af66fc99e Initial load
duke
parents:
diff changeset
478 // event will cause the jmethodIDs to be allocated at class load time.
a61af66fc99e Initial load
duke
parents:
diff changeset
479 // The jmethodIDs cannot be allocated in a signal handler because locks
a61af66fc99e Initial load
duke
parents:
diff changeset
480 // cannot be grabbed in a signal handler safely.
a61af66fc99e Initial load
duke
parents:
diff changeset
481 //
a61af66fc99e Initial load
duke
parents:
diff changeset
482 // void (*AsyncGetCallTrace)(ASGCT_CallTrace *trace, jint depth, void* ucontext)
a61af66fc99e Initial load
duke
parents:
diff changeset
483 //
a61af66fc99e Initial load
duke
parents:
diff changeset
484 // Called by the profiler to obtain the current method call stack trace for
a61af66fc99e Initial load
duke
parents:
diff changeset
485 // a given thread. The thread is identified by the env_id field in the
a61af66fc99e Initial load
duke
parents:
diff changeset
486 // ASGCT_CallTrace structure. The profiler agent should allocate a ASGCT_CallTrace
a61af66fc99e Initial load
duke
parents:
diff changeset
487 // structure with enough memory for the requested stack depth. The VM fills in
a61af66fc99e Initial load
duke
parents:
diff changeset
488 // the frames buffer and the num_frames field.
a61af66fc99e Initial load
duke
parents:
diff changeset
489 //
a61af66fc99e Initial load
duke
parents:
diff changeset
490 // Arguments:
a61af66fc99e Initial load
duke
parents:
diff changeset
491 //
a61af66fc99e Initial load
duke
parents:
diff changeset
492 // trace - trace data structure to be filled by the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
493 // depth - depth of the call stack trace.
a61af66fc99e Initial load
duke
parents:
diff changeset
494 // ucontext - ucontext_t of the LWP
a61af66fc99e Initial load
duke
parents:
diff changeset
495 //
a61af66fc99e Initial load
duke
parents:
diff changeset
496 // ASGCT_CallTrace:
a61af66fc99e Initial load
duke
parents:
diff changeset
497 // typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
498 // JNIEnv *env_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
499 // jint num_frames;
a61af66fc99e Initial load
duke
parents:
diff changeset
500 // ASGCT_CallFrame *frames;
a61af66fc99e Initial load
duke
parents:
diff changeset
501 // } ASGCT_CallTrace;
a61af66fc99e Initial load
duke
parents:
diff changeset
502 //
a61af66fc99e Initial load
duke
parents:
diff changeset
503 // Fields:
a61af66fc99e Initial load
duke
parents:
diff changeset
504 // env_id - ID of thread which executed this trace.
a61af66fc99e Initial load
duke
parents:
diff changeset
505 // num_frames - number of frames in the trace.
a61af66fc99e Initial load
duke
parents:
diff changeset
506 // (< 0 indicates the frame is not walkable).
a61af66fc99e Initial load
duke
parents:
diff changeset
507 // frames - the ASGCT_CallFrames that make up this trace. Callee followed by callers.
a61af66fc99e Initial load
duke
parents:
diff changeset
508 //
a61af66fc99e Initial load
duke
parents:
diff changeset
509 // ASGCT_CallFrame:
a61af66fc99e Initial load
duke
parents:
diff changeset
510 // typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
511 // jint lineno;
a61af66fc99e Initial load
duke
parents:
diff changeset
512 // jmethodID method_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
513 // } ASGCT_CallFrame;
a61af66fc99e Initial load
duke
parents:
diff changeset
514 //
a61af66fc99e Initial load
duke
parents:
diff changeset
515 // Fields:
a61af66fc99e Initial load
duke
parents:
diff changeset
516 // 1) For Java frame (interpreted and compiled),
a61af66fc99e Initial load
duke
parents:
diff changeset
517 // lineno - bci of the method being executed or -1 if bci is not available
a61af66fc99e Initial load
duke
parents:
diff changeset
518 // method_id - jmethodID of the method being executed
a61af66fc99e Initial load
duke
parents:
diff changeset
519 // 2) For native method
a61af66fc99e Initial load
duke
parents:
diff changeset
520 // lineno - (-3)
a61af66fc99e Initial load
duke
parents:
diff changeset
521 // method_id - jmethodID of the method being executed
a61af66fc99e Initial load
duke
parents:
diff changeset
522
a61af66fc99e Initial load
duke
parents:
diff changeset
523 extern "C" {
2191
d70fe6ab4436 6588413: Use -fvisibility=hidden for gcc compiles
coleenp
parents: 1972
diff changeset
524 JNIEXPORT
0
a61af66fc99e Initial load
duke
parents:
diff changeset
525 void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) {
a61af66fc99e Initial load
duke
parents:
diff changeset
526 JavaThread* thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
527
a61af66fc99e Initial load
duke
parents:
diff changeset
528 if (trace->env_id == NULL ||
a61af66fc99e Initial load
duke
parents:
diff changeset
529 (thread = JavaThread::thread_from_jni_environment(trace->env_id)) == NULL ||
a61af66fc99e Initial load
duke
parents:
diff changeset
530 thread->is_exiting()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
531
a61af66fc99e Initial load
duke
parents:
diff changeset
532 // 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
533 trace->num_frames = ticks_thread_exit; // -8
0
a61af66fc99e Initial load
duke
parents:
diff changeset
534 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
535 }
a61af66fc99e Initial load
duke
parents:
diff changeset
536
a61af66fc99e Initial load
duke
parents:
diff changeset
537 if (thread->in_deopt_handler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
538 // 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
539 trace->num_frames = ticks_deopt; // -9
0
a61af66fc99e Initial load
duke
parents:
diff changeset
540 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
541 }
a61af66fc99e Initial load
duke
parents:
diff changeset
542
a61af66fc99e Initial load
duke
parents:
diff changeset
543 assert(JavaThread::current() == thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
544 "AsyncGetCallTrace must be called by the current interrupted thread");
a61af66fc99e Initial load
duke
parents:
diff changeset
545
a61af66fc99e Initial load
duke
parents:
diff changeset
546 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
547 trace->num_frames = ticks_no_class_load; // -1
0
a61af66fc99e Initial load
duke
parents:
diff changeset
548 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
549 }
a61af66fc99e Initial load
duke
parents:
diff changeset
550
a61af66fc99e Initial load
duke
parents:
diff changeset
551 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
552 trace->num_frames = ticks_GC_active; // -2
0
a61af66fc99e Initial load
duke
parents:
diff changeset
553 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
554 }
a61af66fc99e Initial load
duke
parents:
diff changeset
555
a61af66fc99e Initial load
duke
parents:
diff changeset
556 switch (thread->thread_state()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
557 case _thread_new:
a61af66fc99e Initial load
duke
parents:
diff changeset
558 case _thread_uninitialized:
a61af66fc99e Initial load
duke
parents:
diff changeset
559 case _thread_new_trans:
a61af66fc99e Initial load
duke
parents:
diff changeset
560 // We found the thread on the threads list above, but it is too
a61af66fc99e Initial load
duke
parents:
diff changeset
561 // young to be useful so return that there are no Java frames.
a61af66fc99e Initial load
duke
parents:
diff changeset
562 trace->num_frames = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
563 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
564 case _thread_in_native:
a61af66fc99e Initial load
duke
parents:
diff changeset
565 case _thread_in_native_trans:
a61af66fc99e Initial load
duke
parents:
diff changeset
566 case _thread_blocked:
a61af66fc99e Initial load
duke
parents:
diff changeset
567 case _thread_blocked_trans:
a61af66fc99e Initial load
duke
parents:
diff changeset
568 case _thread_in_vm:
a61af66fc99e Initial load
duke
parents:
diff changeset
569 case _thread_in_vm_trans:
a61af66fc99e Initial load
duke
parents:
diff changeset
570 {
a61af66fc99e Initial load
duke
parents:
diff changeset
571 frame fr;
a61af66fc99e Initial load
duke
parents:
diff changeset
572
a61af66fc99e Initial load
duke
parents:
diff changeset
573 // param isInJava == false - indicate we aren't in Java code
a61af66fc99e Initial load
duke
parents:
diff changeset
574 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
575 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
576 } else {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
577 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
578 trace->num_frames = 0; // No Java frames
0
a61af66fc99e Initial load
duke
parents:
diff changeset
579 } else {
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
580 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
581 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
582
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
583 // 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
584 // 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
585 // 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
586 // 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
587 // 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
588 // 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
589
0
a61af66fc99e Initial load
duke
parents:
diff changeset
590 }
a61af66fc99e Initial load
duke
parents:
diff changeset
591 }
a61af66fc99e Initial load
duke
parents:
diff changeset
592 }
a61af66fc99e Initial load
duke
parents:
diff changeset
593 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
594 case _thread_in_Java:
a61af66fc99e Initial load
duke
parents:
diff changeset
595 case _thread_in_Java_trans:
a61af66fc99e Initial load
duke
parents:
diff changeset
596 {
a61af66fc99e Initial load
duke
parents:
diff changeset
597 frame fr;
a61af66fc99e Initial load
duke
parents:
diff changeset
598
a61af66fc99e Initial load
duke
parents:
diff changeset
599 // param isInJava == true - indicate we are in Java code
a61af66fc99e Initial load
duke
parents:
diff changeset
600 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
601 trace->num_frames = ticks_unknown_Java; // -5 unknown frame
0
a61af66fc99e Initial load
duke
parents:
diff changeset
602 } else {
107
93b6525e3b82 6603919: Stackwalking crash on x86 -server with Sun Studio's collect -j on
sgoldman
parents: 0
diff changeset
603 trace->num_frames = ticks_not_walkable_Java; // -6, non walkable frame by default
0
a61af66fc99e Initial load
duke
parents:
diff changeset
604 forte_fill_call_trace_given_top(thread, trace, depth, fr);
a61af66fc99e Initial load
duke
parents:
diff changeset
605 }
a61af66fc99e Initial load
duke
parents:
diff changeset
606 }
a61af66fc99e Initial load
duke
parents:
diff changeset
607 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
608 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
609 // Unknown thread state
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_unknown_state; // -7
0
a61af66fc99e Initial load
duke
parents:
diff changeset
611 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
612 }
a61af66fc99e Initial load
duke
parents:
diff changeset
613 }
a61af66fc99e Initial load
duke
parents:
diff changeset
614
a61af66fc99e Initial load
duke
parents:
diff changeset
615
a61af66fc99e Initial load
duke
parents:
diff changeset
616 #ifndef _WINDOWS
a61af66fc99e Initial load
duke
parents:
diff changeset
617 // Support for the Forte(TM) Peformance Tools collector.
a61af66fc99e Initial load
duke
parents:
diff changeset
618 //
a61af66fc99e Initial load
duke
parents:
diff changeset
619 // The method prototype is derived from libcollector.h. For more
a61af66fc99e Initial load
duke
parents:
diff changeset
620 // information, please see the libcollect man page.
a61af66fc99e Initial load
duke
parents:
diff changeset
621
a61af66fc99e Initial load
duke
parents:
diff changeset
622 // Method to let libcollector know about a dynamically loaded function.
a61af66fc99e Initial load
duke
parents:
diff changeset
623 // Because it is weakly bound, the calls become NOP's when the library
a61af66fc99e Initial load
duke
parents:
diff changeset
624 // isn't present.
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3899
diff changeset
625 #ifdef __APPLE__
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3899
diff changeset
626 // XXXDARWIN: Link errors occur even when __attribute__((weak_import))
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3899
diff changeset
627 // is added
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3899
diff changeset
628 #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) (0)
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3899
diff changeset
629 #else
0
a61af66fc99e Initial load
duke
parents:
diff changeset
630 void collector_func_load(char* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
631 void* null_argument_1,
a61af66fc99e Initial load
duke
parents:
diff changeset
632 void* null_argument_2,
a61af66fc99e Initial load
duke
parents:
diff changeset
633 void *vaddr,
a61af66fc99e Initial load
duke
parents:
diff changeset
634 int size,
a61af66fc99e Initial load
duke
parents:
diff changeset
635 int zero_argument,
a61af66fc99e Initial load
duke
parents:
diff changeset
636 void* null_argument_3);
a61af66fc99e Initial load
duke
parents:
diff changeset
637 #pragma weak collector_func_load
a61af66fc99e Initial load
duke
parents:
diff changeset
638 #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \
10973
ef57c43512d6 8014431: cleanup warnings indicated by the -Wunused-value compiler option on linux
ccheung
parents: 10354
diff changeset
639 ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),(void)0 : (void)0 )
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 3899
diff changeset
640 #endif // __APPLE__
0
a61af66fc99e Initial load
duke
parents:
diff changeset
641 #endif // !_WINDOWS
a61af66fc99e Initial load
duke
parents:
diff changeset
642
a61af66fc99e Initial load
duke
parents:
diff changeset
643 } // end extern "C"
14403
75ef1a499665 8019973: PPC64 (part 11): Fix IA64 preprocessor conditionals on AIX.
goetz
parents: 10973
diff changeset
644 #endif // !IA64 && !PPC64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
645
a61af66fc99e Initial load
duke
parents:
diff changeset
646 void Forte::register_stub(const char* name, address start, address end) {
14403
75ef1a499665 8019973: PPC64 (part 11): Fix IA64 preprocessor conditionals on AIX.
goetz
parents: 10973
diff changeset
647 #if !defined(_WINDOWS) && !defined(IA64) && !defined(PPC64)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
648 assert(pointer_delta(end, start, sizeof(jbyte)) < INT_MAX,
1489
cff162798819 6888953: some calls to function-like macros are missing semicolons
jcoomes
parents: 1349
diff changeset
649 "Code size exceeds maximum range");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
650
a61af66fc99e Initial load
duke
parents:
diff changeset
651 collector_func_load((char*)name, NULL, NULL, start,
a61af66fc99e Initial load
duke
parents:
diff changeset
652 pointer_delta(end, start, sizeof(jbyte)), 0, NULL);
14403
75ef1a499665 8019973: PPC64 (part 11): Fix IA64 preprocessor conditionals on AIX.
goetz
parents: 10973
diff changeset
653 #endif // !_WINDOWS && !IA64 && !PPC64
0
a61af66fc99e Initial load
duke
parents:
diff changeset
654 }
10354
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
655
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
656 #else // INCLUDE_JVMTI
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
657 extern "C" {
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
658 JNIEXPORT
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
659 void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) {
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
660 trace->num_frames = ticks_no_class_load; // -1
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
661 }
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
662 }
dcb062bea05b 8013461: There is a symbol AsyncGetCallTrace in libjvm.symbols that does not exist in minimal/libjvm.a when DEBUG_LEVEL == release
jprovino
parents: 7176
diff changeset
663 #endif // INCLUDE_JVMTI