Skip to content

Commit 33dda88

Browse files
committed
8351842: Windows specific issues in combination of JEP 493 and --with-external-symbols-in-bundles=public
Reviewed-by: erikj, mbaesken
1 parent 6f03c78 commit 33dda88

File tree

7 files changed

+56
-67
lines changed

7 files changed

+56
-67
lines changed

make/Bundles.gmk

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,6 @@ define SetupBundleFileBody
125125
&& $(TAR) cf - -$(TAR_INCLUDE_PARAM) $$($1_$$d_LIST_FILE) \
126126
$(TAR_IGNORE_EXIT_VALUE) ) \
127127
| ( $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) && $(TAR) xf - )$$(NEWLINE) )
128-
# Rename stripped pdb files
129-
ifeq ($(call isTargetOs, windows)+$(SHIP_DEBUG_SYMBOLS), true+public)
130-
for f in `$(FIND) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) -name "*.stripped.pdb"`; do \
131-
$(ECHO) Renaming $$$${f} to $$$${f%stripped.pdb}pdb $(LOG_INFO); \
132-
$(MV) $$$${f} $$$${f%stripped.pdb}pdb; \
133-
done
134-
endif
135128
# Unzip any zipped debuginfo files
136129
ifeq ($$($1_UNZIP_DEBUGINFO), true)
137130
for f in `$(FIND) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) -name "*.diz"`; do \
@@ -222,14 +215,6 @@ ifneq ($(filter product-bundles% legacy-bundles, $(MAKECMDGOALS)), )
222215
ifeq ($(call isTargetOs, windows), true)
223216
ifeq ($(SHIP_DEBUG_SYMBOLS), )
224217
JDK_SYMBOLS_EXCLUDE_PATTERN := %.pdb
225-
else
226-
ifeq ($(SHIP_DEBUG_SYMBOLS), public)
227-
JDK_SYMBOLS_EXCLUDE_PATTERN := \
228-
$(filter-out \
229-
%.stripped.pdb, \
230-
$(filter %.pdb, $(ALL_JDK_FILES)) \
231-
)
232-
endif
233218
endif
234219
endif
235220

@@ -244,10 +229,7 @@ ifneq ($(filter product-bundles% legacy-bundles, $(MAKECMDGOALS)), )
244229
)
245230

246231
JDK_SYMBOLS_BUNDLE_FILES := \
247-
$(filter-out \
248-
%.stripped.pdb, \
249-
$(call FindFiles, $(SYMBOLS_IMAGE_DIR)) \
250-
)
232+
$(call FindFiles, $(SYMBOLS_IMAGE_DIR))
251233

252234
TEST_DEMOS_BUNDLE_FILES := $(filter $(JDK_DEMOS_IMAGE_HOMEDIR)/demo/%, \
253235
$(ALL_JDK_DEMOS_FILES))
@@ -267,14 +249,6 @@ ifneq ($(filter product-bundles% legacy-bundles, $(MAKECMDGOALS)), )
267249
ifeq ($(call isTargetOs, windows), true)
268250
ifeq ($(SHIP_DEBUG_SYMBOLS), )
269251
JRE_SYMBOLS_EXCLUDE_PATTERN := %.pdb
270-
else
271-
ifeq ($(SHIP_DEBUG_SYMBOLS), public)
272-
JRE_SYMBOLS_EXCLUDE_PATTERN := \
273-
$(filter-out \
274-
%.stripped.pdb, \
275-
$(filter %.pdb, $(ALL_JRE_FILES)) \
276-
)
277-
endif
278252
endif
279253
endif
280254

make/Images.gmk

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -282,29 +282,33 @@ else
282282
endif
283283
CMDS_TARGET_SUBDIR := bin
284284

