Skip to content

Commit dd1d004

Browse files
olsajiriacmel
authored andcommitted
perf jvmti: Separate jvmti cmlr check
The Compiled Method Load Record (cmlr) is JDK specific interface to access JVM stack info. This makes the jvmti agent code not compile under another jdk, which does not support that. Separating jvmti cmlr check into special feature check, and adding HAVE_JVMTI_CMLR macro to indicate that. Mark cmlr code in jvmti/libjvmti.c with HAVE_JVMTI_CMLR, so we can compile it on system without cmlr support. This change makes the jvmti compile with java-1.8.0-ibm package. It's without the line numbers support, but the rest works. Adding NO_JVMTI_CMLR compile variable for testing. Signed-off-by: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ben Gainey <[email protected]> Cc: Gustavo Luiz Duarte <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent ecd94f1 commit dd1d004

File tree

6 files changed

+37
-1
lines changed

6 files changed

+37
-1
lines changed

tools/build/feature/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ FILES= \
5555
test-sdt.bin \
5656
test-cxx.bin \
5757
test-jvmti.bin \
58+
test-jvmti-cmlr.bin \
5859
test-sched_getcpu.bin \
5960
test-setns.bin \
6061
test-libopencsd.bin \
@@ -267,6 +268,9 @@ $(OUTPUT)test-cxx.bin:
267268
$(OUTPUT)test-jvmti.bin:
268269
$(BUILD)
269270

271+
$(OUTPUT)test-jvmti-cmlr.bin:
272+
$(BUILD)
273+
270274
$(OUTPUT)test-llvm.bin:
271275
$(BUILDXX) -std=gnu++11 \
272276
-I$(shell $(LLVM_CONFIG) --includedir) \

tools/build/feature/test-jvmti-cmlr.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include <jvmti.h>
3+
#include <jvmticmlr.h>
4+
5+
int main(void)
6+
{
7+
jvmtiCompiledMethodLoadInlineRecord rec __attribute__((unused));
8+
jvmtiCompiledMethodLoadRecordHeader hdr __attribute__((unused));
9+
PCStackInfo p __attribute__((unused));
10+
return 0;
11+
}

tools/build/feature/test-jvmti.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <jvmti.h>
3-
#include <jvmticmlr.h>
43

54
int main(void)
65
{

tools/perf/Makefile.config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,13 @@ ifndef NO_JVMTI
855855
$(call feature_check,jvmti)
856856
ifeq ($(feature-jvmti), 1)
857857
$(call detected_var,JDIR)
858+
ifndef NO_JVMTI_CMLR
859+
FEATURE_CHECK_CFLAGS-jvmti-cmlr := $(FEATURE_CHECK_CFLAGS-jvmti)
860+
$(call feature_check,jvmti-cmlr)
861+
ifeq ($(feature-jvmti-cmlr), 1)
862+
CFLAGS += -DHAVE_JVMTI_CMLR
863+
endif
864+
endif # NO_JVMTI_CMLR
858865
else
859866
$(warning No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel)
860867
NO_JVMTI := 1

tools/perf/Makefile.perf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ include ../scripts/utilities.mak
9595
#
9696
# Define NO_JVMTI if you do not want jvmti agent built
9797
#
98+
# Define NO_JVMTI_CMLR (debug only) if you do not want to process CMLR
99+
# data for java source lines.
100+
#
98101
# Define LIBCLANGLLVM if you DO want builtin clang and llvm support.
99102
# When selected, pass LLVM_CONFIG=/path/to/llvm-config to `make' if
100103
# llvm-config is not in $PATH.

tools/perf/jvmti/libjvmti.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
#include <stdlib.h>
77
#include <err.h>
88
#include <jvmti.h>
9+
#ifdef HAVE_JVMTI_CMLR
910
#include <jvmticmlr.h>
11+
#endif
1012
#include <limits.h>
1113

1214
#include "jvmti_agent.h"
@@ -27,6 +29,7 @@ static void print_error(jvmtiEnv *jvmti, const char *msg, jvmtiError ret)
2729
}
2830
}
2931

32+
#ifdef HAVE_JVMTI_CMLR
3033
static jvmtiError
3134
do_get_line_numbers(jvmtiEnv *jvmti, void *pc, jmethodID m, jint bci,
3235
jvmti_line_info_t *tab, jint *nr)
@@ -125,6 +128,15 @@ get_line_numbers(jvmtiEnv *jvmti, const void *compile_info, jvmti_line_info_t **
125128
*nr_lines = lines_total;
126129
return JVMTI_ERROR_NONE;
127130
}
131+
#else /* HAVE_JVMTI_CMLR */
132+
133+
static jvmtiError
134+
get_line_numbers(jvmtiEnv *jvmti __maybe_unused, const void *compile_info __maybe_unused,
135+
jvmti_line_info_t **tab __maybe_unused, int *nr_lines __maybe_unused)
136+
{
137+
return JVMTI_ERROR_NONE;
138+
}
139+
#endif /* HAVE_JVMTI_CMLR */
128140

129141
static void
130142
copy_class_filename(const char * class_sign, const char * file_name, char * result, size_t max_length)

0 commit comments

Comments
 (0)