src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/win32_x86/Win32X86JavaThreadPDAccess.java
changeset 47816 ac0af7750da9
parent 47216 71c04702a3d5
equal deleted inserted replaced
47815:87f114c6a99f 47816:ac0af7750da9
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    40 public class Win32X86JavaThreadPDAccess implements JavaThreadPDAccess {
    40 public class Win32X86JavaThreadPDAccess implements JavaThreadPDAccess {
    41   private static AddressField  lastJavaFPField;
    41   private static AddressField  lastJavaFPField;
    42   private static AddressField  osThreadField;
    42   private static AddressField  osThreadField;
    43 
    43 
    44   // Field from OSThread
    44   // Field from OSThread
    45   private static Field         osThreadThreadIdField;
    45   private static Field         threadIdField;
    46 
    46 
    47   // This is currently unneeded but is being kept in case we change
    47   // This is currently unneeded but is being kept in case we change
    48   // the currentFrameGuess algorithm
    48   // the currentFrameGuess algorithm
    49   private static final long GUESS_SCAN_RANGE = 128 * 1024;
    49   private static final long GUESS_SCAN_RANGE = 128 * 1024;
    50 
    50 
    61     Type anchorType = db.lookupType("JavaFrameAnchor");
    61     Type anchorType = db.lookupType("JavaFrameAnchor");
    62     lastJavaFPField         = anchorType.getAddressField("_last_Java_fp");
    62     lastJavaFPField         = anchorType.getAddressField("_last_Java_fp");
    63     osThreadField           = type.getAddressField("_osthread");
    63     osThreadField           = type.getAddressField("_osthread");
    64 
    64 
    65     type = db.lookupType("OSThread");
    65     type = db.lookupType("OSThread");
    66     osThreadThreadIdField = type.getField("_thread_id");
    66     threadIdField = type.getField("_thread_id");
    67   }
    67   }
    68 
    68 
    69   public Address getLastJavaFP(Address addr) {
    69   public Address getLastJavaFP(Address addr) {
    70     return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset()));
    70     return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset()));
    71   }
    71   }
   127     // Fetch the OSThread (for now and for simplicity, not making a
   127     // Fetch the OSThread (for now and for simplicity, not making a
   128     // separate "OSThread" class in this package)
   128     // separate "OSThread" class in this package)
   129     Address osThreadAddr = osThreadField.getValue(addr);
   129     Address osThreadAddr = osThreadField.getValue(addr);
   130     // Get the address of the thread_id within the OSThread
   130     // Get the address of the thread_id within the OSThread
   131     Address threadIdAddr =
   131     Address threadIdAddr =
   132       osThreadAddr.addOffsetTo(osThreadThreadIdField.getOffset());
   132       osThreadAddr.addOffsetTo(threadIdField.getOffset());
   133     JVMDebugger debugger = VM.getVM().getDebugger();
   133     JVMDebugger debugger = VM.getVM().getDebugger();
   134     return debugger.getThreadForIdentifierAddress(threadIdAddr);
   134     return debugger.getThreadForIdentifierAddress(threadIdAddr);
   135   }
   135   }
   136 }
   136 }