Skip to content

Commit 49366bd

Browse files
committed
Add selected tracepoints for OpenJ9 -Xtrace
Depends on eclipse-openj9/openj9#20936 Issue https://github.ibm.com/runtimes/semeru-requests/issues/46 Signed-off-by: Peter Shipton <[email protected]>
1 parent c979e50 commit 49366bd

23 files changed

+431
-3
lines changed

closed/CopyToBuildJdk.gmk

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
# 2 along with this work; if not, see <http://www.gnu.org/licenses/>.
1919
# ===========================================================================
2020

21+
# ===========================================================================
22+
# (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
23+
# ===========================================================================
24+
2125
all :
2226

2327
.PHONY : all
@@ -201,6 +205,7 @@ endif # windows
201205
$(foreach file, \
202206
$(SRC_ROOT)/closed/classlib.properties \
203207
$(OPENJ9_VM_BUILD_DIR)/J9TraceFormat.dat \
208+
$(OPENJ9_VM_BUILD_DIR)/JCLTraceFormat.dat \
204209
$(OPENJ9_VM_BUILD_DIR)/OMRTraceFormat.dat, \
205210
$(call openj9_copy_files,, $(file) $(JDK_OUTPUTDIR)/lib/$(notdir $(file))))
206211

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* ===========================================================================
3+
* (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
4+
* ===========================================================================
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+
* IBM designates this particular file as subject to the "Classpath" exception
11+
* as provided by IBM in the LICENSE file that accompanied this code.
12+
*
13+
* This code is distributed in the hope that it will be useful, but WITHOUT
14+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16+
* version 2 for more details (a copy is included in the LICENSE file that
17+
* accompanied this code).
18+
*
19+
* You should have received a copy of the GNU General Public License version
20+
* 2 along with this work; if not, see <http://www.gnu.org/licenses/>.
21+
*
22+
* ===========================================================================
23+
*/
24+
25+
#include "jni.h"
26+
#include "jvm.h"
27+
28+
/* These definitions required by j9.h are in the OpenJ9 jni.h, but OpenJDK jni.h is used here. */
29+
struct GCStatus;
30+
typedef struct GCStatus GCStatus;
31+
struct JavaVMQuery;
32+
typedef struct JavaVMQuery JavaVMQuery;
33+
struct JVMExtensionInterface_;
34+
typedef const struct JVMExtensionInterface_ *JVMExt;
35+
36+
#define COPY_PROGRESS_INFO_MASK 0
37+
#if defined(AIX)
38+
#define AIXPPC
39+
#define RS6000
40+
#endif /* defined(AIX) */
41+
#if defined(MACOSX)
42+
#define OSX
43+
#endif /* defined(MACOSX) */
44+
#if defined(WIN32)
45+
#define OMR_OS_WINDOWS
46+
#endif /* defined(WIN32) */
47+
48+
#include "j9.h"
49+
#include "tracehelp.c"
50+
#include "ut_jcl_nio.c"
51+
52+
JNIEXPORT jint JNICALL
53+
JNI_OnLoad(JavaVM *vm, void *reserved)
54+
{
55+
UT_JCL_NIO_MODULE_LOADED(J9_UTINTERFACE_FROM_VM((J9JavaVM *)vm));
56+
57+
return JNI_VERSION_1_2;
58+
}

jdk/make/lib/CoreLibraries.gmk

+16-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#
2525

2626
# ===========================================================================
27-
# (c) Copyright IBM Corp. 2023, 2023 All Rights Reserved
27+
# (c) Copyright IBM Corp. 2023, 2025 All Rights Reserved
2828
# ===========================================================================
2929

3030
# Include custom extensions if available.
@@ -152,6 +152,21 @@ LIBJAVA_SRC_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/l
152152
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/common \
153153
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/util
154154

155+
BUILD_LIBJAVA_check_version.c_CFLAGS := \
156+
-I$(OPENJ9_TOPDIR)/runtime/include \
157+
-I$(OPENJ9_TOPDIR)/runtime/oti \
158+
-I$(OPENJ9OMR_TOPDIR)/include_core \
159+
-I$(OUTPUT_ROOT)/vm/runtime \
160+
-I$(OPENJ9_TOPDIR)/runtime/jcl \
161+
-I$(OPENJ9_TOPDIR)/runtime/util \
162+
-I$(OUTPUT_ROOT)/vm/runtime/jcl
163+
BUILD_LIBJAVA_io_util_md.c_CFLAGS := \
164+
-I$(OPENJ9OMR_TOPDIR)/include_core \
165+
-I$(OUTPUT_ROOT)/vm/runtime/jcl
166+
BUILD_LIBJAVA_UnixFileSystem_md.c_CFLAGS := \
167+
-I$(OPENJ9OMR_TOPDIR)/include_core \
168+
-I$(OUTPUT_ROOT)/vm/runtime/jcl
169+
155170
ifeq ($(OPENJDK_TARGET_OS), windows)
156171
LIBJAVA_SRC_DIRS += $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/util/locale/provider
157172
else ifeq ($(OPENJDK_TARGET_OS), macosx)

jdk/make/lib/NetworkingLibraries.gmk

+31
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
# questions.
2424
#
2525

26+
# ===========================================================================
27+
# (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
28+
# ===========================================================================
29+
2630
LIBNET_SRC_DIRS := $(JDK_TOPDIR)/src/share/native/java/net \
2731
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/net \
2832
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/net/ \
@@ -37,6 +41,33 @@ endif
3741

3842
LIBNET_CFLAGS := $(foreach dir, $(LIBNET_SRC_DIRS), -I$(dir))
3943

44+
BUILD_LIBNET_aix_close.c_CFLAGS := \
45+
-I$(OPENJ9OMR_TOPDIR)/include_core \
46+
-I$(OUTPUT_ROOT)/vm/runtime/jcl
47+
BUILD_LIBNET_bsd_close.c_CFLAGS := \
48+
-I$(OPENJ9OMR_TOPDIR)/include_core \
49+
-I$(OUTPUT_ROOT)/vm/runtime/jcl
50+
BUILD_LIBNET_DualStackPlainSocketImpl.c_CFLAGS := \
51+
-I$(OPENJ9OMR_TOPDIR)/include_core \
52+
-I$(OUTPUT_ROOT)/vm/runtime/jcl
53+
BUILD_LIBNET_linux_close.c_CFLAGS := \
54+
-I$(OPENJ9OMR_TOPDIR)/include_core \
55+
-I$(OUTPUT_ROOT)/vm/runtime/jcl
56+
BUILD_LIBNET_net_util.c_CFLAGS := \
57+
-I$(OPENJ9_TOPDIR)/runtime/include \
58+
-I$(OPENJ9_TOPDIR)/runtime/oti \
59+
-I$(OPENJ9OMR_TOPDIR)/include_core \
60+
-I$(OUTPUT_ROOT)/vm/runtime \
61+
-I$(OPENJ9_TOPDIR)/runtime/jcl \
62+
-I$(OPENJ9_TOPDIR)/runtime/util \
63+
-I$(OUTPUT_ROOT)/vm/runtime/jcl
64+
BUILD_LIBNET_PlainSocketImpl.c_CFLAGS := \
65+
-I$(OPENJ9OMR_TOPDIR)/include_core \
66+
-I$(OUTPUT_ROOT)/vm/runtime/jcl
67+
BUILD_LIBNET_TwoStacksPlainSocketImpl.c_CFLAGS := \
68+
-I$(OPENJ9OMR_TOPDIR)/include_core \
69+
-I$(OUTPUT_ROOT)/vm/runtime/jcl
70+
4071
LIBNET_EXCLUDE_FILES :=
4172
ifneq ($(OPENJDK_TARGET_OS), linux)
4273
LIBNET_EXCLUDE_FILES += linux_close.c

jdk/make/lib/NioLibraries.gmk

+24
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@
2323
# questions.
2424
#
2525

26+
# ===========================================================================
27+
# (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
28+
# ===========================================================================
29+
2630
BUILD_LIBNIO_SRC := \
2731
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/nio \
32+
$(SRC_ROOT)/closed/adds/jdk/src/share/native/sun/nio/ch \
2833
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/ch \
2934
$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/fs
3035

@@ -34,6 +39,24 @@ BUILD_LIBNIO_CFLAGS := \
3439
-I$(JDK_TOPDIR)/src/share/native/java/net \
3540
-I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/net
3641

42+
BUILD_LIBNIO_FileDispatcherImpl.c_CFLAGS := \
43+
-I$(OPENJ9OMR_TOPDIR)/include_core \
44+
-I$(OUTPUT_ROOT)/vm/runtime/jcl
45+
BUILD_LIBNIO_Net.c_CFLAGS := \
46+
-I$(OPENJ9OMR_TOPDIR)/include_core \
47+
-I$(OUTPUT_ROOT)/vm/runtime/jcl
48+
BUILD_LIBNIO_nio_util.c_CFLAGS := \
49+
-I$(OPENJ9_TOPDIR)/runtime/include \
50+
-I$(OPENJ9_TOPDIR)/runtime/oti \
51+
-I$(OPENJ9OMR_TOPDIR)/include_core \
52+
-I$(OUTPUT_ROOT)/vm/runtime \
53+
-I$(OPENJ9_TOPDIR)/runtime/jcl \
54+
-I$(OPENJ9_TOPDIR)/runtime/util \
55+
-I$(OUTPUT_ROOT)/vm/runtime/jcl
56+
BUILD_LIBNIO_SocketDispatcher.c_CFLAGS := \
57+
-I$(OPENJ9OMR_TOPDIR)/include_core \
58+
-I$(OUTPUT_ROOT)/vm/runtime/jcl
59+
3760
BUILD_LIBNIO_FILES := \
3861
DatagramChannelImpl.c \
3962
DatagramDispatcher.c \
@@ -43,6 +66,7 @@ BUILD_LIBNIO_FILES := \
4366
IOUtil.c \
4467
MappedByteBuffer.c \
4568
Net.c \
69+
nio_util.c \
4670
ServerSocketChannelImpl.c \
4771
SocketChannelImpl.c \
4872
SocketDispatcher.c

jdk/make/mapfiles/libnio/mapfile-linux

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
# questions.
2424
#
2525

26+
# ===========================================================================
27+
# (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
28+
# ===========================================================================
29+
2630
SUNWprivate_1.1 {
2731
global:
2832
Java_java_nio_MappedByteBuffer_force0;
@@ -203,6 +207,7 @@ SUNWprivate_1.1 {
203207
Java_sun_nio_fs_UnixNativeDispatcher_getpwnam0;
204208
Java_sun_nio_fs_UnixNativeDispatcher_getgrnam0;
205209
Java_sun_nio_fs_UnixCopyFile_transfer;
210+
JNI_OnLoad;
206211
handleSocketError;
207212

208213
local:

jdk/make/mapfiles/libnio/mapfile-macosx

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
# questions.
2424
#
2525

26+
# ===========================================================================
27+
# (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
28+
# ===========================================================================
29+
2630
SUNWprivate_1.1 {
2731
global:
2832
Java_java_nio_MappedByteBuffer_force0;
@@ -175,6 +179,7 @@ SUNWprivate_1.1 {
175179
Java_sun_nio_fs_UnixNativeDispatcher_getpwnam0;
176180
Java_sun_nio_fs_UnixNativeDispatcher_getgrnam0;
177181
Java_sun_nio_fs_UnixCopyFile_transfer;
182+
JNI_OnLoad;
178183
handleSocketError;
179184

180185
local:

jdk/src/aix/native/java/net/aix_close.c

+20
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
* questions.
2525
*/
2626

27+
/*
28+
* ===========================================================================
29+
* (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
30+
* ===========================================================================
31+
*/
32+
2733
/*
2834
* This file contains implementations of NET_... functions. The NET_.. functions are
2935
* wrappers for common file- and socket functions plus provisions for non-blocking IO.
@@ -55,6 +61,9 @@
5561
#include <errno.h>
5662

5763
#include <sys/poll.h>
64+
#include <arpa/inet.h>
65+
66+
#include "ut_jcl_net.h"
5867

5968
/*
6069
* Stack allocated by thread when doing blocking operation
@@ -370,6 +379,7 @@ int NET_Dup2(int fd, int fd2) {
370379
* preempted and the I/O system call will return -1/EBADF.
371380
*/
372381
int NET_SocketClose(int fd) {
382+
Trc_NET_SocketClose(fd);
373383
return closefd(-1, fd);
374384
}
375385

@@ -444,6 +454,16 @@ int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
444454
return -1;
445455
}
446456

457+
if (AF_INET == addr->sa_family) {
458+
char buf[INET_ADDRSTRLEN];
459+
struct sockaddr_in *sa = (struct sockaddr_in *)addr;
460+
Trc_NET_Connect4(s, inet_ntop(AF_INET, &sa->sin_addr, buf, sizeof(buf)), ntohs(sa->sin_port), addrlen);
461+
} else if (AF_INET6 == addr->sa_family) {
462+
char buf[INET6_ADDRSTRLEN];
463+
struct sockaddr_in6 *sa = (struct sockaddr_in6 *)addr;
464+
Trc_NET_Connect6(s, inet_ntop(AF_INET6, &sa->sin6_addr, buf, sizeof(buf)), ntohs(sa->sin6_port), ntohl(sa->sin6_scope_id), addrlen);
465+
}
466+
447467
/* On AIX, when the system call connect() is interrupted, the connection
448468
* is not aborted and it will be established asynchronously by the kernel.
449469
* Hence, no need to restart connect() when EINTR is received

jdk/src/share/native/common/check_version.c

+29-1
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,38 @@
2424
*/
2525
/*
2626
* ===========================================================================
27-
* (c) Copyright IBM Corp. 2024, 2024 All Rights Reserved
27+
* (c) Copyright IBM Corp. 2024, 2025 All Rights Reserved
2828
* ===========================================================================
2929
*/
3030

3131
#include "jni.h"
3232
#include "jvm.h"
3333

34+
/* These definitions required by j9.h are in the OpenJ9 jni.h, but OpenJDK jni.h is used here. */
35+
struct GCStatus;
36+
typedef struct GCStatus GCStatus;
37+
struct JavaVMQuery;
38+
typedef struct JavaVMQuery JavaVMQuery;
39+
struct JVMExtensionInterface_;
40+
typedef const struct JVMExtensionInterface_ *JVMExt;
41+
42+
#define COPY_PROGRESS_INFO_MASK 0
43+
#if defined(AIX)
44+
#define AIXPPC
45+
#define RS6000
46+
#endif /* defined(AIX) */
47+
#if defined(MACOSX)
48+
#define OSX
49+
#endif /* defined(MACOSX) */
50+
#if defined(WIN32)
51+
#define OMR_OS_WINDOWS
52+
#endif /* defined(WIN32) */
53+
54+
#include "j9.h"
55+
#include "ut_jcl_java.h"
56+
#include "tracehelp.c"
57+
#include "ut_jcl_java.c"
58+
3459
JNIEXPORT jint JNICALL
3560
JNI_OnLoad(JavaVM *vm, void *reserved)
3661
{
@@ -45,5 +70,8 @@ JNI_OnLoad(JavaVM *vm, void *reserved)
4570
(*env)->FatalError(env, buf);
4671
}
4772
}
73+
74+
UT_JCL_JAVA_MODULE_LOADED(J9_UTINTERFACE_FROM_VM((J9JavaVM *)vm));
75+
4876
return JNI_VERSION_1_2;
4977
}

jdk/src/share/native/java/net/net_util.c

+33
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,41 @@
2323
* questions.
2424
*/
2525

26+
/*
27+
* ===========================================================================
28+
* (c) Copyright IBM Corp. 2025, 2025 All Rights Reserved
29+
* ===========================================================================
30+
*/
31+
2632
#include "jni.h"
2733
#include "jvm.h"
2834
#include "jni_util.h"
2935
#include "net_util.h"
3036

37+
/* These definitions required by j9.h are in the OpenJ9 jni.h, but OpenJDK jni.h is used here. */
38+
struct GCStatus;
39+
typedef struct GCStatus GCStatus;
40+
struct JavaVMQuery;
41+
typedef struct JavaVMQuery JavaVMQuery;
42+
struct JVMExtensionInterface_;
43+
typedef const struct JVMExtensionInterface_ *JVMExt;
44+
45+
#define COPY_PROGRESS_INFO_MASK 0
46+
#if defined(AIX)
47+
#define AIXPPC
48+
#define RS6000
49+
#endif /* defined(AIX) */
50+
#if defined(MACOSX)
51+
#define OSX
52+
#endif /* defined(MACOSX) */
53+
#if defined(WIN32)
54+
#define OMR_OS_WINDOWS
55+
#endif /* defined(WIN32) */
56+
57+
#include "j9.h"
58+
#include "tracehelp.c"
59+
#include "ut_jcl_net.c"
60+
3161
int IPv6_supported() ;
3262

3363
static int IPv6_available;
@@ -53,6 +83,9 @@ JNI_OnLoad(JavaVM *vm, void *reserved)
5383
return JNI_VERSION_1_2;
5484
}
5585
}
86+
87+
UT_JCL_NET_MODULE_LOADED(J9_UTINTERFACE_FROM_VM((J9JavaVM *)vm));
88+
5689
iCls = (*env)->FindClass(env, "java/lang/Boolean");
5790
CHECK_NULL_RETURN(iCls, JNI_VERSION_1_2);
5891
mid = (*env)->GetStaticMethodID(env, iCls, "getBoolean", "(Ljava/lang/String;)Z");

0 commit comments

Comments
 (0)