< prev index next >

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

Print this page




 286     if (error != JVMTI_ERROR_NONE) {
 287         ERROR_MESSAGE(("JDWP unable to get potential JVMTI capabilities: %s(%d)",
 288                         jvmtiErrorText(error), error));
 289         return JNI_ERR;
 290     }
 291 
 292     /* Fill in ones that we must have */
 293     (void)memset(&needed_capabilities,0,sizeof(needed_capabilities));
 294     needed_capabilities.can_access_local_variables              = 1;
 295     needed_capabilities.can_generate_single_step_events         = 1;
 296     needed_capabilities.can_generate_exception_events           = 1;
 297     needed_capabilities.can_generate_frame_pop_events           = 1;
 298     needed_capabilities.can_generate_breakpoint_events          = 1;
 299     needed_capabilities.can_suspend                             = 1;
 300     needed_capabilities.can_generate_method_entry_events        = 1;
 301     needed_capabilities.can_generate_method_exit_events         = 1;
 302     needed_capabilities.can_generate_garbage_collection_events  = 1;
 303     needed_capabilities.can_maintain_original_method_order      = 1;
 304     needed_capabilities.can_generate_monitor_events             = 1;
 305     needed_capabilities.can_tag_objects                         = 1;


 306 
 307     /* And what potential ones that would be nice to have */
 308     needed_capabilities.can_force_early_return
 309                 = potential_capabilities.can_force_early_return;
 310     needed_capabilities.can_generate_field_modification_events
 311                 = potential_capabilities.can_generate_field_modification_events;
 312     needed_capabilities.can_generate_field_access_events
 313                 = potential_capabilities.can_generate_field_access_events;
 314     needed_capabilities.can_get_bytecodes
 315                 = potential_capabilities.can_get_bytecodes;
 316     needed_capabilities.can_get_synthetic_attribute
 317                 = potential_capabilities.can_get_synthetic_attribute;
 318     needed_capabilities.can_get_owned_monitor_info
 319                 = potential_capabilities.can_get_owned_monitor_info;
 320     needed_capabilities.can_get_current_contended_monitor
 321                 = potential_capabilities.can_get_current_contended_monitor;
 322     needed_capabilities.can_get_monitor_info
 323                 = potential_capabilities.can_get_monitor_info;
 324     needed_capabilities.can_pop_frame
 325                 = potential_capabilities.can_pop_frame;


 857 printUsage(void)
 858 {
 859      TTY_MESSAGE((
 860  "               Java Debugger JDWP Agent Library\n"
 861  "               --------------------------------\n"
 862  "\n"
 863  "  (see http://java.sun.com/products/jpda 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) {


1104             if (currentTransport == 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                 }




 286     if (error != JVMTI_ERROR_NONE) {
 287         ERROR_MESSAGE(("JDWP unable to get potential JVMTI capabilities: %s(%d)",
 288                         jvmtiErrorText(error), error));
 289         return JNI_ERR;
 290     }
 291 
 292     /* Fill in ones that we must have */
 293     (void)memset(&needed_capabilities,0,sizeof(needed_capabilities));
 294     needed_capabilities.can_access_local_variables              = 1;
 295     needed_capabilities.can_generate_single_step_events         = 1;
 296     needed_capabilities.can_generate_exception_events           = 1;
 297     needed_capabilities.can_generate_frame_pop_events           = 1;
 298     needed_capabilities.can_generate_breakpoint_events          = 1;
 299     needed_capabilities.can_suspend                             = 1;
 300     needed_capabilities.can_generate_method_entry_events        = 1;
 301     needed_capabilities.can_generate_method_exit_events         = 1;
 302     needed_capabilities.can_generate_garbage_collection_events  = 1;
 303     needed_capabilities.can_maintain_original_method_order      = 1;
 304     needed_capabilities.can_generate_monitor_events             = 1;
 305     needed_capabilities.can_tag_objects                         = 1;
 306     needed_capabilities.can_support_fibers                      = 1;
 307     needed_capabilities.can_support_continuations               = 1;
 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;


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


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


1111             if (currentTransport == NULL) {
1112                 errmsg = "allow specified without transport";
1113                 goto bad_option_with_errmsg;
1114             }
1115             /*LINTED*/
1116             if (!get_tok(&str, current, (int)(end - current), ',')) {
1117                 goto syntax_error;
1118             }
1119             currentTransport->allow = current;
1120             current += strlen(current) + 1;
1121          } else if (strcmp(buf, "timeout") == 0) {
1122             if (currentTransport == NULL) {
1123                 errmsg = "timeout specified without transport";
1124                 goto bad_option_with_errmsg;
1125             }
1126             /*LINTED*/
1127             if (!get_tok(&str, current, (int)(end - current), ',')) {
1128                 goto syntax_error;
1129             }
1130             currentTransport->timeout = atol(current);
1131             current += strlen(current) + 1;
1132         } else if (strcmp(buf, "fibers") == 0) {
1133             if (!get_tok(&str, current, (int)(end - current), ',')) {
1134                 goto syntax_error;
1135             }
1136             if (strcmp(current, "y") == 0) {
1137                 gdata->fibersSupported = JNI_TRUE;
1138                 gdata->notifyDebuggerOfAllFibers = JNI_FALSE;
1139             } else if (strcmp(current, "all") == 0) {
1140                 gdata->fibersSupported = JNI_TRUE;
1141                 gdata->notifyDebuggerOfAllFibers = JNI_TRUE;
1142             } else if (strcmp(current, "n") == 0) {
1143                 gdata->fibersSupported = JNI_FALSE;
1144                 gdata->notifyDebuggerOfAllFibers = JNI_FALSE;
1145             } else {
1146                 goto syntax_error;
1147             }
1148             current += strlen(current) + 1;
1149         } else if (strcmp(buf, "launch") == 0) {
1150             /*LINTED*/
1151             if (!get_tok(&str, current, (int)(end - current), ',')) {
1152                 goto syntax_error;
1153             }
1154             launchOnInit = current;
1155             current += strlen(current) + 1;
1156         } else if (strcmp(buf, "onthrow") == 0) {
1157             /* Read class name and convert in place to a signature */
1158             *current = 'L';
1159             /*LINTED*/
1160             if (!get_tok(&str, current + 1, (int)(end - current - 1), ',')) {
1161                 goto syntax_error;
1162             }
1163             initOnException = current;
1164             while (*current != '\0') {
1165                 if (*current == '.') {
1166                     *current = '/';
1167                 }


< prev index next >