src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.c
author ysuenaga
Fri, 27 Jul 2018 00:54:39 +0900
changeset 51203 220c9188db4f
parent 47216 71c04702a3d5
child 53379 e47074d2d8cc
permissions -rw-r--r--
8205992: jhsdb cannot attach to Java processes running in Docker containers Reviewed-by: cjplummer, jgeorge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
51203
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
     2
 * Copyright (c) 2002, 2018, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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
#include <jni.h>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "libproc.h"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
15850
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
    28
#include <elf.h>
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
    29
#include <sys/types.h>
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
    30
#include <sys/stat.h>
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
    31
#include <fcntl.h>
20295
a5dd1b071c32 8025613: clang: remove -Wno-unused-value
twisti
parents: 15850
diff changeset
    32
#include <stdlib.h>
15850
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
    33
#include <string.h>
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
    34
#include <limits.h>
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
    35
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
#if defined(x86_64) && !defined(amd64)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
#define amd64 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
#ifdef i386
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
#include "sun_jvm_hotspot_debugger_x86_X86ThreadContext.h"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
#ifdef amd64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
#include "sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext.h"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
#if defined(sparc) || defined(sparcv9)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
#include "sun_jvm_hotspot_debugger_sparc_SPARCThreadContext.h"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
35075
ca79cbf3f106 8073139: PPC64: User-visible arch directory and os.arch value on ppc64le cause issues with Java tooling
asmundak
parents: 35049
diff changeset
    52
#if defined(ppc64) || defined(ppc64le)
28369
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
    53
#include "sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext.h"
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
    54
#endif
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
    55
31399
167037a29ab4 8078521: AARCH64: Add AArch64 SA support
aph
parents: 29185
diff changeset
    56
#ifdef aarch64
167037a29ab4 8078521: AARCH64: Add AArch64 SA support
aph
parents: 29185
diff changeset
    57
#include "sun_jvm_hotspot_debugger_aarch64_AARCH64ThreadContext.h"
167037a29ab4 8078521: AARCH64: Add AArch64 SA support
aph
parents: 29185
diff changeset
    58
#endif
167037a29ab4 8078521: AARCH64: Add AArch64 SA support
aph
parents: 29185
diff changeset
    59
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
static jfieldID p_ps_prochandle_ID = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
static jfieldID threadList_ID = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
static jfieldID loadObjectList_ID = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
static jmethodID createClosestSymbol_ID = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
static jmethodID createLoadObject_ID = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
static jmethodID getThreadForThreadId_ID = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
static jmethodID listAdd_ID = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
51203
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
    69
/*
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
    70
 * SA_ALTROOT environment variable.
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
    71
 * This memory holds env string for putenv(3).
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
    72
 */
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
    73
static char *saaltroot = NULL;
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
    74
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
#define CHECK_EXCEPTION_(value) if ((*env)->ExceptionOccurred(env)) { return value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
#define CHECK_EXCEPTION if ((*env)->ExceptionOccurred(env)) { return;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
#define THROW_NEW_DEBUGGER_EXCEPTION_(str, value) { throw_new_debugger_exception(env, str); return value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
#define THROW_NEW_DEBUGGER_EXCEPTION(str) { throw_new_debugger_exception(env, str); return;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
13529
dc25e69fd16d 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 5547
diff changeset
    80
