Skip to content

Commit 6df7134

Browse files
committed
fix zipped core file support
1 parent b7346c3 commit 6df7134

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

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

Lines changed: 19 additions & 5 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,8 +203,9 @@ 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-
207-
private static String parseCoreFileLocationFromOutput(String crashOutputString) {
206+
private static final String ALT_LOCATION_STRING = "alternatively, falling back to";
207+
208+
private static String parseCoreFileLocationFromOutput(String crashOutputString) throws IOException {
208209
System.out.println("crashOutputString = [" + crashOutputString + "]");
209210

210211
// Find the line of output that contains LOCATION_STRING
@@ -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)