src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/windbg/ia64/WindbgIA64Thread.java
branchhttp-client-branch
changeset 55973 4d9b002587db
parent 55972 3fe2ae6d97a4
parent 48202 309dbeb79657
child 55977 a31a16b95f6f
equal deleted inserted replaced
55972:3fe2ae6d97a4 55973:4d9b002587db
     1 /*
       
     2  * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     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
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  *
       
    23  */
       
    24 
       
    25 package sun.jvm.hotspot.debugger.windbg.ia64;
       
    26 
       
    27 import sun.jvm.hotspot.debugger.*;
       
    28 import sun.jvm.hotspot.debugger.ia64.*;
       
    29 import sun.jvm.hotspot.debugger.windbg.*;
       
    30 
       
    31 class WindbgIA64Thread implements ThreadProxy {
       
    32   private WindbgDebugger debugger;
       
    33   private long           sysId;
       
    34   private boolean        gotID;
       
    35   private long           id;
       
    36 
       
    37   /** The address argument must be the address of the HANDLE of the
       
    38       desired thread in the target process. */
       
    39   WindbgIA64Thread(WindbgDebugger debugger, Address addr) {
       
    40     this.debugger = debugger;
       
    41     // FIXME: size of data fetched here should be configurable.
       
    42     // However, making it so would produce a dependency on the "types"
       
    43     // package from the debugger package, which is not desired.
       
    44 
       
    45     // another hack here is that we use sys thread id instead of handle.
       
    46     // windbg can't get details based on handles it seems.
       
    47     // I assume that osThread_win32 thread struct has _thread_id (which
       
    48     // sys thread id) just after handle field.
       
    49 
       
    50     this.sysId   = (int) addr.addOffsetTo(debugger.getAddressSize()).getCIntegerAt(0, 4, true);
       
    51     gotID = false;
       
    52   }
       
    53 
       
    54   WindbgIA64Thread(WindbgDebugger debugger, long sysId) {
       
    55     this.debugger = debugger;
       
    56     this.sysId    = sysId;
       
    57     gotID         = false;
       
    58   }
       
    59 
       
    60   public ThreadContext getContext() throws IllegalThreadStateException {
       
    61     long[] data = debugger.getThreadIntegerRegisterSet(getThreadID());
       
    62     WindbgIA64ThreadContext context = new WindbgIA64ThreadContext(debugger);
       
    63     for (int i = 0; i < data.length; i++) {
       
    64       context.setRegister(i, data[i]);
       
    65     }
       
    66     return context;
       
    67   }
       
    68 
       
    69   public boolean canSetContext() throws DebuggerException {
       
    70     return false;
       
    71   }
       
    72 
       
    73   public void setContext(ThreadContext thrCtx)
       
    74     throws IllegalThreadStateException, DebuggerException {
       
    75     throw new DebuggerException("Unimplemented");
       
    76   }
       
    77 
       
    78   public boolean equals(Object obj) {
       
    79     if ((obj == null) || !(obj instanceof WindbgIA64Thread)) {
       
    80       return false;
       
    81     }
       
    82 
       
    83     return (((WindbgIA64Thread) obj).getThreadID() == getThreadID());
       
    84   }
       
    85 
       
    86   public int hashCode() {
       
    87     return (int) getThreadID();
       
    88   }
       
    89 
       
    90   public String toString() {
       
    91     return Long.toString(getThreadID());
       
    92   }
       
    93 
       
    94   /** Retrieves the thread ID of this thread by examining the Thread
       
    95       Information Block. */
       
    96   private long getThreadID() {
       
    97     if (!gotID) {
       
    98        id = debugger.getThreadIdFromSysId(sysId);
       
    99     }
       
   100 
       
   101     return id;
       
   102   }
       
   103 }