1 Star 0 Fork 81

Benshuai5D/openjdk-1.8.0

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
0033-8211326-add-OS-user-related-information-to-hs_err-fi.patch 2.93 KB
一键复制 编辑 原始数据 按行查看 历史
Date: Thu, 8 Jun 2023 20:47:32 +0800
Subject: [PATCH 33/59] 8211326: add OS user related information to hs_err file
Bug url: https://bugs.openjdk.org/browse/JDK-8211326
---
hotspot/src/os/posix/vm/os_posix.cpp | 33 ++++++++++++++++++++++
hotspot/src/os/posix/vm/os_posix.hpp | 3 ++
hotspot/src/share/vm/utilities/vmError.cpp | 8 ++++++
3 files changed, 44 insertions(+)
diff --git a/hotspot/src/os/posix/vm/os_posix.cpp b/hotspot/src/os/posix/vm/os_posix.cpp
index 678a1059f..189c8b411 100644
--- a/hotspot/src/os/posix/vm/os_posix.cpp
+++ b/hotspot/src/os/posix/vm/os_posix.cpp
@@ -33,6 +33,8 @@
#include <unistd.h>
#include <sys/resource.h>
#include <sys/utsname.h>
+#include <grp.h>
+#include <pwd.h>
#include <pthread.h>
#include <signal.h>
@@ -233,6 +235,37 @@ void os::Posix::print_uname_info(outputStream* st) {
st->cr();
}
+void os::Posix::print_umask(outputStream* st, mode_t umsk) {
+ st->print((umsk & S_IRUSR) ? "r" : "-");
+ st->print((umsk & S_IWUSR) ? "w" : "-");
+ st->print((umsk & S_IXUSR) ? "x" : "-");
+ st->print((umsk & S_IRGRP) ? "r" : "-");
+ st->print((umsk & S_IWGRP) ? "w" : "-");
+ st->print((umsk & S_IXGRP) ? "x" : "-");
+ st->print((umsk & S_IROTH) ? "r" : "-");
+ st->print((umsk & S_IWOTH) ? "w" : "-");
+ st->print((umsk & S_IXOTH) ? "x" : "-");
+}
+
+void os::Posix::print_user_info(outputStream* st) {
+ unsigned id = (unsigned) ::getuid();
+ st->print("uid : %u ", id);
+ id = (unsigned) ::geteuid();
+ st->print("euid : %u ", id);
+ id = (unsigned) ::getgid();
+ st->print("gid : %u ", id);
+ id = (unsigned) ::getegid();
+ st->print_cr("egid : %u", id);
+ st->cr();
+
+ mode_t umsk = ::umask(0);
+ (void)::umask(umsk);
+ st->print("umask: %04o (", (unsigned) umsk);
+ print_umask(st, umsk);
+ st->print_cr(")");
+ st->cr();
+}
+
bool os::has_allocatable_memory_limit(julong* limit) {
struct rlimit rlim;
int getrlimit_res = getrlimit(RLIMIT_AS, &rlim);
diff --git a/hotspot/src/os/posix/vm/os_posix.hpp b/hotspot/src/os/posix/vm/os_posix.hpp
index d3e55d020..0d29bfbaf 100644
--- a/hotspot/src/os/posix/vm/os_posix.hpp
+++ b/hotspot/src/os/posix/vm/os_posix.hpp
@@ -69,6 +69,9 @@ public:
// effective gid, or if given uid is root.
static bool matches_effective_uid_and_gid_or_root(uid_t uid, gid_t gid);
+ static void print_umask(outputStream* st, mode_t umsk);
+
+ static void print_user_info(outputStream* st);
};
/*
diff --git a/hotspot/src/share/vm/utilities/vmError.cpp b/hotspot/src/share/vm/utilities/vmError.cpp
index 351c21200..44562fe36 100644
--- a/hotspot/src/share/vm/utilities/vmError.cpp
+++ b/hotspot/src/share/vm/utilities/vmError.cpp
@@ -713,6 +713,14 @@ void VMError::report(outputStream* st) {
st->cr();
}
+#ifndef _WIN32
+ STEP(165, "(printing user info)" )
+
+ if (ExtensiveErrorReports && _verbose) {
+ os::Posix::print_user_info(st);
+ }
+#endif
+
STEP(170, "(printing all threads)" )
// all threads
--
2.22.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangyunbo7/openjdk-1.8.0.git
git@gitee.com:zhangyunbo7/openjdk-1.8.0.git
zhangyunbo7
openjdk-1.8.0
openjdk-1.8.0
master

搜索帮助