Skip to content

Commit d96f38b

Browse files
ftheveneterikj79
authored andcommittedOct 25, 2023
8317510: Change Windows debug symbol files naming to avoid losing info when an executable and a library share the same name
Reviewed-by: ihse, erikj
1 parent 10427c0 commit d96f38b

File tree

8 files changed

+99
-36
lines changed

8 files changed

+99
-36
lines changed
 

‎make/CreateJmods.gmk

+3-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2014, 2023, 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
@@ -81,13 +81,11 @@ endif
8181
ifneq ($(CMDS_DIR), )
8282
DEPS += $(call FindFiles, $(CMDS_DIR))
8383
ifeq ($(call isTargetOs, windows)+$(SHIP_DEBUG_SYMBOLS), true+public)
84-
# For public debug symbols on Windows, we have to use stripped pdbs, rename them
85-
# and filter out a few launcher pdbs where there's a lib that goes by the same name
84+
# For public debug symbols on Windows, we have to use stripped pdbs and rename them
8685
rename_stripped = $(patsubst %.stripped.pdb,%.pdb,$1)
8786
CMDS_DIR_FILTERED := $(subst modules_cmds,modules_cmds_filtered, $(CMDS_DIR))
8887
FILES_CMDS := $(filter-out %.pdb, $(call FindFiles, $(CMDS_DIR))) \
89-
$(filter-out %jimage.stripped.pdb %jpackage.stripped.pdb %java.stripped.pdb, \
90-
$(filter %.stripped.pdb, $(call FindFiles, $(CMDS_DIR))))
88+
$(filter %.stripped.pdb, $(call FindFiles, $(CMDS_DIR)))
9189
$(eval $(call SetupCopyFiles, COPY_FILTERED_CMDS, \
9290
SRC := $(CMDS_DIR), \
9391
DEST := $(CMDS_DIR_FILTERED), \
@@ -96,18 +94,6 @@ ifneq ($(CMDS_DIR), )
9694
))
9795
DEPS += $(COPY_FILTERED_CMDS)
9896
JMOD_FLAGS += --cmds $(CMDS_DIR_FILTERED)
99-
else ifeq ($(call isTargetOs, windows)+$(SHIP_DEBUG_SYMBOLS), true+full)
100-
# For full debug symbols on Windows, we have to filter out a few launcher pdbs
101-
# where there's a lib that goes by the same name
102-
CMDS_DIR_FILTERED := $(subst modules_cmds,modules_cmds_filtered, $(CMDS_DIR))
103-
$(eval $(call SetupCopyFiles, COPY_FILTERED_CMDS, \
104-
SRC := $(CMDS_DIR), \
105-
DEST := $(CMDS_DIR_FILTERED), \
106-
FILES := $(filter-out %jimage.pdb %jpackage.pdb %java.pdb, \
107-
$(call FindFiles, $(CMDS_DIR))), \
108-
))
109-
DEPS += $(COPY_FILTERED_CMDS)
110-
JMOD_FLAGS += --cmds $(CMDS_DIR_FILTERED)
11197
else
11298
JMOD_FLAGS += --cmds $(CMDS_DIR)
11399
endif

‎make/Images.gmk

+2-5
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,6 @@ else
274274
endif
275275
endif
276276

277-
FILTERED_PDBS := %jimage.stripped.pdb %jpackage.stripped.pdb %java.stripped.pdb \
278-
%jimage.pdb %jpackage.pdb %java.pdb %jimage.map %jpackage.map %java.map
279-
280277
# Param 1 - either JDK or JRE
281278
SetupCopyDebuginfo = \
282279
$(foreach m, $(ALL_$1_MODULES), \
@@ -290,8 +287,8 @@ SetupCopyDebuginfo = \
290287
$(eval $(call SetupCopyFiles, COPY_$1_CMDS_DEBUGINFO_$m, \
291288
SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds/$m, \
292289
DEST := $($1_IMAGE_DIR)/$(CMDS_TARGET_SUBDIR), \
293-
FILES := $(filter-out $(FILTERED_PDBS), $(call FindDebuginfoFiles, \
294-
$(SUPPORT_OUTPUTDIR)/modules_cmds/$m)), \
290+
FILES := $(call FindDebuginfoFiles, \
291+
$(SUPPORT_OUTPUTDIR)/modules_cmds/$m), \
295292
)) \
296293
$(eval $1_TARGETS += $$(COPY_$1_CMDS_DEBUGINFO_$m)) \
297294
)

