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