src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebuggerLocal.java
author ysuenaga
Mon, 04 Nov 2019 22:31:59 +0900
changeset 58913 e2dfab7beccb
parent 53379 e47074d2d8cc
permissions -rw-r--r--
8233285: Demangling C++ symbols in jhsdb jstack --mixed Reviewed-by: cjplummer, sspitsyn, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53379
e47074d2d8cc 8181313: SA: Remove libthread_db dependency on Linux
ysuenaga
parents: 51203
diff changeset
     2
 * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 670
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
package sun.jvm.hotspot.debugger.linux;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
17310
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    27
import java.io.File;
51203
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
    28
import java.io.IOException;
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
    29
import java.io.UncheckedIOException;
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
    30
import java.nio.file.Files;
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
    31
import java.nio.file.Path;
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
    32
import java.nio.file.Paths;
17310
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    33
import java.util.ArrayList;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    34
import java.util.List;
51203
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
    35
import java.util.Map;
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
    36
import java.util.NoSuchElementException;
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
    37
import java.util.stream.Collectors;
17310
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    38
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    39
import sun.jvm.hotspot.debugger.Address;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    40
import sun.jvm.hotspot.debugger.DebuggerBase;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    41
import sun.jvm.hotspot.debugger.DebuggerException;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    42
import sun.jvm.hotspot.debugger.DebuggerUtilities;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    43
import sun.jvm.hotspot.debugger.MachineDescription;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    44
import sun.jvm.hotspot.debugger.NotInHeapException;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    45
import sun.jvm.hotspot.debugger.OopHandle;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    46
import sun.jvm.hotspot.debugger.ReadResult;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    47
import sun.jvm.hotspot.debugger.ThreadProxy;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    48
import sun.jvm.hotspot.debugger.UnalignedAddressException;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    49
import sun.jvm.hotspot.debugger.UnmappedAddressException;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    50
import sun.jvm.hotspot.debugger.cdbg.CDebugger;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    51
import sun.jvm.hotspot.debugger.cdbg.ClosestSymbol;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    52
import sun.jvm.hotspot.debugger.cdbg.LoadObject;
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
    53