285-
# Param 1 - either JDK or JRE
285+
# Copy debug info files into symbols bundle.
286+
# In case of Windows and --with-external-symbols-in-bundles=public, take care to remove *.stripped.pdb files
286287
SetupCopyDebuginfo = \
287288
$(foreach m, $(ALL_$1_MODULES), \
289+
$(eval dbgfiles := $(call FindDebuginfoFiles, $(SUPPORT_OUTPUTDIR)/modules_libs/$m)) \
290+
$(eval dbgfiles := $(if $(filter true+public,$(call isTargetOs,windows)+$(SHIP_DEBUG_SYMBOLS)), \
291+
$(filter-out %.stripped.pdb,$(dbgfiles)),$(dbgfiles)) \
292+
) \
288293
$(eval $(call SetupCopyFiles, COPY_$1_LIBS_DEBUGINFO_$m, \
289294
SRC := $(SUPPORT_OUTPUTDIR)/modules_libs/$m, \
290295
DEST := $($1_IMAGE_DIR)/$(LIBS_TARGET_SUBDIR), \
291-
FILES := $(call FindDebuginfoFiles, \
292-
$(SUPPORT_OUTPUTDIR)/modules_libs/$m), \
296+
FILES := $(dbgfiles), \
293297
)) \
294298
$(eval $1_TARGETS += $$(COPY_$1_LIBS_DEBUGINFO_$m)) \
299+
$(eval dbgfiles := $(call FindDebuginfoFiles, $(SUPPORT_OUTPUTDIR)/modules_cmds/$m)) \
300+
$(eval dbgfiles := $(if $(filter true+public,$(call isTargetOs,windows)+$(SHIP_DEBUG_SYMBOLS)), \
301+
$(filter-out %.stripped.pdb,$(dbgfiles)),$(dbgfiles)) \
302+
) \
295303
$(eval $(call SetupCopyFiles, COPY_$1_CMDS_DEBUGINFO_$m, \
296304
SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds/$m, \
297305
DEST := $($1_IMAGE_DIR)/$(CMDS_TARGET_SUBDIR), \
298-
FILES := $(call FindDebuginfoFiles, \
299-
$(SUPPORT_OUTPUTDIR)/modules_cmds/$m), \
306+
FILES := $(dbgfiles), \
300307
)) \
301308
$(eval $1_TARGETS += $$(COPY_$1_CMDS_DEBUGINFO_$m)) \
302309
)
303310

304-
# No space before argument to avoid having to put $(strip ) everywhere in
305-
# implementation above.
306-
$(call SetupCopyDebuginfo,JDK)
307-
$(call SetupCopyDebuginfo,JRE)
311+
# No space before argument to avoid having to put $(strip ) everywhere in implementation above.
308312
$(call SetupCopyDebuginfo,SYMBOLS)
309313

310314
################################################################################

make/hotspot/lib/CompileJvm.gmk

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,19 @@ JVM_STRIPFLAGS ?= $(STRIPFLAGS)
151151
# This source set is reused so save in cache.
152152
$(call FillFindCache, $(JVM_SRC_DIRS))
153153

154+
ifeq ($(SHIP_DEBUG_SYMBOLS), full)
155+
CFLAGS_SHIP_DEBUGINFO := -DSHIP_DEBUGINFO_FULL
156+
else ifeq ($(SHIP_DEBUG_SYMBOLS), public)
157+
CFLAGS_SHIP_DEBUGINFO := -DSHIP_DEBUGINFO_PUBLIC
158+
endif
159+
154160
ifeq ($(call isTargetOs, windows), true)
155161
ifeq ($(STATIC_LIBS), true)
156162
WIN_EXPORT_FILE := $(JVM_OUTPUTDIR)/static-win-exports.def
157163
else
158164
WIN_EXPORT_FILE := $(JVM_OUTPUTDIR)/win-exports.def
159165
endif
160166

161-
ifeq ($(SHIP_DEBUG_SYMBOLS), public)
162-
CFLAGS_STRIPPED_DEBUGINFO := -DHAS_STRIPPED_DEBUGINFO
163-
endif
164-
165167
JVM_LDFLAGS += -def:$(WIN_EXPORT_FILE)
166168
endif
167169

