2
# Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation. Oracle designates this
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
11
# This code is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
# version 2 for more details (a copy is included in the LICENSE file that
15
# accompanied this code).
17
# You should have received a copy of the GNU General Public License version
18
# 2 along with this work; if not, write to the Free Software Foundation,
19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
# or visit www.oracle.com if you need additional information or have any
26
################################################################################
27
# This file contains functionality related to native debug symbol handling.
29
################################################################################
30
define CreateDebugSymbols
31
ifneq ($$($1_COPY_DEBUG_SYMBOLS), false)
32
$1_COPY_DEBUG_SYMBOLS := $(COPY_DEBUG_SYMBOLS)
35
ifneq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), false)
36
$1_ZIP_EXTERNAL_DEBUG_SYMBOLS := $(ZIP_EXTERNAL_DEBUG_SYMBOLS)
39
$1_CREATE_DEBUGINFO := false
40
ifeq ($$($1_COPY_DEBUG_SYMBOLS), true)
41
ifneq ($$($1_DEBUG_SYMBOLS), false)
42
$$(call SetIfEmpty, $1_SYMBOLS_DIR, $$($1_OUTPUT_DIR))
43
# Only copy debug symbols for dynamic libraries and programs.
44
ifneq ($$($1_TYPE), STATIC_LIBRARY)
45
$1_CREATE_DEBUGINFO := true
47
# Setup where the platform specific debuginfo files end up
48
ifeq ($(call isTargetOs, windows), true)
49
$1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_BASENAME).pdb \
50
$$($1_SYMBOLS_DIR)/$$($1_BASENAME).map
51
$1_DEBUGINFO_ZIP := $$($1_SYMBOLS_DIR)/$$($1_BASENAME).diz
52
else ifeq ($(call isTargetOs, macosx), true)
53
$1_DEBUGINFO_FILES := \
54
$$($1_SYMBOLS_DIR)/$$($1_BASENAME).dSYM/Contents/Info.plist \
55
$$($1_SYMBOLS_DIR)/$$($1_BASENAME).dSYM/Contents/Resources/DWARF/$$($1_BASENAME)
56
$1_DEBUGINFO_ZIP := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).diz
57
else ifeq ($(call isTargetOsType, unix), true)
58
$1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).debuginfo
59
$1_DEBUGINFO_ZIP := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).diz
62
ifeq ($(call isTargetOs, windows), true)
63
$1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_SYMBOLS_DIR)/$$($1_BASENAME).pdb" \
64
"-map:$$($1_SYMBOLS_DIR)/$$($1_BASENAME).map"
65
ifeq ($(SHIP_DEBUG_SYMBOLS), public)
66
$1_EXTRA_LDFLAGS += "-pdbstripped:$$($1_SYMBOLS_DIR)/$$($1_BASENAME).stripped.pdb"
70
# Since the link rule creates more than one file that we want to track,
71
# we have to use some tricks to get make to cooperate. To properly
72
# trigger downstream dependants of $$($1_DEBUGINFO_FILES), we must have
73
# a recipe in the rule below. To avoid rerunning the recipe every time
74
# have it touch the target. If a debuginfo file is deleted by something
75
# external, explicitly delete the TARGET to trigger a rebuild of both.
76
ifneq ($$(wildcard $$($1_DEBUGINFO_FILES)), $$($1_DEBUGINFO_FILES))
77
$$(call LogDebug, Deleting $$($1_BASENAME) because debuginfo files are missing)
78
$$(shell $(RM) $$($1_TARGET))
80
$$($1_DEBUGINFO_FILES): $$($1_TARGET)
81
$$(if $$(CORRECT_FUNCTION_IN_RECIPE_EVALUATION), \
82
$$(if $$(wildcard $$@), , $$(error $$@ was not created for $$<)) \
86
$1 += $$($1_DEBUGINFO_FILES)
88
ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
89
# The dependency on TARGET is needed for debuginfo files
90
# to be rebuilt properly.
91
$$($1_DEBUGINFO_ZIP): $$($1_DEBUGINFO_FILES) $$($1_TARGET)
92
$(CD) $$($1_SYMBOLS_DIR) && \
93
$(ZIPEXE) -q -r $$@ $$(subst $$($1_SYMBOLS_DIR)/,, $$($1_DEBUGINFO_FILES))
95
$1 += $$($1_DEBUGINFO_ZIP)
97
endif # !STATIC_LIBRARY
98
endif # $1_DEBUG_SYMBOLS != false
99
endif # COPY_DEBUG_SYMBOLS