6888954: argument formatting for assert() and friends

Reviewed-by: kvn, twisti, apetrusenko, never, dcubed
This commit is contained in:
John Coomes 2010-04-22 13:23:15 -07:00
parent 7e76feaf42
commit 99196ff9ca
37 changed files with 396 additions and 211 deletions

View file

@ -652,6 +652,11 @@ class CommandLineFlags {
product(bool, PrintGCApplicationStoppedTime, false, \
"Print the time the application has been stopped") \
\
notproduct(uintx, ErrorHandlerTest, 0, \
"If > 0, provokes an error after VM initialization; the value" \
"determines which error to provoke. See test_error_handler()" \
"in debug.cpp.") \
\
develop(bool, Verbose, false, \
"Prints additional debugging information from other modes") \
\

View file

@ -62,7 +62,7 @@ void MemProfiler::engage() {
// Create log file
_log_fp = fopen(log_name , "w+");
if (_log_fp == NULL) {
fatal1("MemProfiler: Cannot create log file: %s", log_name);
fatal(err_msg("MemProfiler: Cannot create log file: %s", log_name));
}
fprintf(_log_fp, "MemProfiler: sizes are in Kb, time is in seconds since startup\n\n");
fprintf(_log_fp, " time, #thr, #cls, heap, heap, perm, perm, code, hndls, rescs, oopmp\n");

View file

@ -1288,8 +1288,9 @@ void Monitor::set_owner_implementation(Thread *new_owner) {
!(this == Safepoint_lock && contains(locks, Terminator_lock) &&
SafepointSynchronize::is_synchronizing())) {
new_owner->print_owned_locks();
fatal4("acquiring lock %s/%d out of order with lock %s/%d -- possible deadlock",
this->name(), this->rank(), locks->name(), locks->rank());
fatal(err_msg("acquiring lock %s/%d out of order with lock %s/%d -- "
"possible deadlock", this->name(), this->rank(),
locks->name(), locks->rank()));
}
this->_next = new_owner->_owned_locks;
@ -1342,7 +1343,8 @@ void Monitor::check_prelock_state(Thread *thread) {
|| rank() == Mutex::special, "wrong thread state for using locks");
if (StrictSafepointChecks) {
if (thread->is_VM_thread() && !allow_vm_block()) {
fatal1("VM thread using lock %s (not allowed to block on)", name());
fatal(err_msg("VM thread using lock %s (not allowed to block on)",
name()));
}
debug_only(if (rank() != Mutex::special) \
thread->check_for_valid_safepoint_state(false);)

View file

@ -136,7 +136,7 @@ void assert_locked_or_safepoint(const Monitor * lock) {
// see if invoker of VM operation owns it
VM_Operation* op = VMThread::vm_operation();
if (op != NULL && op->calling_thread() == lock->owner()) return;
fatal1("must own lock %s", lock->name());
fatal(err_msg("must own lock %s", lock->name()));
}
// a stronger assertion than the above
@ -144,7 +144,7 @@ void assert_lock_strong(const Monitor * lock) {
if (IgnoreLockingAssertions) return;
assert(lock != NULL, "Need non-NULL lock");
if (lock->owned_by_self()) return;
fatal1("must own lock %s", lock->name());
fatal(err_msg("must own lock %s", lock->name()));
}
#endif

View file

@ -406,8 +406,10 @@ char *os::strdup(const char *str) {
#ifdef ASSERT
inline size_t get_size(void* obj) {
size_t size = *size_addr_from_obj(obj);
if (size < 0 )
fatal2("free: size field of object #%p was overwritten (%lu)", obj, size);
if (size < 0) {
fatal(err_msg("free: size field of object #" PTR_FORMAT " was overwritten ("
SIZE_FORMAT ")", obj, size));
}
return size;
}

View file

@ -594,7 +594,7 @@ void SafepointSynchronize::block(JavaThread *thread) {
break;
default:
fatal1("Illegal threadstate encountered: %d", state);
fatal(err_msg("Illegal threadstate encountered: %d", state));
}
// Check for pending. async. exceptions or suspends - except if the

View file

@ -57,7 +57,7 @@ SignatureIterator::SignatureIterator(Thread *thread, symbolOop signature) {
}
void SignatureIterator::expect(char c) {
if (_signature->byte_at(_index) != c) fatal1("expecting %c", c);
if (_signature->byte_at(_index) != c) fatal(err_msg("expecting %c", c));
_index++;
}

View file

@ -118,7 +118,10 @@ void StubRoutines::initialize1() {
ResourceMark rm;
TraceTime timer("StubRoutines generation 1", TraceStartupTime);
_code1 = BufferBlob::create("StubRoutines (1)", code_size1);
if( _code1 == NULL) vm_exit_out_of_memory1(code_size1, "CodeCache: no room for %s", "StubRoutines (1)");
if (_code1 == NULL) {
vm_exit_out_of_memory(code_size1,
"CodeCache: no room for StubRoutines (1)");
}
CodeBuffer buffer(_code1->instructions_begin(), _code1->instructions_size());
StubGenerator_generate(&buffer, false);
}
@ -164,7 +167,10 @@ void StubRoutines::initialize2() {
ResourceMark rm;
TraceTime timer("StubRoutines generation 2", TraceStartupTime);
_code2 = BufferBlob::create("StubRoutines (2)", code_size2);
if( _code2 == NULL) vm_exit_out_of_memory1(code_size2, "CodeCache: no room for %s", "StubRoutines (2)");
if (_code2 == NULL) {
vm_exit_out_of_memory(code_size2,
"CodeCache: no room for StubRoutines (2)");
}
CodeBuffer buffer(_code2->instructions_begin(), _code2->instructions_size());
StubGenerator_generate(&buffer, true);
}

View file

@ -593,7 +593,8 @@ void VMThread::execute(VM_Operation* op) {
// Check the VM operation allows nested VM operation. This normally not the case, e.g., the compiler
// does not allow nested scavenges or compiles.
if (!prev_vm_operation->allow_nested_vm_operations()) {
fatal2("Nested VM operation %s requested by operation %s", op->name(), vm_operation()->name());
fatal(err_msg("Nested VM operation %s requested by operation %s",
op->name(), vm_operation()->name()));
}
op->set_calling_thread(prev_vm_operation->calling_thread(), prev_vm_operation->priority());
}