8375477: CoreUtils support for SA tests should attempt to locate and unzip core files when they have been zipped

Reviewed-by: lmesnik, kevinw
This commit is contained in:
Chris Plummer 2026-01-27 20:39:35 +00:00
parent eb6e74b1fa
commit fa1b1d677a

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -203,6 +203,7 @@ public class CoreUtils {
private static final String CORE_PATTERN_FILE_NAME = "/proc/sys/kernel/core_pattern"; private static final String CORE_PATTERN_FILE_NAME = "/proc/sys/kernel/core_pattern";
private static final String LOCATION_STRING = "location: "; private static final String LOCATION_STRING = "location: ";
private static final String ALT_LOCATION_STRING = "alternatively, falling back to";
private static String parseCoreFileLocationFromOutput(String crashOutputString) { private static String parseCoreFileLocationFromOutput(String crashOutputString) {
System.out.println("crashOutputString = [" + crashOutputString + "]"); System.out.println("crashOutputString = [" + crashOutputString + "]");
@ -220,12 +221,25 @@ public class CoreUtils {
// Find the core file name in the output. // Find the core file name in the output.
String coreWithPid; String coreWithPid;
if (stringWithLocation.contains("or ") && !Platform.isWindows()) { if (Platform.isLinux() && stringWithLocation.contains(ALT_LOCATION_STRING)) {
Matcher m = Pattern.compile("or.* ([^ ]+[^\\)])\\)?").matcher(stringWithLocation); /*
* If hotspot detects that /proc/sys/kernel/core_pattern starts with a "|",
* it generates a messages something like the following:
* # Core dump will be written. Default location: Determined by the following:
* "/var/bin/core.sh %p" (alternatively, falling back to
* /ws/jdk/build/linux-x64/test-support/jtreg_open_test_hotspot_jtreg_serviceability_sa_ClhsdbFindPC_java/scratch/2/core.10353)
* We try to detect this and glean this alternative path from the message. The
* hope here is that either this is where the core file actually ends up, or that
* the script referenced by the core_pattern is just zipping the core file, in
* which case a call to unzipCores() will have already unzipped the core file
* into this path.
*/
Matcher m = Pattern.compile(ALT_LOCATION_STRING + ".* ([^ ]+[^\\)])\\)?").matcher(stringWithLocation);
if (!m.find()) { if (!m.find()) {
throw new RuntimeException("Couldn't find path to core inside location string"); throw new RuntimeException("Couldn't find path to core inside location string");
} }
coreWithPid = m.group(1); coreWithPid = m.group(1);
System.out.println("getCoreFileLocation found alt coreWithPid = " + coreWithPid);
} else { } else {
coreWithPid = stringWithLocation.trim(); coreWithPid = stringWithLocation.trim();
} }