From ccf261403b028f269c684d0d3b48242b2cfcc816 Mon Sep 17 00:00:00 2001 From: Michael Starzinger Date: Tue, 10 Mar 2009 11:23:15 +0100 Subject: [PATCH] * src/vm/vm.cpp (vm_abort_errnum, vm_abort_errno): Removed obsolete functions. * src/vm/vm.hpp: Likewise. * src/mm/memory.cpp: Adapted to use os::abort_errnum() instead. * src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp: Likewise. * src/threads/posix/thread-posix.cpp: Likewise. * src/threads/posix/thread-posix.hpp: Likewise. * src/vm/jit/oprofile-agent.cpp: Likewise. * src/vm/options.c: Likewise. * src/vm/signal.cpp: Likewise. --- src/mm/memory.cpp | 2 +- .../com_sun_cldc_io_j2me_socket_Protocol.cpp | 11 ++++---- src/threads/posix/thread-posix.cpp | 23 +++++++++-------- src/threads/posix/thread-posix.hpp | 4 ++- src/vm/jit/oprofile-agent.cpp | 2 +- src/vm/options.c | 4 ++- src/vm/signal.cpp | 21 ++++++++-------- src/vm/vm.cpp | 25 ++++++++----------- src/vm/vm.hpp | 2 -- 9 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/mm/memory.cpp b/src/mm/memory.cpp index f074e1d20..8c0c5b2a5 100644 --- a/src/mm/memory.cpp +++ b/src/mm/memory.cpp @@ -69,7 +69,7 @@ void memory_mprotect(void *addr, size_t len, int prot) { if (os::mprotect(addr, len, prot) != 0) - vm_abort_errno("memory_mprotect: os::mprotect failed"); + os::abort_errno("memory_mprotect: os::mprotect failed"); } diff --git a/src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp b/src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp index 16bebd345..860d88d5d 100644 --- a/src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp +++ b/src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp @@ -45,6 +45,7 @@ #endif #include "vm/global.h" +#include "vm/os.hpp" #include "vm/vm.hpp" /* REMOVE ME: temporarily */ @@ -116,7 +117,7 @@ JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf(JNIEnv return -1; } else if (result < 0) { - vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf: recv failed"); + os::abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf: recv failed"); } return result; @@ -141,7 +142,7 @@ JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readByte(JNIEnv } else if (result < 0) { // TODO Should throw an IOException. - vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_readByte: recv failed"); + os::abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_readByte: recv failed"); } return byte; @@ -164,7 +165,7 @@ JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf(JNIEnv if (result < 0) { // TODO Should throw an IOException. - vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf: send failed"); + os::abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf: send failed"); } return result; @@ -184,7 +185,7 @@ JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte(JNIEn ssize_t result = send(handle, &byte, 1, 0); if (result < 0) - vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte: send failed"); + os::abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte: send failed"); return result; } @@ -213,7 +214,7 @@ JNIEXPORT void JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_close0(JNIEnv * int result = close(handle); if (result < 0) - vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_close0: close failed"); + os::abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_close0: close failed"); } } // extern "C" diff --git a/src/threads/posix/thread-posix.cpp b/src/threads/posix/thread-posix.cpp index bcc25c9f1..b91e50f1d 100644 --- a/src/threads/posix/thread-posix.cpp +++ b/src/threads/posix/thread-posix.cpp @@ -68,6 +68,7 @@ #include "vm/globals.hpp" #include "vm/javaobjects.hpp" #include "vm/options.h" +#include "vm/os.hpp" #include "vm/signallocal.hpp" #include "vm/string.hpp" #include "vm/vm.hpp" @@ -547,21 +548,21 @@ void threads_impl_thread_free(threadobject *t) result = pthread_cond_destroy(&(t->flc_cond)); if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed"); + os::abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed"); delete t->waitmutex; result = pthread_cond_destroy(&(t->waitcond)); if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed"); + os::abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed"); delete t->suspendmutex; result = pthread_cond_destroy(&(t->suspendcond)); if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed"); + os::abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed"); } #endif @@ -597,7 +598,7 @@ void threads_impl_preinit(void) #if !defined(HAVE___THREAD) result = pthread_key_create(&thread_current_key, NULL); if (result != 0) - vm_abort_errnum(result, "threads_impl_preinit: pthread_key_create failed"); + os::abort_errnum(result, "threads_impl_preinit: pthread_key_create failed"); #endif } @@ -671,12 +672,12 @@ void threads_impl_init(void) result = pthread_attr_init(&attr); if (result != 0) - vm_abort_errnum(result, "threads_impl_init: pthread_attr_init failed"); + os::abort_errnum(result, "threads_impl_init: pthread_attr_init failed"); result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (result != 0) - vm_abort_errnum(result, "threads_impl_init: pthread_attr_setdetachstate failed"); + os::abort_errnum(result, "threads_impl_init: pthread_attr_setdetachstate failed"); } @@ -927,33 +928,33 @@ void threads_impl_thread_start(threadobject *thread, functionptr f) result = pthread_attr_init(&attr); if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_init failed"); + os::abort_errnum(result, "threads_impl_thread_start: pthread_attr_init failed"); result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_setdetachstate failed"); + os::abort_errnum(result, "threads_impl_thread_start: pthread_attr_setdetachstate failed"); /* initialize thread stacksize */ result = pthread_attr_setstacksize(&attr, opt_stacksize); if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_setstacksize failed"); + os::abort_errnum(result, "threads_impl_thread_start: pthread_attr_setstacksize failed"); /* create the thread */ result = pthread_create(&(thread->tid), &attr, threads_startup_thread, &startup); if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_start: pthread_create failed"); + os::abort_errnum(result, "threads_impl_thread_start: pthread_create failed"); /* destroy the thread attributes */ result = pthread_attr_destroy(&attr); if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_destroy failed"); + os::abort_errnum(result, "threads_impl_thread_start: pthread_attr_destroy failed"); /* signal that pthread_create has returned, so thread->tid is valid */ diff --git a/src/threads/posix/thread-posix.hpp b/src/threads/posix/thread-posix.hpp index 8f0e55c71..7dafeae30 100644 --- a/src/threads/posix/thread-posix.hpp +++ b/src/threads/posix/thread-posix.hpp @@ -266,7 +266,9 @@ inline static void thread_set_current(threadobject* t) result = pthread_setspecific(thread_current_key, t); if (result != 0) - vm_abort_errnum(result, "thread_set_current: pthread_setspecific failed"); +#warning Use below method instead! + //os::abort_errnum(result, "thread_set_current: pthread_setspecific failed"); + vm_abort("thread_set_current: pthread_setspecific failed"); #endif } diff --git a/src/vm/jit/oprofile-agent.cpp b/src/vm/jit/oprofile-agent.cpp index 9c6f44ee4..0846f9941 100644 --- a/src/vm/jit/oprofile-agent.cpp +++ b/src/vm/jit/oprofile-agent.cpp @@ -43,7 +43,7 @@ void OprofileAgent::initialize(void) { _handle = op_open_agent(); if (!_handle) - vm_abort_errno("unable to open opagent handle:"); + os::abort_errno("unable to open opagent handle:"); } /** diff --git a/src/vm/options.c b/src/vm/options.c index b5b88a710..3c8ff46a5 100644 --- a/src/vm/options.c +++ b/src/vm/options.c @@ -743,7 +743,9 @@ void options_xx(JavaVMInitArgs *vm_args) file = fopen(filename, "w"); if (file == NULL) - vm_abort_errno("options_xx: fopen failed"); +#warning Use below method instead! + //os::abort_errno("options_xx: fopen failed"); + vm_abort("options_xx: fopen failed"); opt_ProfileMemoryUsageGNUPlot = file; break; diff --git a/src/vm/signal.cpp b/src/vm/signal.cpp index 15d6263b6..9bfe3da3d 100644 --- a/src/vm/signal.cpp +++ b/src/vm/signal.cpp @@ -50,6 +50,7 @@ #include "vm/globals.hpp" #include "vm/method.hpp" #include "vm/options.h" +#include "vm/os.hpp" #include "vm/signallocal.hpp" #include "vm/vm.hpp" @@ -86,22 +87,22 @@ bool signal_init(void) this thread. */ if (sigemptyset(&mask) != 0) - vm_abort_errno("signal_init: sigemptyset failed"); + os::abort_errno("signal_init: sigemptyset failed"); #if !defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) /* Let OpenJDK handle SIGINT itself. */ if (sigaddset(&mask, SIGINT) != 0) - vm_abort_errno("signal_init: sigaddset failed"); + os::abort_errno("signal_init: sigaddset failed"); #endif #if !defined(__FREEBSD__) if (sigaddset(&mask, SIGQUIT) != 0) - vm_abort_errno("signal_init: sigaddset failed"); + os::abort_errno("signal_init: sigaddset failed"); #endif if (sigprocmask(SIG_BLOCK, &mask, NULL) != 0) - vm_abort_errno("signal_init: sigprocmask failed"); + os::abort_errno("signal_init: sigprocmask failed"); #if defined(__LINUX__) && defined(ENABLE_THREADS) /* XXX Remove for exact-GC. */ @@ -229,13 +230,13 @@ void signal_register_signal(int signum, functionptr handler, int flags) function = (void (*)(int, siginfo_t *, void *)) handler; if (sigemptyset(&act.sa_mask) != 0) - vm_abort_errno("signal_register_signal: sigemptyset failed"); + os::abort_errno("signal_register_signal: sigemptyset failed"); act.sa_sigaction = function; act.sa_flags = flags; if (sigaction(signum, &act, NULL) != 0) - vm_abort_errno("signal_register_signal: sigaction failed"); + os::abort_errno("signal_register_signal: sigaction failed"); } @@ -257,18 +258,18 @@ static void signal_thread(void) t = THREADOBJECT; if (sigemptyset(&mask) != 0) - vm_abort_errno("signal_thread: sigemptyset failed"); + os::abort_errno("signal_thread: sigemptyset failed"); #if !defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) /* Let OpenJDK handle SIGINT itself. */ if (sigaddset(&mask, SIGINT) != 0) - vm_abort_errno("signal_thread: sigaddset failed"); + os::abort_errno("signal_thread: sigaddset failed"); #endif #if !defined(__FREEBSD__) if (sigaddset(&mask, SIGQUIT) != 0) - vm_abort_errno("signal_thread: sigaddset failed"); + os::abort_errno("signal_thread: sigaddset failed"); #endif for (;;) { @@ -285,7 +286,7 @@ static void signal_thread(void) } while (result == EINTR); if (result != 0) - vm_abort_errnum(result, "signal_thread: sigwait failed"); + os::abort_errnum(result, "signal_thread: sigwait failed"); #if defined(ENABLE_THREADS) thread_set_state_runnable(t); diff --git a/src/vm/vm.cpp b/src/vm/vm.cpp index cc60d2b68..c4ab5f40c 100644 --- a/src/vm/vm.cpp +++ b/src/vm/vm.cpp @@ -2562,27 +2562,22 @@ void vm_abort(const char* text, ...) { va_list ap; - va_start(ap, text); - os::abort(text, ap); - va_end(ap); -} + log_println("vm_abort: WARNING, port me to C++ and use os::abort() instead."); -void vm_abort_errnum(int errnum, const char* text, ...) -{ - va_list ap; + // Print the log message. + log_start(); va_start(ap, text); - os::abort_errnum(errnum, text, ap); + log_vprint(text, ap); va_end(ap); -} -void vm_abort_errno(const char* text, ...) -{ - va_list ap; + log_finish(); - va_start(ap, text); - os::abort_errno(text, ap); - va_end(ap); + // Print a backtrace. + os::print_backtrace(); + + // Now abort the VM. + os::abort(); } } diff --git a/src/vm/vm.hpp b/src/vm/vm.hpp index 22a355083..30242d4f0 100644 --- a/src/vm/vm.hpp +++ b/src/vm/vm.hpp @@ -193,8 +193,6 @@ java_handle_t *vm_call_method_objectarray(methodinfo *m, java_handle_t *o, java_ // Legacy C interface. void vm_abort(const char* text, ...); -void vm_abort_errnum(int errnum, const char* text, ...); -void vm_abort_errno(const char* text, ...); #ifdef __cplusplus } -- 2.25.1