Skip to content

Commit dfaf7aa

Browse files
committed
feat: use packaged symbols directly when JDWP_FAT_BUILD is ON
Allows us to ship a single libjdwp_fat.so file that does not depend on any other shared libraries Signed-off-by: Akash Yadav <contact@itsaky.com>
1 parent 66a3c4b commit dfaf7aa

5 files changed

Lines changed: 45 additions & 3 deletions

File tree

src/share/back/debugInit.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
// ANDROID-CHANGED: Need to sent metrics before debugInit_exit
4848
#include "timing.h"
4949

50+
// COTG-CHANGED: Fat build support
51+
#ifdef JDWP_FAT_BUILD
52+
#include "npt.h"
53+
#endif
54+
5055
/* How the options get to OnLoad: */
5156
#define XDEBUG "-Xdebug"
5257
#define XRUN "-Xrunjdwp"
@@ -343,7 +348,11 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
343348
// ANDROID-CHANGED: Load libnpt.so with no path to use the system linker config to find it.
344349
dbgsysBuildLibName(npt_lib, sizeof(npt_lib), "", NPT_LIBNAME);
345350
/* Npt and Utf function init */
351+
#ifdef JDWP_FAT_BUILD
352+
nptInitialize(&(gdata->npt), NPT_VERSION, NULL);
353+
#else
346354
NPT_INITIALIZE(npt_lib, &(gdata->npt), NPT_VERSION, NULL);
355+
#endif
347356
if (gdata->npt == NULL) {
348357
ERROR_MESSAGE(("JDWP: unable to initialize NPT library"));
349358
return JNI_ERR;

src/share/back/transport.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
#include "debugLoop.h"
2929
#include "sys.h"
3030

31+
#ifdef JDWP_FAT_BUILD
32+
#include "dt_socket_extern.h"
33+
#endif
34+
3135
static jdwpTransportEnv *transport;
3236
static jrawMonitorID listenerLock;
3337
static jrawMonitorID sendLock;
@@ -135,15 +139,25 @@ loadTransport(const char *name, jdwpTransportEnv **transportPtr)
135139
{
136140
JNIEnv *env;
137141
jdwpTransport_OnLoad_t onLoad;
138-
void *handle;
139-
const char *libdir;
140142

141143
/* Make sure library name is not empty */
142144
if (name == NULL) {
143145
ERROR_MESSAGE(("library name is empty"));
144146
return JDWP_ERROR(TRANSPORT_LOAD);
145147
}
146148

149+
#ifdef JDWP_FAT_BUILD
150+
if (strcmp(name, "dt_socket") == 0) {
151+
onLoad = &socketTransport_OnLoad;
152+
} else {
153+
ERROR_MESSAGE(("unknown transport library: %s", name));
154+
return JDWP_ERROR(TRANSPORT_LOAD);
155+
}
156+
#else
157+
158+
void *handle;
159+
const char *libdir;
160+
147161
/* First, look in sun.boot.library.path. This should find the standard
148162
* dt_socket and dt_shmem transport libraries, or any library
149163
* that was delivered with the J2SE.
@@ -186,6 +200,8 @@ loadTransport(const char *name, jdwpTransportEnv **transportPtr)
186200
return JDWP_ERROR(TRANSPORT_LOAD);
187201
}
188202

203+
#endif // JDWP_FAT_BUILD
204+
189205
/* Get transport interface */
190206
env = getEnv();
191207
if ( env != NULL ) {

src/share/npt/npt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "npt_md.h"
3939
#include "utf.h"
4040

41-
#define NPT_ERROR(s) { (void)__android_log_print(ANDROID_LOG_ERROR, "LocalJDWP-NPT", "NPT ERROR: %s\n", s); exit(1); }
41+
#define NPT_ERROR(s) { (void)__android_log_print(ANDROID_LOG_ERROR, "COTG-JDWP-NPT", "NPT ERROR: %s\n", s); exit(1); }
4242

4343
#ifdef __cplusplus
4444
extern "C" {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef __DT_SOCKET_HEADER
2+
#define __DT_SOCKET_HEADER
3+
4+
#include "jni.h"
5+
#include "jdwpTransport.h"
6+
7+
extern jint socketTransport_OnLoad(JavaVM *, jdwpTransportCallback *,
8+
jint, jdwpTransportEnv **);
9+
10+
#endif

src/share/transport/socket/socketTransport.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include <android/log.h>
3232

33+
#include "dt_socket_extern.h"
3334
#include "jdwpTransport.h"
3435
#include "sysSocket.h"
3536

@@ -757,3 +758,9 @@ jdwpTransport_OnLoad(JavaVM *vm, jdwpTransportCallback* cbTablePtr,
757758
tlsIndex = dbgsysTlsAlloc();
758759
return JNI_OK;
759760
}
761+
762+
JNIEXPORT jint JNICALL
763+
socketTransport_OnLoad(JavaVM *vm, jdwpTransportCallback* cbTablePtr,
764+
jint version, jdwpTransportEnv** result) {
765+
return jdwpTransport_OnLoad(vm, cbTablePtr, version, result);
766+
}

0 commit comments

Comments
 (0)