8198862: Stop doing funky compilation stuff for dtrace

Reviewed-by: erikj, tbell
This commit is contained in:
Magnus Ihse Bursie 2018-03-03 08:39:08 +01:00
parent 9f72c07d5a
commit 3e166182e0
7 changed files with 79 additions and 107 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 2018, 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
@ -46,7 +46,7 @@ ifeq ($(call check-jvm-feature, dtrace), true)
$(call LogInfo, Generating dtrace header file $(@F))
$(call MakeDir, $(@D) $(DTRACE_SUPPORT_DIR))
$(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, \
( $(CC) -E $(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).d ) )
($(CPP) $(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).d))
$(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -h -o $@ -s $(DTRACE_SUPPORT_DIR)/$(@F).d)
# Process all .d files in DTRACE_SOURCE_DIR. They are:

View File

@ -49,13 +49,9 @@ ifeq ($(call check-jvm-feature, dtrace), true)
NAME := dtraceGenOffsets, \
TYPE := EXECUTABLE, \
SRC := $(TOPDIR)/make/hotspot/src/native/dtrace, \
CC := $(BUILD_CXX), \
CXX := $(BUILD_CXX), \
LDEXE := $(BUILD_CXX), \
generateJvmOffsets.cpp_CXXFLAGS := $(JVM_CFLAGS) -mt -xnolib -norunpath, \
generateJvmOffsetsMain.c_CFLAGS := -mt -m64 -norunpath -z nodefs, \
TOOLCHAIN := $(TOOLCHAIN_BUILD), \
LDFLAGS := -m64, \
LIBS := -lc, \
CFLAGS := -m64 $(JVM_CFLAGS), \
OBJECT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets/objs, \
OUTPUT_DIR := $(JVM_VARIANT_OUTPUTDIR)/tools/dtrace-gen-offsets, \
))
@ -78,24 +74,11 @@ ifeq ($(call check-jvm-feature, dtrace), true)
JVM_OFFSETS_INDEX_H := $(DTRACE_SUPPORT_DIR)/JvmOffsetsIndex.h
# Run the dtrace-gen-offset tool to generate these three files.
# The generated JvmOffsets.cpp is compiled with the rest of libjvm.
$(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_H), header))
$(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_INDEX_H), index))
$(eval $(call SetupDtraceOffsetsGeneration, $(JVM_OFFSETS_CPP), table))
############################################################################
# Compile JVM_OFFSETS_OBJ which is linked with libjvm.so.
# JvmOffsets.cpp is compiled without the common JVM_CFLAGS. Otherwise, the
# natural way would have been to included this source code in BUILD_LIBJVM.
JVM_OFFSETS_CFLAGS := -m64
ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
JVM_OFFSETS_CFLAGS += -xarch=sparc
endif
$(JVM_OFFSETS_OBJ): $(JVM_OFFSETS_CPP) $(JVM_OFFSETS_H)
$(call LogInfo, Compiling dtrace file JvmOffsets.cpp (for libjvm.so))
$(call ExecuteWithLog, $@, $(CXX) -c -I$(<D) -o $@ $(JVM_OFFSETS_CFLAGS) $<)
############################################################################
# Generate DTRACE_OBJ which is linked with libjvm.so.
@ -147,8 +130,8 @@ ifeq ($(call check-jvm-feature, dtrace), true)
$(DTRACE_OBJ): $(JVM_OUTPUTDIR)/objs/dtrace.d $(DTRACE_INSTRUMENTED_OBJS)
$(call LogInfo, Generating $(@F) from $(<F) and object files)
$(call MakeDir, $(DTRACE_SUPPORT_DIR))
$(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, $(CC) -E \
$(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).d)
$(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, \
($(CPP) $(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).d))
$(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -xlazyload -o $@ \
-s $(DTRACE_SUPPORT_DIR)/$(@F).d $(sort $(DTRACE_INSTRUMENTED_OBJS)))
@ -161,15 +144,23 @@ ifeq ($(call check-jvm-feature, dtrace), true)
# We work around this by fixing the types for these symbols using elfedit,
# after dtrace has generated the .o file.
JHELPER_DTRACE_SRC := $(TOPDIR)/src/hotspot/os/solaris/dtrace/jhelper.d
DTRACE_EXTERNAL_SYMBOLS := $(shell $(GREP) ^extern $(JHELPER_DTRACE_SRC) | $(AWK) '{ gsub(";","") ; print $$3 }')
DTRACE_ELFEDIT_COMMANDS := $(foreach symbol, $(DTRACE_EXTERNAL_SYMBOLS), \
-e 'sym:st_type $(symbol) 1')
GetElfeditCommands = \
$(foreach symbol, \
$(shell $(GREP) ^extern $(JHELPER_DTRACE_SRC) | $(AWK) '{ gsub(";","") ; print $$3 }'), \
-e 'sym:st_type $(symbol) 1')
# Make sure we run our selected compiler for preprocessing instead of letting
# the dtrace tool pick it on it's own.
$(DTRACE_JHELPER_OBJ): $(JHELPER_DTRACE_SRC) $(JVM_OFFSETS_INDEX_H)
$(call LogInfo, Running dtrace for $(<F))
$(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) $(DTRACE_CPP_FLAGS) -C \
-I$(DTRACE_SUPPORT_DIR) -o $@ -s $<)
$(call ExecuteWithLog, $@.elfedit, $(ELFEDIT) $(DTRACE_ELFEDIT_COMMANDS) $@)
$(call MakeDir, $(DTRACE_SUPPORT_DIR))
$(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, \
($(CPP) $(DTRACE_CPP_FLAGS) -I$(DTRACE_SUPPORT_DIR) $^ \
> $(DTRACE_SUPPORT_DIR)/$(@F).d))
$(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -o $@ \
-s $(DTRACE_SUPPORT_DIR)/$(@F).d)
$(call ExecuteWithLog, $@.elfedit, $(ELFEDIT) $(call GetElfeditCommands) $@)
############################################################################
# Build the stand-alone dtrace libraries

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2016, 2018, 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
@ -29,8 +29,11 @@ ifeq ($(call check-jvm-feature, dtrace), true)
# CompileJvm.gmk
DTRACE_OBJ := $(JVM_OUTPUTDIR)/objs/dtrace.o
DTRACE_JHELPER_OBJ := $(JVM_OUTPUTDIR)/objs/dtrace_jhelper.o
JVM_OFFSETS_OBJ := $(JVM_OUTPUTDIR)/objs/JvmOffsets.o
DTRACE_EXTRA_OBJECT_FILES := $(DTRACE_OBJ) $(DTRACE_JHELPER_OBJ)
DTRACE_EXTRA_OBJECT_FILES := $(DTRACE_OBJ) $(DTRACE_JHELPER_OBJ) $(JVM_OFFSETS_OBJ)
# Since we cannot generate JvmOffsets.cpp as part of the gensrc step,
# we need this special hook to get it to compile with the rest of libjvm.
JVM_OFFSETS_CPP := $(DTRACE_SUPPORT_DIR)/JvmOffsets.cpp
DTRACE_EXTRA_SOURCE_FILES := $(JVM_OFFSETS_CPP)
endif
endif

