Thu, 14 Mar 2013 00:33:08 -0700
8003348: SA can not read core file on OS
Summary: Macosx uses Mach-O file format for binary files, not ELF format. Currently SA works on core files on other platforms, t his change enables SA work on core file generated on Darwin.
Reviewed-by: sla, sspitsyn
Contributed-by: yumin.qi@oracle.com
1 #
2 # Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
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.
8 #
9 # This code is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 # version 2 for more details (a copy is included in the LICENSE file that
13 # accompanied this code).
14 #
15 # You should have received a copy of the GNU General Public License version
16 # 2 along with this work; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 #
19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 # or visit www.oracle.com if you need additional information or have any
21 # questions.
22 #
23 #
25 # Rules to build serviceability agent library, used by vm.make
27 # libsaproc.so(dylib): serviceability agent
28 SAPROC = saproc
30 ifeq ($(OS_VENDOR), Darwin)
31 LIBSAPROC = lib$(SAPROC).dylib
32 else
33 LIBSAPROC = lib$(SAPROC).so
34 endif
36 AGENT_DIR = $(GAMMADIR)/agent
38 SASRCDIR = $(AGENT_DIR)/src/os/$(Platform_os_family)
40 BSD_NON_STUB_SASRCFILES = $(SASRCDIR)/salibelf.c \
41 $(SASRCDIR)/symtab.c \
42 $(SASRCDIR)/libproc_impl.c \
43 $(SASRCDIR)/ps_proc.c \
44 $(SASRCDIR)/ps_core.c \
45 $(SASRCDIR)/BsdDebuggerLocal.c \
46 $(AGENT_DIR)/src/share/native/sadis.c
48 DARWIN_NON_STUB_SASRCFILES = $(SASRCDIR)/symtab.c \
49 $(SASRCDIR)/libproc_impl.c \
50 $(SASRCDIR)/ps_core.c \
51 $(SASRCDIR)/MacosxDebuggerLocal.m \
52 $(AGENT_DIR)/src/share/native/sadis.c
54 ifeq ($(OS_VENDOR), FreeBSD)
55 SASRCFILES = $(BSD_NON_STUB_SASRCFILES)
56 SALIBS = -lutil -lthread_db
57 SAARCH = $(ARCHFLAG)
58 else
59 ifeq ($(OS_VENDOR), Darwin)
60 SASRCFILES = $(DARWIN_NON_STUB_SASRCFILES)
61 SALIBS = -g -framework Foundation -F/System/Library/Frameworks/JavaVM.framework/Frameworks -framework JavaNativeFoundation -framework Security -framework CoreFoundation
62 #objc compiler blows up on -march=i586, perhaps it should not be included in the macosx intel 32-bit C++ compiles?
63 SAARCH = $(subst -march=i586,,$(ARCHFLAG))
64 else
65 SASRCFILES = $(SASRCDIR)/StubDebuggerLocal.c
66 SALIBS =
67 SAARCH = $(ARCHFLAG)
68 endif
69 endif
71 SAMAPFILE = $(SASRCDIR)/mapfile
73 DEST_SAPROC = $(JDK_LIBDIR)/$(LIBSAPROC)
75 # DEBUG_BINARIES overrides everything, use full -g debug information
76 ifeq ($(DEBUG_BINARIES), true)
77 SA_DEBUG_CFLAGS = -g
78 endif
80 # if $(AGENT_DIR) does not exist, we don't build SA
81 # also, we don't build SA on Itanium, PPC, ARM or zero.
83 ifneq ($(wildcard $(AGENT_DIR)),)
84 ifneq ($(filter-out ia64 arm ppc zero,$(SRCARCH)),)
85 BUILDLIBSAPROC = $(LIBSAPROC)
86 endif
87 endif
90 ifneq ($(OS_VENDOR), Darwin)
91 SA_LFLAGS = $(MAPFLAG:FILENAME=$(SAMAPFILE))
92 endif
93 SA_LFLAGS += $(LDFLAGS_HASH_STYLE)
95 ifeq ($(OS_VENDOR), Darwin)
96 BOOT_JAVA_INCLUDES = -I$(BOOT_JAVA_HOME)/include \
97 -I$(BOOT_JAVA_HOME)/include/$(shell uname -s | tr "[:upper:]" "[:lower:]") \
98 -I/System/Library/Frameworks/JavaVM.framework/Headers
99 else
100 BOOT_JAVA_INCLUDES = -I$(BOOT_JAVA_HOME)/include \
101 -I$(BOOT_JAVA_HOME)/include/$(shell uname -s | tr "[:upper:]" "[:lower:]")
102 endif
104 $(LIBSAPROC): $(SASRCFILES) $(SAMAPFILE)
105 $(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \
106 echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \
107 exit 1; \
108 fi
109 @echo Making SA debugger back-end...
110 $(QUIETLY) $(CC) -D$(BUILDARCH) -D_GNU_SOURCE \
111 $(SYMFLAG) $(SAARCH) $(SHARED_FLAG) $(PICFLAG) \
112 -I$(SASRCDIR) \
113 -I$(GENERATED) \
114 $(BOOT_JAVA_INCLUDES) \
115 $(SASRCFILES) \
116 $(SA_LFLAGS) \
117 $(SA_DEBUG_CFLAGS) \
118 -o $@ \
119 $(SALIBS)
121 install_saproc: $(BUILDLIBSAPROC)
122 $(QUIETLY) if [ -e $(LIBSAPROC) ] ; then \
123 echo "Copying $(LIBSAPROC) to $(DEST_SAPROC)"; \
124 cp -f $(LIBSAPROC) $(DEST_SAPROC) && echo "Done"; \
125 fi
127 .PHONY: install_saproc