| File: | jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c |
| Warning: | line 638, column 19 Access to field 'vmDead' results in a dereference of a null pointer (loaded from variable 'gdata') |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* | |||
| 2 | * Copyright (c) 1998, 2021, 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. Oracle designates this | |||
| 8 | * particular file as subject to the "Classpath" exception as provided | |||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | |||
| 10 | * | |||
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT | |||
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |||
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |||
| 14 | * version 2 for more details (a copy is included in the LICENSE file that | |||
| 15 | * accompanied this code). | |||
| 16 | * | |||
| 17 | * You should have received a copy of the GNU General Public License version | |||
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, | |||
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |||
| 20 | * | |||
| 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |||
| 22 | * or visit www.oracle.com if you need additional information or have any | |||
| 23 | * questions. | |||
| 24 | */ | |||
| 25 | ||||
| 26 | #include <ctype.h> | |||
| 27 | ||||
| 28 | #include "util.h" | |||
| 29 | #include "commonRef.h" | |||
| 30 | #include "debugDispatch.h" | |||
| 31 | #include "eventHandler.h" | |||
| 32 | #include "eventHelper.h" | |||
| 33 | #include "threadControl.h" | |||
| 34 | #include "stepControl.h" | |||
| 35 | #include "transport.h" | |||
| 36 | #include "classTrack.h" | |||
| 37 | #include "debugLoop.h" | |||
| 38 | #include "bag.h" | |||
| 39 | #include "invoker.h" | |||
| 40 | #include "sys.h" | |||
| 41 | ||||
| 42 | /* How the options get to OnLoad: */ | |||
| 43 | #define XRUN"-Xrunjdwp" "-Xrunjdwp" | |||
| 44 | #define AGENTLIB"-agentlib:jdwp" "-agentlib:jdwp" | |||
| 45 | ||||
| 46 | /* Debug version defaults */ | |||
| 47 | #ifdef DEBUG1 | |||
| 48 | #define DEFAULT_ASSERT_ON1 JNI_TRUE1 | |||
| 49 | #define DEFAULT_ASSERT_FATAL1 JNI_TRUE1 | |||
| 50 | #define DEFAULT_LOGFILE"jdwp.log" "jdwp.log" | |||
| 51 | #else | |||
| 52 | #define DEFAULT_ASSERT_ON1 JNI_FALSE0 | |||
| 53 | #define DEFAULT_ASSERT_FATAL1 JNI_FALSE0 | |||
| 54 | #define DEFAULT_LOGFILE"jdwp.log" NULL((void*)0) | |||
| 55 | #endif | |||
| 56 | ||||
| 57 | static jboolean vmInitialized; | |||
| 58 | static jrawMonitorID initMonitor; | |||
| 59 | static jboolean initComplete; | |||
| 60 | static jbyte currentSessionID; | |||
| 61 | ||||
| 62 | /* | |||
| 63 | * Options set through the OnLoad options string. All of these values | |||
| 64 | * are set once at VM startup and never reset. | |||
| 65 | */ | |||
| 66 | static jboolean isServer = JNI_FALSE0; /* Listens for connecting debuggers? */ | |||
| 67 | static jboolean isStrict = JNI_FALSE0; /* Unused */ | |||
| 68 | static jboolean useStandardAlloc = JNI_FALSE0; /* Use standard malloc/free? */ | |||
| 69 | static struct bag *transports; /* of TransportSpec */ | |||
| 70 | ||||
| 71 | static jboolean initOnStartup = JNI_TRUE1; /* init immediately */ | |||
| 72 | static char *initOnException = NULL((void*)0); /* init when this exception thrown */ | |||
| 73 | static jboolean initOnUncaught = JNI_FALSE0; /* init when uncaught exc thrown */ | |||
| 74 | ||||
| 75 | static char *launchOnInit = NULL((void*)0); /* launch this app during init */ | |||
| 76 | static jboolean suspendOnInit = JNI_TRUE1; /* suspend all app threads after init */ | |||
| 77 | static jboolean dopause = JNI_FALSE0; /* pause for debugger attach */ | |||
| 78 | static jboolean docoredump = JNI_FALSE0; /* core dump on exit */ | |||
| 79 | static char *logfile = NULL((void*)0); /* Name of logfile (if logging) */ | |||
| 80 | static unsigned logflags = 0; /* Log flags */ | |||
| 81 | ||||
| 82 | static char *names; /* strings derived from OnLoad options */ | |||
| 83 | ||||
| 84 | static jboolean allowStartViaJcmd = JNI_FALSE0; /* if true we allow the debugging to be started via a jcmd */ | |||
| 85 | static jboolean startedViaJcmd = JNI_FALSE0; /* if false, we have not yet started debugging via a jcmd */ | |||
| 86 | ||||
| 87 | /* | |||
| 88 | * Elements of the transports bag | |||
| 89 | */ | |||
| 90 | typedef struct TransportSpec { | |||
| 91 | char *name; | |||
| 92 | char *address; | |||
| 93 | long timeout; | |||
| 94 | char *allow; | |||
| 95 | } TransportSpec; | |||
| 96 | ||||
| 97 | /* | |||
| 98 | * Forward Refs | |||
| 99 | */ | |||
| 100 | static void JNICALL cbEarlyVMInit(jvmtiEnv*, JNIEnv *, jthread); | |||
| 101 | static void JNICALL cbEarlyVMDeath(jvmtiEnv*, JNIEnv *); | |||
| 102 | static void JNICALL cbEarlyException(jvmtiEnv*, JNIEnv *, | |||
| 103 | jthread, jmethodID, jlocation, jobject, jmethodID, jlocation); | |||
| 104 | ||||
| 105 | static void initialize(JNIEnv *env, jthread thread, EventIndex triggering_ei); | |||
| 106 | static jboolean parseOptions(char *str); | |||
| 107 | ||||
| 108 | /* | |||
| 109 | * Phase 1: Initial load. | |||
| 110 | * | |||
| 111 | * OnLoad is called by the VM immediately after the back-end | |||
| 112 | * library is loaded. We can do very little in this function since | |||
| 113 | * the VM has not completed initialization. So, we parse the JDWP | |||
| 114 | * options and set up a simple initial event callbacks for JVMTI events. | |||
| 115 | * When a triggering event occurs, that callback will begin debugger initialization. | |||
| 116 | */ | |||
| 117 | ||||
| 118 | /* Get a static area to hold the Global Data */ | |||
| 119 | static BackendGlobalData * | |||
| 120 | get_gdata(void) | |||
| 121 | { | |||
| 122 | static BackendGlobalData s; | |||
| 123 | (void)memset(&s, 0, sizeof(BackendGlobalData)); | |||
| 124 | return &s; | |||
| 125 | } | |||
| 126 | ||||
| 127 | static jvmtiError | |||
| 128 | set_event_notification(jvmtiEventMode mode, EventIndex ei) | |||
| 129 | { | |||
| 130 | jvmtiError error; | |||
| 131 | error = JVMTI_FUNC_PTR(gdata->jvmti,SetEventNotificationMode)(*((*((((gdata->log_flags & (0x00000004))?(log_message_begin ("JVMTI","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,131), log_message_end ("%s()","SetEventNotificationMode")):( (void)0)),(gdata->jvmti))))->SetEventNotificationMode)) | |||
| 132 | (gdata->jvmti, mode, eventIndex2jvmti(ei), NULL((void*)0)); | |||
| 133 | if (error != JVMTI_ERROR_NONE) { | |||
| 134 | ERROR_MESSAGE(("JDWP unable to configure initial JVMTI event %s: %s(%d)",( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,135), log_message_end ("JDWP unable to configure initial JVMTI event %s: %s(%d)" , eventText(ei), jvmtiErrorText(error), error)):((void)0)), error_message ("JDWP unable to configure initial JVMTI event %s: %s(%d)", eventText (ei), jvmtiErrorText(error), error) ) | |||
| 135 | eventText(ei), jvmtiErrorText(error), error))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,135), log_message_end ("JDWP unable to configure initial JVMTI event %s: %s(%d)" , eventText(ei), jvmtiErrorText(error), error)):((void)0)), error_message ("JDWP unable to configure initial JVMTI event %s: %s(%d)", eventText (ei), jvmtiErrorText(error), error) ); | |||
| 136 | } | |||
| 137 | return error; | |||
| 138 | } | |||
| 139 | ||||
| 140 | typedef struct { | |||
| 141 | int major; | |||
| 142 | int minor; | |||
| 143 | } version_type; | |||
| 144 | ||||
| 145 | typedef struct { | |||
| 146 | version_type runtime; | |||
| 147 | version_type compiletime; | |||
| 148 | } compatible_versions_type; | |||
| 149 | ||||
| 150 | /* | |||
| 151 | * List of explicitly compatible JVMTI versions, specified as | |||
| 152 | * { runtime version, compile-time version } pairs. -1 is a wildcard. | |||
| 153 | */ | |||
| 154 | static int nof_compatible_versions = 3; | |||
| 155 | static compatible_versions_type compatible_versions_list[] = { | |||
| 156 | /* | |||
| 157 | * FIXUP: Allow version 0 to be compatible with anything | |||
| 158 | * Special check for FCS of 1.0. | |||
| 159 | */ | |||
| 160 | { { 0, -1 }, { -1, -1 } }, | |||
| 161 | { { -1, -1 }, { 0, -1 } }, | |||
| 162 | /* | |||
| 163 | * 1.2 is runtime compatible with 1.1 -- just make sure to check the | |||
| 164 | * version before using any new 1.2 features | |||
| 165 | */ | |||
| 166 | { { 1, 1 }, { 1, 2 } } | |||
| 167 | }; | |||
| 168 | ||||
| 169 | ||||
| 170 | /* Logic to determine JVMTI version compatibility */ | |||
| 171 | static jboolean | |||
| 172 | compatible_versions(jint major_runtime, jint minor_runtime, | |||
| 173 | jint major_compiletime, jint minor_compiletime) | |||
| 174 | { | |||
| 175 | /* | |||
| 176 | * First check to see if versions are explicitly compatible via the | |||
| 177 | * list specified above. | |||
| 178 | */ | |||
| 179 | int i; | |||
| 180 | for (i = 0; i < nof_compatible_versions; ++i) { | |||
| 181 | version_type runtime = compatible_versions_list[i].runtime; | |||
| 182 | version_type comptime = compatible_versions_list[i].compiletime; | |||
| 183 | ||||
| 184 | if ((major_runtime == runtime.major || runtime.major == -1) && | |||
| 185 | (minor_runtime == runtime.minor || runtime.minor == -1) && | |||
| 186 | (major_compiletime == comptime.major || comptime.major == -1) && | |||
| 187 | (minor_compiletime == comptime.minor || comptime.minor == -1)) { | |||
| 188 | return JNI_TRUE1; | |||
| 189 | } | |||
| 190 | } | |||
| 191 | ||||
| 192 | return major_runtime == major_compiletime && | |||
| 193 | minor_runtime >= minor_compiletime; | |||
| 194 | } | |||
| 195 | ||||
| 196 | /* OnLoad startup: | |||
| 197 | * Returning JNI_ERR will cause the java_g VM to core dump, be careful. | |||
| 198 | */ | |||
| 199 | JNIEXPORT__attribute__((visibility("default"))) jint JNICALL | |||
| 200 | DEF_Agent_OnLoadAgent_OnLoad(JavaVM *vm, char *options, void *reserved) | |||
| 201 | { | |||
| 202 | jvmtiError error; | |||
| 203 | jvmtiCapabilities needed_capabilities; | |||
| 204 | jvmtiCapabilities potential_capabilities; | |||
| 205 | jint jvmtiCompileTimeMajorVersion; | |||
| 206 | jint jvmtiCompileTimeMinorVersion; | |||
| 207 | jint jvmtiCompileTimeMicroVersion; | |||
| 208 | ||||
| 209 | /* See if it's already loaded */ | |||
| 210 | if ( gdata!=NULL((void*)0) && gdata->isLoaded==JNI_TRUE1 ) { | |||
| 211 | ERROR_MESSAGE(("Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options."))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,211), log_message_end ("Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options." )):((void)0)), error_message ("Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options." ) ); | |||
| 212 | return JNI_ERR(-1); | |||
| 213 | } | |||
| 214 | ||||
| 215 | /* If gdata is defined and the VM died, why are we here? */ | |||
| 216 | if ( gdata!=NULL((void*)0) && gdata->vmDead ) { | |||
| 217 | ERROR_MESSAGE(("JDWP unable to load, VM died"))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,217), log_message_end ("JDWP unable to load, VM died")):((void )0)), error_message ("JDWP unable to load, VM died") ); | |||
| 218 | return JNI_ERR(-1); | |||
| 219 | } | |||
| 220 | ||||
| 221 | /* Get global data area */ | |||
| 222 | gdata = get_gdata(); | |||
| 223 | if (gdata == NULL((void*)0)) { | |||
| 224 | ERROR_MESSAGE(("JDWP unable to allocate memory"))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,224), log_message_end ("JDWP unable to allocate memory")):(( void)0)), error_message ("JDWP unable to allocate memory") ); | |||
| 225 | return JNI_ERR(-1); | |||
| 226 | } | |||
| 227 | gdata->isLoaded = JNI_TRUE1; | |||
| 228 | ||||
| 229 | /* Start filling in gdata */ | |||
| 230 | gdata->jvm = vm; | |||
| 231 | vmInitialized = JNI_FALSE0; | |||
| 232 | gdata->vmDead = JNI_FALSE0; | |||
| 233 | ||||
| 234 | /* Get the JVMTI Env, IMPORTANT: Do this first! For jvmtiAllocate(). */ | |||
| 235 | error = JVM_FUNC_PTR(vm,GetEnv)(*((*((((gdata->log_flags & (0x00000001)) ?(log_message_begin ("JVM","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,235), log_message_end ("%s()","GetEnv")):((void)0)), (vm)))) ->GetEnv)) | |||
| 236 | (vm, (void **)&(gdata->jvmti), JVMTI_VERSION_1); | |||
| 237 | if (error != JNI_OK0) { | |||
| 238 | ERROR_MESSAGE(("JDWP unable to access JVMTI Version 1 (0x%x),"( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,241), log_message_end ("JDWP unable to access JVMTI Version 1 (0x%x)," " is your J2SE a 1.5 or newer version?" " JNIEnv's GetEnv() returned %d" , JVMTI_VERSION_1, error)):((void)0)), error_message ("JDWP unable to access JVMTI Version 1 (0x%x)," " is your J2SE a 1.5 or newer version?" " JNIEnv's GetEnv() returned %d" , JVMTI_VERSION_1, error) ) | |||
| 239 | " is your J2SE a 1.5 or newer version?"( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,241), log_message_end ("JDWP unable to access JVMTI Version 1 (0x%x)," " is your J2SE a 1.5 or newer version?" " JNIEnv's GetEnv() returned %d" , JVMTI_VERSION_1, error)):((void)0)), error_message ("JDWP unable to access JVMTI Version 1 (0x%x)," " is your J2SE a 1.5 or newer version?" " JNIEnv's GetEnv() returned %d" , JVMTI_VERSION_1, error) ) | |||
| 240 | " JNIEnv's GetEnv() returned %d",( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,241), log_message_end ("JDWP unable to access JVMTI Version 1 (0x%x)," " is your J2SE a 1.5 or newer version?" " JNIEnv's GetEnv() returned %d" , JVMTI_VERSION_1, error)):((void)0)), error_message ("JDWP unable to access JVMTI Version 1 (0x%x)," " is your J2SE a 1.5 or newer version?" " JNIEnv's GetEnv() returned %d" , JVMTI_VERSION_1, error) ) | |||
| 241 | JVMTI_VERSION_1, error))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,241), log_message_end ("JDWP unable to access JVMTI Version 1 (0x%x)," " is your J2SE a 1.5 or newer version?" " JNIEnv's GetEnv() returned %d" , JVMTI_VERSION_1, error)):((void)0)), error_message ("JDWP unable to access JVMTI Version 1 (0x%x)," " is your J2SE a 1.5 or newer version?" " JNIEnv's GetEnv() returned %d" , JVMTI_VERSION_1, error) ); | |||
| 242 | forceExit(1); /* Kill entire process, no core dump */ | |||
| 243 | } | |||
| 244 | ||||
| 245 | /* Check to make sure the version of jvmti.h we compiled with | |||
| 246 | * matches the runtime version we are using. | |||
| 247 | */ | |||
| 248 | jvmtiCompileTimeMajorVersion = ( JVMTI_VERSION & JVMTI_VERSION_MASK_MAJOR ) | |||
| 249 | >> JVMTI_VERSION_SHIFT_MAJOR; | |||
| 250 | jvmtiCompileTimeMinorVersion = ( JVMTI_VERSION & JVMTI_VERSION_MASK_MINOR ) | |||
| 251 | >> JVMTI_VERSION_SHIFT_MINOR; | |||
| 252 | jvmtiCompileTimeMicroVersion = ( JVMTI_VERSION & JVMTI_VERSION_MASK_MICRO ) | |||
| 253 | >> JVMTI_VERSION_SHIFT_MICRO; | |||
| 254 | ||||
| 255 | /* Check for compatibility */ | |||
| 256 | if ( !compatible_versions(jvmtiMajorVersion(), jvmtiMinorVersion(), | |||
| 257 | jvmtiCompileTimeMajorVersion, jvmtiCompileTimeMinorVersion) ) { | |||
| 258 | ||||
| 259 | ERROR_MESSAGE(("This jdwp native library will not work with this VM's "( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,266), log_message_end ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ):((void)0)), error_message ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ) | |||
| 260 | "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].",( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,266), log_message_end ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ):((void)0)), error_message ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ) | |||
| 261 | jvmtiMajorVersion(),( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,266), log_message_end ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ):((void)0)), error_message ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ) | |||
| 262 | jvmtiMinorVersion(),( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,266), log_message_end ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ):((void)0)), error_message ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ) | |||
| 263 | jvmtiMicroVersion(),( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,266), log_message_end ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ):((void)0)), error_message ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ) | |||
| 264 | jvmtiCompileTimeMajorVersion,( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,266), log_message_end ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ):((void)0)), error_message ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ) | |||
| 265 | jvmtiCompileTimeMinorVersion,( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,266), log_message_end ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ):((void)0)), error_message ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ) | |||
| 266 | jvmtiCompileTimeMicroVersion))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,266), log_message_end ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ):((void)0)), error_message ("This jdwp native library will not work with this VM's " "version of JVMTI (%d.%d.%d), it needs JVMTI %d.%d[.%d].", jvmtiMajorVersion (), jvmtiMinorVersion(), jvmtiMicroVersion(), jvmtiCompileTimeMajorVersion , jvmtiCompileTimeMinorVersion, jvmtiCompileTimeMicroVersion) ); | |||
| 267 | ||||
| 268 | /* Do not let VM get a fatal error, we don't want a core dump here. */ | |||
| 269 | forceExit(1); /* Kill entire process, no core dump wanted */ | |||
| 270 | } | |||
| 271 | ||||
| 272 | /* Parse input options */ | |||
| 273 | if (!parseOptions(options)) { | |||
| 274 | /* No message necessary, should have been printed out already */ | |||
| 275 | /* Do not let VM get a fatal error, we don't want a core dump here. */ | |||
| 276 | forceExit(1); /* Kill entire process, no core dump wanted */ | |||
| 277 | } | |||
| 278 | ||||
| 279 | LOG_MISC(("Onload: %s", options))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,279), log_message_end ("Onload: %s", options)):((void)0)); | |||
| 280 | ||||
| 281 | /* Get potential capabilities */ | |||
| 282 | (void)memset(&potential_capabilities,0,sizeof(potential_capabilities)); | |||
| 283 | error = JVMTI_FUNC_PTR(gdata->jvmti,GetPotentialCapabilities)(*((*((((gdata->log_flags & (0x00000004))?(log_message_begin ("JVMTI","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,283), log_message_end ("%s()","GetPotentialCapabilities")):( (void)0)),(gdata->jvmti))))->GetPotentialCapabilities)) | |||
| 284 | (gdata->jvmti, &potential_capabilities); | |||
| 285 | if (error != JVMTI_ERROR_NONE) { | |||
| 286 | ERROR_MESSAGE(("JDWP unable to get potential JVMTI capabilities: %s(%d)",( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,287), log_message_end ("JDWP unable to get potential JVMTI capabilities: %s(%d)" , jvmtiErrorText(error), error)):((void)0)), error_message ("JDWP unable to get potential JVMTI capabilities: %s(%d)" , jvmtiErrorText(error), error) ) | |||
| 287 | jvmtiErrorText(error), error))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,287), log_message_end ("JDWP unable to get potential JVMTI capabilities: %s(%d)" , jvmtiErrorText(error), error)):((void)0)), error_message ("JDWP unable to get potential JVMTI capabilities: %s(%d)" , jvmtiErrorText(error), error) ); | |||
| 288 | return JNI_ERR(-1); | |||
| 289 | } | |||
| 290 | ||||
| 291 | /* Fill in ones that we must have */ | |||
| 292 | (void)memset(&needed_capabilities,0,sizeof(needed_capabilities)); | |||
| 293 | needed_capabilities.can_access_local_variables = 1; | |||
| 294 | needed_capabilities.can_generate_single_step_events = 1; | |||
| 295 | needed_capabilities.can_generate_exception_events = 1; | |||
| 296 | needed_capabilities.can_generate_frame_pop_events = 1; | |||
| 297 | needed_capabilities.can_generate_breakpoint_events = 1; | |||
| 298 | needed_capabilities.can_suspend = 1; | |||
| 299 | needed_capabilities.can_generate_method_entry_events = 1; | |||
| 300 | needed_capabilities.can_generate_method_exit_events = 1; | |||
| 301 | needed_capabilities.can_generate_garbage_collection_events = 1; | |||
| 302 | needed_capabilities.can_maintain_original_method_order = 1; | |||
| 303 | needed_capabilities.can_generate_monitor_events = 1; | |||
| 304 | needed_capabilities.can_tag_objects = 1; | |||
| 305 | ||||
| 306 | /* And what potential ones that would be nice to have */ | |||
| 307 | needed_capabilities.can_force_early_return | |||
| 308 | = potential_capabilities.can_force_early_return; | |||
| 309 | needed_capabilities.can_generate_field_modification_events | |||
| 310 | = potential_capabilities.can_generate_field_modification_events; | |||
| 311 | needed_capabilities.can_generate_field_access_events | |||
| 312 | = potential_capabilities.can_generate_field_access_events; | |||
| 313 | needed_capabilities.can_get_bytecodes | |||
| 314 | = potential_capabilities.can_get_bytecodes; | |||
| 315 | needed_capabilities.can_get_synthetic_attribute | |||
| 316 | = potential_capabilities.can_get_synthetic_attribute; | |||
| 317 | needed_capabilities.can_get_owned_monitor_info | |||
| 318 | = potential_capabilities.can_get_owned_monitor_info; | |||
| 319 | needed_capabilities.can_get_current_contended_monitor | |||
| 320 | = potential_capabilities.can_get_current_contended_monitor; | |||
| 321 | needed_capabilities.can_get_monitor_info | |||
| 322 | = potential_capabilities.can_get_monitor_info; | |||
| 323 | needed_capabilities.can_pop_frame | |||
| 324 | = potential_capabilities.can_pop_frame; | |||
| 325 | needed_capabilities.can_redefine_classes | |||
| 326 | = potential_capabilities.can_redefine_classes; | |||
| 327 | needed_capabilities.can_redefine_any_class | |||
| 328 | = potential_capabilities.can_redefine_any_class; | |||
| 329 | needed_capabilities.can_get_owned_monitor_stack_depth_info | |||
| 330 | = potential_capabilities.can_get_owned_monitor_stack_depth_info; | |||
| 331 | needed_capabilities.can_get_constant_pool | |||
| 332 | = potential_capabilities.can_get_constant_pool; | |||
| 333 | { | |||
| 334 | needed_capabilities.can_get_source_debug_extension = 1; | |||
| 335 | needed_capabilities.can_get_source_file_name = 1; | |||
| 336 | needed_capabilities.can_get_line_numbers = 1; | |||
| 337 | needed_capabilities.can_signal_thread | |||
| 338 | = potential_capabilities.can_signal_thread; | |||
| 339 | } | |||
| 340 | ||||
| 341 | /* Add the capabilities */ | |||
| 342 | error = JVMTI_FUNC_PTR(gdata->jvmti,AddCapabilities)(*((*((((gdata->log_flags & (0x00000004))?(log_message_begin ("JVMTI","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,342), log_message_end ("%s()","AddCapabilities")):((void)0)) ,(gdata->jvmti))))->AddCapabilities)) | |||
| 343 | (gdata->jvmti, &needed_capabilities); | |||
| 344 | if (error != JVMTI_ERROR_NONE) { | |||
| 345 | ERROR_MESSAGE(("JDWP unable to get necessary JVMTI capabilities."))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,345), log_message_end ("JDWP unable to get necessary JVMTI capabilities." )):((void)0)), error_message ("JDWP unable to get necessary JVMTI capabilities." ) ); | |||
| 346 | forceExit(1); /* Kill entire process, no core dump wanted */ | |||
| 347 | } | |||
| 348 | ||||
| 349 | /* Initialize event number mapping tables */ | |||
| 350 | eventIndexInit(); | |||
| 351 | ||||
| 352 | /* Set the initial JVMTI event notifications */ | |||
| 353 | error = set_event_notification(JVMTI_ENABLE, EI_VM_DEATH); | |||
| 354 | if (error != JVMTI_ERROR_NONE) { | |||
| 355 | return JNI_ERR(-1); | |||
| 356 | } | |||
| 357 | error = set_event_notification(JVMTI_ENABLE, EI_VM_INIT); | |||
| 358 | if (error != JVMTI_ERROR_NONE) { | |||
| 359 | return JNI_ERR(-1); | |||
| 360 | } | |||
| 361 | if (initOnUncaught || (initOnException != NULL((void*)0))) { | |||
| 362 | error = set_event_notification(JVMTI_ENABLE, EI_EXCEPTION); | |||
| 363 | if (error != JVMTI_ERROR_NONE) { | |||
| 364 | return JNI_ERR(-1); | |||
| 365 | } | |||
| 366 | } | |||
| 367 | ||||
| 368 | /* Set callbacks just for 3 functions */ | |||
| 369 | (void)memset(&(gdata->callbacks),0,sizeof(gdata->callbacks)); | |||
| 370 | gdata->callbacks.VMInit = &cbEarlyVMInit; | |||
| 371 | gdata->callbacks.VMDeath = &cbEarlyVMDeath; | |||
| 372 | gdata->callbacks.Exception = &cbEarlyException; | |||
| 373 | error = JVMTI_FUNC_PTR(gdata->jvmti,SetEventCallbacks)(*((*((((gdata->log_flags & (0x00000004))?(log_message_begin ("JVMTI","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,373), log_message_end ("%s()","SetEventCallbacks")):((void)0 )),(gdata->jvmti))))->SetEventCallbacks)) | |||
| 374 | (gdata->jvmti, &(gdata->callbacks), sizeof(gdata->callbacks)); | |||
| 375 | if (error != JVMTI_ERROR_NONE) { | |||
| 376 | ERROR_MESSAGE(("JDWP unable to set JVMTI event callbacks: %s(%d)",( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,377), log_message_end ("JDWP unable to set JVMTI event callbacks: %s(%d)" , jvmtiErrorText(error), error)):((void)0)), error_message ("JDWP unable to set JVMTI event callbacks: %s(%d)" , jvmtiErrorText(error), error) ) | |||
| 377 | jvmtiErrorText(error), error))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,377), log_message_end ("JDWP unable to set JVMTI event callbacks: %s(%d)" , jvmtiErrorText(error), error)):((void)0)), error_message ("JDWP unable to set JVMTI event callbacks: %s(%d)" , jvmtiErrorText(error), error) ); | |||
| 378 | return JNI_ERR(-1); | |||
| 379 | } | |||
| 380 | ||||
| 381 | LOG_MISC(("OnLoad: DONE"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,381), log_message_end ("OnLoad: DONE")):((void)0)); | |||
| 382 | return JNI_OK0; | |||
| 383 | } | |||
| 384 | ||||
| 385 | JNIEXPORT__attribute__((visibility("default"))) void JNICALL | |||
| 386 | DEF_Agent_OnUnloadAgent_OnUnload(JavaVM *vm) | |||
| 387 | { | |||
| 388 | ||||
| 389 | gdata->isLoaded = JNI_FALSE0; | |||
| 390 | ||||
| 391 | /* Cleanup, but make sure VM is alive before using JNI, and | |||
| 392 | * make sure JVMTI environment is ok before deallocating | |||
| 393 | * memory allocated through JVMTI, which all of it is. | |||
| 394 | */ | |||
| 395 | ||||
| 396 | /* | |||
| 397 | * Close transport before exit | |||
| 398 | */ | |||
| 399 | if (transport_is_open()) { | |||
| 400 | transport_close(); | |||
| 401 | } | |||
| 402 | } | |||
| 403 | ||||
| 404 | /* | |||
| 405 | * Phase 2: Initial events. Phase 2 consists of waiting for the | |||
| 406 | * event that triggers full initialization. Under normal circumstances | |||
| 407 | * (initOnStartup == TRUE) this is the JVMTI_EVENT_VM_INIT event. | |||
| 408 | * Otherwise, we delay initialization until the app throws a | |||
| 409 | * particular exception. The triggering event invokes | |||
| 410 | * the bulk of the initialization, including creation of threads and | |||
| 411 | * monitors, transport setup, and installation of a new event callback which | |||
| 412 | * handles the complete set of events. | |||
| 413 | * | |||
| 414 | * Since the triggering event comes in on an application thread, some of the | |||
| 415 | * initialization is difficult to do here. Specifically, this thread along | |||
| 416 | * with all other app threads may need to be suspended until a debugger | |||
| 417 | * connects. These kinds of tasks are left to the third phase which is | |||
| 418 | * invoked by one of the spawned debugger threads, the event handler. | |||
| 419 | */ | |||
| 420 | ||||
| 421 | /* | |||
| 422 | * Wait for a triggering event; then kick off debugger | |||
| 423 | * initialization. A different event callback will be installed by | |||
| 424 | * debugger initialization, and this function will not be called | |||
| 425 | * again. | |||
| 426 | */ | |||
| 427 | ||||
| 428 | /* | |||
| 429 | * TO DO: Decide whether we need to protect this code with | |||
| 430 | * a lock. It might be too early to create a monitor safely (?). | |||
| 431 | */ | |||
| 432 | ||||
| 433 | static void JNICALL | |||
| 434 | cbEarlyVMInit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) | |||
| 435 | { | |||
| 436 | LOG_CB(("cbEarlyVMInit"))((gdata->log_flags & (0x00000040))?(log_message_begin( "CB","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,436), log_message_end ("cbEarlyVMInit")):((void)0)); | |||
| 437 | if ( gdata->vmDead ) { | |||
| 438 | EXIT_ERROR(AGENT_ERROR_INTERNAL,"VM dead at VM_INIT time"){ print_message(stderr, "JDWP exit error ", "\n", "%s(%d): %s [%s:%d]" , jvmtiErrorText((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX+64 +1))), ((jvmtiError)(JVMTI_ERROR_MAX+64+1)), ("VM dead at VM_INIT time" ==((void*)0)?"":"VM dead at VM_INIT time"), "/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" , 438); debugInit_exit((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX +64+1)), "VM dead at VM_INIT time"); }; | |||
| 439 | } | |||
| 440 | if (initOnStartup) | |||
| 441 | initialize(env, thread, EI_VM_INIT); | |||
| 442 | vmInitialized = JNI_TRUE1; | |||
| 443 | LOG_MISC(("END cbEarlyVMInit"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,443), log_message_end ("END cbEarlyVMInit")):((void)0)); | |||
| 444 | } | |||
| 445 | ||||
| 446 | static void | |||
| 447 | disposeEnvironment(jvmtiEnv *jvmti_env) | |||
| 448 | { | |||
| 449 | jvmtiError error; | |||
| 450 | ||||
| 451 | error = JVMTI_FUNC_PTR(jvmti_env,DisposeEnvironment)(*((*((((gdata->log_flags & (0x00000004))?(log_message_begin ("JVMTI","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,451), log_message_end ("%s()","DisposeEnvironment")):((void) 0)),(jvmti_env))))->DisposeEnvironment))(jvmti_env); | |||
| 452 | if ( error == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) | |||
| 453 | error = JVMTI_ERROR_NONE; /* Hack! FIXUP when JVMTI has disposeEnv */ | |||
| 454 | /* What should error return say? */ | |||
| 455 | if (error != JVMTI_ERROR_NONE) { | |||
| 456 | ERROR_MESSAGE(("JDWP unable to dispose of JVMTI environment: %s(%d)",( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,457), log_message_end ("JDWP unable to dispose of JVMTI environment: %s(%d)" , jvmtiErrorText(error), error)):((void)0)), error_message ("JDWP unable to dispose of JVMTI environment: %s(%d)" , jvmtiErrorText(error), error) ) | |||
| 457 | jvmtiErrorText(error), error))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,457), log_message_end ("JDWP unable to dispose of JVMTI environment: %s(%d)" , jvmtiErrorText(error), error)):((void)0)), error_message ("JDWP unable to dispose of JVMTI environment: %s(%d)" , jvmtiErrorText(error), error) ); | |||
| 458 | } | |||
| 459 | gdata->jvmti = NULL((void*)0); | |||
| 460 | } | |||
| 461 | ||||
| 462 | static void JNICALL | |||
| 463 | cbEarlyVMDeath(jvmtiEnv *jvmti_env, JNIEnv *env) | |||
| 464 | { | |||
| 465 | LOG_CB(("cbEarlyVMDeath"))((gdata->log_flags & (0x00000040))?(log_message_begin( "CB","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,465), log_message_end ("cbEarlyVMDeath")):((void)0)); | |||
| 466 | if ( gdata->vmDead ) { | |||
| 467 | EXIT_ERROR(AGENT_ERROR_INTERNAL,"VM died more than once"){ print_message(stderr, "JDWP exit error ", "\n", "%s(%d): %s [%s:%d]" , jvmtiErrorText((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX+64 +1))), ((jvmtiError)(JVMTI_ERROR_MAX+64+1)), ("VM died more than once" ==((void*)0)?"":"VM died more than once"), "/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" , 467); debugInit_exit((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX +64+1)), "VM died more than once"); }; | |||
| 468 | } | |||
| 469 | disposeEnvironment(jvmti_env); | |||
| 470 | gdata->jvmti = NULL((void*)0); | |||
| 471 | gdata->jvm = NULL((void*)0); | |||
| 472 | gdata->vmDead = JNI_TRUE1; | |||
| 473 | LOG_MISC(("END cbEarlyVMDeath"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,473), log_message_end ("END cbEarlyVMDeath")):((void)0)); | |||
| 474 | } | |||
| 475 | ||||
| 476 | static void JNICALL | |||
| 477 | cbEarlyException(jvmtiEnv *jvmti_env, JNIEnv *env, | |||
| 478 | jthread thread, jmethodID method, jlocation location, | |||
| 479 | jobject exception, | |||
| 480 | jmethodID catch_method, jlocation catch_location) | |||
| 481 | { | |||
| 482 | jvmtiError error; | |||
| 483 | jthrowable currentException; | |||
| 484 | ||||
| 485 | LOG_CB(("cbEarlyException: thread=%p", thread))((gdata->log_flags & (0x00000040))?(log_message_begin( "CB","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,485), log_message_end ("cbEarlyException: thread=%p", thread )):((void)0)); | |||
| 486 | ||||
| 487 | if ( gdata->vmDead ) { | |||
| 488 | EXIT_ERROR(AGENT_ERROR_INTERNAL,"VM dead at initial Exception event"){ print_message(stderr, "JDWP exit error ", "\n", "%s(%d): %s [%s:%d]" , jvmtiErrorText((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX+64 +1))), ((jvmtiError)(JVMTI_ERROR_MAX+64+1)), ("VM dead at initial Exception event" ==((void*)0)?"":"VM dead at initial Exception event"), "/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" , 488); debugInit_exit((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX +64+1)), "VM dead at initial Exception event"); }; | |||
| 489 | } | |||
| 490 | if (!vmInitialized) { | |||
| 491 | LOG_MISC(("VM is not initialized yet"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,491), log_message_end ("VM is not initialized yet")):((void) 0)); | |||
| 492 | return; | |||
| 493 | } | |||
| 494 | ||||
| 495 | /* | |||
| 496 | * We want to preserve any current exception that might get wiped | |||
| 497 | * out during event handling (e.g. JNI calls). We have to rely on | |||
| 498 | * space for the local reference on the current frame because | |||
| 499 | * doing a PushLocalFrame here might itself generate an exception. | |||
| 500 | */ | |||
| 501 | ||||
| 502 | currentException = JNI_FUNC_PTR(env,ExceptionOccurred)(*((*((((gdata->log_flags & (0x00000002)) ?(log_message_begin ("JNI","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,502), log_message_end ("%s()","ExceptionOccurred")):((void)0 )), (env))))->ExceptionOccurred))(env); | |||
| 503 | JNI_FUNC_PTR(env,ExceptionClear)(*((*((((gdata->log_flags & (0x00000002)) ?(log_message_begin ("JNI","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,503), log_message_end ("%s()","ExceptionClear")):((void)0)), (env))))->ExceptionClear))(env); | |||
| 504 | ||||
| 505 | if (initOnUncaught && catch_method == NULL((void*)0)) { | |||
| 506 | ||||
| 507 | LOG_MISC(("Initializing on uncaught exception"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,507), log_message_end ("Initializing on uncaught exception") ):((void)0)); | |||
| 508 | initialize(env, thread, EI_EXCEPTION); | |||
| 509 | ||||
| 510 | } else if (initOnException != NULL((void*)0)) { | |||
| 511 | ||||
| 512 | jclass clazz; | |||
| 513 | ||||
| 514 | /* Get class of exception thrown */ | |||
| 515 | clazz = JNI_FUNC_PTR(env,GetObjectClass)(*((*((((gdata->log_flags & (0x00000002)) ?(log_message_begin ("JNI","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,515), log_message_end ("%s()","GetObjectClass")):((void)0)), (env))))->GetObjectClass))(env, exception); | |||
| 516 | if ( clazz != NULL((void*)0) ) { | |||
| 517 | char *signature = NULL((void*)0); | |||
| 518 | /* initing on throw, check */ | |||
| 519 | error = classSignature(clazz, &signature, NULL((void*)0)); | |||
| 520 | LOG_MISC(("Checking specific exception: looking for %s, got %s",((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,521), log_message_end ("Checking specific exception: looking for %s, got %s" , initOnException, signature)):((void)0)) | |||
| 521 | initOnException, signature))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,521), log_message_end ("Checking specific exception: looking for %s, got %s" , initOnException, signature)):((void)0)); | |||
| 522 | if ( (error==JVMTI_ERROR_NONE) && | |||
| 523 | (strcmp(signature, initOnException) == 0)) { | |||
| 524 | LOG_MISC(("Initializing on specific exception"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,524), log_message_end ("Initializing on specific exception") ):((void)0)); | |||
| 525 | initialize(env, thread, EI_EXCEPTION); | |||
| 526 | } else { | |||
| 527 | error = AGENT_ERROR_INTERNAL((jvmtiError)(JVMTI_ERROR_MAX+64+1)); /* Just to cause restore */ | |||
| 528 | } | |||
| 529 | if ( signature != NULL((void*)0) ) { | |||
| 530 | jvmtiDeallocate(signature); | |||
| 531 | } | |||
| 532 | } else { | |||
| 533 | error = AGENT_ERROR_INTERNAL((jvmtiError)(JVMTI_ERROR_MAX+64+1)); /* Just to cause restore */ | |||
| 534 | } | |||
| 535 | ||||
| 536 | /* If initialize didn't happen, we need to restore things */ | |||
| 537 | if ( error != JVMTI_ERROR_NONE ) { | |||
| 538 | /* | |||
| 539 | * Restore exception state from before callback call | |||
| 540 | */ | |||
| 541 | LOG_MISC(("No initialization, didn't find right exception"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,541), log_message_end ("No initialization, didn't find right exception" )):((void)0)); | |||
| 542 | if (currentException != NULL((void*)0)) { | |||
| 543 | JNI_FUNC_PTR(env,Throw)(*((*((((gdata->log_flags & (0x00000002)) ?(log_message_begin ("JNI","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,543), log_message_end ("%s()","Throw")):((void)0)), (env)))) ->Throw))(env, currentException); | |||
| 544 | } else { | |||
| 545 | JNI_FUNC_PTR(env,ExceptionClear)(*((*((((gdata->log_flags & (0x00000002)) ?(log_message_begin ("JNI","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,545), log_message_end ("%s()","ExceptionClear")):((void)0)), (env))))->ExceptionClear))(env); | |||
| 546 | } | |||
| 547 | } | |||
| 548 | ||||
| 549 | } | |||
| 550 | ||||
| 551 | LOG_MISC(("END cbEarlyException"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,551), log_message_end ("END cbEarlyException")):((void)0)); | |||
| 552 | ||||
| 553 | } | |||
| 554 | ||||
| 555 | typedef struct EnumerateArg { | |||
| 556 | jboolean isServer; | |||
| 557 | jdwpError error; | |||
| 558 | jint startCount; | |||
| 559 | } EnumerateArg; | |||
| 560 | ||||
| 561 | static jboolean | |||
| 562 | startTransport(void *item, void *arg) | |||
| 563 | { | |||
| 564 | TransportSpec *transport = item; | |||
| 565 | EnumerateArg *enumArg = arg; | |||
| 566 | jdwpError serror; | |||
| 567 | ||||
| 568 | LOG_MISC(("Begin startTransport"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,568), log_message_end ("Begin startTransport")):((void)0)); | |||
| 569 | serror = transport_startTransport(enumArg->isServer, transport->name, | |||
| 570 | transport->address, transport->timeout, | |||
| 571 | transport->allow); | |||
| 572 | if (serror != JDWP_ERROR(NONE)0) { | |||
| 573 | ERROR_MESSAGE(("JDWP Transport %s failed to initialize, %s(%d)",( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,574), log_message_end ("JDWP Transport %s failed to initialize, %s(%d)" , transport->name, jdwpErrorText(serror), serror)):((void) 0)), error_message ("JDWP Transport %s failed to initialize, %s(%d)" , transport->name, jdwpErrorText(serror), serror) ) | |||
| 574 | transport->name, jdwpErrorText(serror), serror))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,574), log_message_end ("JDWP Transport %s failed to initialize, %s(%d)" , transport->name, jdwpErrorText(serror), serror)):((void) 0)), error_message ("JDWP Transport %s failed to initialize, %s(%d)" , transport->name, jdwpErrorText(serror), serror) ); | |||
| 575 | enumArg->error = serror; | |||
| 576 | } else { | |||
| 577 | /* (Don't overwrite any previous error) */ | |||
| 578 | ||||
| 579 | enumArg->startCount++; | |||
| 580 | } | |||
| 581 | ||||
| 582 | LOG_MISC(("End startTransport"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,582), log_message_end ("End startTransport")):((void)0)); | |||
| 583 | ||||
| 584 | return JNI_TRUE1; /* Always continue, even if there was an error */ | |||
| 585 | } | |||
| 586 | ||||
| 587 | static void | |||
| 588 | signalInitComplete(void) | |||
| 589 | { | |||
| 590 | /* | |||
| 591 | * Initialization is complete | |||
| 592 | */ | |||
| 593 | LOG_MISC(("signal initialization complete"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,593), log_message_end ("signal initialization complete")):(( void)0)); | |||
| 594 | debugMonitorEnter(initMonitor); | |||
| 595 | initComplete = JNI_TRUE1; | |||
| 596 | debugMonitorNotifyAll(initMonitor); | |||
| 597 | debugMonitorExit(initMonitor); | |||
| 598 | } | |||
| 599 | ||||
| 600 | /* | |||
| 601 | * Determine if initialization is complete. | |||
| 602 | */ | |||
| 603 | jboolean | |||
| 604 | debugInit_isInitComplete(void) | |||
| 605 | { | |||
| 606 | return initComplete; | |||
| 607 | } | |||
| 608 | ||||
| 609 | /* | |||
| 610 | * Wait for all initialization to complete. | |||
| 611 | */ | |||
| 612 | void | |||
| 613 | debugInit_waitInitComplete(void) | |||
| 614 | { | |||
| 615 | debugMonitorEnter(initMonitor); | |||
| 616 | while (!initComplete) { | |||
| 617 | debugMonitorWait(initMonitor); | |||
| 618 | } | |||
| 619 | debugMonitorExit(initMonitor); | |||
| 620 | } | |||
| 621 | ||||
| 622 | /* All process exit() calls come from here */ | |||
| 623 | void | |||
| 624 | forceExit(int exit_code) | |||
| 625 | { | |||
| 626 | /* make sure the transport is closed down before we exit() */ | |||
| 627 | transport_close(); | |||
| 628 | exit(exit_code); | |||
| 629 | } | |||
| 630 | ||||
| 631 | /* All JVM fatal error exits lead here (e.g. we need to kill the VM). */ | |||
| 632 | static void | |||
| 633 | jniFatalError(JNIEnv *env, const char *msg, jvmtiError error, int exit_code) | |||
| 634 | { | |||
| 635 | JavaVM *vm; | |||
| 636 | char buf[512]; | |||
| 637 | ||||
| 638 | gdata->vmDead = JNI_TRUE1; | |||
| ||||
| 639 | if ( msg==NULL((void*)0) ) | |||
| 640 | msg = "UNKNOWN REASON"; | |||
| 641 | vm = gdata->jvm; | |||
| 642 | if ( env==NULL((void*)0) && vm!=NULL((void*)0) ) { | |||
| 643 | jint rc = (*((*vm)->GetEnv))(vm, (void **)&env, JNI_VERSION_1_20x00010002); | |||
| 644 | if (rc != JNI_OK0 ) { | |||
| 645 | env = NULL((void*)0); | |||
| 646 | } | |||
| 647 | } | |||
| 648 | if ( error != JVMTI_ERROR_NONE ) { | |||
| 649 | (void)snprintf(buf, sizeof(buf), "JDWP %s, jvmtiError=%s(%d)",__builtin___snprintf_chk (buf, sizeof(buf), 2 - 1, __builtin_object_size (buf, 2 > 1), "JDWP %s, jvmtiError=%s(%d)", msg, jvmtiErrorText (error), error) | |||
| 650 | msg, jvmtiErrorText(error), error)__builtin___snprintf_chk (buf, sizeof(buf), 2 - 1, __builtin_object_size (buf, 2 > 1), "JDWP %s, jvmtiError=%s(%d)", msg, jvmtiErrorText (error), error); | |||
| 651 | } else { | |||
| 652 | (void)snprintf(buf, sizeof(buf), "JDWP %s", msg)__builtin___snprintf_chk (buf, sizeof(buf), 2 - 1, __builtin_object_size (buf, 2 > 1), "JDWP %s", msg); | |||
| 653 | } | |||
| 654 | if (env != NULL((void*)0)) { | |||
| 655 | (*((*env)->FatalError))(env, buf); | |||
| 656 | } else { | |||
| 657 | /* Should rarely ever reach here, means VM is really dead */ | |||
| 658 | print_message(stderrstderr, "ERROR: JDWP: ", "\n", | |||
| 659 | "Can't call JNI FatalError(NULL, \"%s\")", buf); | |||
| 660 | } | |||
| 661 | forceExit(exit_code); | |||
| 662 | } | |||
| 663 | ||||
| 664 | /* | |||
| 665 | * Initialize debugger back end modules | |||
| 666 | */ | |||
| 667 | static void | |||
| 668 | initialize(JNIEnv *env, jthread thread, EventIndex triggering_ei) | |||
| 669 | { | |||
| 670 | jvmtiError error; | |||
| 671 | EnumerateArg arg; | |||
| 672 | jbyte suspendPolicy; | |||
| 673 | ||||
| 674 | LOG_MISC(("Begin initialize()"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,674), log_message_end ("Begin initialize()")):((void)0)); | |||
| 675 | currentSessionID = 0; | |||
| 676 | initComplete = JNI_FALSE0; | |||
| 677 | ||||
| 678 | if ( gdata->vmDead ) { | |||
| 679 | EXIT_ERROR(AGENT_ERROR_INTERNAL,"VM dead at initialize() time"){ print_message(stderr, "JDWP exit error ", "\n", "%s(%d): %s [%s:%d]" , jvmtiErrorText((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX+64 +1))), ((jvmtiError)(JVMTI_ERROR_MAX+64+1)), ("VM dead at initialize() time" ==((void*)0)?"":"VM dead at initialize() time"), "/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" , 679); debugInit_exit((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX +64+1)), "VM dead at initialize() time"); }; | |||
| 680 | } | |||
| 681 | ||||
| 682 | /* Turn off the initial JVMTI event notifications */ | |||
| 683 | error = set_event_notification(JVMTI_DISABLE, EI_EXCEPTION); | |||
| 684 | if (error != JVMTI_ERROR_NONE) { | |||
| 685 | EXIT_ERROR(error, "unable to disable JVMTI event notification"){ print_message(stderr, "JDWP exit error ", "\n", "%s(%d): %s [%s:%d]" , jvmtiErrorText((jvmtiError)error), error, ("unable to disable JVMTI event notification" ==((void*)0)?"":"unable to disable JVMTI event notification") , "/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" , 685); debugInit_exit((jvmtiError)error, "unable to disable JVMTI event notification" ); }; | |||
| 686 | } | |||
| 687 | error = set_event_notification(JVMTI_DISABLE, EI_VM_INIT); | |||
| 688 | if (error != JVMTI_ERROR_NONE) { | |||
| 689 | EXIT_ERROR(error, "unable to disable JVMTI event notification"){ print_message(stderr, "JDWP exit error ", "\n", "%s(%d): %s [%s:%d]" , jvmtiErrorText((jvmtiError)error), error, ("unable to disable JVMTI event notification" ==((void*)0)?"":"unable to disable JVMTI event notification") , "/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" , 689); debugInit_exit((jvmtiError)error, "unable to disable JVMTI event notification" ); }; | |||
| 690 | } | |||
| 691 | error = set_event_notification(JVMTI_DISABLE, EI_VM_DEATH); | |||
| 692 | if (error != JVMTI_ERROR_NONE) { | |||
| 693 | EXIT_ERROR(error, "unable to disable JVMTI event notification"){ print_message(stderr, "JDWP exit error ", "\n", "%s(%d): %s [%s:%d]" , jvmtiErrorText((jvmtiError)error), error, ("unable to disable JVMTI event notification" ==((void*)0)?"":"unable to disable JVMTI event notification") , "/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" , 693); debugInit_exit((jvmtiError)error, "unable to disable JVMTI event notification" ); }; | |||
| 694 | } | |||
| 695 | ||||
| 696 | /* Remove initial event callbacks */ | |||
| 697 | (void)memset(&(gdata->callbacks),0,sizeof(gdata->callbacks)); | |||
| 698 | error = JVMTI_FUNC_PTR(gdata->jvmti,SetEventCallbacks)(*((*((((gdata->log_flags & (0x00000004))?(log_message_begin ("JVMTI","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,698), log_message_end ("%s()","SetEventCallbacks")):((void)0 )),(gdata->jvmti))))->SetEventCallbacks)) | |||
| 699 | (gdata->jvmti, &(gdata->callbacks), sizeof(gdata->callbacks)); | |||
| 700 | if (error != JVMTI_ERROR_NONE) { | |||
| 701 | EXIT_ERROR(error, "unable to clear JVMTI callbacks"){ print_message(stderr, "JDWP exit error ", "\n", "%s(%d): %s [%s:%d]" , jvmtiErrorText((jvmtiError)error), error, ("unable to clear JVMTI callbacks" ==((void*)0)?"":"unable to clear JVMTI callbacks"), "/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" , 701); debugInit_exit((jvmtiError)error, "unable to clear JVMTI callbacks" ); }; | |||
| 702 | } | |||
| 703 | ||||
| 704 | commonRef_initialize(); | |||
| 705 | util_initialize(env); | |||
| 706 | threadControl_initialize(); | |||
| 707 | stepControl_initialize(); | |||
| 708 | invoker_initialize(); | |||
| 709 | debugDispatch_initialize(); | |||
| 710 | classTrack_initialize(env); | |||
| 711 | debugLoop_initialize(); | |||
| 712 | ||||
| 713 | initMonitor = debugMonitorCreate("JDWP Initialization Monitor"); | |||
| 714 | ||||
| 715 | ||||
| 716 | /* | |||
| 717 | * Initialize transports | |||
| 718 | */ | |||
| 719 | arg.isServer = isServer; | |||
| 720 | arg.error = JDWP_ERROR(NONE)0; | |||
| 721 | arg.startCount = 0; | |||
| 722 | ||||
| 723 | transport_initialize(); | |||
| 724 | (void)bagEnumerateOver(transports, startTransport, &arg); | |||
| 725 | ||||
| 726 | /* | |||
| 727 | * Exit with an error only if | |||
| 728 | * 1) none of the transports was successfully started, and | |||
| 729 | * 2) the application has not yet started running | |||
| 730 | */ | |||
| 731 | if ((arg.error != JDWP_ERROR(NONE)0) && | |||
| 732 | (arg.startCount == 0) && | |||
| 733 | initOnStartup) { | |||
| 734 | EXIT_ERROR(map2jvmtiError(arg.error), "No transports initialized"){ print_message(stderr, "JDWP exit error ", "\n", "%s(%d): %s [%s:%d]" , jvmtiErrorText((jvmtiError)map2jvmtiError(arg.error)), map2jvmtiError (arg.error), ("No transports initialized"==((void*)0)?"":"No transports initialized" ), "/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" , 734); debugInit_exit((jvmtiError)map2jvmtiError(arg.error), "No transports initialized"); }; | |||
| 735 | } | |||
| 736 | ||||
| 737 | eventHandler_initialize(currentSessionID); | |||
| 738 | ||||
| 739 | signalInitComplete(); | |||
| 740 | ||||
| 741 | transport_waitForConnection(); | |||
| 742 | ||||
| 743 | suspendPolicy = suspendOnInit ? JDWP_SUSPEND_POLICY(ALL)2 | |||
| 744 | : JDWP_SUSPEND_POLICY(NONE)0; | |||
| 745 | if (triggering_ei == EI_VM_INIT) { | |||
| 746 | LOG_MISC(("triggering_ei == EI_VM_INIT"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,746), log_message_end ("triggering_ei == EI_VM_INIT")):((void )0)); | |||
| 747 | eventHelper_reportVMInit(env, currentSessionID, thread, suspendPolicy); | |||
| 748 | } else { | |||
| 749 | /* | |||
| 750 | * TO DO: Kludgy way of getting the triggering event to the | |||
| 751 | * just-attached debugger. It would be nice to make this a little | |||
| 752 | * cleaner. There is also a race condition where other events | |||
| 753 | * can get in the queue (from other not-yet-suspended threads) | |||
| 754 | * before this one does. (Also need to handle allocation error below?) | |||
| 755 | */ | |||
| 756 | EventInfo info; | |||
| 757 | struct bag *initEventBag; | |||
| 758 | LOG_MISC(("triggering_ei != EI_VM_INIT"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,758), log_message_end ("triggering_ei != EI_VM_INIT")):((void )0)); | |||
| 759 | initEventBag = eventHelper_createEventBag(); | |||
| 760 | (void)memset(&info,0,sizeof(info)); | |||
| 761 | info.ei = triggering_ei; | |||
| 762 | eventHelper_recordEvent(&info, 0, suspendPolicy, initEventBag); | |||
| 763 | (void)eventHelper_reportEvents(currentSessionID, initEventBag); | |||
| 764 | bagDestroyBag(initEventBag); | |||
| 765 | } | |||
| 766 | ||||
| 767 | if ( gdata->vmDead ) { | |||
| 768 | EXIT_ERROR(AGENT_ERROR_INTERNAL,"VM dead before initialize() completes"){ print_message(stderr, "JDWP exit error ", "\n", "%s(%d): %s [%s:%d]" , jvmtiErrorText((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX+64 +1))), ((jvmtiError)(JVMTI_ERROR_MAX+64+1)), ("VM dead before initialize() completes" ==((void*)0)?"":"VM dead before initialize() completes"), "/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" , 768); debugInit_exit((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX +64+1)), "VM dead before initialize() completes"); }; | |||
| 769 | } | |||
| 770 | LOG_MISC(("End initialize()"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,770), log_message_end ("End initialize()")):((void)0)); | |||
| 771 | } | |||
| 772 | ||||
| 773 | /* | |||
| 774 | * Restore all static data to the initialized state so that another | |||
| 775 | * debugger can connect properly later. | |||
| 776 | */ | |||
| 777 | void | |||
| 778 | debugInit_reset(JNIEnv *env) | |||
| 779 | { | |||
| 780 | EnumerateArg arg; | |||
| 781 | ||||
| 782 | LOG_MISC(("debugInit_reset() beginning"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,782), log_message_end ("debugInit_reset() beginning")):((void )0)); | |||
| 783 | ||||
| 784 | currentSessionID++; | |||
| 785 | initComplete = JNI_FALSE0; | |||
| 786 | ||||
| 787 | eventHandler_reset(currentSessionID); | |||
| 788 | transport_reset(); | |||
| 789 | debugDispatch_reset(); | |||
| 790 | invoker_reset(); | |||
| 791 | stepControl_reset(); | |||
| 792 | threadControl_reset(); | |||
| 793 | util_reset(); | |||
| 794 | commonRef_reset(env); | |||
| 795 | classTrack_reset(); | |||
| 796 | ||||
| 797 | /* | |||
| 798 | * If this is a server, we are now ready to accept another connection. | |||
| 799 | * If it's a client, then we've cleaned up some (more should be added | |||
| 800 | * later) and we're done. | |||
| 801 | */ | |||
| 802 | if (isServer) { | |||
| 803 | arg.isServer = JNI_TRUE1; | |||
| 804 | arg.error = JDWP_ERROR(NONE)0; | |||
| 805 | arg.startCount = 0; | |||
| 806 | (void)bagEnumerateOver(transports, startTransport, &arg); | |||
| 807 | ||||
| 808 | signalInitComplete(); | |||
| 809 | ||||
| 810 | transport_waitForConnection(); | |||
| 811 | } else { | |||
| 812 | signalInitComplete(); /* Why? */ | |||
| 813 | } | |||
| 814 | ||||
| 815 | LOG_MISC(("debugInit_reset() completed."))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,815), log_message_end ("debugInit_reset() completed.")):((void )0)); | |||
| 816 | } | |||
| 817 | ||||
| 818 | ||||
| 819 | char * | |||
| 820 | debugInit_launchOnInit(void) | |||
| 821 | { | |||
| 822 | return launchOnInit; | |||
| 823 | } | |||
| 824 | ||||
| 825 | jboolean | |||
| 826 | debugInit_suspendOnInit(void) | |||
| 827 | { | |||
| 828 | return suspendOnInit; | |||
| 829 | } | |||
| 830 | ||||
| 831 | /* | |||
| 832 | * code below is shamelessly swiped from hprof. | |||
| 833 | */ | |||
| 834 | ||||
| 835 | static int | |||
| 836 | get_tok(char **src, char *buf, int buflen, char sep) | |||
| 837 | { | |||
| 838 | int i; | |||
| 839 | char *p = *src; | |||
| 840 | for (i = 0; i < buflen; i++) { | |||
| 841 | if (p[i] == 0 || p[i] == sep) { | |||
| 842 | buf[i] = 0; | |||
| 843 | if (p[i] == sep) { | |||
| 844 | i++; | |||
| 845 | } | |||
| 846 | *src += i; | |||
| 847 | return i; | |||
| 848 | } | |||
| 849 | buf[i] = p[i]; | |||
| 850 | } | |||
| 851 | /* overflow */ | |||
| 852 | return 0; | |||
| 853 | } | |||
| 854 | ||||
| 855 | static void | |||
| 856 | printUsage(void) | |||
| 857 | { | |||
| 858 | TTY_MESSAGE((( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 859 | " Java Debugger JDWP Agent Library\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 860 | " --------------------------------\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 861 | "\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 862 | " (See the \"VM Invocation Options\" section of the JPDA\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 863 | " \"Connection and Invocation Details\" document for more information.)\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 864 | "\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 865 | "jdwp usage: java " AGENTLIB "=[help]|[<option>=<value>, ...]\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 866 | "\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 867 | "Option Name and Value Description Default\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 868 | "--------------------- ----------- -------\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 869 | "suspend=y|n wait on startup? y\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 870 | "transport=<name> transport spec none\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 871 | "address=<listen/attach address> transport spec \"\"\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 872 | "server=y|n listen for debugger? n\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 873 | "launch=<command line> run debugger on event none\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 874 | "onthrow=<exception name> debug on throw none\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 875 | "onuncaught=y|n debug on any uncaught? n\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 876 | "timeout=<timeout value> for listen/attach in milliseconds n\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 877 | "mutf8=y|n output modified utf-8 n\n"( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ) | |||
| 878 | "quiet=y|n control over terminal messages n\n"))( tty_message ( " Java Debugger JDWP Agent Library\n" " --------------------------------\n" "\n" " (See the \"VM Invocation Options\" section of the JPDA\n" " \"Connection and Invocation Details\" document for more information.)\n" "\n" "jdwp usage: java " "-agentlib:jdwp" "=[help]|[<option>=<value>, ...]\n" "\n" "Option Name and Value Description Default\n" "--------------------- ----------- -------\n" "suspend=y|n wait on startup? y\n" "transport=<name> transport spec none\n" "address=<listen/attach address> transport spec \"\"\n" "server=y|n listen for debugger? n\n" "launch=<command line> run debugger on event none\n" "onthrow=<exception name> debug on throw none\n" "onuncaught=y|n debug on any uncaught? n\n" "timeout=<timeout value> for listen/attach in milliseconds n\n" "mutf8=y|n output modified utf-8 n\n" "quiet=y|n control over terminal messages n\n" ) ); | |||
| 879 | ||||
| 880 | TTY_MESSAGE((( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 881 | "Obsolete Options\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 882 | "----------------\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 883 | "strict=y|n\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 884 | "stdalloc=y|n\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 885 | "\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 886 | "Examples\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 887 | "--------\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 888 | " - Using sockets connect to a debugger at a specific address:\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 889 | " java " AGENTLIB "=transport=dt_socket,address=localhost:8000 ...\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 890 | " - Using sockets listen for a debugger to attach:\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 891 | " java " AGENTLIB "=transport=dt_socket,server=y,suspend=y ...\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 892 | "\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 893 | "Notes\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 894 | "-----\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 895 | " - A timeout value of 0 (the default) is no timeout.\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 896 | "\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 897 | "Warnings\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 898 | "--------\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 899 | " - The older " XRUN " interface can still be used, but will be removed in\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 900 | " a future release, for example:\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 901 | " java " XRUN ":[help]|[<option>=<value>, ...]\n"( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ) | |||
| 902 | ))( tty_message ( "Obsolete Options\n" "----------------\n" "strict=y|n\n" "stdalloc=y|n\n" "\n" "Examples\n" "--------\n" " - Using sockets connect to a debugger at a specific address:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,address=localhost:8000 ...\n" " - Using sockets listen for a debugger to attach:\n" " java " "-agentlib:jdwp" "=transport=dt_socket,server=y,suspend=y ...\n" "\n" "Notes\n" "-----\n" " - A timeout value of 0 (the default) is no timeout.\n" "\n" "Warnings\n" "--------\n" " - The older " "-Xrunjdwp" " interface can still be used, but will be removed in\n" " a future release, for example:\n" " java " "-Xrunjdwp" ":[help]|[<option>=<value>, ...]\n" ) ); | |||
| 903 | ||||
| 904 | #ifdef DEBUG1 | |||
| 905 | ||||
| 906 | TTY_MESSAGE((( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 907 | "\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 908 | "Debugging Options Description Default\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 909 | "----------------- ----------- -------\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 910 | "pause=y|n pause to debug PID n\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 911 | "coredump=y|n coredump at exit n\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 912 | "errorexit=y|n exit on any error n\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 913 | "logfile=filename name of log file none\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 914 | "logflags=flags log flags (bitmask) none\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 915 | " JVM calls = 0x001\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 916 | " JNI calls = 0x002\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 917 | " JVMTI calls = 0x004\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 918 | " misc events = 0x008\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 919 | " step logs = 0x010\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 920 | " locations = 0x020\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 921 | " callbacks = 0x040\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 922 | " errors = 0x080\n"( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ) | |||
| 923 | " everything = 0xfff"))( tty_message ( "\n" "Debugging Options Description Default\n" "----------------- ----------- -------\n" "pause=y|n pause to debug PID n\n" "coredump=y|n coredump at exit n\n" "errorexit=y|n exit on any error n\n" "logfile=filename name of log file none\n" "logflags=flags log flags (bitmask) none\n" " JVM calls = 0x001\n" " JNI calls = 0x002\n" " JVMTI calls = 0x004\n" " misc events = 0x008\n" " step logs = 0x010\n" " locations = 0x020\n" " callbacks = 0x040\n" " errors = 0x080\n" " everything = 0xfff") ); | |||
| 924 | ||||
| 925 | TTY_MESSAGE((( tty_message ( "debugflags=flags debug flags (bitmask) none\n" " USE_ITERATE_THROUGH_HEAP 0x01\n" "\n" "Environment Variables\n" "---------------------\n" "_JAVA_JDWP_OPTIONS\n" " Options can be added externally via this environment variable.\n" " Anything contained in it will get a comma prepended to it (if needed),\n" " then it will be added to the end of the options supplied via the\n" " " "-Xrunjdwp" " or " "-agentlib:jdwp" " command line option.\n" ) ) | |||
| 926 | "debugflags=flags debug flags (bitmask) none\n"( tty_message ( "debugflags=flags debug flags (bitmask) none\n" " USE_ITERATE_THROUGH_HEAP 0x01\n" "\n" "Environment Variables\n" "---------------------\n" "_JAVA_JDWP_OPTIONS\n" " Options can be added externally via this environment variable.\n" " Anything contained in it will get a comma prepended to it (if needed),\n" " then it will be added to the end of the options supplied via the\n" " " "-Xrunjdwp" " or " "-agentlib:jdwp" " command line option.\n" ) ) | |||
| 927 | " USE_ITERATE_THROUGH_HEAP 0x01\n"( tty_message ( "debugflags=flags debug flags (bitmask) none\n" " USE_ITERATE_THROUGH_HEAP 0x01\n" "\n" "Environment Variables\n" "---------------------\n" "_JAVA_JDWP_OPTIONS\n" " Options can be added externally via this environment variable.\n" " Anything contained in it will get a comma prepended to it (if needed),\n" " then it will be added to the end of the options supplied via the\n" " " "-Xrunjdwp" " or " "-agentlib:jdwp" " command line option.\n" ) ) | |||
| 928 | "\n"( tty_message ( "debugflags=flags debug flags (bitmask) none\n" " USE_ITERATE_THROUGH_HEAP 0x01\n" "\n" "Environment Variables\n" "---------------------\n" "_JAVA_JDWP_OPTIONS\n" " Options can be added externally via this environment variable.\n" " Anything contained in it will get a comma prepended to it (if needed),\n" " then it will be added to the end of the options supplied via the\n" " " "-Xrunjdwp" " or " "-agentlib:jdwp" " command line option.\n" ) ) | |||
| 929 | "Environment Variables\n"( tty_message ( "debugflags=flags debug flags (bitmask) none\n" " USE_ITERATE_THROUGH_HEAP 0x01\n" "\n" "Environment Variables\n" "---------------------\n" "_JAVA_JDWP_OPTIONS\n" " Options can be added externally via this environment variable.\n" " Anything contained in it will get a comma prepended to it (if needed),\n" " then it will be added to the end of the options supplied via the\n" " " "-Xrunjdwp" " or " "-agentlib:jdwp" " command line option.\n" ) ) | |||
| 930 | "---------------------\n"( tty_message ( "debugflags=flags debug flags (bitmask) none\n" " USE_ITERATE_THROUGH_HEAP 0x01\n" "\n" "Environment Variables\n" "---------------------\n" "_JAVA_JDWP_OPTIONS\n" " Options can be added externally via this environment variable.\n" " Anything contained in it will get a comma prepended to it (if needed),\n" " then it will be added to the end of the options supplied via the\n" " " "-Xrunjdwp" " or " "-agentlib:jdwp" " command line option.\n" ) ) | |||
| 931 | "_JAVA_JDWP_OPTIONS\n"( tty_message ( "debugflags=flags debug flags (bitmask) none\n" " USE_ITERATE_THROUGH_HEAP 0x01\n" "\n" "Environment Variables\n" "---------------------\n" "_JAVA_JDWP_OPTIONS\n" " Options can be added externally via this environment variable.\n" " Anything contained in it will get a comma prepended to it (if needed),\n" " then it will be added to the end of the options supplied via the\n" " " "-Xrunjdwp" " or " "-agentlib:jdwp" " command line option.\n" ) ) | |||
| 932 | " Options can be added externally via this environment variable.\n"( tty_message ( "debugflags=flags debug flags (bitmask) none\n" " USE_ITERATE_THROUGH_HEAP 0x01\n" "\n" "Environment Variables\n" "---------------------\n" "_JAVA_JDWP_OPTIONS\n" " Options can be added externally via this environment variable.\n" " Anything contained in it will get a comma prepended to it (if needed),\n" " then it will be added to the end of the options supplied via the\n" " " "-Xrunjdwp" " or " "-agentlib:jdwp" " command line option.\n" ) ) | |||
| 933 | " Anything contained in it will get a comma prepended to it (if needed),\n"( tty_message ( "debugflags=flags debug flags (bitmask) none\n" " USE_ITERATE_THROUGH_HEAP 0x01\n" "\n" "Environment Variables\n" "---------------------\n" "_JAVA_JDWP_OPTIONS\n" " Options can be added externally via this environment variable.\n" " Anything contained in it will get a comma prepended to it (if needed),\n" " then it will be added to the end of the options supplied via the\n" " " "-Xrunjdwp" " or " "-agentlib:jdwp" " command line option.\n" ) ) | |||
| 934 | " then it will be added to the end of the options supplied via the\n"( tty_message ( "debugflags=flags debug flags (bitmask) none\n" " USE_ITERATE_THROUGH_HEAP 0x01\n" "\n" "Environment Variables\n" "---------------------\n" "_JAVA_JDWP_OPTIONS\n" " Options can be added externally via this environment variable.\n" " Anything contained in it will get a comma prepended to it (if needed),\n" " then it will be added to the end of the options supplied via the\n" " " "-Xrunjdwp" " or " "-agentlib:jdwp" " command line option.\n" ) ) | |||
| 935 | " " XRUN " or " AGENTLIB " command line option.\n"( tty_message ( "debugflags=flags debug flags (bitmask) none\n" " USE_ITERATE_THROUGH_HEAP 0x01\n" "\n" "Environment Variables\n" "---------------------\n" "_JAVA_JDWP_OPTIONS\n" " Options can be added externally via this environment variable.\n" " Anything contained in it will get a comma prepended to it (if needed),\n" " then it will be added to the end of the options supplied via the\n" " " "-Xrunjdwp" " or " "-agentlib:jdwp" " command line option.\n" ) ) | |||
| 936 | ))( tty_message ( "debugflags=flags debug flags (bitmask) none\n" " USE_ITERATE_THROUGH_HEAP 0x01\n" "\n" "Environment Variables\n" "---------------------\n" "_JAVA_JDWP_OPTIONS\n" " Options can be added externally via this environment variable.\n" " Anything contained in it will get a comma prepended to it (if needed),\n" " then it will be added to the end of the options supplied via the\n" " " "-Xrunjdwp" " or " "-agentlib:jdwp" " command line option.\n" ) ); | |||
| 937 | ||||
| 938 | #endif | |||
| 939 | ||||
| 940 | ||||
| 941 | ||||
| 942 | } | |||
| 943 | ||||
| 944 | static jboolean checkAddress(void *bagItem, void *arg) | |||
| 945 | { | |||
| 946 | TransportSpec *spec = (TransportSpec *)bagItem; | |||
| 947 | if (spec->address == NULL((void*)0)) { | |||
| 948 | ERROR_MESSAGE(("JDWP Non-server transport %s must have a connection "( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,950), log_message_end ("JDWP Non-server transport %s must have a connection " "address specified through the 'address=' option", spec-> name)):((void)0)), error_message ("JDWP Non-server transport %s must have a connection " "address specified through the 'address=' option", spec-> name) ) | |||
| 949 | "address specified through the 'address=' option",( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,950), log_message_end ("JDWP Non-server transport %s must have a connection " "address specified through the 'address=' option", spec-> name)):((void)0)), error_message ("JDWP Non-server transport %s must have a connection " "address specified through the 'address=' option", spec-> name) ) | |||
| 950 | spec->name))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,950), log_message_end ("JDWP Non-server transport %s must have a connection " "address specified through the 'address=' option", spec-> name)):((void)0)), error_message ("JDWP Non-server transport %s must have a connection " "address specified through the 'address=' option", spec-> name) ); | |||
| 951 | return JNI_FALSE0; | |||
| 952 | } else { | |||
| 953 | return JNI_TRUE1; | |||
| 954 | } | |||
| 955 | } | |||
| 956 | ||||
| 957 | static char * | |||
| 958 | add_to_options(char *options, char *new_options) | |||
| 959 | { | |||
| 960 | size_t originalLength; | |||
| 961 | char *combinedOptions; | |||
| 962 | ||||
| 963 | /* | |||
| 964 | * Allocate enough space for both strings and | |||
| 965 | * comma in between. | |||
| 966 | */ | |||
| 967 | originalLength = strlen(options); | |||
| 968 | combinedOptions = jvmtiAllocate((jint)originalLength + 1 + | |||
| 969 | (jint)strlen(new_options) + 1); | |||
| 970 | if (combinedOptions == NULL((void*)0)) { | |||
| 971 | return NULL((void*)0); | |||
| 972 | } | |||
| 973 | ||||
| 974 | (void)strcpy(combinedOptions, options); | |||
| 975 | (void)strcat(combinedOptions, ","); | |||
| 976 | (void)strcat(combinedOptions, new_options); | |||
| 977 | ||||
| 978 | return combinedOptions; | |||
| 979 | } | |||
| 980 | ||||
| 981 | static jboolean | |||
| 982 | get_boolean(char **pstr, jboolean *answer) | |||
| 983 | { | |||
| 984 | char buf[80]; | |||
| 985 | *answer = JNI_FALSE0; | |||
| 986 | /*LINTED*/ | |||
| 987 | if (get_tok(pstr, buf, (int)sizeof(buf), ',')) { | |||
| 988 | if (strcmp(buf, "y") == 0) { | |||
| 989 | *answer = JNI_TRUE1; | |||
| 990 | return JNI_TRUE1; | |||
| 991 | } else if (strcmp(buf, "n") == 0) { | |||
| 992 | *answer = JNI_FALSE0; | |||
| 993 | return JNI_TRUE1; | |||
| 994 | } | |||
| 995 | } | |||
| 996 | return JNI_FALSE0; | |||
| 997 | } | |||
| 998 | ||||
| 999 | /* atexit() callback */ | |||
| 1000 | static void | |||
| 1001 | atexit_finish_logging(void) | |||
| 1002 | { | |||
| 1003 | /* Normal exit(0) (not _exit()) may only reach here */ | |||
| 1004 | finish_logging(); /* Only first call matters */ | |||
| 1005 | } | |||
| 1006 | ||||
| 1007 | static jboolean | |||
| 1008 | parseOptions(char *options) | |||
| 1009 | { | |||
| 1010 | TransportSpec *currentTransport = NULL((void*)0); | |||
| 1011 | char *end; | |||
| 1012 | char *current; | |||
| 1013 | int length; | |||
| 1014 | char *str; | |||
| 1015 | char *errmsg; | |||
| 1016 | jboolean onJcmd = JNI_FALSE0; | |||
| 1017 | ||||
| 1018 | /* Set defaults */ | |||
| 1019 | gdata->assertOn = DEFAULT_ASSERT_ON1; | |||
| 1020 | gdata->assertFatal = DEFAULT_ASSERT_FATAL1; | |||
| 1021 | logfile = DEFAULT_LOGFILE"jdwp.log"; | |||
| 1022 | ||||
| 1023 | /* Options being NULL will end up being an error. */ | |||
| 1024 | if (options == NULL((void*)0)) { | |||
| 1025 | options = ""; | |||
| 1026 | } | |||
| 1027 | ||||
| 1028 | /* Check for "help" BEFORE we add any environmental settings */ | |||
| 1029 | if ((strcmp(options, "help")) == 0) { | |||
| 1030 | printUsage(); | |||
| 1031 | forceExit(0); /* Kill entire process, no core dump wanted */ | |||
| 1032 | } | |||
| 1033 | ||||
| 1034 | /* These buffers are never freed */ | |||
| 1035 | { | |||
| 1036 | char *envOptions; | |||
| 1037 | ||||
| 1038 | /* | |||
| 1039 | * Add environmentally specified options. | |||
| 1040 | */ | |||
| 1041 | envOptions = getenv("_JAVA_JDWP_OPTIONS"); | |||
| 1042 | if (envOptions != NULL((void*)0)) { | |||
| 1043 | options = add_to_options(options, envOptions); | |||
| 1044 | if ( options==NULL((void*)0) ) { | |||
| 1045 | EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"options"){ print_message(stderr, "JDWP exit error ", "\n", "%s(%d): %s [%s:%d]" , jvmtiErrorText((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX+64 +8))), ((jvmtiError)(JVMTI_ERROR_MAX+64+8)), ("options"==((void *)0)?"":"options"), "/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" , 1045); debugInit_exit((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX +64+8)), "options"); }; | |||
| 1046 | } | |||
| 1047 | } | |||
| 1048 | ||||
| 1049 | /* | |||
| 1050 | * Allocate a buffer for names derived from option strings. It should | |||
| 1051 | * never be longer than the original options string itself. | |||
| 1052 | * Also keep a copy of the options in gdata->options. | |||
| 1053 | */ | |||
| 1054 | length = (int)strlen(options); | |||
| 1055 | gdata->options = jvmtiAllocate(length + 1); | |||
| 1056 | if (gdata->options == NULL((void*)0)) { | |||
| 1057 | EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"options"){ print_message(stderr, "JDWP exit error ", "\n", "%s(%d): %s [%s:%d]" , jvmtiErrorText((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX+64 +8))), ((jvmtiError)(JVMTI_ERROR_MAX+64+8)), ("options"==((void *)0)?"":"options"), "/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" , 1057); debugInit_exit((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX +64+8)), "options"); }; | |||
| 1058 | } | |||
| 1059 | (void)strcpy(gdata->options, options); | |||
| 1060 | names = jvmtiAllocate(length + 1); | |||
| 1061 | if (names == NULL((void*)0)) { | |||
| 1062 | EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"options"){ print_message(stderr, "JDWP exit error ", "\n", "%s(%d): %s [%s:%d]" , jvmtiErrorText((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX+64 +8))), ((jvmtiError)(JVMTI_ERROR_MAX+64+8)), ("options"==((void *)0)?"":"options"), "/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" , 1062); debugInit_exit((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX +64+8)), "options"); }; | |||
| 1063 | } | |||
| 1064 | ||||
| 1065 | transports = bagCreateBag(sizeof(TransportSpec), 3); | |||
| 1066 | if (transports == NULL((void*)0)) { | |||
| 1067 | EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"transports"){ print_message(stderr, "JDWP exit error ", "\n", "%s(%d): %s [%s:%d]" , jvmtiErrorText((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX+64 +8))), ((jvmtiError)(JVMTI_ERROR_MAX+64+8)), ("transports"==( (void*)0)?"":"transports"), "/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" , 1067); debugInit_exit((jvmtiError)((jvmtiError)(JVMTI_ERROR_MAX +64+8)), "transports"); }; | |||
| 1068 | } | |||
| 1069 | } | |||
| 1070 | ||||
| 1071 | current = names; | |||
| 1072 | end = names + length; | |||
| 1073 | str = options; | |||
| 1074 | ||||
| 1075 | while (*str) { | |||
| 1076 | char buf[100]; | |||
| 1077 | /*LINTED*/ | |||
| 1078 | if (!get_tok(&str, buf, (int)sizeof(buf), '=')) { | |||
| 1079 | goto syntax_error; | |||
| 1080 | } | |||
| 1081 | if (strcmp(buf, "transport") == 0) { | |||
| 1082 | currentTransport = bagAdd(transports); | |||
| 1083 | /*LINTED*/ | |||
| 1084 | if (!get_tok(&str, current, (int)(end - current), ',')) { | |||
| 1085 | goto syntax_error; | |||
| 1086 | } | |||
| 1087 | currentTransport->name = current; | |||
| 1088 | currentTransport->address = NULL((void*)0); | |||
| 1089 | currentTransport->allow = NULL((void*)0); | |||
| 1090 | currentTransport->timeout = 0L; | |||
| 1091 | current += strlen(current) + 1; | |||
| 1092 | } else if (strcmp(buf, "address") == 0) { | |||
| 1093 | if (currentTransport == NULL((void*)0)) { | |||
| 1094 | errmsg = "address specified without transport"; | |||
| 1095 | goto bad_option_with_errmsg; | |||
| 1096 | } | |||
| 1097 | /*LINTED*/ | |||
| 1098 | if (!get_tok(&str, current, (int)(end - current), ',')) { | |||
| 1099 | goto syntax_error; | |||
| 1100 | } | |||
| 1101 | currentTransport->address = current; | |||
| 1102 | current += strlen(current) + 1; | |||
| 1103 | } else if (strcmp(buf, "allow") == 0) { | |||
| 1104 | if (currentTransport == NULL((void*)0)) { | |||
| 1105 | errmsg = "allow specified without transport"; | |||
| 1106 | goto bad_option_with_errmsg; | |||
| 1107 | } | |||
| 1108 | /*LINTED*/ | |||
| 1109 | if (!get_tok(&str, current, (int)(end - current), ',')) { | |||
| 1110 | goto syntax_error; | |||
| 1111 | } | |||
| 1112 | currentTransport->allow = current; | |||
| 1113 | current += strlen(current) + 1; | |||
| 1114 | } else if (strcmp(buf, "timeout") == 0) { | |||
| 1115 | if (currentTransport == NULL((void*)0)) { | |||
| 1116 | errmsg = "timeout specified without transport"; | |||
| 1117 | goto bad_option_with_errmsg; | |||
| 1118 | } | |||
| 1119 | /*LINTED*/ | |||
| 1120 | if (!get_tok(&str, current, (int)(end - current), ',')) { | |||
| 1121 | goto syntax_error; | |||
| 1122 | } | |||
| 1123 | currentTransport->timeout = atol(current); | |||
| 1124 | current += strlen(current) + 1; | |||
| 1125 | } else if (strcmp(buf, "launch") == 0) { | |||
| 1126 | /*LINTED*/ | |||
| 1127 | if (!get_tok(&str, current, (int)(end - current), ',')) { | |||
| 1128 | goto syntax_error; | |||
| 1129 | } | |||
| 1130 | launchOnInit = current; | |||
| 1131 | current += strlen(current) + 1; | |||
| 1132 | } else if (strcmp(buf, "onthrow") == 0) { | |||
| 1133 | /* Read class name and convert in place to a signature */ | |||
| 1134 | *current = 'L'; | |||
| 1135 | /*LINTED*/ | |||
| 1136 | if (!get_tok(&str, current + 1, (int)(end - current - 1), ',')) { | |||
| 1137 | goto syntax_error; | |||
| 1138 | } | |||
| 1139 | initOnException = current; | |||
| 1140 | while (*current != '\0') { | |||
| 1141 | if (*current == '.') { | |||
| 1142 | *current = '/'; | |||
| 1143 | } | |||
| 1144 | current++; | |||
| 1145 | } | |||
| 1146 | *current++ = ';'; | |||
| 1147 | *current++ = '\0'; | |||
| 1148 | } else if (strcmp(buf, "assert") == 0) { | |||
| 1149 | /*LINTED*/ | |||
| 1150 | if (!get_tok(&str, current, (int)(end - current), ',')) { | |||
| 1151 | goto syntax_error; | |||
| 1152 | } | |||
| 1153 | if (strcmp(current, "y") == 0) { | |||
| 1154 | gdata->assertOn = JNI_TRUE1; | |||
| 1155 | gdata->assertFatal = JNI_FALSE0; | |||
| 1156 | } else if (strcmp(current, "fatal") == 0) { | |||
| 1157 | gdata->assertOn = JNI_TRUE1; | |||
| 1158 | gdata->assertFatal = JNI_TRUE1; | |||
| 1159 | } else if (strcmp(current, "n") == 0) { | |||
| 1160 | gdata->assertOn = JNI_FALSE0; | |||
| 1161 | gdata->assertFatal = JNI_FALSE0; | |||
| 1162 | } else { | |||
| 1163 | goto syntax_error; | |||
| 1164 | } | |||
| 1165 | current += strlen(current) + 1; | |||
| 1166 | } else if (strcmp(buf, "pause") == 0) { | |||
| 1167 | if ( !get_boolean(&str, &dopause) ) { | |||
| 1168 | goto syntax_error; | |||
| 1169 | } | |||
| 1170 | if ( dopause ) { | |||
| 1171 | do_pause(); | |||
| 1172 | } | |||
| 1173 | } else if (strcmp(buf, "coredump") == 0) { | |||
| 1174 | if ( !get_boolean(&str, &docoredump) ) { | |||
| 1175 | goto syntax_error; | |||
| 1176 | } | |||
| 1177 | } else if (strcmp(buf, "errorexit") == 0) { | |||
| 1178 | if ( !get_boolean(&str, &(gdata->doerrorexit)) ) { | |||
| 1179 | goto syntax_error; | |||
| 1180 | } | |||
| 1181 | } else if (strcmp(buf, "exitpause") == 0) { | |||
| 1182 | errmsg = "The exitpause option removed, use -XX:OnError"; | |||
| 1183 | goto bad_option_with_errmsg; | |||
| 1184 | } else if (strcmp(buf, "precrash") == 0) { | |||
| 1185 | errmsg = "The precrash option removed, use -XX:OnError"; | |||
| 1186 | goto bad_option_with_errmsg; | |||
| 1187 | } else if (strcmp(buf, "logfile") == 0) { | |||
| 1188 | /*LINTED*/ | |||
| 1189 | if (!get_tok(&str, current, (int)(end - current), ',')) { | |||
| 1190 | goto syntax_error; | |||
| 1191 | } | |||
| 1192 | logfile = current; | |||
| 1193 | current += strlen(current) + 1; | |||
| 1194 | } else if (strcmp(buf, "logflags") == 0) { | |||
| 1195 | /*LINTED*/ | |||
| 1196 | if (!get_tok(&str, current, (int)(end - current), ',')) { | |||
| 1197 | goto syntax_error; | |||
| 1198 | } | |||
| 1199 | /*LINTED*/ | |||
| 1200 | logflags = (unsigned)strtol(current, NULL((void*)0), 0); | |||
| 1201 | } else if (strcmp(buf, "debugflags") == 0) { | |||
| 1202 | /*LINTED*/ | |||
| 1203 | if (!get_tok(&str, current, (int)(end - current), ',')) { | |||
| 1204 | goto syntax_error; | |||
| 1205 | } | |||
| 1206 | /*LINTED*/ | |||
| 1207 | gdata->debugflags = (unsigned)strtol(current, NULL((void*)0), 0); | |||
| 1208 | } else if ( strcmp(buf, "suspend")==0 ) { | |||
| 1209 | if ( !get_boolean(&str, &suspendOnInit) ) { | |||
| 1210 | goto syntax_error; | |||
| 1211 | } | |||
| 1212 | } else if ( strcmp(buf, "server")==0 ) { | |||
| 1213 | if ( !get_boolean(&str, &isServer) ) { | |||
| 1214 | goto syntax_error; | |||
| 1215 | } | |||
| 1216 | } else if ( strcmp(buf, "strict")==0 ) { /* Obsolete, but accept it */ | |||
| 1217 | if ( !get_boolean(&str, &isStrict) ) { | |||
| 1218 | goto syntax_error; | |||
| 1219 | } | |||
| 1220 | } else if ( strcmp(buf, "quiet")==0 ) { | |||
| 1221 | if ( !get_boolean(&str, &(gdata->quiet)) ) { | |||
| 1222 | goto syntax_error; | |||
| 1223 | } | |||
| 1224 | } else if ( strcmp(buf, "onuncaught")==0 ) { | |||
| 1225 | if ( !get_boolean(&str, &initOnUncaught) ) { | |||
| 1226 | goto syntax_error; | |||
| 1227 | } | |||
| 1228 | } else if ( strcmp(buf, "mutf8")==0 ) { | |||
| 1229 | if ( !get_boolean(&str, &(gdata->modifiedUtf8)) ) { | |||
| 1230 | goto syntax_error; | |||
| 1231 | } | |||
| 1232 | } else if ( strcmp(buf, "stdalloc")==0 ) { /* Obsolete, but accept it */ | |||
| 1233 | if ( !get_boolean(&str, &useStandardAlloc) ) { | |||
| 1234 | goto syntax_error; | |||
| 1235 | } | |||
| 1236 | } else if (strcmp(buf, "onjcmd") == 0) { | |||
| 1237 | if (!get_boolean(&str, &onJcmd)) { | |||
| 1238 | goto syntax_error; | |||
| 1239 | } | |||
| 1240 | } else { | |||
| 1241 | goto syntax_error; | |||
| 1242 | } | |||
| 1243 | } | |||
| 1244 | ||||
| 1245 | /* Setup logging now */ | |||
| 1246 | if ( logfile!=NULL((void*)0) ) { | |||
| 1247 | setup_logging(logfile, logflags); | |||
| 1248 | (void)atexit(&atexit_finish_logging); | |||
| 1249 | } | |||
| 1250 | ||||
| 1251 | if (bagSize(transports) == 0) { | |||
| 1252 | errmsg = "no transport specified"; | |||
| 1253 | goto bad_option_with_errmsg; | |||
| 1254 | } | |||
| 1255 | ||||
| 1256 | /* | |||
| 1257 | * TO DO: Remove when multiple transports are allowed. (replace with | |||
| 1258 | * check below. | |||
| 1259 | */ | |||
| 1260 | if (bagSize(transports) > 1) { | |||
| 1261 | errmsg = "multiple transports are not supported in this release"; | |||
| 1262 | goto bad_option_with_errmsg; | |||
| 1263 | } | |||
| 1264 | ||||
| 1265 | if (!isServer) { | |||
| 1266 | jboolean specified = bagEnumerateOver(transports, checkAddress, NULL((void*)0)); | |||
| 1267 | if (!specified) { | |||
| 1268 | /* message already printed */ | |||
| 1269 | goto bad_option_no_msg; | |||
| 1270 | } | |||
| 1271 | } | |||
| 1272 | ||||
| 1273 | /* | |||
| 1274 | * The user has selected to wait for an exception before init happens | |||
| 1275 | */ | |||
| 1276 | if ((initOnException != NULL((void*)0)) || (initOnUncaught)) { | |||
| 1277 | initOnStartup = JNI_FALSE0; | |||
| 1278 | ||||
| 1279 | if (launchOnInit == NULL((void*)0)) { | |||
| 1280 | /* | |||
| 1281 | * These rely on the launch=/usr/bin/foo | |||
| 1282 | * suboption, so it is an error if user did not | |||
| 1283 | * provide one. | |||
| 1284 | */ | |||
| 1285 | errmsg = "Specify launch=<command line> when using onthrow or onuncaught suboption"; | |||
| 1286 | goto bad_option_with_errmsg; | |||
| 1287 | } | |||
| 1288 | } | |||
| 1289 | ||||
| 1290 | if (onJcmd) { | |||
| 1291 | if (launchOnInit != NULL((void*)0)) { | |||
| 1292 | errmsg = "Cannot combine onjcmd and launch suboptions"; | |||
| 1293 | goto bad_option_with_errmsg; | |||
| 1294 | } | |||
| 1295 | if (!isServer) { | |||
| 1296 | errmsg = "Can only use onjcmd with server=y"; | |||
| 1297 | goto bad_option_with_errmsg; | |||
| 1298 | } | |||
| 1299 | suspendOnInit = JNI_FALSE0; | |||
| 1300 | initOnStartup = JNI_FALSE0; | |||
| 1301 | allowStartViaJcmd = JNI_TRUE1; | |||
| 1302 | } | |||
| 1303 | ||||
| 1304 | return JNI_TRUE1; | |||
| 1305 | ||||
| 1306 | syntax_error: | |||
| 1307 | ERROR_MESSAGE(("JDWP option syntax error: %s=%s", AGENTLIB, options))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,1307), log_message_end ("JDWP option syntax error: %s=%s", "-agentlib:jdwp" , options)):((void)0)), error_message ("JDWP option syntax error: %s=%s" , "-agentlib:jdwp", options) ); | |||
| 1308 | return JNI_FALSE0; | |||
| 1309 | ||||
| 1310 | bad_option_with_errmsg: | |||
| 1311 | ERROR_MESSAGE(("JDWP %s: %s=%s", errmsg, AGENTLIB, options))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,1311), log_message_end ("JDWP %s: %s=%s", errmsg, "-agentlib:jdwp" , options)):((void)0)), error_message ("JDWP %s: %s=%s", errmsg , "-agentlib:jdwp", options) ); | |||
| 1312 | return JNI_FALSE0; | |||
| 1313 | ||||
| 1314 | bad_option_no_msg: | |||
| 1315 | ERROR_MESSAGE(("JDWP %s: %s=%s", "invalid option", AGENTLIB, options))( ((gdata->log_flags & (0x00000080))?(log_message_begin ("ERROR","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,1315), log_message_end ("JDWP %s: %s=%s", "invalid option", "-agentlib:jdwp" , options)):((void)0)), error_message ("JDWP %s: %s=%s", "invalid option" , "-agentlib:jdwp", options) ); | |||
| 1316 | return JNI_FALSE0; | |||
| 1317 | } | |||
| 1318 | ||||
| 1319 | /* All normal exit doors lead here */ | |||
| 1320 | void | |||
| 1321 | debugInit_exit(jvmtiError error, const char *msg) | |||
| 1322 | { | |||
| 1323 | enum exit_codes { EXIT_NO_ERRORS = 0, EXIT_JVMTI_ERROR = 1, EXIT_TRANSPORT_ERROR = 2 }; | |||
| 1324 | ||||
| 1325 | // Release commandLoop vmDeathLock if necessary | |||
| 1326 | commandLoop_exitVmDeathLockOnError(); | |||
| 1327 | ||||
| 1328 | // Prepare to exit. Log error and finish logging | |||
| 1329 | LOG_MISC(("Exiting with error %s(%d): %s", jvmtiErrorText(error), error,((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,1330), log_message_end ("Exiting with error %s(%d): %s", jvmtiErrorText (error), error, ((msg == ((void*)0)) ? "" : msg))):((void)0)) | |||
| 1330 | ((msg == NULL) ? "" : msg)))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,1330), log_message_end ("Exiting with error %s(%d): %s", jvmtiErrorText (error), error, ((msg == ((void*)0)) ? "" : msg))):((void)0)); | |||
| 1331 | ||||
| 1332 | // coredump requested by command line. Keep JVMTI data dirty | |||
| 1333 | if (error
| |||
| 1334 | LOG_MISC(("Dumping core as requested by command line"))((gdata->log_flags & (0x00000008)) ?(log_message_begin ("MISC","/home/daniel/Projects/java/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c" ,1334), log_message_end ("Dumping core as requested by command line" )):((void)0)); | |||
| 1335 | finish_logging(); | |||
| 1336 | abort(); | |||
| 1337 | } | |||
| 1338 | ||||
| 1339 | finish_logging(); | |||
| 1340 | ||||
| 1341 | // Cleanup the JVMTI if we have one | |||
| 1342 | if (gdata != NULL((void*)0)) { | |||
| 1343 | gdata->vmDead = JNI_TRUE1; | |||
| 1344 | if (gdata->jvmti != NULL((void*)0)) { | |||
| 1345 | // Dispose of jvmti (gdata->jvmti becomes NULL) | |||
| 1346 | disposeEnvironment(gdata->jvmti); | |||
| 1347 | } | |||
| 1348 | } | |||
| 1349 | ||||
| 1350 | // We are here with no errors. Kill entire process and exit with zero exit code | |||
| 1351 | if (error
| |||
| 1352 | forceExit(EXIT_NO_ERRORS); | |||
| 1353 | return; | |||
| 1354 | } | |||
| 1355 | ||||
| 1356 | // No transport initilized. | |||
| 1357 | // As we don't have any details here exiting with separate exit code | |||
| 1358 | if (error == AGENT_ERROR_TRANSPORT_INIT((jvmtiError)(JVMTI_ERROR_MAX+64+17))) { | |||
| 1359 | forceExit(EXIT_TRANSPORT_ERROR); | |||
| 1360 | return; | |||
| 1361 | } | |||
| 1362 | ||||
| 1363 | // We have JVMTI error. Call hotspot jni_FatalError handler | |||
| 1364 | jniFatalError(NULL((void*)0), msg, error, EXIT_JVMTI_ERROR); | |||
| 1365 | ||||
| 1366 | // hotspot calls os:abort() so we should never reach code below, | |||
| 1367 | // but guard against possible hotspot changes | |||
| 1368 | ||||
| 1369 | // Last chance to die, this kills the entire process. | |||
| 1370 | forceExit(EXIT_JVMTI_ERROR); | |||
| 1371 | } | |||
| 1372 | ||||
| 1373 | static jboolean getFirstTransport(void *item, void *arg) | |||
| 1374 | { | |||
| 1375 | TransportSpec** store = arg; | |||
| 1376 | *store = item; | |||
| 1377 | ||||
| 1378 | return JNI_FALSE0; /* Want the first */ | |||
| 1379 | } | |||
| 1380 | ||||
| 1381 | /* Call to start up debugging. */ | |||
| 1382 | JNIEXPORT__attribute__((visibility("default"))) char const* JNICALL debugInit_startDebuggingViaCommand(JNIEnv* env, jthread thread, char const** transport_name, | |||
| 1383 | char const** address, jboolean* first_start) { | |||
| 1384 | jboolean is_first_start = JNI_FALSE0; | |||
| 1385 | TransportSpec* spec = NULL((void*)0); | |||
| 1386 | ||||
| 1387 | if (!vmInitialized) { | |||
| ||||
| 1388 | return "Not yet initialized. Try again later."; | |||
| 1389 | } | |||
| 1390 | ||||
| 1391 | if (!allowStartViaJcmd) { | |||
| 1392 | return "Starting debugging via jcmd was not enabled via the onjcmd option of the jdwp agent."; | |||
| 1393 | } | |||
| 1394 | ||||
| 1395 | if (!startedViaJcmd) { | |||
| 1396 | startedViaJcmd = JNI_TRUE1; | |||
| 1397 | is_first_start = JNI_TRUE1; | |||
| 1398 | initialize(env, thread, EI_VM_INIT); | |||
| 1399 | } | |||
| 1400 | ||||
| 1401 | bagEnumerateOver(transports, getFirstTransport, &spec); | |||
| 1402 | ||||
| 1403 | if ((spec != NULL((void*)0)) && (transport_name != NULL((void*)0)) && (address != NULL((void*)0))) { | |||
| 1404 | *transport_name = spec->name; | |||
| 1405 | *address = spec->address; | |||
| 1406 | } | |||
| 1407 | ||||
| 1408 | if (first_start != NULL((void*)0)) { | |||
| 1409 | *first_start = is_first_start; | |||
| 1410 | } | |||
| 1411 | ||||
| 1412 | return NULL((void*)0); | |||
| 1413 | } |