import sun.jvm.hotspot.utilities.PlatformInfo;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
/** <P> An implementation of the JVMDebugger interface. The basic debug
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    facilities are implemented through ptrace interface in the JNI code
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    (libsaproc.so). Library maps and symbol table management are done in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    JNI. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    <P> <B>NOTE</B> that since we have the notion of fetching "Java
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    primitive types" from the remote process (which might have
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    different sizes than we expect) we have a bootstrapping
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    problem. We need to know the sizes of these types before we can
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    fetch them. The current implementation solves this problem by
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    requiring that it be configured with these type sizes before they
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    can be fetched. The readJ(Type) routines here will throw a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    RuntimeException if they are called before the debugger is
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    configured with the Java primitive type sizes. </P> */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
public class LinuxDebuggerLocal extends DebuggerBase implements LinuxDebugger {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    private boolean useGCC32ABI;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    private boolean attached;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    private long    p_ps_prochandle; // native debugger handle
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    private boolean isCore;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    // CDebugger support
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    private LinuxCDebugger cdbg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    // threadList and loadObjectList are filled by attach0 method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    private List threadList;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    private List loadObjectList;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
51203
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
    83
    // PID namespace support
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
    84
    // It maps the LWPID in the host to the LWPID in the container.
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
    85
    private Map<Integer, Integer> nspidMap;
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
    86
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    // called by native method lookupByAddress0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    private ClosestSymbol createClosestSymbol(String name, long offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
       return new ClosestSymbol(name, offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    // called by native method attach0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    private LoadObject createLoadObject(String fileName, long textsize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
                                        long base) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
       File f = new File(fileName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
       Address baseAddr = newAddress(base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
       return new SharedObject(this, fileName, f.length(), baseAddr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    // native methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    private native static void init0()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
                                throws DebuggerException;
51203
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   104
    private native void setSAAltRoot0(String altroot);
53379
e47074d2d8cc 8181313: SA: Remove libthread_db dependency on Linux
ysuenaga
parents: 51203
diff changeset
   105
    private native void attach0(int pid)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
                                throws DebuggerException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    private native void attach0(String execName, String coreName)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
                                throws DebuggerException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    private native void detach0()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
                                throws DebuggerException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    private native long lookupByName0(String objectName, String symbol)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
                                throws DebuggerException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    private native ClosestSymbol lookupByAddress0(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
                                throws DebuggerException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    private native long[] getThreadIntegerRegisterSet0(int lwp_id)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
                                throws DebuggerException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    private native byte[] readBytesFromProcess0(long address, long numBytes)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
                                throws DebuggerException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    public native static int  getAddressSize() ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
58913
e2dfab7beccb 8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents: 53379
diff changeset
   121
    @Override
e2dfab7beccb 8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents: 53379
diff changeset
   122
    public native String demangle(String sym);
e2dfab7beccb 8233285: Demangling C++ symbols in jhsdb jstack --mixed
ysuenaga
parents: 53379
diff changeset
   123
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    // Note on Linux threads are really processes. When target process is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    // attached by a serviceability agent thread, only that thread can do
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    // ptrace operations on the target. This is because from kernel's point
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    // view, other threads are just separate processes and they are not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    // attached to the target. When they attempt to make ptrace calls,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    // an ESRCH error will be returned as kernel believes target is not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    // being traced by the caller.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    // To work around the problem, we use a worker thread here to handle
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    // all JNI functions that are making ptrace calls.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    interface WorkerThreadTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
       public void doit(LinuxDebuggerLocal debugger) throws DebuggerException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    class LinuxDebuggerLocalWorkerThread extends Thread {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
       LinuxDebuggerLocal debugger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
       WorkerThreadTask task;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
       DebuggerException lastException;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
       public LinuxDebuggerLocalWorkerThread(LinuxDebuggerLocal debugger) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
         this.debugger = debugger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
         setDaemon(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
       public void run() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
          synchronized (workerThread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
             for (;;) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
                if (task != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
                   lastException = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
                   try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
                      task.doit(debugger);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
                   } catch (DebuggerException exp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
                      lastException = exp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
                   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
                   task = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
                   workerThread.notifyAll();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
                try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
                   workerThread.wait();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
                } catch (InterruptedException x) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
             }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
       public WorkerThreadTask execute(WorkerThreadTask task) throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
          synchronized (workerThread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
             this.task = task;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
             workerThread.notifyAll();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
             while (this.task != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
                try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
                   workerThread.wait();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
                } catch (InterruptedException x) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
             }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
             if (lastException != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
                throw new DebuggerException(lastException);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
             } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
                return task;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
             }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    private LinuxDebuggerLocalWorkerThread workerThread = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    //----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    // Implementation of Debugger interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    /** <P> machDesc may not be null. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    <P> useCache should be set to true if debugging is being done
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    locally, and to false if the debugger is being created for the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    purpose of supporting remote debugging. </P> */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    public LinuxDebuggerLocal(MachineDescription machDesc,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
                              boolean useCache) throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
        this.machDesc = machDesc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
        utils = new DebuggerUtilities(machDesc.getAddressSize(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
                                      machDesc.isBigEndian()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
           public void checkAlignment(long address, long alignment) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
             // Need to override default checkAlignment because we need to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
             // relax alignment constraints on Linux/x86
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
             if ( (address % alignment != 0)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
                &&(alignment != 8 || address % 4 != 0)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
                throw new UnalignedAddressException(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
                        "Trying to read at address: "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
                      + addressValueToString(address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
                      + " with alignment: " + alignment,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
                        address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
             }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
           }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
        };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
        if (useCache) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
            // FIXME: re-test necessity of cache on Linux, where data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
            // fetching is faster
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
            // Cache portion of the remote process's address space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
            // Fetching data over the socket connection to dbx is slow.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
            // Might be faster if we were using a binary protocol to talk to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
            // dbx, but would have to test. For now, this cache works best
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
            // if it covers the entire heap of the remote process. FIXME: at
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
            // least should make this tunable from the outside, i.e., via
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
            // the UI. This is a cache of 4096 4K pages, or 16 MB. The page
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
            // size must be adjusted to be the hardware's page size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
            // (FIXME: should pick this up from the debugger.)
48166
2659c4fe8ea7 8191324: SA cleanup -- part 2
jgeorge
parents: 47216
diff changeset
   229
            initCache(4096, parseCacheNumPagesProperty(4096));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
        workerThread = new LinuxDebuggerLocalWorkerThread(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
        workerThread.start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    /** From the Debugger interface via JVMDebugger */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    public boolean hasProcessList() throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    /** From the Debugger interface via JVMDebugger */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    public List getProcessList() throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
        throw new DebuggerException("getProcessList not implemented yet");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    private void checkAttached() throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
        if (attached) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
            if (isCore) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
                throw new DebuggerException("attached to a core dump already");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
            } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
                throw new DebuggerException("attached to a process already");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
    private void requireAttach() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
        if (! attached) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
            throw new RuntimeException("not attached to a process or a core!");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    /* called from attach methods */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    private void findABIVersion() throws DebuggerException {
17310
b4118c427cc0 8005038: remove crufty '_g' support from SA
sla
parents: 13969
diff changeset
   264
        if (lookupByName0("libjvm.so", "__vt_10JavaThread") != 0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
            // old C++ ABI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
            useGCC32ABI = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
            // new C++ ABI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
            useGCC32ABI = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
51203
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   273
    // Get namespace PID from /proc/<PID>/status.
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   274
    private int getNamespacePID(Path statusPath) {
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   275
        try (var lines = Files.lines(statusPath)) {
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   276
            return lines.map(s -> s.split("\\s+"))
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   277
                        .filter(a -> a.length == 3)
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   278
                        .filter(a -> a[0].equals("NSpid:"))
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   279
                        .mapToInt(a -> Integer.valueOf(a[2]))
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   280
                        .findFirst()
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   281
                        .getAsInt();
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   282
        } catch (IOException | NoSuchElementException e) {
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   283
            return Integer.valueOf(statusPath.getParent()
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   284
                                             .toFile()
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   285
                                             .getName());
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   286
        }
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   287
    }
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   288
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   289
    // Get LWPID in the host from the container's LWPID.
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   290
    // Returns -1 if the process is running in the host.
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   291
    public int getHostPID(int id) {
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   292
        return (nspidMap == null) ? -1 : nspidMap.get(id);
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   293
    }
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   294
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   295
    // Fill namespace PID map from procfs.
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   296
    // This method scans all tasks (/proc/<PID>/task) in the process.
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   297
    private void fillNSpidMap(Path proc) {
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   298
        Path task = Paths.get(proc.toString(), "task");
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   299
        try (var tasks = Files.list(task)) {
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   300
            nspidMap = tasks.filter(p -> !p.toString().startsWith("."))
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   301
                            .collect(Collectors.toMap(p -> Integer.valueOf(getNamespacePID(Paths.get(p.toString(), "status"))),
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   302
                                                      p -> Integer.valueOf(p.toFile().getName())));
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   303
        } catch (IOException e) {
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   304
            throw new UncheckedIOException(e);
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   305
        }
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   306
    }
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   307
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    /** From the Debugger interface via JVMDebugger */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    public synchronized void attach(int processID) throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
        checkAttached();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
        threadList = new ArrayList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
        loadObjectList = new ArrayList();
51203
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   313
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   314
        Path proc = Paths.get("/proc", Integer.toString(processID));
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   315
        int NSpid = getNamespacePID(Paths.get(proc.toString(), "status"));
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   316
        if (NSpid != processID) {
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   317
            // If PID different from namespace PID, we can assume the process
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   318
            // is running in the container.
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   319
            // So we need to set SA_ALTROOT environment variable that SA reads
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   320
            // binaries in the container.
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   321
            setSAAltRoot0(Paths.get(proc.toString(), "root").toString());
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   322
            fillNSpidMap(proc);
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   323
        }
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 48166
diff changeset
   324
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
        class AttachTask implements WorkerThreadTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
           int pid;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
           public void doit(LinuxDebuggerLocal debugger) {
53379
e47074d2d8cc 8181313: SA: Remove libthread_db dependency on Linux
ysuenaga
parents: 51203
diff changeset
   328
              debugger.attach0(pid);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
              debugger.attached = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
              debugger.isCore = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
              findABIVersion();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
           }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
        AttachTask task = new AttachTask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
        task.pid = processID;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
        workerThread.execute(task);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
    /** From the Debugger interface via JVMDebugger */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    public synchronized void attach(String execName, String coreName) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
        checkAttached();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
        threadList = new ArrayList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
        loadObjectList = new ArrayList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
        attach0(execName, coreName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
        attached = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
        isCore = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
        findABIVersion();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    /** From the Debugger interface via JVMDebugger */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
    public synchronized boolean detach() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
        if (!attached) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
            return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
        threadList = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
        loadObjectList = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
        if (isCore) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
            detach0();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
            attached = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
            return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
            class DetachTask implements WorkerThreadTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
                boolean result = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
                public void doit(LinuxDebuggerLocal debugger) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
                    debugger.detach0();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
                    debugger.attached = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
                    result = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
            DetachTask task = new DetachTask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
            workerThread.execute(task);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
            return task.result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
    /** From the Debugger interface via JVMDebugger */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    public Address parseAddress(String addressString)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
            throws NumberFormatException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
        long addr = utils.scanAddress(addressString);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
        if (addr == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
            return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
        return new LinuxAddress(this, addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
    /** From the Debugger interface via JVMDebugger */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
    public String getOS() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
        return PlatformInfo.getOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
    /** From the Debugger interface via JVMDebugger */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
    public String getCPU() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
        return PlatformInfo.getCPU();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
    public boolean hasConsole() throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
    public String consoleExecuteCommand(String cmd) throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
        throw new DebuggerException("No debugger console available on Linux");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    public String getConsolePrompt() throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
        return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
    /* called from lookup */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    private long handleGCC32ABI(long addr, String symbol) throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
        if (useGCC32ABI && symbol.startsWith("_ZTV")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
            return addr + (2 * machDesc.getAddressSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
            return addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
    /** From the SymbolLookup interface via Debugger and JVMDebugger */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
    public synchronized Address lookup(String objectName, String symbol) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
        requireAttach();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
        if (!attached) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
            return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
        if (isCore) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
            long addr = lookupByName0(objectName, symbol);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
            return (addr == 0)? null : new LinuxAddress(this, handleGCC32ABI(addr, symbol));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
            class LookupByNameTask implements WorkerThreadTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
                String objectName, symbol;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
                Address result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
                public void doit(LinuxDebuggerLocal debugger) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
                    long addr = debugger.lookupByName0(objectName, symbol);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
                    result = (addr == 0 ? null : new LinuxAddress(debugger, handleGCC32ABI(addr, symbol)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
            LookupByNameTask task = new LookupByNameTask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
            task.objectName = objectName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
            task.symbol = symbol;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
            workerThread.execute(task);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
            return task.result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
    /** From the SymbolLookup interface via Debugger and JVMDebugger */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    public synchronized OopHandle lookupOop(String objectName, String symbol) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
        Address addr = lookup(objectName, symbol);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
        if (addr == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
            return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
        return addr.addOffsetToAsOopHandle(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
    /** From the Debugger interface */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
    public MachineDescription getMachineDescription() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
        return machDesc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
    //----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
    // Implementation of ThreadAccess interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
    /** From the ThreadAccess interface via Debugger and JVMDebugger */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
    public ThreadProxy getThreadForIdentifierAddress(Address addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
        return new LinuxThread(this, addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
    /** From the ThreadAccess interface via Debugger and JVMDebugger */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
    public ThreadProxy getThreadForThreadId(long id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
        return new LinuxThread(this, id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
    //----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
    // Internal routines (for implementation of LinuxAddress).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
    // These must not be called until the MachineDescription has been set up.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
    /** From the LinuxDebugger interface */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
    public String addressValueToString(long address) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
        return utils.addressValueToString(address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
    /** From the LinuxDebugger interface */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
    public LinuxAddress readAddress(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
            throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
        long value = readAddressValue(address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
        return (value == 0 ? null : new LinuxAddress(this, value));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
    }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   495
    public LinuxAddress readCompOopAddress(long address)
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   496
            throws UnmappedAddressException, UnalignedAddressException {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   497
        long value = readCompOopAddressValue(address);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   498
        return (value == 0 ? null : new LinuxAddress(this, value));
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   499
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   501
    public LinuxAddress readCompKlassAddress(long address)
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   502
            throws UnmappedAddressException, UnalignedAddressException {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   503
        long value = readCompKlassAddressValue(address);
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   504
        return (value == 0 ? null : new LinuxAddress(this, value));
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   505
    }
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   506
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
    /** From the LinuxDebugger interface */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
    public LinuxOopHandle readOopHandle(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
            throws UnmappedAddressException, UnalignedAddressException,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
                NotInHeapException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
        long value = readAddressValue(address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
        return (value == 0 ? null : new LinuxOopHandle(this, value));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
    }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   514
    public LinuxOopHandle readCompOopHandle(long address)
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   515
            throws UnmappedAddressException, UnalignedAddressException,
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   516
                NotInHeapException {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   517
        long value = readCompOopAddressValue(address);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   518
        return (value == 0 ? null : new LinuxOopHandle(this, value));
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   519
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
    //----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
    // Thread context access
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
    public synchronized long[] getThreadIntegerRegisterSet(int lwp_id)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
                                            throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
        requireAttach();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
        if (isCore) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
            return getThreadIntegerRegisterSet0(lwp_id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
            class GetThreadIntegerRegisterSetTask implements WorkerThreadTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
                int lwp_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
                long[] result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
                public void doit(LinuxDebuggerLocal debugger) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
                    result = debugger.getThreadIntegerRegisterSet0(lwp_id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
            GetThreadIntegerRegisterSetTask task = new GetThreadIntegerRegisterSetTask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
            task.lwp_id = lwp_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
            workerThread.execute(task);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
            return task.result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
    /** Need to override this to relax alignment checks on x86. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
    public long readCInteger(long address, long numBytes, boolean isUnsigned)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
        throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
        // Only slightly relaxed semantics -- this is a hack, but is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
        // necessary on x86 where it seems the compiler is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
        // putting some global 64-bit data on 32-bit boundaries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
        if (numBytes == 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
            utils.checkAlignment(address, 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
            utils.checkAlignment(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
        byte[] data = readBytes(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
        return utils.dataToCInteger(data, isUnsigned);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
    // Overridden from DebuggerBase because we need to relax alignment
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
    // constraints on x86
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
    public long readJLong(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
        throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
        utils.checkAlignment(address, jintSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
        byte[] data = readBytes(address, jlongSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
        return utils.dataToJLong(data, jlongSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
    //----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
    // Address access. Can not be package private, but should only be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
    // accessed by the architecture-specific subpackages.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
    /** From the LinuxDebugger interface */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
    public long getAddressValue(Address addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
      if (addr == null) return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
      return ((LinuxAddress) addr).getValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
    /** From the LinuxDebugger interface */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
    public Address newAddress(long value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
      if (value == 0) return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
      return new LinuxAddress(this, value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
    /** From the LinuxCDebugger interface */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
    public List/*<ThreadProxy>*/ getThreadList() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
      requireAttach();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
      return threadList;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
    /** From the LinuxCDebugger interface */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
    public List/*<LoadObject>*/ getLoadObjectList() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
      requireAttach();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
      return loadObjectList;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
    /** From the LinuxCDebugger interface */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
    public synchronized ClosestSymbol lookup(long addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
       requireAttach();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
       if (isCore) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
          return lookupByAddress0(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
       } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
          class LookupByAddressTask implements WorkerThreadTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
             long addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
             ClosestSymbol result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
             public void doit(LinuxDebuggerLocal debugger) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
                 result = debugger.lookupByAddress0(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
             }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
          LookupByAddressTask task = new LookupByAddressTask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
          task.addr = addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
          workerThread.execute(task);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
          return task.result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
    public CDebugger getCDebugger() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
      if (cdbg == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
         cdbg = new LinuxCDebugger(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
      return cdbg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
    /** This reads bytes from the remote process. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
    public synchronized ReadResult readBytesFromProcess(long address,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
            long numBytes) throws UnmappedAddressException, DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
        requireAttach();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
        if (isCore) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
            byte[] res = readBytesFromProcess0(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
            return (res != null)? new ReadResult(res) : new ReadResult(address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
            class ReadBytesFromProcessTask implements WorkerThreadTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
                long address, numBytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
                ReadResult result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
                public void doit(LinuxDebuggerLocal debugger) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
                    byte[] res = debugger.readBytesFromProcess0(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
                    if (res != null)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
                        result = new ReadResult(res);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
                    else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
                        result = new ReadResult(address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
            ReadBytesFromProcessTask task = new ReadBytesFromProcessTask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
            task.address = address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
            task.numBytes = numBytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
            workerThread.execute(task);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
            return task.result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
    public void writeBytesToProcess(long address, long numBytes, byte[] data)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
        throws UnmappedAddressException, DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
        // FIXME
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
        throw new DebuggerException("Unimplemented");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
    static {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
        System.loadLibrary("saproc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
        init0();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
}