@@ -187,7 +189,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJVM, \
187189
CFLAGS := $(JVM_CFLAGS), \
188190
abstract_vm_version.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
189191
arguments.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
190-
whitebox.cpp_CXXFLAGS := $(CFLAGS_STRIPPED_DEBUGINFO), \
192+
whitebox.cpp_CXXFLAGS := $(CFLAGS_SHIP_DEBUGINFO), \
191193
DISABLED_WARNINGS_gcc := $(DISABLED_WARNINGS_gcc), \
192194
DISABLED_WARNINGS_gcc_ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp := nonnull, \
193195
DISABLED_WARNINGS_gcc_bytecodeInterpreter.cpp := unused-label, \

src/hotspot/share/prims/whitebox.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,16 @@ WB_ENTRY(jboolean, WB_ConcurrentGCRunTo(JNIEnv* env, jobject o, jobject at))
508508
return ConcurrentGCBreakpoints::run_to(c_name);
509509
WB_END
510510

511-
WB_ENTRY(jboolean, WB_HasExternalSymbolsStripped(JNIEnv* env, jobject o))
512-
#if defined(HAS_STRIPPED_DEBUGINFO)
511+
WB_ENTRY(jboolean, WB_ShipDebugInfoFull(JNIEnv* env, jobject o))
512+
#if defined(SHIP_DEBUGINFO_FULL)
513+
return true;
514+
#else
515+
return false;
516+
#endif
517+
WB_END
518+
519+
WB_ENTRY(jboolean, WB_ShipDebugInfoPublic(JNIEnv* env, jobject o))
520+
#if defined(SHIP_DEBUGINFO_PUBLIC)
513521
return true;
514522
#else
515523
return false;
@@ -2840,7 +2848,8 @@ static JNINativeMethod methods[] = {
28402848
{CC"getVMLargePageSize", CC"()J", (void*)&WB_GetVMLargePageSize},
28412849
{CC"getHeapSpaceAlignment", CC"()J", (void*)&WB_GetHeapSpaceAlignment},
28422850
{CC"getHeapAlignment", CC"()J", (void*)&WB_GetHeapAlignment},
2843-
{CC"hasExternalSymbolsStripped", CC"()Z", (void*)&WB_HasExternalSymbolsStripped},
2851+
{CC"shipsFullDebugInfo", CC"()Z", (void*)&WB_ShipDebugInfoFull},
2852+
{CC"shipsPublicDebugInfo", CC"()Z", (void*)&WB_ShipDebugInfoPublic},
28442853
{CC"countAliveClasses0", CC"(Ljava/lang/String;)I", (void*)&WB_CountAliveClasses },
28452854
{CC"getSymbolRefcount", CC"(Ljava/lang/String;)I", (void*)&WB_GetSymbolRefcount },
28462855
{CC"parseCommandLine0",

test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ public class CheckForProperDetailStackTrace {
6363
private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
6464
private static final Path MODS_DIR = Paths.get(TEST_CLASSES, "mods");
6565

66-
// Windows has source information only in full pdbs, not in stripped pdbs
67-
private static boolean expectSourceInformation = Platform.isLinux() || Platform.isWindows();
68-
69-
static WhiteBox wb = WhiteBox.getWhiteBox();
66+
// In some configurations on Windows, we could have stripped pdbs which do not have source information.
67+
private static boolean expectSourceInformation = (Platform.isLinux() || Platform.isWindows()) &&
68+
WhiteBox.getWhiteBox().shipsFullDebugInfo();
7069

7170
/* The stack trace we look for by default. Note that :: has been replaced by .*
7271
to make sure it matches even if the symbol is not unmangled.
@@ -145,12 +144,8 @@ public static void main(String args[]) throws Exception {
145144
throw new RuntimeException("Expected stack trace missing from output");
146145
}
147146

148-
if (wb.hasExternalSymbolsStripped()) {
149-
expectSourceInformation = false;
150-
}
151-
152-
System.out.println("Looking for source information:");
153147
if (expectSourceInformation) {
148+
System.out.println("Looking for source information:");
154149
if (!stackTraceMatches(".*moduleEntry.cpp.*", output)) {
155150
output.reportDiagnosticSummary();
156151
throw new RuntimeException("Expected source information missing from output");

test/jdk/jdk/modules/etc/JmodExcludedFiles.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2024, 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
@@ -25,9 +25,12 @@
2525
* @test
2626
* @bug 8159927
2727
* @modules java.base/jdk.internal.util
28+
* @library /test/lib
2829
* @requires jlink.packagedModules
29-
* @run main JmodExcludedFiles
30-
* @summary Test that JDK JMOD files do not include native debug symbols
30+
* @build jdk.test.whitebox.WhiteBox
31+
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
32+
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JmodExcludedFiles
33+
* @summary Test that JDK JMOD files do not include native debug symbols when it is not configured
3134
*/
3235

3336
import java.nio.file.DirectoryStream;
@@ -37,9 +40,11 @@
3740
import java.util.zip.ZipEntry;
3841
import java.util.zip.ZipFile;
3942
import jdk.internal.util.OperatingSystem;
43+
import jdk.test.whitebox.WhiteBox;
4044

4145
public class JmodExcludedFiles {
4246
private static String javaHome = System.getProperty("java.home");
47+
private static final boolean expectSymbols = WhiteBox.getWhiteBox().shipsDebugInfo();
4348

4449
public static void main(String[] args) throws Exception {
4550
Path jmods = Path.of(javaHome, "jmods");
@@ -76,24 +81,19 @@ boolean isNativeDebugSymbol(String name) {
7681
if (i != -1) {
7782
if (n.substring(0, i).endsWith(".dSYM")) {
7883
System.err.println("Found symbols in " + jmod + ": " + name);
79-
return true;
84+
return expectSymbols ? false: true;
8085
}
8186
}
8287
}
8388
if (OperatingSystem.isWindows() && name.endsWith(".pdb")) {
84-
// on Windows we check if we should have public symbols through --with-external-symbols-in-bundles=public (JDK-8237192)
85-
String strippedpdb = javaHome + "/bin/" + name.substring(index + 1, name.length() - 4) + ".stripped.pdb";
86-
if (!Files.exists(Paths.get(strippedpdb))) {
87-
System.err.println("Found symbols in " + jmod + ": " + name +
88-
". No stripped pdb file " + strippedpdb + " exists.");
89-
return true;
90-
}
89+
System.err.println("Found symbols in " + jmod + ": " + name);
90+
return expectSymbols ? false: true;
9191
}
9292
if (name.endsWith(".diz")
9393
|| name.endsWith(".debuginfo")
9494
|| name.endsWith(".map")) {
9595
System.err.println("Found symbols in " + jmod + ": " + name);
96-
return true;
96+
return expectSymbols ? false: true;
9797
}
9898
}
9999
return false;

test/lib/jdk/test/whitebox/WhiteBox.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public synchronized static WhiteBox getWhiteBox() {
6666

6767
// Memory
6868
private native long getObjectAddress0(Object o);
69-
public long getObjectAddress(Object o) {
69+
public long getObjectAddress(Object o) {
7070
Objects.requireNonNull(o);
7171
return getObjectAddress0(o);
7272
}
@@ -78,7 +78,12 @@ public long getObjectAddress(Object o) {
7878
public native long getHeapSpaceAlignment();
7979
public native long getHeapAlignment();
8080

81-
public native boolean hasExternalSymbolsStripped();
81+
public native boolean shipsFullDebugInfo();
82+
public native boolean shipsPublicDebugInfo();
83+
84+
public boolean shipsDebugInfo() {
85+
return shipsFullDebugInfo() || shipsPublicDebugInfo();
86+
}
8287

8388
private native boolean isObjectInOldGen0(Object o);
8489
public boolean isObjectInOldGen(Object o) {

0 commit comments

Comments
 (0)