Skip to content

Commit ff1a7a6

Browse files
plummercjvladimirlagunov
authored andcommitted
8375477: CoreUtils support for SA tests should attempt to locate and unzip core files when they have been zipped
Reviewed-by: lmesnik, kevinw
1 parent f57dbb0 commit ff1a7a6

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

test/lib/jdk/test/lib/util/CoreUtils.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -203,6 +203,7 @@ public static String getCoreFileLocation(String crashOutputString, long pid) thr
203203

204204
private static final String CORE_PATTERN_FILE_NAME = "/proc/sys/kernel/core_pattern";
205205
private static final String LOCATION_STRING = "location: ";
206+
private static final String ALT_LOCATION_STRING = "alternatively, falling back to";
206207

207208
private static String parseCoreFileLocationFromOutput(String crashOutputString) {
208209
System.out.println("crashOutputString = [" + crashOutputString + "]");
@@ -220,12 +221,25 @@ private static String parseCoreFileLocationFromOutput(String crashOutputString)
220221

221222
// Find the core file name in the output.
222223
String coreWithPid;
223-
if (stringWithLocation.contains("or ") && !Platform.isWindows()) {
224-
Matcher m = Pattern.compile("or.* ([^ ]+[^\\)])\\)?").matcher(stringWithLocation);
224+
if (Platform.isLinux() && stringWithLocation.contains(ALT_LOCATION_STRING)) {
225+
/*
226+
* If hotspot detects that /proc/sys/kernel/core_pattern starts with a "|",
227+
* it generates a messages something like the following:
228+
* # Core dump will be written. Default location: Determined by the following:
229+
* "/var/bin/core.sh %p" (alternatively, falling back to
230+
* /ws/jdk/build/linux-x64/test-support/jtreg_open_test_hotspot_jtreg_serviceability_sa_ClhsdbFindPC_java/scratch/2/core.10353)
231+
* We try to detect this and glean this alternative path from the message. The
232+
* hope here is that either this is where the core file actually ends up, or that
233+
* the script referenced by the core_pattern is just zipping the core file, in
234+
* which case a call to unzipCores() will have already unzipped the core file
235+
* into this path.
236+
*/
237+
Matcher m = Pattern.compile(ALT_LOCATION_STRING + ".* ([^ ]+[^\\)])\\)?").matcher(stringWithLocation);
225238
if (!m.find()) {
226239
throw new RuntimeException("Couldn't find path to core inside location string");
227240
}
228241
coreWithPid = m.group(1);
242+
System.out.println("getCoreFileLocation found alt coreWithPid = " + coreWithPid);
229243
} else {
230244
coreWithPid = stringWithLocation.trim();
231245
}

0 commit comments

Comments
 (0)