7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 #include "precompiled.hpp" 27 #include "runtime/frame.hpp" 28 #include "runtime/thread.hpp" 29 30 // Forte Analyzer AsyncGetCallTrace profiling support is not implemented on Linux/PPC. 31 bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr, void* ucontext, bool isInJava) { 32 Unimplemented(); 33 return false; 34 } 35 36 void JavaThread::cache_global_variables() { } | 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 #include "precompiled.hpp" 27 #include "runtime/frame.inline.hpp" 28 #include "runtime/thread.hpp" 29 30 bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, bool isInJava) { 31 assert(this->is_Java_thread(), "must be JavaThread"); 32 33 // If we have a last_Java_frame, then we should use it even if 34 // isInJava == true. It should be more reliable than ucontext info. 35 if (has_last_Java_frame() && frame_anchor()->walkable()) { 36 *fr_addr = pd_last_frame(); 37 return true; 38 } 39 40 // At this point, we don't have a last_Java_frame, so 41 // we try to glean some information out of the ucontext 42 // if we were running Java code when SIGPROF came in. 43 if (isInJava) { 44 ucontext_t* uc = (ucontext_t*) ucontext; 45 frame ret_frame((intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/], 46 (address)uc->uc_mcontext.regs->nip); 47 48 if (ret_frame.pc() == NULL) { 49 // ucontext wasn't useful 50 return false; 51 } 52 53 if (ret_frame.is_interpreted_frame()) { 54 frame::ijava_state* istate = ret_frame.get_ijava_state(); 55 if (!((Method*)(istate->method))->is_metaspace_object()) { 56 return false; 57 } 58 uint64_t reg_bcp = uc->uc_mcontext.regs->gpr[14/*R14_bcp*/]; 59 uint64_t istate_bcp = istate->bcp; 60 uint64_t code_start = (uint64_t)(((Method*)(istate->method))->code_base()); 61 uint64_t code_end = (uint64_t)(((Method*)istate->method)->code_base() + ((Method*)istate->method)->code_size()); 62 if (istate_bcp >= code_start && istate_bcp < code_end) { 63 // we have a valid bcp, don't touch it, do nothing 64 } else if (reg_bcp >= code_start && reg_bcp < code_end) { 65 istate->bcp = reg_bcp; 66 } else { 67 return false; 68 } 69 } 70 if (!ret_frame.safe_for_sender(this)) { 71 // nothing else to try if the frame isn't good 72 return false; 73 } 74 *fr_addr = ret_frame; 75 return true; 76 } 77 // nothing else to try 78 return false; 79 } 80 81 // Forte Analyzer AsyncGetCallTrace profiling support is not implemented on Linux/PPC. 82 bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr, void* ucontext, bool isInJava) { 83 assert(this->is_Java_thread(), "must be JavaThread"); 84 return pd_get_top_frame_for_profiling(fr_addr, ucontext, isInJava); 85 } 86 87 void JavaThread::cache_global_variables() { } |