Skip to content

Commit

Permalink
Use os::lasterror to output user-friendly error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
swesonga committed Feb 29, 2024
1 parent 5655cea commit dbfd5ea
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/hotspot/os/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4120,7 +4120,13 @@ DWORD os::win32::active_processors_in_job_object() {
warning("os::malloc() failed to allocate %ld bytes for QueryInformationJobObject", job_object_information_length);
}
} else {
warning("Unexpected QueryInformationJobObject error code: GetLastError->%ld.", last_error);
char buf[512];
size_t buf_len = os::lasterror(buf, sizeof(buf));
if (buf_len != 0) {
warning(buf);
} else {
warning("Attempt to query job object information failed.");
}
assert(false, "Unexpected QueryInformationJobObject error code");
return 0;
}
Expand All @@ -4143,7 +4149,13 @@ DWORD os::win32::system_logical_processor_count() {
if (nullptr == system_logical_processor_info) {
warning("os::malloc() failed to allocate %ld bytes for GetLogicalProcessorInformationEx buffer", returned_length);
} else if (GetLogicalProcessorInformationEx(relationship_type, system_logical_processor_info, &returned_length) == 0) {
warning("GetLogicalProcessorInformationEx() failed: GetLastError->%ld.", GetLastError());
char buf[512];
size_t buf_len = os::lasterror(buf, sizeof(buf));
if (buf_len != 0) {
warning(buf);
} else {
warning("Attempt to determine logical processor count from GetLogicalProcessorInformationEx() failed.");
}
} else {
DWORD processor_groups = system_logical_processor_info->Group.ActiveGroupCount;

Expand All @@ -4160,7 +4172,13 @@ DWORD os::win32::system_logical_processor_count() {

os::free(system_logical_processor_info);
} else {
warning("GetLogicalProcessorInformationEx() failed: GetLastError->%ld.", last_error);
char buf[512];
size_t buf_len = os::lasterror(buf, sizeof(buf));
if (buf_len != 0) {
warning(buf);
} else {
warning("Attempt to determine logical processor count from GetLogicalProcessorInformationEx() failed.");
}
}
}

Expand Down

0 comments on commit dbfd5ea

Please sign in to comment.