‎make/ZipSecurity.gmk

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ ifeq ($(call isTargetOs, windows), true)
8787
$(eval $(call SetupZipArchive,BUILD_JGSS_BIN_ZIP, \
8888
SRC := $(SUPPORT_OUTPUTDIR), \
8989
INCLUDE_FILES := modules_libs/java.security.jgss/w2k_lsa_auth.dll \
90-
modules_libs/java.security.jgss/w2k_lsa_auth.diz \
91-
modules_libs/java.security.jgss/w2k_lsa_auth.map \
92-
modules_libs/java.security.jgss/w2k_lsa_auth.pdb, \
90+
modules_libs/java.security.jgss/w2k_lsa_auth.dll.diz \
91+
modules_libs/java.security.jgss/w2k_lsa_auth.dll.map \
92+
modules_libs/java.security.jgss/w2k_lsa_auth.dll.pdb, \
9393
ZIP := $(IMAGES_OUTPUTDIR)/$(JGSS_ZIP_NAME)))
9494

9595
TARGETS += $(IMAGES_OUTPUTDIR)/$(JGSS_ZIP_NAME)

‎make/common/NativeCompilation.gmk

+10-6
Original file line numberDiff line numberDiff line change
@@ -1073,13 +1073,13 @@ define SetupNativeCompilationBody
10731073
ifneq ($$($1_TYPE), STATIC_LIBRARY)
10741074
# Generate debuginfo files.
10751075
ifeq ($(call isTargetOs, windows), true)
1076-
$1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).pdb" \
1077-
"-map:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).map"
1076+
$1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_SYMBOLS_DIR)/$$($1_BASENAME).pdb" \
1077+
"-map:$$($1_SYMBOLS_DIR)/$$($1_BASENAME).map"
10781078
ifeq ($(SHIP_DEBUG_SYMBOLS), public)
1079-
$1_EXTRA_LDFLAGS += "-pdbstripped:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).stripped.pdb"
1079+
$1_EXTRA_LDFLAGS += "-pdbstripped:$$($1_SYMBOLS_DIR)/$$($1_BASENAME).stripped.pdb"
10801080
endif
1081-
$1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).pdb \
1082-
$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).map
1081+
$1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_BASENAME).pdb \
1082+
$$($1_SYMBOLS_DIR)/$$($1_BASENAME).map
10831083

10841084
else ifeq ($(call isTargetOs, linux), true)
10851085
$1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).debuginfo
@@ -1127,7 +1127,11 @@ define SetupNativeCompilationBody
11271127
$1 += $$($1_DEBUGINFO_FILES)
11281128

11291129
ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
1130-
$1_DEBUGINFO_ZIP := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).diz
1130+
ifeq ($(call isTargetOs, windows), true)
1131+
$1_DEBUGINFO_ZIP := $$($1_SYMBOLS_DIR)/$$($1_BASENAME).diz
1132+
else
1133+
$1_DEBUGINFO_ZIP := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).diz
1134+
endif
11311135
$1 += $$($1_DEBUGINFO_ZIP)
11321136

11331137
# The dependency on TARGET is needed for debuginfo files

‎make/hotspot/test/GtestImage.gmk

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ifeq ($(call isTargetOs, windows), true)
6161
$(eval $(call SetupCopyFiles, COPY_GTEST_PDB_$v, \
6262
SRC := $(HOTSPOT_OUTPUTDIR)/variant-$v/libjvm/gtest, \
6363
DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \
64-
FILES := jvm.pdb gtestLauncher.pdb, \
64+
FILES := jvm.dll.pdb gtestLauncher.exe.pdb, \
6565
)) \
6666
$(eval TARGETS += $$(COPY_GTEST_PDB_$v)) \
6767
) \