void throw_new_debugger_exception(JNIEnv* env, const char* errMsg) {
26411
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
    81
  jclass clazz;
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
    82
  clazz = (*env)->FindClass(env, "sun/jvm/hotspot/debugger/DebuggerException");
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
    83
  CHECK_EXCEPTION;
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
    84
  (*env)->ThrowNew(env, clazz, errMsg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
13529
dc25e69fd16d 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 5547
diff changeset
    87
struct ps_prochandle* get_proc_handle(JNIEnv* env, jobject this_obj) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  jlong ptr = (*env)->GetLongField(env, this_obj, p_ps_prochandle_ID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  return (struct ps_prochandle*)(intptr_t)ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
 * Class:     sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
 * Method:    init0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
 * Signature: ()V
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_init0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  (JNIEnv *env, jclass cls) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  jclass listClass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
20295
a5dd1b071c32 8025613: clang: remove -Wno-unused-value
twisti
parents: 15850
diff changeset
   101
  if (init_libproc(getenv("LIBSAPROC_DEBUG") != NULL) != true) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
     THROW_NEW_DEBUGGER_EXCEPTION("can't initialize libproc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  // fields we use
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  p_ps_prochandle_ID = (*env)->GetFieldID(env, cls, "p_ps_prochandle", "J");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  threadList_ID = (*env)->GetFieldID(env, cls, "threadList", "Ljava/util/List;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  loadObjectList_ID = (*env)->GetFieldID(env, cls, "loadObjectList", "Ljava/util/List;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // methods we use
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  createClosestSymbol_ID = (*env)->GetMethodID(env, cls, "createClosestSymbol",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
                    "(Ljava/lang/String;J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  createLoadObject_ID = (*env)->GetMethodID(env, cls, "createLoadObject",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
                    "(Ljava/lang/String;JJ)Lsun/jvm/hotspot/debugger/cdbg/LoadObject;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  getThreadForThreadId_ID = (*env)->GetMethodID(env, cls, "getThreadForThreadId",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
                                                     "(J)Lsun/jvm/hotspot/debugger/ThreadProxy;");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // java.util.List method we call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  listClass = (*env)->FindClass(env, "java/util/List");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  listAdd_ID = (*env)->GetMethodID(env, listClass, "add", "(Ljava/lang/Object;)Z");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
JNIEXPORT jint JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_getAddressSize
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  (JNIEnv *env, jclass cls)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
 return 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
 return 4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
static void fillThreadsAndLoadObjects(JNIEnv* env, jobject this_obj, struct ps_prochandle* ph) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  int n = 0, i = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  // add threads
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  n = get_num_threads(ph);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  for (i = 0; i < n; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    jobject thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    jobject threadList;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    lwpid_t lwpid;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    lwpid = get_lwp_id(ph, i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    thread = (*env)->CallObjectMethod(env, this_obj, getThreadForThreadId_ID,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
                                      (jlong)lwpid);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    threadList = (*env)->GetObjectField(env, this_obj, threadList_ID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    (*env)->CallBooleanMethod(env, threadList, listAdd_ID, thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  // add load objects
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  n = get_num_libs(ph);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  for (i = 0; i < n; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
     uintptr_t base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
     const char* name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
     jobject loadObject;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
     jobject loadObjectList;
26411
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
   169
     jstring str;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
     base = get_lib_base(ph, i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
     name = get_lib_name(ph, i);
26411
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
   173
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
   174
     str = (*env)->NewStringUTF(env, name);
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
   175
     CHECK_EXCEPTION;
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
   176
     loadObject = (*env)->CallObjectMethod(env, this_obj, createLoadObject_ID, str, (jlong)0, (jlong)base);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
     CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
     loadObjectList = (*env)->GetObjectField(env, this_obj, loadObjectList_ID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
     CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
     (*env)->CallBooleanMethod(env, loadObjectList, listAdd_ID, loadObject);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
     CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
15850
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   185
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   186
/*
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   187
 * Verify that a named ELF binary file (core or executable) has the same
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   188
 * bitness as ourselves.
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   189
 * Throw an exception if there is a mismatch or other problem.
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   190
 *
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   191
 * If we proceed using a mismatched debugger/debuggee, the best to hope
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   192
 * for is a missing symbol, the worst is a crash searching for debug symbols.
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   193
 */
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   194
void verifyBitness(JNIEnv *env, const char *binaryName) {
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   195
  int fd = open(binaryName, O_RDONLY);
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   196
  if (fd < 0) {
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   197
    THROW_NEW_DEBUGGER_EXCEPTION("cannot open binary file");
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   198
  }
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   199
  unsigned char elf_ident[EI_NIDENT];
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   200
  int i = read(fd, &elf_ident, sizeof(elf_ident));
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   201
  close(fd);
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   202
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   203
  if (i < 0) {
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   204
    THROW_NEW_DEBUGGER_EXCEPTION("cannot read binary file");
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   205
  }
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   206
#ifndef _LP64
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   207
  if (elf_ident[EI_CLASS] == ELFCLASS64) {
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   208
    THROW_NEW_DEBUGGER_EXCEPTION("debuggee is 64 bit, use 64-bit java for debugger");
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   209
  }
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   210
#else
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   211
  if (elf_ident[EI_CLASS] != ELFCLASS64) {
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   212
    THROW_NEW_DEBUGGER_EXCEPTION("debuggee is 32 bit, use 32 bit java for debugger");
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   213
  }
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   214
#endif
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   215
}
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   216
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   217
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
 * Class:     sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal
51203
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   220
 * Method:    setSAAltRoot0
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   221
 * Signature: (Ljava/lang/String;)V
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
 */
51203
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   223
JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_setSAAltRoot0
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   224
  (JNIEnv *env, jobject this_obj, jstring altroot) {
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   225
  if (saaltroot != NULL) {
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   226
    free(saaltroot);
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   227
  }
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   228
  const char *path = (*env)->GetStringUTFChars(env, altroot, JNI_FALSE);
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   229
  /*
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   230
   * `saaltroot` is used for putenv().
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   231
   * So we need to keep this memory.
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   232
   */
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   233
  static const char *PREFIX = "SA_ALTROOT=";
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   234
  size_t len = strlen(PREFIX) + strlen(path) + 1;
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   235
  saaltroot = (char *)malloc(len);
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   236
  snprintf(saaltroot, len, "%s%s", PREFIX, path);
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   237
  putenv(saaltroot);
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   238
  (*env)->ReleaseStringUTFChars(env, altroot, path);
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   239
}
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   240
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   241
/*
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   242
 * Class:     sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   243
 * Method:    attach0
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   244
 * Signature: (IZ)V
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   245
 */
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   246
JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_attach0__IZ
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   247
  (JNIEnv *env, jobject this_obj, jint jpid, jboolean is_in_container) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
15850
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   249
  // For bitness checking, locate binary at /proc/jpid/exe
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   250
  char buf[PATH_MAX];
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   251
  snprintf((char *) &buf, PATH_MAX, "/proc/%d/exe", jpid);
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   252
  verifyBitness(env, (char *) &buf);
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   253
  CHECK_EXCEPTION;
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   254
35049
5a30aa672689 8145099: Better error message when SA can't attach to a process
sla
parents: 31399
diff changeset
   255
  char err_buf[200];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  struct ps_prochandle* ph;
51203
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   257
  if ((ph = Pgrab(jpid, err_buf, sizeof(err_buf), is_in_container)) == NULL) {
35049
5a30aa672689 8145099: Better error message when SA can't attach to a process
sla
parents: 31399
diff changeset
   258
    char msg[230];
5a30aa672689 8145099: Better error message when SA can't attach to a process
sla
parents: 31399
diff changeset
   259
    snprintf(msg, sizeof(msg), "Can't attach to the process: %s", err_buf);
5a30aa672689 8145099: Better error message when SA can't attach to a process
sla
parents: 31399
diff changeset
   260
    THROW_NEW_DEBUGGER_EXCEPTION(msg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  (*env)->SetLongField(env, this_obj, p_ps_prochandle_ID, (jlong)(intptr_t)ph);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  fillThreadsAndLoadObjects(env, this_obj, ph);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
 * Class:     sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
 * Method:    attach0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_attach0__Ljava_lang_String_2Ljava_lang_String_2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  (JNIEnv *env, jobject this_obj, jstring execName, jstring coreName) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  const char *execName_cstr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  const char *coreName_cstr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  jboolean isCopy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  struct ps_prochandle* ph;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  execName_cstr = (*env)->GetStringUTFChars(env, execName, &isCopy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  coreName_cstr = (*env)->GetStringUTFChars(env, coreName, &isCopy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  CHECK_EXCEPTION;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
15850
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   283
  verifyBitness(env, execName_cstr);
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   284
  CHECK_EXCEPTION;
0d2f541fd6ed 8008807: SA: jstack crash when target has mismatched bitness (Linux)
kevinw
parents: 15475
diff changeset
   285
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  if ( (ph = Pgrab_core(execName_cstr, coreName_cstr)) == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    (*env)->ReleaseStringUTFChars(env, execName, execName_cstr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    (*env)->ReleaseStringUTFChars(env, coreName, coreName_cstr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
    THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the core file");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  (*env)->SetLongField(env, this_obj, p_ps_prochandle_ID, (jlong)(intptr_t)ph);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  (*env)->ReleaseStringUTFChars(env, execName, execName_cstr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  (*env)->ReleaseStringUTFChars(env, coreName, coreName_cstr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  fillThreadsAndLoadObjects(env, this_obj, ph);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
 * Class:     sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
 * Method:    detach0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
 * Signature: ()V
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_detach0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  (JNIEnv *env, jobject this_obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  struct ps_prochandle* ph = get_proc_handle(env, this_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  if (ph != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
     Prelease(ph);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  }
51203
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   308
  if (saaltroot != NULL) {
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   309
    free(saaltroot);
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   310
    saaltroot = NULL;
220c9188db4f 8205992: jhsdb cannot attach to Java processes running in Docker containers
ysuenaga
parents: 47216
diff changeset
   311
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
 * Class:     sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
 * Method:    lookupByName0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
 * Signature: (Ljava/lang/String;Ljava/lang/String;)J
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_lookupByName0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  (JNIEnv *env, jobject this_obj, jstring objectName, jstring symbolName) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  const char *objectName_cstr, *symbolName_cstr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  jlong addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  jboolean isCopy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  struct ps_prochandle* ph = get_proc_handle(env, this_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  objectName_cstr = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  if (objectName != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    objectName_cstr = (*env)->GetStringUTFChars(env, objectName, &isCopy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
    CHECK_EXCEPTION_(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  symbolName_cstr = (*env)->GetStringUTFChars(env, symbolName, &isCopy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  CHECK_EXCEPTION_(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  addr = (jlong) lookup_symbol(ph, objectName_cstr, symbolName_cstr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  if (objectName_cstr != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
    (*env)->ReleaseStringUTFChars(env, objectName, objectName_cstr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  (*env)->ReleaseStringUTFChars(env, symbolName, symbolName_cstr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  return addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
 * Class:     sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
 * Method:    lookupByAddress0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
 * Signature: (J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
JNIEXPORT jobject JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_lookupByAddress0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  (JNIEnv *env, jobject this_obj, jlong addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  uintptr_t offset;
26411
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
   351
  jobject obj;
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
   352
  jstring str;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  const char* sym = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  struct ps_prochandle* ph = get_proc_handle(env, this_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  sym = symbol_for_pc(ph, (uintptr_t) addr, &offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  if (sym == NULL) return 0;
26411
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
   358
  str = (*env)->NewStringUTF(env, sym);
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
   359
  CHECK_EXCEPTION_(NULL);
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
   360
  obj = (*env)->CallObjectMethod(env, this_obj, createClosestSymbol_ID, str, (jlong)offset);
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
   361
  CHECK_EXCEPTION_(NULL);
8daa5fdf642f 8029172: warnings from b117 for hotspot.agent.src.os.linux: JNI exception pending
dsamersoff
parents: 20295
diff changeset
   362
  return obj;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
 * Class:     sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
 * Method:    readBytesFromProcess0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
 * Signature: (JJ)Lsun/jvm/hotspot/debugger/ReadResult;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_readBytesFromProcess0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  (JNIEnv *env, jobject this_obj, jlong addr, jlong numBytes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  jboolean isCopy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  jbyteArray array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  jbyte *bufPtr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  ps_err_e err;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  array = (*env)->NewByteArray(env, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  CHECK_EXCEPTION_(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  bufPtr = (*env)->GetByteArrayElements(env, array, &isCopy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  CHECK_EXCEPTION_(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  err = ps_pdread(get_proc_handle(env, this_obj), (psaddr_t) (uintptr_t)addr, bufPtr, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  (*env)->ReleaseByteArrayElements(env, array, bufPtr, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  return (err == PS_OK)? array : 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
35075
ca79cbf3f106 8073139: PPC64: User-visible arch directory and os.arch value on ppc64le cause issues with Java tooling
asmundak
parents: 35049
diff changeset
   388
#if defined(i386) || defined(amd64) || defined(sparc) || defined(sparcv9) | defined(ppc64) || defined(ppc64le) || defined(aarch64)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_getThreadIntegerRegisterSet0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  (JNIEnv *env, jobject this_obj, jint lwp_id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  struct user_regs_struct gregs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  jboolean isCopy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  jlongArray array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  jlong *regs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  struct ps_prochandle* ph = get_proc_handle(env, this_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  if (get_lwp_regs(ph, lwp_id, &gregs) != true) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
     THROW_NEW_DEBUGGER_EXCEPTION_("get_thread_regs failed for a lwp", 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
#undef NPRGREG
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
#ifdef i386
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
#define NPRGREG sun_jvm_hotspot_debugger_x86_X86ThreadContext_NPRGREG
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
#ifdef amd64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
#define NPRGREG sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_NPRGREG
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
#endif
29180
50369728b00e 8064611: AARCH64: Changes to HotSpot shared code
aph
parents: 26411
diff changeset
   410
#ifdef aarch64
31399
167037a29ab4 8078521: AARCH64: Add AArch64 SA support
aph
parents: 29185
diff changeset
   411
#define NPRGREG sun_jvm_hotspot_debugger_aarch64_AARCH64ThreadContext_NPRGREG
29180
50369728b00e 8064611: AARCH64: Changes to HotSpot shared code
aph
parents: 26411
diff changeset
   412
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
#if defined(sparc) || defined(sparcv9)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
#define NPRGREG sun_jvm_hotspot_debugger_sparc_SPARCThreadContext_NPRGREG
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
#endif
35075
ca79cbf3f106 8073139: PPC64: User-visible arch directory and os.arch value on ppc64le cause issues with Java tooling
asmundak
parents: 35049
diff changeset
   416
#if defined(ppc64) || defined(ppc64le)
28369
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   417
#define NPRGREG sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext_NPRGREG
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   418
#endif
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   419
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  array = (*env)->NewLongArray(env, NPRGREG);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  CHECK_EXCEPTION_(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  regs = (*env)->GetLongArrayElements(env, array, &isCopy);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
#undef REG_INDEX
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
#ifdef i386
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_x86_X86ThreadContext_##reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  regs[REG_INDEX(GS)]  = (uintptr_t) gregs.xgs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  regs[REG_INDEX(FS)]  = (uintptr_t) gregs.xfs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  regs[REG_INDEX(ES)]  = (uintptr_t) gregs.xes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  regs[REG_INDEX(DS)]  = (uintptr_t) gregs.xds;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  regs[REG_INDEX(EDI)] = (uintptr_t) gregs.edi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  regs[REG_INDEX(ESI)] = (uintptr_t) gregs.esi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  regs[REG_INDEX(FP)] = (uintptr_t) gregs.ebp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  regs[REG_INDEX(SP)] = (uintptr_t) gregs.esp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  regs[REG_INDEX(EBX)] = (uintptr_t) gregs.ebx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  regs[REG_INDEX(EDX)] = (uintptr_t) gregs.edx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  regs[REG_INDEX(ECX)] = (uintptr_t) gregs.ecx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  regs[REG_INDEX(EAX)] = (uintptr_t) gregs.eax;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  regs[REG_INDEX(PC)] = (uintptr_t) gregs.eip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  regs[REG_INDEX(CS)]  = (uintptr_t) gregs.xcs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  regs[REG_INDEX(SS)]  = (uintptr_t) gregs.xss;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
#endif /* i386 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
#ifdef amd64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_##reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  regs[REG_INDEX(R15)] = gregs.r15;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  regs[REG_INDEX(R14)] = gregs.r14;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  regs[REG_INDEX(R13)] = gregs.r13;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  regs[REG_INDEX(R12)] = gregs.r12;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  regs[REG_INDEX(RBP)] = gregs.rbp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  regs[REG_INDEX(RBX)] = gregs.rbx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  regs[REG_INDEX(R11)] = gregs.r11;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  regs[REG_INDEX(R10)] = gregs.r10;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  regs[REG_INDEX(R9)] = gregs.r9;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  regs[REG_INDEX(R8)] = gregs.r8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  regs[REG_INDEX(RAX)] = gregs.rax;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  regs[REG_INDEX(RCX)] = gregs.rcx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  regs[REG_INDEX(RDX)] = gregs.rdx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  regs[REG_INDEX(RSI)] = gregs.rsi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  regs[REG_INDEX(RDI)] = gregs.rdi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  regs[REG_INDEX(RIP)] = gregs.rip;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  regs[REG_INDEX(CS)] = gregs.cs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  regs[REG_INDEX(RSP)] = gregs.rsp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  regs[REG_INDEX(SS)] = gregs.ss;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  regs[REG_INDEX(FSBASE)] = gregs.fs_base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  regs[REG_INDEX(GSBASE)] = gregs.gs_base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  regs[REG_INDEX(DS)] = gregs.ds;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  regs[REG_INDEX(ES)] = gregs.es;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  regs[REG_INDEX(FS)] = gregs.fs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  regs[REG_INDEX(GS)] = gregs.gs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
#endif /* amd64 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
#if defined(sparc) || defined(sparcv9)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_sparc_SPARCThreadContext_##reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  regs[REG_INDEX(R_PSR)] = gregs.tstate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  regs[REG_INDEX(R_PC)]  = gregs.tpc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  regs[REG_INDEX(R_nPC)] = gregs.tnpc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  regs[REG_INDEX(R_Y)]   = gregs.y;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  regs[REG_INDEX(R_PSR)] = gregs.psr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  regs[REG_INDEX(R_PC)]  = gregs.pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  regs[REG_INDEX(R_nPC)] = gregs.npc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  regs[REG_INDEX(R_Y)]   = gregs.y;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  regs[REG_INDEX(R_G0)]  =            0 ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  regs[REG_INDEX(R_G1)]  = gregs.u_regs[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  regs[REG_INDEX(R_G2)]  = gregs.u_regs[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  regs[REG_INDEX(R_G3)]  = gregs.u_regs[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  regs[REG_INDEX(R_G4)]  = gregs.u_regs[3];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  regs[REG_INDEX(R_G5)]  = gregs.u_regs[4];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  regs[REG_INDEX(R_G6)]  = gregs.u_regs[5];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  regs[REG_INDEX(R_G7)]  = gregs.u_regs[6];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  regs[REG_INDEX(R_O0)]  = gregs.u_regs[7];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  regs[REG_INDEX(R_O1)]  = gregs.u_regs[8];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  regs[REG_INDEX(R_O2)]  = gregs.u_regs[ 9];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  regs[REG_INDEX(R_O3)]  = gregs.u_regs[10];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  regs[REG_INDEX(R_O4)]  = gregs.u_regs[11];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  regs[REG_INDEX(R_O5)]  = gregs.u_regs[12];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  regs[REG_INDEX(R_O6)]  = gregs.u_regs[13];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  regs[REG_INDEX(R_O7)]  = gregs.u_regs[14];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
#endif /* sparc */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
29180
50369728b00e 8064611: AARCH64: Changes to HotSpot shared code
aph
parents: 26411
diff changeset
   512
#if defined(aarch64)
50369728b00e 8064611: AARCH64: Changes to HotSpot shared code
aph
parents: 26411
diff changeset
   513
50369728b00e 8064611: AARCH64: Changes to HotSpot shared code
aph
parents: 26411
diff changeset
   514
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_aarch64_AARCH64ThreadContext_##reg
50369728b00e 8064611: AARCH64: Changes to HotSpot shared code
aph
parents: 26411
diff changeset
   515
31399
167037a29ab4 8078521: AARCH64: Add AArch64 SA support
aph
parents: 29185
diff changeset
   516
  {
167037a29ab4 8078521: AARCH64: Add AArch64 SA support
aph
parents: 29185
diff changeset
   517
    int i;
167037a29ab4 8078521: AARCH64: Add AArch64 SA support
aph
parents: 29185
diff changeset
   518
    for (i = 0; i < 31; i++)
167037a29ab4 8078521: AARCH64: Add AArch64 SA support
aph
parents: 29185
diff changeset
   519
      regs[i] = gregs.regs[i];
167037a29ab4 8078521: AARCH64: Add AArch64 SA support
aph
parents: 29185
diff changeset
   520
    regs[REG_INDEX(SP)] = gregs.sp;
167037a29ab4 8078521: AARCH64: Add AArch64 SA support
aph
parents: 29185
diff changeset
   521
    regs[REG_INDEX(PC)] = gregs.pc;
167037a29ab4 8078521: AARCH64: Add AArch64 SA support
aph
parents: 29185
diff changeset
   522
  }
29180
50369728b00e 8064611: AARCH64: Changes to HotSpot shared code
aph
parents: 26411
diff changeset
   523
#endif /* aarch64 */
50369728b00e 8064611: AARCH64: Changes to HotSpot shared code
aph
parents: 26411
diff changeset
   524
35075
ca79cbf3f106 8073139: PPC64: User-visible arch directory and os.arch value on ppc64le cause issues with Java tooling
asmundak
parents: 35049
diff changeset
   525
#if defined(ppc64) || defined(ppc64le)
28369
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   526
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext_##reg
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   527
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   528
  regs[REG_INDEX(LR)] = gregs.link;
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   529
  regs[REG_INDEX(NIP)] = gregs.nip;
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   530
  regs[REG_INDEX(R0)]  = gregs.gpr[0];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   531
  regs[REG_INDEX(R1)]  = gregs.gpr[1];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   532
  regs[REG_INDEX(R2)]  = gregs.gpr[2];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   533
  regs[REG_INDEX(R3)]  = gregs.gpr[3];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   534
  regs[REG_INDEX(R4)]  = gregs.gpr[4];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   535
  regs[REG_INDEX(R5)]  = gregs.gpr[5];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   536
  regs[REG_INDEX(R6)]  = gregs.gpr[6];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   537
  regs[REG_INDEX(R7)]  = gregs.gpr[7];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   538
  regs[REG_INDEX(R8)]  = gregs.gpr[8];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   539
  regs[REG_INDEX(R9)]  = gregs.gpr[9];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   540
  regs[REG_INDEX(R10)] = gregs.gpr[10];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   541
  regs[REG_INDEX(R11)] = gregs.gpr[11];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   542
  regs[REG_INDEX(R12)] = gregs.gpr[12];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   543
  regs[REG_INDEX(R13)] = gregs.gpr[13];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   544
  regs[REG_INDEX(R14)] = gregs.gpr[14];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   545
  regs[REG_INDEX(R15)] = gregs.gpr[15];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   546
  regs[REG_INDEX(R16)] = gregs.gpr[16];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   547
  regs[REG_INDEX(R17)] = gregs.gpr[17];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   548
  regs[REG_INDEX(R18)] = gregs.gpr[18];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   549
  regs[REG_INDEX(R19)] = gregs.gpr[19];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   550
  regs[REG_INDEX(R20)] = gregs.gpr[20];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   551
  regs[REG_INDEX(R21)] = gregs.gpr[21];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   552
  regs[REG_INDEX(R22)] = gregs.gpr[22];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   553
  regs[REG_INDEX(R23)] = gregs.gpr[23];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   554
  regs[REG_INDEX(R24)] = gregs.gpr[24];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   555
  regs[REG_INDEX(R25)] = gregs.gpr[25];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   556
  regs[REG_INDEX(R26)] = gregs.gpr[26];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   557
  regs[REG_INDEX(R27)] = gregs.gpr[27];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   558
  regs[REG_INDEX(R28)] = gregs.gpr[28];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   559
  regs[REG_INDEX(R29)] = gregs.gpr[29];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   560
  regs[REG_INDEX(R30)] = gregs.gpr[30];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   561
  regs[REG_INDEX(R31)] = gregs.gpr[31];
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   562
a62a208f18de 8049716: PPC64: Implement SA on Linux/PPC64
simonis
parents: 26411
diff changeset
   563
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  (*env)->ReleaseLongArrayElements(env, array, regs, JNI_COMMIT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
  return array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
}
13529
dc25e69fd16d 7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents: 5547
diff changeset
   568
#endif