debug.cpp revision 1410
196N/A * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A#
include "incls/_precompiled.incl" 0N/A // NOTE: don't turn the lines below into a comment -- if you're getting 0N/A // a compile error here, change the settings to define ASSERT 0N/A // In case error happens before init or during shutdown 0N/A// Don't rely on anything that is initialized by Threads::create_vm(). For 0N/A// example, don't use tty. 0N/A // The following 1-element cache requires that passed-in 0N/A // file names are always only constant literals. 0N/A // scan the SuppressErrorAt option 0N/A if ((*
cp) ==
'\0')
break;
0N/A // "file:line!" means the assert suppression is not silent 0N/A // update 1-element cache for fast silent matches 0N/A // print a friendly hint: 0N/A// Place-holder for non-existent suppression check: 0N/A// Used by report_vm_out_of_memory to detect recursion. 0N/A // We try to gather additional information for the first out of memory 0N/A // error only; gathering additional data might cause an allocation and a 0N/A // recursive out_of_memory condition. 0N/A // If we succeed in changing the value, we're the first one in. 0N/A // A number of threads may attempt to report OutOfMemoryError at around the 0N/A // same time. To avoid dumping the heap or executing the data collection 0N/A // commands multiple times we just do it once when the first threads reports 0N/A // create heap dump before OnOutOfMemoryError commands are executed 0N/A// call this when the VM is dying--it might loosen some asserts 1410N/A // If asserts are disabled, use the corresponding guarantee instead. 1410N/A const char*
const msg =
"this message should be truncated during formatting";
1410N/A "%s%s# %s%s# %s%s# %s%s# %s%s# " 1410N/A "%s%s# %s%s# %s%s# %s%s# %s",
1410N/A msg,
eol,
msg,
eol,
msg,
eol,
msg,
eol,
msg,
eol,
1410N/A msg,
eol,
msg,
eol,
msg,
eol,
msg,
eol,
msg,
eol,
1410N/A // This is last because it does not generate an hs_err* file on Windows. 0N/A// ------ helper functions for debugging go here ------------ 0N/A// All debug entries should be wrapped with a stack allocated 0N/A// Command object. It makes sure a resource mark is set and 0N/A// flushes the logfile to prevent file sharing problems. 0N/A // Actually we look through all CodeBlobs (the nm name has been kept for backwards compatability) 0N/A // try to run a verify on the entire system 0N/A // note: this may not be safe if we're not at a safepoint; for debugging, 0N/A // this manipulates the safepoint settings to avoid assertion failures 0N/A // Ensure Eden top is correct before verification 0N/Aextern "C" void pp(
void* p) {
0N/A// pv: print vm-printable object 0N/Aextern "C" void ps() {
// print stack 0N/A // Prints the stack of the current Java thread 0N/A // If the last_Java_fp is set we are in C land and 0N/A // can call the standard stack_trace function. 0N/A tty->
print(
"(guessing starting frame id=%#p based on current fp)\n", f.
id());
0N/Aextern "C" void psf() {
// print stack frames 0N/Aextern "C" void pss() {
// print all stacks 0N/Aextern "C" void debug() {
// to set things up for compiler debugging 0N/A// Given a heap address that was valid before the most recent GC, if 0N/A// the oop that used to contain it is still live, prints the new 0N/A// location of the oop and the address. Useful for tracking down 0N/A// certain kinds of naked oop and oop map bugs. 0N/A // Print New Location of old heap address 0N/A tty->
print_cr(
"Requires build with VALIDATE_MARK_SWEEP defined (debug build) and RecordMarkSweepCompaction enabled");
0N/A // the interpreter is generated into a buffer blob 0N/A // the stubroutines are generated into a buffer blob 0N/A // the InlineCacheBuffer is using stubs generated into a buffer blob 0N/A // If we couldn't find it it just may mean that heap wasn't parseable 0N/A // See if we were just given an oop directly 432N/A // Check for privilege stack 0N/A // If the addr is a java thread print information about that. 0N/A // Try an OS specific find 0N/A //FlatProfiler::oops_do(&lookFor); 0N/A// Another interface that isn't ambiguous in dbx. 0N/A// Can we someday rename the other find to hsfind? 0N/A// int versions of all methods to avoid having to type type casts in the debugger 0N/A tty->
print_cr(
" pv(intptr_t p)- ((PrintableResourceObj*) p)->print()");
0N/A// BobV's command parser for debugging on windows when nothing else works. 0N/A (
char *)
"ps",
CMDID_PS,
" Print Current Thread Stack Trace",
0N/A (
char *)
"pp",
CMDID_PP,
" Find out something about a pointer",
0N/A// get_debug_command() 0N/A// Read a command from standard input. 0N/A// This is useful when you have a debugger 0N/A// which doesn't support calling into functions. 0N/A for ( i=0; ; i++ ) {
0N/A for ( i=0; ; i++ ) {
0N/A tty->
print(
"Please enter the hex addr to pass to findm: ");
0N/A tty->
print(
"Please enter the hex addr to pass to findnm: ");
0N/A tty->
print(
"Please enter the hex addr to pass to pp: ");
0N/A for ( j=0; ; j++ ) {
0N/A tty->
print(
"Please enter the hex addr to pass to hsfind: ");