This commit is contained in:
Paul Hohensee 2012-01-05 17:16:13 -05:00
commit 66388c03c9
5 changed files with 44 additions and 66 deletions

View File

@ -59,6 +59,10 @@ void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char*
VMError::report_coredump_status(buffer, success);
}
int os::get_last_error() {
return errno;
}
bool os::is_debugger_attached() {
// not implemented
return false;

View File

@ -132,7 +132,6 @@ PVOID topLevelVectoredExceptionHandler = NULL;
// save DLL module handle, used by GetModuleFileName
HINSTANCE vm_lib_handle;
static int getLastErrorString(char *buf, size_t len);
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) {
switch (reason) {
@ -1452,7 +1451,7 @@ void * os::dll_load(const char *name, char *ebuf, int ebuflen)
return result;
}
long errcode = GetLastError();
DWORD errcode = GetLastError();
if (errcode == ERROR_MOD_NOT_FOUND) {
strncpy(ebuf, "Can't find dependent libraries", ebuflen-1);
ebuf[ebuflen-1]='\0';
@ -1463,11 +1462,11 @@ void * os::dll_load(const char *name, char *ebuf, int ebuflen)
// If we can read dll-info and find that dll was built
// for an architecture other than Hotspot is running in
// - then print to buffer "DLL was built for a different architecture"
// else call getLastErrorString to obtain system error message
// else call os::lasterror to obtain system error message
// Read system error message into ebuf
// It may or may not be overwritten below (in the for loop and just above)
getLastErrorString(ebuf, (size_t) ebuflen);
lasterror(ebuf, (size_t) ebuflen);
ebuf[ebuflen-1]='\0';
int file_descriptor=::open(name, O_RDONLY | O_BINARY, 0);
if (file_descriptor<0)
@ -1500,7 +1499,7 @@ void * os::dll_load(const char *name, char *ebuf, int ebuflen)
::close(file_descriptor);
if (failed_to_get_lib_arch)
{
// file i/o error - report getLastErrorString(...) msg
// file i/o error - report os::lasterror(...) msg
return NULL;
}
@ -1543,7 +1542,7 @@ void * os::dll_load(const char *name, char *ebuf, int ebuflen)
"Didn't find runing architecture code in arch_array");
// If the architure is right
// but some other error took place - report getLastErrorString(...) msg
// but some other error took place - report os::lasterror(...) msg
if (lib_arch == running_arch)
{
return NULL;
@ -1775,12 +1774,12 @@ void os::print_jni_name_suffix_on(outputStream* st, int args_size) {
// This method is a copy of JDK's sysGetLastErrorString
// from src/windows/hpi/src/system_md.c
size_t os::lasterror(char *buf, size_t len) {
long errval;
size_t os::lasterror(char* buf, size_t len) {
DWORD errval;
if ((errval = GetLastError()) != 0) {
/* DOS error */
int n = (int)FormatMessage(
// DOS error
size_t n = (size_t)FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
errval,
@ -1789,7 +1788,7 @@ size_t os::lasterror(char *buf, size_t len) {
(DWORD)len,
NULL);
if (n > 3) {
/* Drop final '.', CR, LF */
// Drop final '.', CR, LF
if (buf[n - 1] == '\n') n--;
if (buf[n - 1] == '\r') n--;
if (buf[n - 1] == '.') n--;
@ -1799,17 +1798,25 @@ size_t os::lasterror(char *buf, size_t len) {
}
if (errno != 0) {
/* C runtime error that has no corresponding DOS error code */
const char *s = strerror(errno);
// C runtime error that has no corresponding DOS error code
const char* s = strerror(errno);
size_t n = strlen(s);
if (n >= len) n = len - 1;
strncpy(buf, s, n);
buf[n] = '\0';
return n;
}
return 0;
}
int os::get_last_error() {
DWORD error = GetLastError();
if (error == 0)
error = errno;
return (int)error;
}
// sun.misc.Signal
// NOTE that this is a workaround for an apparent kernel bug where if
// a signal handler for SIGBREAK is installed then that signal handler
@ -4746,7 +4753,7 @@ bool os::check_heap(bool force) {
fatal("corrupted C heap");
}
}
int err = GetLastError();
DWORD err = GetLastError();
if (err != ERROR_NO_MORE_ITEMS && err != ERROR_CALL_NOT_IMPLEMENTED) {
fatal(err_msg("heap walk aborted with error %d", err));
}
@ -4778,45 +4785,6 @@ LONG WINAPI os::win32::serialize_fault_filter(struct _EXCEPTION_POINTERS* e) {
return EXCEPTION_CONTINUE_SEARCH;
}
static int getLastErrorString(char *buf, size_t len)
{
long errval;
if ((errval = GetLastError()) != 0)
{
/* DOS error */
size_t n = (size_t)FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
errval,
0,
buf,
(DWORD)len,
NULL);
if (n > 3) {
/* Drop final '.', CR, LF */
if (buf[n - 1] == '\n') n--;
if (buf[n - 1] == '\r') n--;
if (buf[n - 1] == '.') n--;
buf[n] = '\0';
}
return (int)n;
}
if (errno != 0)
{
/* C runtime error that has no corresponding DOS error code */
const char *s = strerror(errno);
size_t n = strlen(s);
if (n >= len) n = len - 1;
strncpy(buf, s, n);
buf[n] = '\0';
return (int)n;
}
return 0;
}
// We don't build a headless jre for Windows
bool os::is_headless_jre() { return false; }

View File

@ -2664,18 +2664,23 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
_max_bootstrap_specifier_index = -1;
if (JvmtiExport::should_post_class_file_load_hook()) {
// Get the cached class file bytes (if any) from the
// class that is being redefined.
JvmtiThreadState *state = JvmtiThreadState::state_for(jt);
KlassHandle *h_class_being_redefined =
state->get_class_being_redefined();
if (h_class_being_redefined != NULL) {
instanceKlassHandle ikh_class_being_redefined =
instanceKlassHandle(THREAD, (*h_class_being_redefined)());
cached_class_file_bytes =
ikh_class_being_redefined->get_cached_class_file_bytes();
cached_class_file_length =
ikh_class_being_redefined->get_cached_class_file_len();
// Get the cached class file bytes (if any) from the class that
// is being redefined or retransformed. We use jvmti_thread_state()
// instead of JvmtiThreadState::state_for(jt) so we don't allocate
// a JvmtiThreadState any earlier than necessary. This will help
// avoid the bug described by 7126851.
JvmtiThreadState *state = jt->jvmti_thread_state();
if (state != NULL) {
KlassHandle *h_class_being_redefined =
state->get_class_being_redefined();
if (h_class_being_redefined != NULL) {
instanceKlassHandle ikh_class_being_redefined =
instanceKlassHandle(THREAD, (*h_class_being_redefined)());
cached_class_file_bytes =
ikh_class_being_redefined->get_cached_class_file_bytes();
cached_class_file_length =
ikh_class_being_redefined->get_cached_class_file_len();
}
}
unsigned char* ptr = cfs->buffer();

View File

@ -502,6 +502,7 @@ class os: AllStatic {
static void print_location(outputStream* st, intptr_t x, bool verbose = false);
static size_t lasterror(char *buf, size_t len);
static int get_last_error();
// Determines whether the calling process is being debugged by a user-mode debugger.
static bool is_debugger_attached();

View File

@ -377,7 +377,7 @@ DeadlockCycle* ThreadService::find_deadlocks_at_safepoint(bool concurrent_locks)
}
}
delete cycle;
return deadlocks;
}