Esempio n. 1
0
 /**
  * Routine for instantiating appropriately-typed wrapper for a JavaThread. Currently needs to be
  * public for OopUtilities to access it.
  */
 public JavaThread createJavaThreadWrapper(Address threadAddr) {
   try {
     JavaThread thread = (JavaThread) virtualConstructor.instantiateWrapperFor(threadAddr);
     thread.setThreadPDAccess(access);
     return thread;
   } catch (Exception e) {
     throw new RuntimeException(
         "Unable to deduce type of thread from address "
             + threadAddr
             + " (expected type JavaThread, CompilerThread, ServiceThread, JvmtiAgentThread or CodeCacheSweeperThread)",
         e);
   }
 }
Esempio n. 2
0
  private static synchronized void initialize(TypeDataBase db) {
    Type type = db.lookupType("Threads");

    threadListField = type.getAddressField("_thread_list");
    numOfThreadsField = type.getCIntegerField("_number_of_threads");

    // Instantiate appropriate platform-specific JavaThreadFactory
    String os = VM.getVM().getOS();
    String cpu = VM.getVM().getCPU();

    access = null;
    // FIXME: find the platform specific PD class by reflection?
    if (os.equals("solaris")) {
      if (cpu.equals("sparc")) {
        access = new SolarisSPARCJavaThreadPDAccess();
      } else if (cpu.equals("x86")) {
        access = new SolarisX86JavaThreadPDAccess();
      } else if (cpu.equals("amd64")) {
        access = new SolarisAMD64JavaThreadPDAccess();
      }
    } else if (os.equals("win32")) {
      if (cpu.equals("x86")) {
        access = new Win32X86JavaThreadPDAccess();
      } else if (cpu.equals("amd64")) {
        access = new Win32AMD64JavaThreadPDAccess();
      }
    } else if (os.equals("linux")) {
      if (cpu.equals("x86")) {
        access = new LinuxX86JavaThreadPDAccess();
      } else if (cpu.equals("amd64")) {
        access = new LinuxAMD64JavaThreadPDAccess();
      } else if (cpu.equals("sparc")) {
        access = new LinuxSPARCJavaThreadPDAccess();
      } else if (cpu.equals("ppc64")) {
        access = new LinuxPPC64JavaThreadPDAccess();
      } else if (cpu.equals("aarch64")) {
        access = new LinuxAARCH64JavaThreadPDAccess();
      } else {
        try {
          access =
              (JavaThreadPDAccess)
                  Class.forName(
                          "sun.jvm.hotspot.runtime.linux_"
                              + cpu.toLowerCase()
                              + ".Linux"
                              + cpu.toUpperCase()
                              + "JavaThreadPDAccess")
                      .newInstance();
        } catch (Exception e) {
          throw new RuntimeException("OS/CPU combination " + os + "/" + cpu + " not yet supported");
        }
      }
    } else if (os.equals("bsd")) {
      if (cpu.equals("x86")) {
        access = new BsdX86JavaThreadPDAccess();
      } else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
        access = new BsdAMD64JavaThreadPDAccess();
      }
    } else if (os.equals("darwin")) {
      if (cpu.equals("amd64") || cpu.equals("x86_64")) {
        access = new BsdAMD64JavaThreadPDAccess();
      }
    }

    if (access == null) {
      throw new RuntimeException("OS/CPU combination " + os + "/" + cpu + " not yet supported");
    }

    virtualConstructor = new VirtualConstructor(db);
    // Add mappings for all known thread types
    virtualConstructor.addMapping("JavaThread", JavaThread.class);
    if (!VM.getVM().isCore()) {
      virtualConstructor.addMapping("CompilerThread", CompilerThread.class);
      virtualConstructor.addMapping("CodeCacheSweeperThread", CodeCacheSweeperThread.class);
    }
    virtualConstructor.addMapping("JvmtiAgentThread", JvmtiAgentThread.class);
    virtualConstructor.addMapping("ServiceThread", ServiceThread.class);
  }