View File

@ -214,6 +214,7 @@ $(eval $(call SetupNativeCompilation, BUILD_LIBJVM, \
TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
OUTPUT_DIR := $(JVM_LIB_OUTPUTDIR), \
SRC := $(JVM_SRC_DIRS), \
EXTRA_FILES := $(DTRACE_EXTRA_SOURCE_FILES), \
EXCLUDES := $(JVM_EXCLUDES), \
EXCLUDE_FILES := $(JVM_EXCLUDE_FILES), \
EXCLUDE_PATTERNS := $(JVM_EXCLUDE_PATTERNS), \

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2018, 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
@ -297,3 +297,30 @@ int generateJvmOffsets(GEN_variant gen_variant) {
fflush(stdout);
return 0;
}
const char *HELP =
"HELP: generateJvmOffsets {-header | -index | -table} \n";
int main(int argc, const char *argv[]) {
GEN_variant gen_var;
if (argc != 2) {
printf("%s", HELP);
return 1;
}
if (0 == strcmp(argv[1], "-header")) {
gen_var = GEN_OFFSET;
}
else if (0 == strcmp(argv[1], "-index")) {
gen_var = GEN_INDEX;
}
else if (0 == strcmp(argv[1], "-table")) {
gen_var = GEN_TABLE;
}
else {
printf("%s", HELP);
return 1;
}
return generateJvmOffsets(gen_var);
}

View File

@ -1,53 +0,0 @@
/*
* Copyright (c) 2003, 2010, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "generateJvmOffsets.h"
const char *HELP =
"HELP: generateJvmOffsets {-header | -index | -table} \n";
int main(int argc, const char *argv[]) {
GEN_variant gen_var;
if (argc != 2) {
printf("%s", HELP);
return 1;
}
if (0 == strcmp(argv[1], "-header")) {
gen_var = GEN_OFFSET;
}
else if (0 == strcmp(argv[1], "-index")) {
gen_var = GEN_INDEX;
}
else if (0 == strcmp(argv[1], "-table")) {
gen_var = GEN_TABLE;
}
else {
printf("%s", HELP);
return 1;
}
return generateJvmOffsets(gen_var);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2018, 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
@ -19,7 +19,7 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*
*/
/* This file is auto-generated */
@ -30,7 +30,7 @@
#ifdef DEBUG
#define MARK_LINE this->line = __LINE__
#else
#define MARK_LINE
#define MARK_LINE
#endif
#ifdef _LP64
@ -59,9 +59,8 @@ extern pointer __1cKBufferBlobG__vtbl_;
#define copyin_int32(ADDR) *(int32_t*) copyin((pointer) (ADDR), sizeof(int32_t))
#define copyin_uint8(ADDR) *(uint8_t*) copyin((pointer) (ADDR), sizeof(uint8_t))
#define SAME(x) x
#define copyin_offset(JVM_CONST) JVM_CONST = \
copyin_int32(JvmOffsetsPtr + SAME(IDX_)JVM_CONST * sizeof(int32_t))
copyin_int32(JvmOffsetsPtr + IDX_##JVM_CONST * sizeof(int32_t))
int init_done;
@ -97,7 +96,7 @@ dtrace:helper:ustack:
/!init_done && !this->done/
{
MARK_LINE;
copyin_offset(POINTER_SIZE);
copyin_offset(COMPILER);
copyin_offset(OFFSET_CollectedHeap_reserved);
@ -158,7 +157,9 @@ dtrace:helper:ustack:
#endif
/* Read address of GrowableArray<CodeHeaps*> */
this->code_heaps_address = copyin_ptr(&``__1cJCodeCacheG_heaps_);
// this->code_heaps_address = copyin_ptr(&``__1cJCodeCacheG_heaps_);
this->code_heaps_address = * ( uint64_t * ) copyin ( ( uint64_t ) ( &``__1cJCodeCacheG_heaps_ ) , sizeof ( uint64_t ) );
/* Read address of _data array field in GrowableArray */
this->code_heaps_array_address = copyin_ptr(this->code_heaps_address + OFFSET_GrowableArray_CodeHeap_data);
this->number_of_heaps = copyin_uint32(this->code_heaps_address + OFFSET_GrowableArray_CodeHeap_len);
@ -168,7 +169,9 @@ dtrace:helper:ustack:
/*
* Get Java heap bounds
*/
this->Universe_collectedHeap = copyin_ptr(&``__1cIUniverseO_collectedHeap_);
// this->Universe_collectedHeap = copyin_ptr(&``__1cIUniverseO_collectedHeap_);
this->Universe_collectedHeap = * ( uint64_t * ) copyin ( ( uint64_t ) ( &``__1cIUniverseO_collectedHeap_ ) , sizeof ( uint64_t ) );
this->heap_start = copyin_ptr(this->Universe_collectedHeap +
OFFSET_CollectedHeap_reserved +
OFFSET_MemRegion_start);
@ -181,8 +184,8 @@ dtrace:helper:ustack:
}
/*
* IMPORTANT: At the moment the ustack helper supports up to 5 code heaps in
* the code cache. If more code heaps are added the following probes have to
* IMPORTANT: At the moment the ustack helper supports up to 5 code heaps in
* the code cache. If more code heaps are added the following probes have to
* be extended. This is done by simply adding a probe to get the heap bounds
* and another probe to set the code heap address of the newly created heap.
*/
@ -197,7 +200,7 @@ dtrace:helper:ustack:
/* CodeHeap 1 */
init_done = 1;
this->code_heap1_address = copyin_ptr(this->code_heaps_array_address);
this->code_heap1_low = copyin_ptr(this->code_heap1_address +
this->code_heap1_low = copyin_ptr(this->code_heap1_address +
OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_low);
this->code_heap1_high = copyin_ptr(this->code_heap1_address +
OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_high);
@ -211,7 +214,7 @@ dtrace:helper:ustack:
init_done = 2;
this->code_heaps_array_address = this->code_heaps_array_address + POINTER_SIZE;
this->code_heap2_address = copyin_ptr(this->code_heaps_array_address);
this->code_heap2_low = copyin_ptr(this->code_heap2_address +
this->code_heap2_low = copyin_ptr(this->code_heap2_address +
OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_low);
this->code_heap2_high = copyin_ptr(this->code_heap2_address +
OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_high);
@ -224,7 +227,7 @@ dtrace:helper:ustack:
init_done = 3;
this->code_heaps_array_address = this->code_heaps_array_address + POINTER_SIZE;
this->code_heap3_address = copyin_ptr(this->code_heaps_array_address);
this->code_heap3_low = copyin_ptr(this->code_heap3_address +
this->code_heap3_low = copyin_ptr(this->code_heap3_address +
OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_low);
this->code_heap3_high = copyin_ptr(this->code_heap3_address +
OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_high);
@ -237,7 +240,7 @@ dtrace:helper:ustack:
init_done = 4;
this->code_heaps_array_address = this->code_heaps_array_address + POINTER_SIZE;
this->code_heap4_address = copyin_ptr(this->code_heaps_array_address);
this->code_heap4_low = copyin_ptr(this->code_heap4_address +
this->code_heap4_low = copyin_ptr(this->code_heap4_address +
OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_low);
this->code_heap4_high = copyin_ptr(this->code_heap4_address +
OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_high);
@ -250,7 +253,7 @@ dtrace:helper:ustack:
init_done = 5;
this->code_heaps_array_address = this->code_heaps_array_address + POINTER_SIZE;
this->code_heap5_address = copyin_ptr(this->code_heaps_array_address);
this->code_heap5_low = copyin_ptr(this->code_heap5_address +
this->code_heap5_low = copyin_ptr(this->code_heap5_address +
OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_low);
this->code_heap5_high = copyin_ptr(this->code_heap5_address +
OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_high);
@ -309,10 +312,10 @@ dtrace:helper:ustack:
/!this->done && this->codecache/
{
MARK_LINE;
/*
/*
* Get code heap configuration
*/
this->code_heap_low = copyin_ptr(this->code_heap_address +
this->code_heap_low = copyin_ptr(this->code_heap_address +
OFFSET_CodeHeap_memory + OFFSET_VirtualSpace_low);
this->code_heap_segmap_low = copyin_ptr(this->code_heap_address +
OFFSET_CodeHeap_segmap + OFFSET_VirtualSpace_low);
@ -506,10 +509,10 @@ dtrace:helper:ustack:
/*
* Now we need to add a trailing '\0' and possibly a tag character.
*/
this->result[this->klassSymbolLength + 1 +
this->result[this->klassSymbolLength + 1 +
this->nameSymbolLength +
this->signatureSymbolLength] = this->suffix;
this->result[this->klassSymbolLength + 2 +
this->result[this->klassSymbolLength + 2 +
this->nameSymbolLength +
this->signatureSymbolLength] = '\0';
@ -519,7 +522,7 @@ dtrace:helper:ustack:
dtrace:helper:ustack:
/this->done && this->error == (char *) NULL/
{
this->result;
this->result;
}
dtrace:helper:ustack: