< prev index next >

src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c

Print this page

 285     if (error != JVMTI_ERROR_NONE) {
 286         ERROR_MESSAGE(("JDWP unable to get potential JVMTI capabilities: %s(%d)",
 287                         jvmtiErrorText(error), error));
 288         return JNI_ERR;
 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;

 857 {
 858      TTY_MESSAGE((
 859  "               Java Debugger JDWP Agent Library\n"
 860  "               --------------------------------\n"
 861  "\n"
 862  "  (See the \"VM Invocation Options\" section of the JPDA\n"
 863  "   \"Connection and Invocation Details\" document for more information.)\n"
 864  "\n"
 865  "jdwp usage: java " AGENTLIB "=[help]|[<option>=<value>, ...]\n"
 866  "\n"
 867  "Option Name and Value            Description                       Default\n"
 868  "---------------------            -----------                       -------\n"
 869  "suspend=y|n                      wait on startup?                  y\n"
 870  "transport=<name>                 transport spec                    none\n"
 871  "address=<listen/attach address>  transport spec                    \"\"\n"
 872  "server=y|n                       listen for debugger?              n\n"
 873  "launch=<command line>            run debugger on event             none\n"
 874  "onthrow=<exception name>         debug on throw                    none\n"
 875  "onuncaught=y|n                   debug on any uncaught?            n\n"
 876  "timeout=<timeout value>          for listen/attach in milliseconds n\n"


 877  "mutf8=y|n                        output modified utf-8             n\n"
 878  "quiet=y|n                        control over terminal messages    n\n"));
 879 
 880     TTY_MESSAGE((
 881  "Obsolete Options\n"
 882  "----------------\n"
 883  "strict=y|n\n"
 884  "stdalloc=y|n\n"
 885  "\n"
 886  "Examples\n"
 887  "--------\n"
 888  "  - Using sockets connect to a debugger at a specific address:\n"
 889  "    java " AGENTLIB "=transport=dt_socket,address=localhost:8000 ...\n"
 890  "  - Using sockets listen for a debugger to attach:\n"
 891  "    java " AGENTLIB "=transport=dt_socket,server=y,suspend=y ...\n"
 892  "\n"
 893  "Notes\n"
 894  "-----\n"
 895  "  - A timeout value of 0 (the default) is no timeout.\n"
 896  "\n"

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;
1011     char *end;
1012     char *current;
1013     int length;
1014     char *str;
1015     char *errmsg;
1016     jboolean onJcmd = JNI_FALSE;
1017 
1018     /* Set defaults */
1019     gdata->assertOn     = DEFAULT_ASSERT_ON;
1020     gdata->assertFatal  = DEFAULT_ASSERT_FATAL;
1021     logfile             = DEFAULT_LOGFILE;
1022 






1023     /* Options being NULL will end up being an error. */
1024     if (options == NULL) {
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) {

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) {
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++;

 285     if (error != JVMTI_ERROR_NONE) {
 286         ERROR_MESSAGE(("JDWP unable to get potential JVMTI capabilities: %s(%d)",
 287                         jvmtiErrorText(error), error));
 288         return JNI_ERR;
 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     if (gdata->vthreadsSupported) {
 306         needed_capabilities.can_support_virtual_threads         = 1;
 307     }
 308 
 309     /* And what potential ones that would be nice to have */
 310     needed_capabilities.can_force_early_return
 311                 = potential_capabilities.can_force_early_return;
 312     needed_capabilities.can_generate_field_modification_events
 313                 = potential_capabilities.can_generate_field_modification_events;
 314     needed_capabilities.can_generate_field_access_events
 315                 = potential_capabilities.can_generate_field_access_events;
 316     needed_capabilities.can_get_bytecodes
 317                 = potential_capabilities.can_get_bytecodes;
 318     needed_capabilities.can_get_synthetic_attribute
 319                 = potential_capabilities.can_get_synthetic_attribute;
 320     needed_capabilities.can_get_owned_monitor_info
 321                 = potential_capabilities.can_get_owned_monitor_info;
 322     needed_capabilities.can_get_current_contended_monitor
 323                 = potential_capabilities.can_get_current_contended_monitor;
 324     needed_capabilities.can_get_monitor_info
 325                 = potential_capabilities.can_get_monitor_info;
 326     needed_capabilities.can_pop_frame
 327                 = potential_capabilities.can_pop_frame;

 860 {
 861      TTY_MESSAGE((
 862  "               Java Debugger JDWP Agent Library\n"
 863  "               --------------------------------\n"
 864  "\n"
 865  "  (See the \"VM Invocation Options\" section of the JPDA\n"
 866  "   \"Connection and Invocation Details\" document for more information.)\n"
 867  "\n"
 868  "jdwp usage: java " AGENTLIB "=[help]|[<option>=<value>, ...]\n"
 869  "\n"
 870  "Option Name and Value            Description                       Default\n"
 871  "---------------------            -----------                       -------\n"
 872  "suspend=y|n                      wait on startup?                  y\n"
 873  "transport=<name>                 transport spec                    none\n"
 874  "address=<listen/attach address>  transport spec                    \"\"\n"
 875  "server=y|n                       listen for debugger?              n\n"
 876  "launch=<command line>            run debugger on event             none\n"
 877  "onthrow=<exception name>         debug on throw                    none\n"
 878  "onuncaught=y|n                   debug on any uncaught?            n\n"
 879  "timeout=<timeout value>          for listen/attach in milliseconds n\n"
 880  "enumeratevthreads=y|n            thread lists include all vthreads n\n"
 881  "notifyvthreads=y|n               send vthread START/END events     y\n"
 882  "mutf8=y|n                        output modified utf-8             n\n"
 883  "quiet=y|n                        control over terminal messages    n\n"));
 884 
 885     TTY_MESSAGE((
 886  "Obsolete Options\n"
 887  "----------------\n"
 888  "strict=y|n\n"
 889  "stdalloc=y|n\n"
 890  "\n"
 891  "Examples\n"
 892  "--------\n"
 893  "  - Using sockets connect to a debugger at a specific address:\n"
 894  "    java " AGENTLIB "=transport=dt_socket,address=localhost:8000 ...\n"
 895  "  - Using sockets listen for a debugger to attach:\n"
 896  "    java " AGENTLIB "=transport=dt_socket,server=y,suspend=y ...\n"
 897  "\n"
 898  "Notes\n"
 899  "-----\n"
 900  "  - A timeout value of 0 (the default) is no timeout.\n"
 901  "\n"

1008     /* Normal exit(0) (not _exit()) may only reach here */
1009     finish_logging();  /* Only first call matters */
1010 }
1011 
1012 static jboolean
1013 parseOptions(char *options)
1014 {
1015     TransportSpec *currentTransport = NULL;
1016     char *end;
1017     char *current;
1018     int length;
1019     char *str;
1020     char *errmsg;
1021     jboolean onJcmd = JNI_FALSE;
1022 
1023     /* Set defaults */
1024     gdata->assertOn     = DEFAULT_ASSERT_ON;
1025     gdata->assertFatal  = DEFAULT_ASSERT_FATAL;
1026     logfile             = DEFAULT_LOGFILE;
1027 
1028     /* Set vthread debugging level. */
1029     gdata->vthreadsSupported = JNI_TRUE;
1030     gdata->trackAllVThreads = JNI_FALSE;
1031     gdata->enumerateVThreads = JNI_FALSE;
1032     gdata->notifyVThreads = JNI_TRUE;
1033 
1034     /* Options being NULL will end up being an error. */
1035     if (options == NULL) {
1036         options = "";
1037     }
1038 
1039     /* Check for "help" BEFORE we add any environmental settings */
1040     if ((strcmp(options, "help")) == 0) {
1041         printUsage();
1042         forceExit(0); /* Kill entire process, no core dump wanted */
1043     }
1044 
1045     /* These buffers are never freed */
1046     {
1047         char *envOptions;
1048 
1049         /*
1050          * Add environmentally specified options.
1051          */
1052         envOptions = getenv("_JAVA_JDWP_OPTIONS");
1053         if (envOptions != NULL) {

1116                 errmsg = "allow 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->allow = current;
1124             current += strlen(current) + 1;
1125          } else if (strcmp(buf, "timeout") == 0) {
1126             if (currentTransport == NULL) {
1127                 errmsg = "timeout specified without transport";
1128                 goto bad_option_with_errmsg;
1129             }
1130             /*LINTED*/
1131             if (!get_tok(&str, current, (int)(end - current), ',')) {
1132                 goto syntax_error;
1133             }
1134             currentTransport->timeout = atol(current);
1135             current += strlen(current) + 1;
1136         } else if (strcmp(buf, "enumeratevthreads") == 0) {
1137             if (!get_tok(&str, current, (int)(end - current), ',')) {
1138                 goto syntax_error;
1139             }
1140             if (strcmp(current, "y") == 0) {
1141                 gdata->enumerateVThreads = JNI_TRUE;
1142             } else if (strcmp(current, "n") == 0) {
1143                 gdata->enumerateVThreads = JNI_FALSE;
1144             } else {
1145                 goto syntax_error;
1146             }
1147             gdata->trackAllVThreads = gdata->enumerateVThreads;
1148             current += strlen(current) + 1;
1149         } else if (strcmp(buf, "notifyvthreads") == 0) {
1150             if (!get_tok(&str, current, (int)(end - current), ',')) {
1151                 goto syntax_error;
1152             }
1153             if (strcmp(current, "y") == 0) {
1154                 gdata->notifyVThreads = JNI_TRUE;
1155             } else if (strcmp(current, "n") == 0) {
1156                 gdata->notifyVThreads = JNI_FALSE;
1157             } else {
1158                 goto syntax_error;
1159             }
1160             current += strlen(current) + 1;
1161         } else if (strcmp(buf, "launch") == 0) {
1162             /*LINTED*/
1163             if (!get_tok(&str, current, (int)(end - current), ',')) {
1164                 goto syntax_error;
1165             }
1166             launchOnInit = current;
1167             current += strlen(current) + 1;
1168         } else if (strcmp(buf, "onthrow") == 0) {
1169             /* Read class name and convert in place to a signature */
1170             *current = 'L';
1171             /*LINTED*/
1172             if (!get_tok(&str, current + 1, (int)(end - current - 1), ',')) {
1173                 goto syntax_error;
1174             }
1175             initOnException = current;
1176             while (*current != '\0') {
1177                 if (*current == '.') {
1178                     *current = '/';
1179                 }
1180                 current++;
< prev index next >