On Wed, 17 Jul 2024 19:59:10 GMT, Sonia Zaldana Calles <szald...@openjdk.org> wrote:
>> Hi all, >> >> This PR addresses [8334492](https://bugs.openjdk.org/browse/JDK-8334492) >> enabling jcmd diagnostic commands that issue an output file to accept the >> `%p` pattern in the file name and substitute it for the PID. >> >> This PR addresses the following diagnostic commands: >> - [x] Compiler.perfmap >> - [x] GC.heap_dump >> - [x] System.dump_map >> - [x] Thread.dump_to_file >> - [x] VM.cds >> >> Note that some jcmd diagnostic commands already enable this functionality >> (`JFR.configure, JFR.dump, JFR.start and JFR.stop`). >> >> I propose opening a separate issue to track updating the man page similarly >> to how it’s done for the JFR diagnostic commands. For example, >> >> >> filename (Optional) Name of the file to which the flight recording >> data is >> written when the recording is stopped. If no filename is >> given, a >> filename is generated from the PID and the current date >> and is >> placed in the directory where the process was started. The >> filename may also be a directory in which case, the >> filename is >> generated from the PID and the current date in the >> specified >> directory. (STRING, no default value) >> >> Note: If a filename is given, '%p' in the filename will be >> replaced by the PID, and '%t' will be replaced by the >> time in >> 'yyyy_MM_dd_HH_mm_ss' format. >> >> >> Unfortunately, per [8276265](https://bugs.openjdk.org/browse/JDK-8276265), >> sources for the jcmd manpage remain in Oracle internal repos so this PR >> can’t address that. >> >> Testing: >> >> - [x] Added test case passes. >> - [x] Modified existing VM.cds tests to also check for `%p` filenames. >> >> Looking forward to your comments and addressing any diagnostic commands I >> might have missed (if any). >> >> Cheers, >> Sonia > > Sonia Zaldana Calles has updated the pull request incrementally with one > additional commit since the last revision: > > Updates based on feedback Changes requested by lmesnik (Reviewer). src/hotspot/share/code/codeCache.cpp line 1791: > 1789: > 1790: #ifdef LINUX > 1791: void CodeCache::write_perf_map(const char* filename, outputStream* out) > { I don't think that it is a right place ti expand arguments here. I think it is more consistent to do it in diagnosticCommand.cpp for any jcmd command. So this logic might be the same for any _filename processing. Moreover it would be better be add 'FileArgument' like 'MemorySizeArgument' that correctly parse patterns like %p for all file arguments, used be all commands and be extensible for new macroses if needed. test/jdk/sun/tools/jcmd/TestJcmdPIDSubstitution.java line 32: > 30: * @modules java.base/jdk.internal.misc > 31: * java.management > 32: * @run main/othervm TestJcmdPIDSubstitution Why othervm is needed here? I suggest to add driver mode instead. test/jdk/sun/tools/jcmd/TestJcmdPIDSubstitution.java line 59: > 57: do { > 58: path = Paths.get("myfile%d".formatted(pid)); > 59: } while(Files.exists(path)); Why this do/while loop is needed? Each test should have it's own empty scratch directory. ------------- PR Review: https://git.openjdk.org/jdk/pull/20198#pullrequestreview-2184333180 PR Review Comment: https://git.openjdk.org/jdk/pull/20198#discussion_r1681931084 PR Review Comment: https://git.openjdk.org/jdk/pull/20198#discussion_r1681921063 PR Review Comment: https://git.openjdk.org/jdk/pull/20198#discussion_r1681920781