< prev index next >

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

Print this page




  66     vmDeathLock = debugMonitorCreate("JDWP VM_DEATH Lock");
  67 }
  68 
  69 void
  70 debugLoop_sync(void)
  71 {
  72     debugMonitorEnter(vmDeathLock);
  73     debugMonitorExit(vmDeathLock);
  74 }
  75 
  76 /*
  77  * This is where all the work gets done.
  78  */
  79 
  80 void
  81 debugLoop_run(void)
  82 {
  83     jboolean shouldListen;
  84     jdwpPacket p;
  85     jvmtiStartFunction func;

  86 
  87     /* Initialize all statics */
  88     /* We may be starting a new connection after an error */
  89     cmdQueue = NULL;
  90     cmdQueueLock = debugMonitorCreate("JDWP Command Queue Lock");
  91     transportError = JNI_FALSE;
  92 
  93     shouldListen = JNI_TRUE;
  94 
  95     func = &reader;
  96     (void)spawnNewThread(func, NULL, "JDWP Command Reader");
  97 
  98     standardHandlers_onConnect();
  99     threadControl_onConnect();
 100 
 101     /* Okay, start reading cmds! */
 102     while (shouldListen) {
 103         if (!dequeue(&p)) {
 104             break;
 105         }


 138             outStream_initReply(&out, inStream_id(&in));
 139 
 140             LOG_MISC(("Command set %d, command %d", cmd->cmdSet, cmd->cmd));
 141 
 142             func = debugDispatch_getHandler(cmd->cmdSet,cmd->cmd);
 143             if (func == NULL) {
 144                 /* we've never heard of this, so I guess we
 145                  * haven't implemented it.
 146                  * Handle gracefully for future expansion
 147                  * and platform / vendor expansion.
 148                  */
 149                 outStream_setError(&out, JDWP_ERROR(NOT_IMPLEMENTED));
 150             } else if (gdata->vmDead &&
 151              ((cmd->cmdSet) != JDWP_COMMAND_SET(VirtualMachine))) {
 152                 /* Protect the VM from calls while dead.
 153                  * VirtualMachine cmdSet quietly ignores some cmds
 154                  * after VM death, so, it sends it's own errors.
 155                  */
 156                 outStream_setError(&out, JDWP_ERROR(VM_DEAD));
 157             } else {
 158                 /* Call the command handler */
 159                 replyToSender = func(&in, &out);







 160             }
 161 
 162             /* Reply to the sender */
 163             if (replyToSender) {
 164                 if (inStream_error(&in)) {
 165                     outStream_setError(&out, inStream_error(&in));
 166                 }
 167                 outStream_sendReply(&out);
 168             }
 169 
 170             /*
 171              * Release the vmDeathLock as the reply has been posted.
 172              */
 173             debugMonitorExit(vmDeathLock);
 174 
 175             inStream_destroy(&in);
 176             outStream_destroy(&out);
 177 
 178             shouldListen = !lastCommand(cmd);
 179         }




  66     vmDeathLock = debugMonitorCreate("JDWP VM_DEATH Lock");
  67 }
  68 
  69 void
  70 debugLoop_sync(void)
  71 {
  72     debugMonitorEnter(vmDeathLock);
  73     debugMonitorExit(vmDeathLock);
  74 }
  75 
  76 /*
  77  * This is where all the work gets done.
  78  */
  79 
  80 void
  81 debugLoop_run(void)
  82 {
  83     jboolean shouldListen;
  84     jdwpPacket p;
  85     jvmtiStartFunction func;
  86     JNIEnv *env = getEnv();
  87 
  88     /* Initialize all statics */
  89     /* We may be starting a new connection after an error */
  90     cmdQueue = NULL;
  91     cmdQueueLock = debugMonitorCreate("JDWP Command Queue Lock");
  92     transportError = JNI_FALSE;
  93 
  94     shouldListen = JNI_TRUE;
  95 
  96     func = &reader;
  97     (void)spawnNewThread(func, NULL, "JDWP Command Reader");
  98 
  99     standardHandlers_onConnect();
 100     threadControl_onConnect();
 101 
 102     /* Okay, start reading cmds! */
 103     while (shouldListen) {
 104         if (!dequeue(&p)) {
 105             break;
 106         }


 139             outStream_initReply(&out, inStream_id(&in));
 140 
 141             LOG_MISC(("Command set %d, command %d", cmd->cmdSet, cmd->cmd));
 142 
 143             func = debugDispatch_getHandler(cmd->cmdSet,cmd->cmd);
 144             if (func == NULL) {
 145                 /* we've never heard of this, so I guess we
 146                  * haven't implemented it.
 147                  * Handle gracefully for future expansion
 148                  * and platform / vendor expansion.
 149                  */
 150                 outStream_setError(&out, JDWP_ERROR(NOT_IMPLEMENTED));
 151             } else if (gdata->vmDead &&
 152              ((cmd->cmdSet) != JDWP_COMMAND_SET(VirtualMachine))) {
 153                 /* Protect the VM from calls while dead.
 154                  * VirtualMachine cmdSet quietly ignores some cmds
 155                  * after VM death, so, it sends it's own errors.
 156                  */
 157                 outStream_setError(&out, JDWP_ERROR(VM_DEAD));
 158             } else {
 159               /* Provide 64 localrefs by default. */
 160               /* fiber fixme: Now that this default set of localrefs is in place, we can remove a
 161                * bunch of WITH_LOCAL_REFS/END_WITH_LOCAL_REFS blocks. The only ones needed are
 162                * ones that could potentially go over 64, likes ones within loops. Note this only
 163                * refers to command handlers called from here, not all uses of WITH_LOCAL_REFS. */
 164                 WITH_LOCAL_REFS(env, 64) {
 165                     /* Call the command handler */
 166                     replyToSender = func(&in, &out);
 167                 } END_WITH_LOCAL_REFS(env);
 168             }
 169 
 170             /* Reply to the sender */
 171             if (replyToSender) {
 172                 if (inStream_error(&in)) {
 173                     outStream_setError(&out, inStream_error(&in));
 174                 }
 175                 outStream_sendReply(&out);
 176             }
 177 
 178             /*
 179              * Release the vmDeathLock as the reply has been posted.
 180              */
 181             debugMonitorExit(vmDeathLock);
 182 
 183             inStream_destroy(&in);
 184             outStream_destroy(&out);
 185 
 186             shouldListen = !lastCommand(cmd);
 187         }


< prev index next >