aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/utilities/debug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/share/vm/utilities/debug.cpp')
-rw-r--r--src/share/vm/utilities/debug.cpp167
1 files changed, 13 insertions, 154 deletions
diff --git a/src/share/vm/utilities/debug.cpp b/src/share/vm/utilities/debug.cpp
index a675c27bf..31d13f794 100644
--- a/src/share/vm/utilities/debug.cpp
+++ b/src/share/vm/utilities/debug.cpp
@@ -314,8 +314,8 @@ bool is_error_reported() {
#ifndef PRODUCT
#include <signal.h>
-void test_error_handler(size_t test_num)
-{
+void test_error_handler() {
+ uintx test_num = ErrorHandlerTest;
if (test_num == 0) return;
// If asserts are disabled, use the corresponding guarantee instead.
@@ -327,6 +327,8 @@ void test_error_handler(size_t test_num)
const char* const eol = os::line_separator();
const char* const msg = "this message should be truncated during formatting";
+ char * const dataPtr = NULL; // bad data pointer
+ const void (*funcPtr)(void) = (const void(*)()) 0xF; // bad function pointer
// Keep this in sync with test/runtime/6888954/vmerrors.sh.
switch (n) {
@@ -348,11 +350,16 @@ void test_error_handler(size_t test_num)
case 9: ShouldNotCallThis();
case 10: ShouldNotReachHere();
case 11: Unimplemented();
- // This is last because it does not generate an hs_err* file on Windows.
- case 12: os::signal_raise(SIGSEGV);
-
- default: ShouldNotReachHere();
+ // There's no guarantee the bad data pointer will crash us
+ // so "break" out to the ShouldNotReachHere().
+ case 12: *dataPtr = '\0'; break;
+ // There's no guarantee the bad function pointer will crash us
+ // so "break" out to the ShouldNotReachHere().
+ case 13: (*funcPtr)(); break;
+
+ default: tty->print_cr("ERROR: %d: unexpected test_num value.", n);
}
+ ShouldNotReachHere();
}
#endif // !PRODUCT
@@ -665,152 +672,4 @@ void help() {
tty->print_cr(" ndebug() - undo debug");
}
-#if 0
-
-// BobV's command parser for debugging on windows when nothing else works.
-
-enum CommandID {
- CMDID_HELP,
- CMDID_QUIT,
- CMDID_HSFIND,
- CMDID_PSS,
- CMDID_PS,
- CMDID_PSF,
- CMDID_FINDM,
- CMDID_FINDNM,
- CMDID_PP,
- CMDID_BPT,
- CMDID_EXIT,
- CMDID_VERIFY,
- CMDID_THREADS,
- CMDID_ILLEGAL = 99
-};
-
-struct CommandParser {
- char *name;
- CommandID code;
- char *description;
-};
-
-struct CommandParser CommandList[] = {
- (char *)"help", CMDID_HELP, " Dump this list",
- (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 Method* 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",
- (char *)"exitvm", CMDID_EXIT, "Exit the VM",
- (char *)"verify", CMDID_VERIFY, "Perform a Heap Verify",
- (char *)"thread", CMDID_THREADS, "Dump Info on all Threads",
- (char *)0, CMDID_ILLEGAL
-};
-
-
-// get_debug_command()
-//
-// Read a command from standard input.
-// This is useful when you have a debugger
-// which doesn't support calling into functions.
-//
-void get_debug_command()
-{
- ssize_t count;
- int i,j;
- bool gotcommand;
- intptr_t addr;
- char buffer[256];
- nmethod *nm;
- Method* m;
-
- tty->print_cr("You have entered the diagnostic command interpreter");
- tty->print("The supported commands are:\n");
- for ( i=0; ; i++ ) {
- if ( CommandList[i].code == CMDID_ILLEGAL )
- break;
- tty->print_cr(" %s \n", CommandList[i].name );
- }
-
- while ( 1 ) {
- gotcommand = false;
- tty->print("Please enter a command: ");
- count = scanf("%s", buffer) ;
- if ( count >=0 ) {
- for ( i=0; ; i++ ) {
- if ( CommandList[i].code == CMDID_ILLEGAL ) {
- if (!gotcommand) tty->print("Invalid command, please try again\n");
- break;
- }
- if ( strcmp(buffer, CommandList[i].name) == 0 ) {
- gotcommand = true;
- switch ( CommandList[i].code ) {
- case CMDID_PS:
- ps();
- break;
- case CMDID_PSS:
- pss();
- break;
- case CMDID_PSF:
- psf();
- break;
- case CMDID_FINDM:
- tty->print("Please enter the hex addr to pass to findm: ");
- scanf("%I64X", &addr);
- m = (Method*)findm(addr);
- tty->print("findm(0x%I64X) returned 0x%I64X\n", addr, m);
- break;
- case CMDID_FINDNM:
- tty->print("Please enter the hex addr to pass to findnm: ");
- scanf("%I64X", &addr);
- nm = (nmethod*)findnm(addr);
- tty->print("findnm(0x%I64X) returned 0x%I64X\n", addr, nm);
- break;
- case CMDID_PP:
- tty->print("Please enter the hex addr to pass to pp: ");
- scanf("%I64X", &addr);
- pp((void*)addr);
- break;
- case CMDID_EXIT:
- exit(0);
- case CMDID_HELP:
- tty->print("Here are the supported commands: ");
- for ( j=0; ; j++ ) {
- if ( CommandList[j].code == CMDID_ILLEGAL )
- break;
- tty->print_cr(" %s -- %s\n", CommandList[j].name,
- CommandList[j].description );
- }
- break;
- case CMDID_QUIT:
- return;
- break;
- case CMDID_BPT:
- BREAKPOINT;
- break;
- case CMDID_VERIFY:
- verify();;
- break;
- case CMDID_THREADS:
- threads();;
- break;
- case CMDID_HSFIND:
- tty->print("Please enter the hex addr to pass to hsfind: ");
- scanf("%I64X", &addr);
- tty->print("Calling hsfind(0x%I64X)\n", addr);
- hsfind(addr);
- break;
- default:
- case CMDID_ILLEGAL:
- break;
- }
- }
- }
- }
- }
-}
-#endif
-
#endif // !PRODUCT