public OopHandle getOopHandle(int x) {
   Address oopAddr = getOopHandleAddress(x);
   if (oopAddr != null) {
     return oopAddr.getOopHandleAt(0);
   }
   return null;
 }
Exemplo n.º 2
0
  public ThreadProxy getThreadProxy(Address addr) {
    // Addr is the address of the JavaThread.
    // Fetch the OSThread (for now and for simplicity, not making a
    // separate "OSThread" class in this package)
    Address osThreadAddr = osThreadField.getValue(addr);
    // Get the address of the _thread_id from the OSThread
    Address threadIdAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset());

    JVMDebugger debugger = VM.getVM().getDebugger();
    return debugger.getThreadForIdentifierAddress(threadIdAddr);
  }
 /**
  * Debugging routine: returns the index (0..top() - 1) of the handle in this block, or -1 if the
  * handle was not contained in this block. Does not search successor blocks.
  */
 public int indexOfHandle(Address jniHandle) {
   for (int i = 0; i < top(); i++) {
     Address addr = getOopHandleAddress(i);
     if (addr != null) {
       if (addr.equals(jniHandle)) {
         return i;
       }
     }
   }
   return -1;
 }
  /** Only returns addresses of valid OopHandles */
  private Address getOopHandleAddress(int x) {
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(x < top(), "out of bounds");
    }

    Address oopAddr = addr.addOffsetTo(handlesField.getOffset() + x * VM.getVM().getOopSize());
    OopHandle handle = oopAddr.getOopHandleAt(0);
    if (VM.getVM().getUniverse().isInReserved(handle)
        && !VM.getVM().getJNIHandles().isDeletedHandle(handle)) {
      /* the oop handle is valid only if it is not freed (i.e. reserved in heap) and is not a deleted oop */
      return oopAddr;
    } else {
      return null;
    }
  }
Exemplo n.º 5
0
  public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException {
    if (pc == null) {
      return null;
    }
    List objs = getLoadObjectList();
    Object[] arr = objs.toArray();
    // load objects are sorted by base address, do binary search
    int mid = -1;
    int low = 0;
    int high = arr.length - 1;

    while (low <= high) {
      mid = (low + high) >> 1;
      LoadObject midVal = (LoadObject) arr[mid];
      long cmp = pc.minus(midVal.getBase());
      if (cmp < 0) {
        high = mid - 1;
      } else if (cmp > 0) {
        long size = midVal.getSize();
        if (cmp >= size) {
          low = mid + 1;
        } else {
          return (LoadObject) arr[mid];
        }
      } else { // match found
        return (LoadObject) arr[mid];
      }
    }
    // no match found.
    return null;
  }
Exemplo n.º 6
0
  public DbxSPARCThread(DbxDebugger debugger, Address addr) {
    this.debugger = debugger;

    // FIXME: the size here should be configurable. However, making it
    // so would produce a dependency on the "types" package from the
    // debugger package, which is not desired.
    this.id = (int) addr.getCIntegerAt(0, 4, true);
  }
 public void visitCompOopAddress(Address addr) {
   Oop next = heap.newOop(addr.getCompOopHandleAt(0));
   LivenessPathElement lp =
       new LivenessPathElement(
           null, new NamedFieldIdentifier(baseRootDescription + " @ " + addr));
   rp.put(lp, next);
   markAndTraverse(next);
 }
Exemplo n.º 8
0
  // refer to Threads::owning_thread_from_monitor_owner
  public JavaThread owningThreadFromMonitor(Address o) {
    if (o == null) return null;
    for (JavaThread thread = first(); thread != null; thread = thread.next()) {
      if (o.equals(thread.threadObjectAddress())) {
        return thread;
      }
    }

    for (JavaThread thread = first(); thread != null; thread = thread.next()) {
      if (thread.isLockOwned(o)) return thread;
    }
    return null;
  }
Exemplo n.º 9
0
 public Address getLastJavaFP(Address addr) {
   return lastJavaFPField.getValue(
       addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset()));
 }