‎make/ide/visualstudio/hotspot/src/classes/build/tools/projectcreator/WinGammaPlatformVC10.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) {
329329
addAttr(rv, "PrecompiledHeaderOutputFile", outDir+Util.sep+"vm.pch");
330330
addAttr(rv, "AssemblerListingLocation", outDir);
331331
addAttr(rv, "ObjectFileName", outDir+Util.sep);
332-
addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"jvm.pdb");
332+
addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"jvm.dll.pdb");
333333
// Set /nologo option
334334
addAttr(rv, "SuppressStartupBanner", "true");
335335
// Surpass the default /Tc or /Tp.
@@ -409,7 +409,7 @@ Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) {
409409
addAttr(rv, "OutputFile", outDll);
410410
addAttr(rv, "SuppressStartupBanner", "true");
411411
addAttr(rv, "ModuleDefinitionFile", outDir+Util.sep+"vm.def");
412-
addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"jvm.pdb");
412+
addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"jvm.dll.pdb");
413413
addAttr(rv, "SubSystem", "Windows");
414414
addAttr(rv, "BaseAddress", "0x8000000");
415415
addAttr(rv, "ImportLibrary", outDir+Util.sep+"jvm.lib");

‎make/scripts/compare_exceptions.sh.incl

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ elif [ "$OPENJDK_TARGET_OS" = "windows" ]; then
4949
SKIP_BIN_DIFF="true"
5050
SKIP_FULLDUMP_DIFF="true"
5151
ACCEPTED_JARZIP_CONTENTS="
52-
/modules_libs/java.security.jgss/w2k_lsa_auth.pdb
53-
/modules_libs/java.security.jgss/w2k_lsa_auth.map
52+
/modules_libs/java.security.jgss/w2k_lsa_auth.dll.pdb
53+
/modules_libs/java.security.jgss/w2k_lsa_auth.dll.map
5454
/modules_libs/java.security.jgss/w2k_lsa_auth.dll
5555
"
5656
elif [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2023, Red Hat, Inc. All rights reserved.
4+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
*
6+
* This code is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License version 2 only, as
8+
* published by the Free Software Foundation.
9+
*
10+
* This code is distributed in the hope that it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13+
* version 2 for more details (a copy is included in the LICENSE file that
14+
* accompanied this code).
15+
*
16+
* You should have received a copy of the GNU General Public License version
17+
* 2 along with this work; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*
20+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21+
* or visit www.oracle.com if you need additional information or have any
22+
* questions.
23+
*/
24+
25+
26+
/*
27+
* @test symbolsHsErr
28+
* @summary Test that function names are present in native frames of hs-err file as a proof that symbols are available.
29+
* @library /test/lib
30+
* @requires vm.flagless
31+
* @requires vm.debug
32+
* @requires os.family == "windows"
33+
* @modules java.base/jdk.internal.misc
34+
* java.management
35+
* @run driver TestSymbolsInHsErrFile
36+
*/
37+
38+
import jdk.test.lib.process.OutputAnalyzer;
39+
import jdk.test.lib.process.ProcessTools;
40+
41+
public class TestSymbolsInHsErrFile {
42+
43+
public static void main(String[] args) throws Exception {
44+
45+
// Start a jvm and cause a SIGSEGV / ACCESS_VIOLATION
46+
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
47+
"-XX:+UnlockDiagnosticVMOptions",
48+
"-Xmx100M",
49+
"-XX:-CreateCoredumpOnCrash",
50+
"-XX:ErrorHandlerTest=14",
51+
"-version");
52+
53+
OutputAnalyzer output = new OutputAnalyzer(pb.start());
54+
output.shouldNotHaveExitValue(0);
55+
56+
// Verify that the hs_err problematic frame contains a function name that points to origin of the crash;
57+
// on Windows/MSVC, if symbols are present and loaded, we should see a ref to either 'crash_with_segfault'
58+
// 'VMError::controlled_crash' depending on whether the compile optimizations (i.e. crash_with_segfault
59+
// was inlined or not):
60+
// # Problematic frame:
61+
// # V [jvm.dll+0x.....] crash_with_segfault+0x10
62+
// or
63+
// # V [jvm.dll+0x.....] VMError::controlled_crash+0x99
64+
//
65+
// If symbols could not be loaded, however, then the frame will contain not function name at all, i.e.
66+
// # Problematic frame:
67+
// # V [jvm.dll+0x.....]
68+
// NB: this is not true for other OS/Compilers, where the functions names are present even with no symbols,
69+
// hence this test being restricted to Windows only.
70+
output.shouldMatch(("# V \\[jvm.dll.*\\].*(crash_with_segfault|controlled_crash).*"));
71+
72+
}
73+
74+
}
75+
76+

0 commit comments

Comments
 (0)
Please sign in to comment.