23 Star 19 Fork 74

src-openEuler / openjdk-1.8.0

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
create-jfr-dump-file-with-pid-or-timestamp-if-specif.patch 3.49 KB
一键复制 编辑 原始数据 按行查看 历史
kuen 提交于 2021-09-17 16:17 . I4AJ95:New features in Bisheng JDK 302
From ef5d7213507f8148ae0b3fd7f82ea4afa5695d72 Mon Sep 17 00:00:00 2001
From: hubodao <hubodao@huawei.com>
Date: Sat, 11 Sep 2021 09:56:54 +0800
Subject: [PATCH 13/23] create jfr dump file with pid or timestamp if specified
Summary: <JFR> : create jfr dump file with pid or timestamp if specified
LLT: NA
Patch Type: huawei
Bug url: NA
---
hotspot/src/share/vm/jfr/dcmd/jfrDcmds.cpp | 16 ++++++++++++++--
.../jdk/jfr/jcmd/TestJcmdDumpWithFileName.java | 16 ++++++++++++++++
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/hotspot/src/share/vm/jfr/dcmd/jfrDcmds.cpp b/hotspot/src/share/vm/jfr/dcmd/jfrDcmds.cpp
index 167405e39..9585de28c 100644
--- a/hotspot/src/share/vm/jfr/dcmd/jfrDcmds.cpp
+++ b/hotspot/src/share/vm/jfr/dcmd/jfrDcmds.cpp
@@ -226,7 +226,13 @@ void JfrDumpFlightRecordingDCmd::execute(DCmdSource source, TRAPS) {
jstring filepath = NULL;
if (_filename.is_set() && _filename.value() != NULL) {
- filepath = JfrJavaSupport::new_string(_filename.value(), CHECK);
+ const char* extended_path = make_log_name(_filename.value(), NULL);
+ if (extended_path != NULL) {
+ filepath = JfrJavaSupport::new_string(extended_path, CHECK);
+ FREE_C_HEAP_ARRAY(char, extended_path, mtInternal);
+ } else {
+ filepath = JfrJavaSupport::new_string(_filename.value(), CHECK);
+ }
}
jobject maxage = NULL;
@@ -394,7 +400,13 @@ void JfrStartFlightRecordingDCmd::execute(DCmdSource source, TRAPS) {
jstring filename = NULL;
if (_filename.is_set() && _filename.value() != NULL) {
- filename = JfrJavaSupport::new_string(_filename.value(), CHECK);
+ const char* dumpPath = make_log_name(_filename.value(), NULL);
+ if (dumpPath != NULL) {
+ filename = JfrJavaSupport::new_string(dumpPath, CHECK);
+ FREE_C_HEAP_ARRAY(char, dumpPath, mtInternal);
+ } else {
+ filename = JfrJavaSupport::new_string(_filename.value(), CHECK);
+ }
}
jobject maxage = NULL;
diff --git a/jdk/test/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java b/jdk/test/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java
index 40ff35b4d..f0c39564f 100644
--- a/jdk/test/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java
+++ b/jdk/test/jdk/jfr/jcmd/TestJcmdDumpWithFileName.java
@@ -48,6 +48,7 @@ public class TestJcmdDumpWithFileName {
testDumpAll();
testDumpNamed();
testDumpNamedWithFilename();
+ testDumpNamedWithFilenameExpansion();
}
private static void testDumpAll() throws Exception {
@@ -96,6 +97,21 @@ public class TestJcmdDumpWithFileName {
}
cleanup();
}
+
+ private static void testDumpNamedWithFilenameExpansion() throws Exception {
+ long pid = ProcessTools.getProcessId();
+ Path dumpPath = Paths.get("dumpPath-%p-%t.jfr").toAbsolutePath();
+ try (Recording r = new Recording()) {
+ r.setName("testDumpNamedWithFilenameExpansion");
+ r.setDestination(dumpPath);
+ r.start();
+ JcmdHelper.jcmd("JFR.dump", "name=testDumpNamedWithFilenameExpansion", "filename=" + dumpPath.toString());
+ Stream<Path> stream = Files.find(Paths.get("."), 1, (s, a) -> s.toString()
+ .matches("^.*dumpPath-pid" + pid + ".\\d{4}.\\d{2}.\\d{2}.\\d{2}.\\d{2}.\\d{2}" + ".jfr") && (a.size() > 0L));
+ Asserts.assertTrue(stream.findAny().isPresent());
+ }
+ cleanup();
+ }
private static boolean namedFile(Path dumpFile) throws IOException {
return Files.exists(dumpFile) && (Files.size(dumpFile) > 0);
--
2.22.0
1
https://gitee.com/src-openeuler/openjdk-1.8.0.git
git@gitee.com:src-openeuler/openjdk-1.8.0.git
src-openeuler
openjdk-1.8.0
openjdk-1.8.0
master

搜索帮助