8284726: Print active locale settings in hs_err reports and in VM.info

Reviewed-by: dholmes, mbaesken, kevinw
This commit is contained in:
Thomas Stuefe 2022-04-27 16:50:22 +00:00
parent b675c597e3
commit 6ce4e755a4
3 changed files with 46 additions and 1 deletions

View File

@ -53,6 +53,7 @@
#include <dirent.h>
#include <dlfcn.h>
#include <grp.h>
#include <locale.h>
#include <netdb.h>
#include <pwd.h>
#include <pthread.h>
@ -548,6 +549,33 @@ void os::Posix::print_user_info(outputStream* st) {
st->cr();
}
// Print all active locale categories, one line each
void os::Posix::print_active_locale(outputStream* st) {
st->print_cr("Active Locale:");
// Posix is quiet about how exactly LC_ALL is implemented.
// Just print it out too, in case LC_ALL is held separately
// from the individual categories.
#define LOCALE_CAT_DO(f) \
f(LC_ALL) \
f(LC_COLLATE) \
f(LC_CTYPE) \
f(LC_MESSAGES) \
f(LC_MONETARY) \
f(LC_NUMERIC) \
f(LC_TIME)
#define XX(cat) { cat, #cat },
const struct { int c; const char* name; } categories[] = {
LOCALE_CAT_DO(XX)
{ -1, NULL }
};
#undef XX
#undef LOCALE_CAT_DO
for (int i = 0; categories[i].c != -1; i ++) {
const char* locale = setlocale(categories[i].c, NULL);
st->print_cr("%s=%s", categories[i].name,
((locale != NULL) ? locale : "<unknown>"));
}
}
bool os::get_host_name(char* buf, size_t buflen) {
struct utsname name;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -104,6 +104,8 @@ public:
static bool handle_stack_overflow(JavaThread* thread, address addr, address pc,
const void* ucVoid,
address* stub);
static void print_active_locale(outputStream* st);
};
/*

View File

@ -1146,6 +1146,15 @@ void VMError::report(outputStream* st, bool _verbose) {
st->cr();
}
#ifndef _WIN32
STEP("printing locale settings")
if (_verbose) {
os::Posix::print_active_locale(st);
st->cr();
}
#endif
STEP("printing signal handlers")
if (_verbose) {
@ -1327,6 +1336,12 @@ void VMError::print_vm_info(outputStream* st) {
os::print_environment_variables(st, env_list);
st->cr();
// STEP("printing locale settings")
#ifndef _WIN32
os::Posix::print_active_locale(st);
st->cr();
#endif
// STEP("printing signal handlers")
os::print_signal_handlers(st, buf, sizeof(buf));