mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 01:19:28 +01:00
8351842: Windows specific issues in combination of JEP 493 and --with-external-symbols-in-bundles=public
Reviewed-by: erikj, mbaesken
This commit is contained in:
@@ -125,13 +125,6 @@ define SetupBundleFileBody
|
||||
&& $(TAR) cf - -$(TAR_INCLUDE_PARAM) $$($1_$$d_LIST_FILE) \
|
||||
$(TAR_IGNORE_EXIT_VALUE) ) \
|
||||
| ( $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) && $(TAR) xf - )$$(NEWLINE) )
|
||||
# Rename stripped pdb files
|
||||
ifeq ($(call isTargetOs, windows)+$(SHIP_DEBUG_SYMBOLS), true+public)
|
||||
for f in `$(FIND) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) -name "*.stripped.pdb"`; do \
|
||||
$(ECHO) Renaming $$$${f} to $$$${f%stripped.pdb}pdb $(LOG_INFO); \
|
||||
$(MV) $$$${f} $$$${f%stripped.pdb}pdb; \
|
||||
done
|
||||
endif
|
||||
# Unzip any zipped debuginfo files
|
||||
ifeq ($$($1_UNZIP_DEBUGINFO), true)
|
||||
for f in `$(FIND) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) -name "*.diz"`; do \
|
||||
@@ -222,14 +215,6 @@ ifneq ($(filter product-bundles% legacy-bundles, $(MAKECMDGOALS)), )
|
||||
ifeq ($(call isTargetOs, windows), true)
|
||||
ifeq ($(SHIP_DEBUG_SYMBOLS), )
|
||||
JDK_SYMBOLS_EXCLUDE_PATTERN := %.pdb
|
||||
else
|
||||
ifeq ($(SHIP_DEBUG_SYMBOLS), public)
|
||||
JDK_SYMBOLS_EXCLUDE_PATTERN := \
|
||||
$(filter-out \
|
||||
%.stripped.pdb, \
|
||||
$(filter %.pdb, $(ALL_JDK_FILES)) \
|
||||
)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -244,10 +229,7 @@ ifneq ($(filter product-bundles% legacy-bundles, $(MAKECMDGOALS)), )
|
||||
)
|
||||
|
||||
JDK_SYMBOLS_BUNDLE_FILES := \
|
||||
$(filter-out \
|
||||
%.stripped.pdb, \
|
||||
$(call FindFiles, $(SYMBOLS_IMAGE_DIR)) \
|
||||
)
|
||||
$(call FindFiles, $(SYMBOLS_IMAGE_DIR))
|
||||
|
||||
TEST_DEMOS_BUNDLE_FILES := $(filter $(JDK_DEMOS_IMAGE_HOMEDIR)/demo/%, \
|
||||
$(ALL_JDK_DEMOS_FILES))
|
||||
@@ -267,14 +249,6 @@ ifneq ($(filter product-bundles% legacy-bundles, $(MAKECMDGOALS)), )
|
||||
ifeq ($(call isTargetOs, windows), true)
|
||||
ifeq ($(SHIP_DEBUG_SYMBOLS), )
|
||||
JRE_SYMBOLS_EXCLUDE_PATTERN := %.pdb
|
||||
else
|
||||
ifeq ($(SHIP_DEBUG_SYMBOLS), public)
|
||||
JRE_SYMBOLS_EXCLUDE_PATTERN := \
|
||||
$(filter-out \
|
||||
%.stripped.pdb, \
|
||||
$(filter %.pdb, $(ALL_JRE_FILES)) \
|
||||
)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
@@ -282,29 +282,33 @@ else
|
||||
endif
|
||||
CMDS_TARGET_SUBDIR := bin
|
||||
|
||||
# Param 1 - either JDK or JRE
|
||||
# Copy debug info files into symbols bundle.
|
||||
# In case of Windows and --with-external-symbols-in-bundles=public, take care to remove *.stripped.pdb files
|
||||
SetupCopyDebuginfo = \
|
||||
$(foreach m, $(ALL_$1_MODULES), \
|
||||
$(eval dbgfiles := $(call FindDebuginfoFiles, $(SUPPORT_OUTPUTDIR)/modules_libs/$m)) \
|
||||
$(eval dbgfiles := $(if $(filter true+public,$(call isTargetOs,windows)+$(SHIP_DEBUG_SYMBOLS)), \
|
||||
$(filter-out %.stripped.pdb,$(dbgfiles)),$(dbgfiles)) \
|
||||
) \
|
||||
$(eval $(call SetupCopyFiles, COPY_$1_LIBS_DEBUGINFO_$m, \
|
||||
SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/$m, \
|
||||
DEST := $($1_IMAGE_DIR)/$(LIBS_TARGET_SUBDIR), \
|
||||
FILES := $(call FindDebuginfoFiles, \
|
||||
$(SUPPORT_OUTPUTDIR)/modules_libs/$m), \
|
||||
FILES := $(dbgfiles), \
|
||||
)) \
|
||||
$(eval $1_TARGETS += $$(COPY_$1_LIBS_DEBUGINFO_$m)) \
|
||||
$(eval dbgfiles := $(call FindDebuginfoFiles, $(SUPPORT_OUTPUTDIR)/modules_cmds/$m)) \
|
||||
$(eval dbgfiles := $(if $(filter true+public,$(call isTargetOs,windows)+$(SHIP_DEBUG_SYMBOLS)), \
|
||||
$(filter-out %.stripped.pdb,$(dbgfiles)),$(dbgfiles)) \
|
||||
) \
|
||||
$(eval $(call SetupCopyFiles, COPY_$1_CMDS_DEBUGINFO_$m, \
|
||||
SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds/$m, \
|
||||
DEST := $($1_IMAGE_DIR)/$(CMDS_TARGET_SUBDIR), \
|
||||
FILES := $(call FindDebuginfoFiles, \
|
||||
$(SUPPORT_OUTPUTDIR)/modules_cmds/$m), \
|
||||
FILES := $(dbgfiles), \
|
||||
)) \
|
||||
$(eval $1_TARGETS += $$(COPY_$1_CMDS_DEBUGINFO_$m)) \
|
||||
)
|
||||
|
||||
# No space before argument to avoid having to put $(strip ) everywhere in
|
||||
# implementation above.
|
||||
$(call SetupCopyDebuginfo,JDK)
|
||||
$(call SetupCopyDebuginfo,JRE)
|
||||
# No space before argument to avoid having to put $(strip ) everywhere in implementation above.
|
||||
$(call SetupCopyDebuginfo,SYMBOLS)
|
||||
|
||||
################################################################################
|
||||
|
||||
@@ -151,6 +151,12 @@ JVM_STRIPFLAGS ?= $(STRIPFLAGS)
|
||||
# This source set is reused so save in cache.
|
||||
$(call FillFindCache, $(JVM_SRC_DIRS))
|
||||
|
||||
ifeq ($(SHIP_DEBUG_SYMBOLS), full)
|
||||
CFLAGS_SHIP_DEBUGINFO := -DSHIP_DEBUGINFO_FULL
|
||||
else ifeq ($(SHIP_DEBUG_SYMBOLS), public)
|
||||
CFLAGS_SHIP_DEBUGINFO := -DSHIP_DEBUGINFO_PUBLIC
|
||||
endif
|
||||
|
||||
ifeq ($(call isTargetOs, windows), true)
|
||||
ifeq ($(STATIC_LIBS), true)
|
||||
WIN_EXPORT_FILE := $(JVM_OUTPUTDIR)/static-win-exports.def
|
||||
@@ -158,10 +164,6 @@ ifeq ($(call isTargetOs, windows), true)
|
||||
WIN_EXPORT_FILE := $(JVM_OUTPUTDIR)/win-exports.def
|
||||
endif
|
||||
|
||||
ifeq ($(SHIP_DEBUG_SYMBOLS), public)
|
||||
CFLAGS_STRIPPED_DEBUGINFO := -DHAS_STRIPPED_DEBUGINFO
|
||||
endif
|
||||
|
||||
JVM_LDFLAGS += -def:$(WIN_EXPORT_FILE)
|
||||
endif
|
||||
|
||||
@@ -187,7 +189,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJVM, \
|
||||
CFLAGS := $(JVM_CFLAGS), \
|
||||
abstract_vm_version.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
|
||||
arguments.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
|
||||
whitebox.cpp_CXXFLAGS := $(CFLAGS_STRIPPED_DEBUGINFO), \
|
||||
whitebox.cpp_CXXFLAGS := $(CFLAGS_SHIP_DEBUGINFO), \
|
||||
DISABLED_WARNINGS_gcc := $(DISABLED_WARNINGS_gcc), \
|
||||
DISABLED_WARNINGS_gcc_ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp := nonnull, \
|
||||
DISABLED_WARNINGS_gcc_bytecodeInterpreter.cpp := unused-label, \
|
||||
|
||||
@@ -508,8 +508,16 @@ WB_ENTRY(jboolean, WB_ConcurrentGCRunTo(JNIEnv* env, jobject o, jobject at))
|
||||
return ConcurrentGCBreakpoints::run_to(c_name);
|
||||
WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_HasExternalSymbolsStripped(JNIEnv* env, jobject o))
|
||||
#if defined(HAS_STRIPPED_DEBUGINFO)
|
||||
WB_ENTRY(jboolean, WB_ShipDebugInfoFull(JNIEnv* env, jobject o))
|
||||
#if defined(SHIP_DEBUGINFO_FULL)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_ShipDebugInfoPublic(JNIEnv* env, jobject o))
|
||||
#if defined(SHIP_DEBUGINFO_PUBLIC)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
@@ -2840,7 +2848,8 @@ static JNINativeMethod methods[] = {
|
||||
{CC"getVMLargePageSize", CC"()J", (void*)&WB_GetVMLargePageSize},
|
||||
{CC"getHeapSpaceAlignment", CC"()J", (void*)&WB_GetHeapSpaceAlignment},
|
||||
{CC"getHeapAlignment", CC"()J", (void*)&WB_GetHeapAlignment},
|
||||
{CC"hasExternalSymbolsStripped", CC"()Z", (void*)&WB_HasExternalSymbolsStripped},
|
||||
{CC"shipsFullDebugInfo", CC"()Z", (void*)&WB_ShipDebugInfoFull},
|
||||
{CC"shipsPublicDebugInfo", CC"()Z", (void*)&WB_ShipDebugInfoPublic},
|
||||
{CC"countAliveClasses0", CC"(Ljava/lang/String;)I", (void*)&WB_CountAliveClasses },
|
||||
{CC"getSymbolRefcount", CC"(Ljava/lang/String;)I", (void*)&WB_GetSymbolRefcount },
|
||||
{CC"parseCommandLine0",
|
||||
|
||||
@@ -63,10 +63,9 @@ public class CheckForProperDetailStackTrace {
|
||||
private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
|
||||
private static final Path MODS_DIR = Paths.get(TEST_CLASSES, "mods");
|
||||
|
||||
// Windows has source information only in full pdbs, not in stripped pdbs
|
||||
private static boolean expectSourceInformation = Platform.isLinux() || Platform.isWindows();
|
||||
|
||||
static WhiteBox wb = WhiteBox.getWhiteBox();
|
||||
// In some configurations on Windows, we could have stripped pdbs which do not have source information.
|
||||
private static boolean expectSourceInformation = (Platform.isLinux() || Platform.isWindows()) &&
|
||||
WhiteBox.getWhiteBox().shipsFullDebugInfo();
|
||||
|
||||
/* The stack trace we look for by default. Note that :: has been replaced by .*
|
||||
to make sure it matches even if the symbol is not unmangled.
|
||||
@@ -145,12 +144,8 @@ public class CheckForProperDetailStackTrace {
|
||||
throw new RuntimeException("Expected stack trace missing from output");
|
||||
}
|
||||
|
||||
if (wb.hasExternalSymbolsStripped()) {
|
||||
expectSourceInformation = false;
|
||||
}
|
||||
|
||||
System.out.println("Looking for source information:");
|
||||
if (expectSourceInformation) {
|
||||
System.out.println("Looking for source information:");
|
||||
if (!stackTraceMatches(".*moduleEntry.cpp.*", output)) {
|
||||
output.reportDiagnosticSummary();
|
||||
throw new RuntimeException("Expected source information missing from output");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -25,9 +25,12 @@
|
||||
* @test
|
||||
* @bug 8159927
|
||||
* @modules java.base/jdk.internal.util
|
||||
* @library /test/lib
|
||||
* @requires jlink.packagedModules
|
||||
* @run main JmodExcludedFiles
|
||||
* @summary Test that JDK JMOD files do not include native debug symbols
|
||||
* @build jdk.test.whitebox.WhiteBox
|
||||
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JmodExcludedFiles
|
||||
* @summary Test that JDK JMOD files do not include native debug symbols when it is not configured
|
||||
*/
|
||||
|
||||
import java.nio.file.DirectoryStream;
|
||||
@@ -37,9 +40,11 @@ import java.nio.file.Paths;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import jdk.internal.util.OperatingSystem;
|
||||
import jdk.test.whitebox.WhiteBox;
|
||||
|
||||
public class JmodExcludedFiles {
|
||||
private static String javaHome = System.getProperty("java.home");
|
||||
private static final boolean expectSymbols = WhiteBox.getWhiteBox().shipsDebugInfo();
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Path jmods = Path.of(javaHome, "jmods");
|
||||
@@ -76,24 +81,19 @@ public class JmodExcludedFiles {
|
||||
if (i != -1) {
|
||||
if (n.substring(0, i).endsWith(".dSYM")) {
|
||||
System.err.println("Found symbols in " + jmod + ": " + name);
|
||||
return true;
|
||||
return expectSymbols ? false: true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OperatingSystem.isWindows() && name.endsWith(".pdb")) {
|
||||
// on Windows we check if we should have public symbols through --with-external-symbols-in-bundles=public (JDK-8237192)
|
||||
String strippedpdb = javaHome + "/bin/" + name.substring(index + 1, name.length() - 4) + ".stripped.pdb";
|
||||
if (!Files.exists(Paths.get(strippedpdb))) {
|
||||
System.err.println("Found symbols in " + jmod + ": " + name +
|
||||
". No stripped pdb file " + strippedpdb + " exists.");
|
||||
return true;
|
||||
}
|
||||
System.err.println("Found symbols in " + jmod + ": " + name);
|
||||
return expectSymbols ? false: true;
|
||||
}
|
||||
if (name.endsWith(".diz")
|
||||
|| name.endsWith(".debuginfo")
|
||||
|| name.endsWith(".map")) {
|
||||
System.err.println("Found symbols in " + jmod + ": " + name);
|
||||
return true;
|
||||
return expectSymbols ? false: true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -66,7 +66,7 @@ public class WhiteBox {
|
||||
|
||||
// Memory
|
||||
private native long getObjectAddress0(Object o);
|
||||
public long getObjectAddress(Object o) {
|
||||
public long getObjectAddress(Object o) {
|
||||
Objects.requireNonNull(o);
|
||||
return getObjectAddress0(o);
|
||||
}
|
||||
@@ -78,7 +78,12 @@ public class WhiteBox {
|
||||
public native long getHeapSpaceAlignment();
|
||||
public native long getHeapAlignment();
|
||||
|
||||
public native boolean hasExternalSymbolsStripped();
|
||||
public native boolean shipsFullDebugInfo();
|
||||
public native boolean shipsPublicDebugInfo();
|
||||
|
||||
public boolean shipsDebugInfo() {
|
||||
return shipsFullDebugInfo() || shipsPublicDebugInfo();
|
||||
}
|
||||
|
||||
private native boolean isObjectInOldGen0(Object o);
|
||||
public boolean isObjectInOldGen(Object o) {
|
||||
|
||||
Reference in New Issue
Block a user