⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 virtualmachinecommandset.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  {    ThreadGroup jdwpGroup = Thread.currentThread().getThreadGroup();    ThreadGroup root = getRootThreadGroup(jdwpGroup);    int numThreads = root.activeCount();    Thread allThreads[] = new Thread[numThreads];    root.enumerate(allThreads);    // We need to loop through for the true count since some threads may have    // been destroyed since we got    // activeCount so those spots in the array will be null. As well we must    // ignore any threads that belong to jdwp    numThreads = 0;    for (int i = 0; i < allThreads.length; i++)      {        Thread thread = allThreads[i];        if (thread == null)          break; // No threads after this point        if (!thread.getThreadGroup().equals(jdwpGroup))          numThreads++;      }    os.writeInt(numThreads);    for (int i = 0; i < allThreads.length; i++)      {        Thread thread = allThreads[i];        if (thread == null)          break; // No threads after this point        if (!thread.getThreadGroup().equals(jdwpGroup))          idMan.getObjectId(thread).write(os);      }  }  private void executeTopLevelThreadGroups(ByteBuffer bb, DataOutputStream os)    throws JdwpException, IOException  {    ThreadGroup jdwpGroup = Thread.currentThread().getThreadGroup ();    ThreadGroup root = getRootThreadGroup(jdwpGroup);    os.writeInt(1); // Just one top level group allowed?    idMan.getObjectId(root);  }  private void executeDispose(ByteBuffer bb, DataOutputStream os)    throws JdwpException  {    // resumeAllThreads isn't sufficient as a thread may have been    // suspended multiple times, we likely need a way to keep track of how many    // times a thread has been suspended or else a stronger resume method for    // this purpose    // VMVirtualMachine.resumeAllThreads ();    // Simply shutting down the jdwp layer will take care of the rest of the    // shutdown other than disabling debugging in the VM    // VMVirtualMachine.disableDebugging();    // Don't implement this until we're sure how to remove all the debugging    // effects from the VM.    throw new NotImplementedException(      "Command VirtualMachine.Dispose not implemented");  }  private void executeIDsizes(ByteBuffer bb, DataOutputStream os)    throws JdwpException, IOException  {    ObjectId oid = new ObjectId();    os.writeInt(oid.size()); // fieldId    os.writeInt(oid.size()); // methodId    os.writeInt(oid.size()); // objectId    os.writeInt(new ReferenceTypeId((byte) 0x00).size()); // referenceTypeId    os.writeInt(oid.size()); // frameId  }  private void executeSuspend(ByteBuffer bb, DataOutputStream os)    throws JdwpException  {    VMVirtualMachine.suspendAllThreads ();  }  private void executeResume(ByteBuffer bb, DataOutputStream os)    throws JdwpException  {    VMVirtualMachine.resumeAllThreads ();  }  private void executeExit(ByteBuffer bb, DataOutputStream os)    throws JdwpException, IOException  {    int exitCode = bb.getInt();    System.exit (exitCode);  }  private void executeCreateString(ByteBuffer bb, DataOutputStream os)    throws JdwpException, IOException  {    String string = JdwpString.readString(bb);    ObjectId stringId = idMan.getObjectId(string);        // Since this string isn't referenced anywhere we'll disable garbage    // collection on it so it's still around when the debugger gets back to it.    stringId.disableCollection();    stringId.write(os);  }  private void executeCapabilities(ByteBuffer bb, DataOutputStream os)    throws JdwpException, IOException  {    // Store these somewhere?    os.writeBoolean(false); // canWatchFieldModification    os.writeBoolean(false); // canWatchFieldAccess    os.writeBoolean(false); // canGetBytecodes    os.writeBoolean(false); // canGetSyntheticAttribute    os.writeBoolean(false); // canGetOwnedMonitorInfo    os.writeBoolean(false); // canGetCurrentContendedMonitor    os.writeBoolean(false); // canGetMonitorInfo  }  private void executeClassPaths(ByteBuffer bb, DataOutputStream os)    throws JdwpException, IOException  {    String baseDir = System.getProperty("user.dir");    JdwpString.writeString(os, baseDir);    // Find and write the classpath    String classPath = System.getProperty("java.class.path");    String[] paths = classPath.split(":");    os.writeInt(paths.length);    for (int i = 0; i < paths.length; i++)      JdwpString.writeString(os, paths[i]);    // Now the bootpath    String bootPath = System.getProperty("sun.boot.class.path");    paths = bootPath.split(":");    os.writeInt(paths.length);    for (int i = 0; i < paths.length; i++)      JdwpString.writeString(os, paths[i]);  }  private void executeDisposeObjects(ByteBuffer bb, DataOutputStream os)    throws JdwpException  {    // Instead of going through the list of objects they give us it's probably    // better just to find the garbage collected objects ourselves    //idMan.update();  }  private void executeHoldEvents(ByteBuffer bb, DataOutputStream os)    throws JdwpException  {    // Going to have to implement a send queue somewhere and do this without    // triggering events    // Until then just don't implement    throw new NotImplementedException(      "Command VirtualMachine.HoldEvents not implemented");  }  // Opposite of executeHoldEvents  private void executeReleaseEvents(ByteBuffer bb, DataOutputStream os)    throws JdwpException  {    throw new NotImplementedException(      "Command VirtualMachine.ReleaseEvents not implemented");  }  private void executeCapabilitiesNew(ByteBuffer bb, DataOutputStream os)    throws JdwpException, IOException  {    // Store these somewhere?    final int CAPABILITIES_NEW_SIZE = 32;    os.writeBoolean(false); // canWatchFieldModification    os.writeBoolean(false); // canWatchFieldAccess    os.writeBoolean(false); // canGetBytecodes    os.writeBoolean(false); // canGetSyntheticAttribute    os.writeBoolean(false); // canGetOwnedMonitorInfo    os.writeBoolean(false); // canGetCurrentContendedMonitor    os.writeBoolean(false); // canGetMonitorInfo    os.writeBoolean(false); // canRedefineClasses    os.writeBoolean(false); // canAddMethod    os.writeBoolean(false); // canUnrestrictedlyRedefineClasses    os.writeBoolean(false); // canPopFrames    os.writeBoolean(false); // canUseInstanceFilters    os.writeBoolean(false); // canGetSourceDebugExtension    os.writeBoolean(false); // canRequestVMDeathEvent    os.writeBoolean(false); // canSetDefaultStratum    for (int i = 15; i < CAPABILITIES_NEW_SIZE; i++)      // Future capabilities      // currently unused      os.writeBoolean(false); // Set to false  }  private void executeRedefineClasses(ByteBuffer bb, DataOutputStream os)    throws JdwpException  {    // Optional command, don't implement    throw new NotImplementedException(      "Command VirtualMachine.RedefineClasses not implemented");  }  private void executeSetDefaultStratum(ByteBuffer bb, DataOutputStream os)    throws JdwpException  {    // Optional command, don't implement    throw new NotImplementedException(      "Command VirtualMachine.SetDefaultStratum not implemented");  }  private void executeAllClassesWithGeneric(ByteBuffer bb, DataOutputStream os)    throws JdwpException  {    // We don't handle generics    throw new NotImplementedException(      "Command VirtualMachine.AllClassesWithGeneric not implemented");  }  /**   * Find the root ThreadGroup of this ThreadGroup   */  private ThreadGroup getRootThreadGroup(ThreadGroup group)  {    ThreadGroup parent = group.getParent();    while (parent != null)      {        group = parent;        parent = group.getParent();      }    return group; // This group was the root  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -