diff --git a/bin/unshuffle_list.txt b/bin/unshuffle_list.txt index 21945a93a71..36ad8feabc4 100644 --- a/bin/unshuffle_list.txt +++ b/bin/unshuffle_list.txt @@ -58,7 +58,6 @@ src/jdk.compiler : jdk/src/jdk.compiler langtools/src/jdk.compiler src/jdk.crypto.cryptoki : jdk/src/jdk.crypto.cryptoki src/jdk.crypto.ec : jdk/src/jdk.crypto.ec src/jdk.crypto.mscapi : jdk/src/jdk.crypto.mscapi -src/jdk.crypto.ucrypto : jdk/src/jdk.crypto.ucrypto src/jdk.dynalink : nashorn/src/jdk.dynalink src/jdk.editpad : jdk/src/jdk.editpad src/jdk.hotspot.agent : hotspot/src/jdk.hotspot.agent @@ -101,13 +100,11 @@ src/jdk.zipfs : jdk/src/jdk.zipfs src/langtools/sample : langtools/src/sample src/linux : jdk/src/linux src/sample : jdk/src/sample -src/solaris : jdk/src/solaris src/hotspot/share : hotspot/src/share/vm src/hotspot/cpu/aarch64 : hotspot/src/cpu/aarch64/vm src/hotspot/cpu/arm : hotspot/src/cpu/arm/vm src/hotspot/cpu/ppc : hotspot/src/cpu/ppc/vm src/hotspot/cpu/s390 : hotspot/src/cpu/s390/vm -src/hotspot/cpu/sparc : hotspot/src/cpu/sparc/vm src/hotspot/cpu/x86 : hotspot/src/cpu/x86/vm src/hotspot/cpu/zero : hotspot/src/cpu/zero/vm src/hotspot/os/aix : hotspot/src/os/aix/vm @@ -115,7 +112,6 @@ src/hotspot/os/bsd : hotspot/src/os/bsd/vm src/hotspot/os/linux : hotspot/src/os/linux/vm src/hotspot/os/posix/dtrace : hotspot/src/os/posix/dtrace src/hotspot/os/posix : hotspot/src/os/posix/vm -src/hotspot/os/solaris : hotspot/src/os/solaris/vm src/hotspot/os/windows : hotspot/src/os/windows/vm src/hotspot/os_cpu/aix_ppc : hotspot/src/os_cpu/aix_ppc/vm src/hotspot/os_cpu/bsd_x86 : hotspot/src/os_cpu/bsd_x86/vm @@ -124,11 +120,8 @@ src/hotspot/os_cpu/linux_aarch64 : hotspot/src/os_cpu/linux_aarch64/vm src/hotspot/os_cpu/linux_arm : hotspot/src/os_cpu/linux_arm/vm src/hotspot/os_cpu/linux_ppc : hotspot/src/os_cpu/linux_ppc/vm src/hotspot/os_cpu/linux_s390 : hotspot/src/os_cpu/linux_s390/vm -src/hotspot/os_cpu/linux_sparc : hotspot/src/os_cpu/linux_sparc/vm src/hotspot/os_cpu/linux_x86 : hotspot/src/os_cpu/linux_x86/vm src/hotspot/os_cpu/linux_zero : hotspot/src/os_cpu/linux_zero/vm -src/hotspot/os_cpu/solaris_sparc : hotspot/src/os_cpu/solaris_sparc/vm -src/hotspot/os_cpu/solaris_x86 : hotspot/src/os_cpu/solaris_x86/vm src/hotspot/os_cpu/windows_x86 : hotspot/src/os_cpu/windows_x86/vm src/hotspot : hotspot/src src/utils/IdealGraphVisualizer : hotspot/src/share/tools/IdealGraphVisualizer diff --git a/doc/building.html b/doc/building.html index 0fd6c117fee..e0cca9534bd 100644 --- a/doc/building.html +++ b/doc/building.html @@ -30,13 +30,11 @@
  • Build Hardware Requirements
  • Operating System Requirements
  • @@ -157,18 +154,15 @@

    The JDK is a massive project, and require machines ranging from decent to powerful to be able to build in a reasonable amount of time, or to be able to complete a build at all.

    We strongly recommend usage of an SSD disk for the build, since disk speed is one of the limiting factors for build performance.

    Building on x86

    -

    At a minimum, a machine with 2-4 cores is advisable, as well as 2-4 GB of RAM. (The more cores to use, the more memory you need.) At least 6 GB of free disk space is required (8 GB minimum for building on Solaris).

    +

    At a minimum, a machine with 2-4 cores is advisable, as well as 2-4 GB of RAM. (The more cores to use, the more memory you need.) At least 6 GB of free disk space is required.

    Even for 32-bit builds, it is recommended to use a 64-bit build machine, and instead create a 32-bit target using --with-target-bits=32.

    -

    Building on sparc

    -

    At a minimum, a machine with 4 cores is advisable, as well as 4 GB of RAM. (The more cores to use, the more memory you need.) At least 8 GB of free disk space is required.

    -

    Note: The sparc port is deprecated.

    Building on aarch64

    At a minimum, a machine with 8 cores is advisable, as well as 8 GB of RAM. (The more cores to use, the more memory you need.) At least 6 GB of free disk space is required.

    If you do not have access to sufficiently powerful hardware, it is also possible to use cross-compiling.

    Building on 32-bit arm

    This is not recommended. Instead, see the section on Cross-compiling.

    Operating System Requirements

    -

    The mainline JDK project supports Linux, Solaris, macOS, AIX and Windows. Support for other operating system, e.g. BSD, exists in separate "port" projects.

    +

    The mainline JDK project supports Linux, macOS, AIX and Windows. Support for other operating system, e.g. BSD, exists in separate "port" projects.

    In general, the JDK can be built on a wide range of versions of these operating systems, but the further you deviate from what is tested on a daily basis, the more likely you are to run into problems.

    This table lists the OS versions used by Oracle when building the JDK. Such information is always subject to change, but this table is up to date at the time of writing.

    @@ -184,20 +178,16 @@ - - - - - +
    Oracle Enterprise Linux 6.4 / 7.6
    SolarisSolaris 11.3 SRU 20
    macOS Mac OS X 10.13 (High Sierra)
    Windows Windows Server 2012 R2
    -

    The double version numbers for Linux and Solaris are due to the hybrid model used at Oracle, where header files and external libraries from an older version are used when building on a more modern version of the OS.

    +

    The double version numbers for Linux are due to the hybrid model used at Oracle, where header files and external libraries from an older version are used when building on a more modern version of the OS.

    The Build Group has a wiki page with Supported Build Platforms. From time to time, this is updated by contributors to list successes or failures of building on different platforms.

    Windows

    Windows XP is not a supported platform, but all newer Windows should be able to build the JDK.

    @@ -223,10 +213,6 @@

    It's possible to build both Windows and Linux binaries from WSL. To build Windows binaries, you must use a Windows boot JDK (located in a Windows-accessible directory). To build Linux binaries, you must use a Linux boot JDK. The default behavior is to build for Windows. To build for Linux, pass --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu to configure.

    If building Windows binaries, the source code must be located in a Windows- accessible directory. This is because Windows executables (such as Visual Studio and the boot JDK) must be able to access the source code. Also, the drive where the source is stored must be mounted as case-insensitive by changing either /etc/fstab or /etc/wsl.conf in WSL. Individual directories may be corrected using the fsutil tool in case the source was cloned before changing the mount options.

    Note that while it's possible to build on WSL, testing is still not fully supported.

    -

    Solaris

    -

    See make/devkit/solaris11.1-package-list.txt for a list of recommended packages to install when building on Solaris. The versions specified in this list is the versions used by the daily builds at Oracle, and is likely to work properly.

    -

    Older versions of Solaris shipped a broken version of objcopy. At least version 2.21.1 is needed, which is provided by Solaris 11 Update 1. Objcopy is needed if you want to have external debug symbols. Please make sure you are using at least version 2.21.1 of objcopy, or that you disable external debug symbols.

    -

    Note: The Solaris port is deprecated.

    macOS

    Apple is using a quite aggressive scheme of pushing OS updates, and coupling these updates with required updates of Xcode. Unfortunately, this makes it difficult for a project such as the JDK to keep pace with a continuously updated machine running macOS. See the section on Apple Xcode on some strategies to deal with this.

    It is recommended that you use at least Mac OS X 10.13 (High Sierra). At the time of writing, the JDK has been successfully compiled on macOS 10.12 (Sierra).

    @@ -259,14 +245,10 @@ Apple Xcode (using clang) -Solaris -Oracle Solaris Studio - - AIX IBM XL C/C++ - + Windows Microsoft Visual Studio @@ -290,10 +272,6 @@ Apple Xcode 10.1 (using clang 10.0.0) -Solaris -Oracle Solaris Studio 12.6 (with compiler version 5.15) - - Windows Microsoft Visual Studio 2019 update 16.5.3 @@ -313,64 +291,6 @@
    xcode-select --install

    It is advisable to keep an older version of Xcode for building the JDK when updating Xcode. This blog page has good suggestions on managing multiple Xcode versions. To use a specific version of Xcode, use xcode-select -s before running configure, or use --with-toolchain-path to point to the version of Xcode to use, e.g. configure --with-toolchain-path=/Applications/Xcode8.app/Contents/Developer/usr/bin

    If you have recently (inadvertently) updated your OS and/or Xcode version, and the JDK can no longer be built, please see the section on Problems with the Build Environment, and Getting Help to find out if there are any recent, non-merged patches available for this update.

    -

    Oracle Solaris Studio

    -

    The minimum accepted version of the Solaris Studio compilers is 5.13 (corresponding to Solaris Studio 12.4). Older versions will not be accepted by configure.

    -

    The Solaris Studio installation should contain at least these packages:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    PackageVersion
    developer/solarisstudio-124/backend12.4-1.0.6.0
    developer/solarisstudio-124/c++12.4-1.0.10.0
    developer/solarisstudio-124/cc12.4-1.0.4.0
    developer/solarisstudio-124/library/c++-libs12.4-1.0.10.0
    developer/solarisstudio-124/library/math-libs12.4-1.0.0.1
    developer/solarisstudio-124/library/studio-gccrt12.4-1.0.0.1
    developer/solarisstudio-124/studio-common12.4-1.0.0.1
    developer/solarisstudio-124/studio-ja12.4-1.0.0.1
    developer/solarisstudio-124/studio-legal12.4-1.0.0.1
    developer/solarisstudio-124/studio-zhCN12.4-1.0.0.1
    -

    Compiling with Solaris Studio can sometimes be finicky. This is the exact version used by Oracle, which worked correctly at the time of writing:

    -
    $ cc -V
    -cc: Sun C 5.13 SunOS_i386 2014/10/20
    -$ CC -V
    -CC: Sun C++ 5.13 SunOS_i386 151846-10 2015/10/30

    Microsoft Visual Studio

    The minimum accepted version of Visual Studio is 2010. Older versions will not be accepted by configure. The maximum accepted version of Visual Studio is 2019. Versions older than 2017 are unlikely to continue working for long.

    If you have multiple versions of Visual Studio installed, configure will by default pick the latest. You can request a specific version to be used by setting --with-toolchain-version, e.g. --with-toolchain-version=2015.

    @@ -394,7 +314,6 @@ CC: Sun C++ 5.13 SunOS_i386 151846-10 2015/10/30

    Use --with-freetype-include=<path> and --with-freetype-lib=<path> if configure does not automatically locate the platform FreeType files.

    CUPS

    @@ -402,15 +321,13 @@ CC: Sun C++ 5.13 SunOS_i386 151846-10 2015/10/30

    Use --with-cups=<path> if configure does not properly locate your CUPS files.

    X11

    -

    Certain X11 libraries and include files are required on Linux and Solaris.

    +

    Certain X11 libraries and include files are required on Linux.

    Use --with-x=<path> if configure does not properly locate your X11 files.

    ALSA

    @@ -443,7 +360,6 @@ CC: Sun C++ 5.13 SunOS_i386 151846-10 2015/10/30

    At least version 3.81 of GNU Make must be used. For distributions supporting GNU Make 4.0 or above, we strongly recommend it. GNU Make 4.0 contains useful functionality to handle parallel building (supported by --with-output-sync) and speed and stability improvements.

    Note that configure locates and verifies a properly functioning version of make and stores the path to this make binary in the configuration. If you start a build using make on the command line, you will be using the version of make found first in your PATH, and not necessarily the one stored in the configuration. This initial make will be used as "bootstrap make", and in a second stage, the make located by configure will be called. Normally, this will present no issues, but if you have a very old make, or a non-GNU Make make in your path, this might cause issues.

    If you want to override the default make found by configure, use the MAKE configure variable, e.g. configure MAKE=/opt/gnu/make.

    -

    On Solaris, it is common to call the GNU version of make by using gmake.

    GNU Bash

    The JDK requires GNU Bash. No other shells are supported.

    At least version 3.2 of GNU Bash must be used.

    @@ -865,9 +781,6 @@ Clock skew detected. Your build may be incomplete.

    then the clock on your build machine is out of sync with the timestamps on the source files. Other errors, apparently unrelated but in fact caused by the clock skew, can occur along with the clock skew warnings. These secondary errors may tend to obscure the fact that the true root cause of the problem is an out-of-sync clock.

    If you see these warnings, reset the clock on the build machine, run make clean and restart the build.

    Out of Memory Errors

    -

    On Solaris, you might get an error message like this:

    -
    Trouble writing out table to disk
    -

    To solve this, increase the amount of swap space on your build machine.

    On Windows, you might get error messages like this:

    fatal error - couldn't allocate heap
     cannot create ... Permission denied
    @@ -919,7 +832,7 @@ sudo mv /tmp/configure /usr/local/bin

    If you are prepared to take some risk of an incorrect build, and know enough of the system to understand how things build and interact, you can speed up the build process considerably by instructing make to only build a portion of the product.

    Building Individual Modules

    The safe way to use fine-grained make targets is to use the module specific make targets. All source code in the JDK is organized so it belongs to a module, e.g. java.base or jdk.jdwp.agent. You can build only a specific module, by giving it as make target: make jdk.jdwp.agent. If the specified module depends on other modules (e.g. java.base), those modules will be built first.

    -

    You can also specify a set of modules, just as you can always specify a set of make targets: make jdk.crypto.cryptoki jdk.crypto.ec jdk.crypto.mscapi jdk.crypto.ucrypto

    +

    You can also specify a set of modules, just as you can always specify a set of make targets: make jdk.crypto.cryptoki jdk.crypto.ec jdk.crypto.mscapi

    Building Individual Module Phases

    The build process for each module is divided into separate phases. Not all modules need all phases. Which are needed depends on what kind of source code and other artifact the module consists of. The phases are:

    Windows sub-menu options include:

    diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.cpp b/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.cpp index e887356385b..9e8be03e04e 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.cpp +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.cpp @@ -52,10 +52,6 @@ #include "sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext.h" #endif -#if defined(sparc) || defined(sparcv9) -#include "sun_jvm_hotspot_debugger_sparc_SPARCThreadContext.h" -#endif - #if defined(ppc64) || defined(ppc64le) #include "sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext.h" #endif @@ -405,7 +401,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLo return (err == PS_OK)? array : 0; } -#if defined(i586) || defined(amd64) || defined(sparc) || defined(sparcv9) | defined(ppc64) || defined(ppc64le) || defined(aarch64) +#if defined(i586) || defined(amd64) || defined(ppc64) || defined(ppc64le) || defined(aarch64) extern "C" JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_getThreadIntegerRegisterSet0 (JNIEnv *env, jobject this_obj, jint lwp_id) { @@ -431,9 +427,6 @@ JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLo #ifdef aarch64 #define NPRGREG sun_jvm_hotspot_debugger_aarch64_AARCH64ThreadContext_NPRGREG #endif -#if defined(sparc) || defined(sparcv9) -#define NPRGREG sun_jvm_hotspot_debugger_sparc_SPARCThreadContext_NPRGREG -#endif #if defined(ppc64) || defined(ppc64le) #define NPRGREG sun_jvm_hotspot_debugger_ppc64_PPC64ThreadContext_NPRGREG #endif @@ -497,39 +490,6 @@ JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLo #endif /* amd64 */ -#if defined(sparc) || defined(sparcv9) - -#define REG_INDEX(reg) sun_jvm_hotspot_debugger_sparc_SPARCThreadContext_##reg - -#ifdef _LP64 - regs[REG_INDEX(R_PSR)] = gregs.tstate; - regs[REG_INDEX(R_PC)] = gregs.tpc; - regs[REG_INDEX(R_nPC)] = gregs.tnpc; - regs[REG_INDEX(R_Y)] = gregs.y; -#else - regs[REG_INDEX(R_PSR)] = gregs.psr; - regs[REG_INDEX(R_PC)] = gregs.pc; - regs[REG_INDEX(R_nPC)] = gregs.npc; - regs[REG_INDEX(R_Y)] = gregs.y; -#endif - regs[REG_INDEX(R_G0)] = 0 ; - regs[REG_INDEX(R_G1)] = gregs.u_regs[0]; - regs[REG_INDEX(R_G2)] = gregs.u_regs[1]; - regs[REG_INDEX(R_G3)] = gregs.u_regs[2]; - regs[REG_INDEX(R_G4)] = gregs.u_regs[3]; - regs[REG_INDEX(R_G5)] = gregs.u_regs[4]; - regs[REG_INDEX(R_G6)] = gregs.u_regs[5]; - regs[REG_INDEX(R_G7)] = gregs.u_regs[6]; - regs[REG_INDEX(R_O0)] = gregs.u_regs[7]; - regs[REG_INDEX(R_O1)] = gregs.u_regs[8]; - regs[REG_INDEX(R_O2)] = gregs.u_regs[ 9]; - regs[REG_INDEX(R_O3)] = gregs.u_regs[10]; - regs[REG_INDEX(R_O4)] = gregs.u_regs[11]; - regs[REG_INDEX(R_O5)] = gregs.u_regs[12]; - regs[REG_INDEX(R_O6)] = gregs.u_regs[13]; - regs[REG_INDEX(R_O7)] = gregs.u_regs[14]; -#endif /* sparc */ - #if defined(aarch64) #define REG_INDEX(reg) sun_jvm_hotspot_debugger_aarch64_AARCH64ThreadContext_##reg diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/libproc.h b/src/jdk.hotspot.agent/linux/native/libsaproc/libproc.h index 1cbbe767564..8c44dc1aeee 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/libproc.h +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/libproc.h @@ -33,7 +33,7 @@ #include -#if defined(sparc) || defined(sparcv9) || defined(ppc64) || defined(ppc64le) +#if defined(ppc64) || defined(ppc64le) #include #define user_regs_struct pt_regs #endif diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c index 0b4e8e4e358..c1fdf0f7496 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -128,11 +128,7 @@ static bool process_get_lwp_regs(struct ps_prochandle* ph, pid_t pid, struct use // Linux on x86 and sparc are different. On x86 ptrace(PTRACE_GETREGS, ...) // uses pointer from 4th argument and ignores 3rd argument. On sparc it uses // pointer from 3rd argument and ignores 4th argument -#if defined(sparc) || defined(sparcv9) -#define ptrace_getregs(request, pid, addr, data) ptrace(request, pid, addr, data) -#else #define ptrace_getregs(request, pid, addr, data) ptrace(request, pid, data, addr) -#endif #if defined(_LP64) && defined(PTRACE_GETREGS64) #define PTRACE_GETREGS_REQ PTRACE_GETREGS64 diff --git a/src/jdk.hotspot.agent/macosx/native/libsaproc/libproc.h b/src/jdk.hotspot.agent/macosx/native/libsaproc/libproc.h index 11e00dcb828..7d2edc656b2 100644 --- a/src/jdk.hotspot.agent/macosx/native/libsaproc/libproc.h +++ b/src/jdk.hotspot.agent/macosx/native/libsaproc/libproc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,19 +59,6 @@ typedef int bool; #include #include #include -#if defined(sparc) || defined(sparcv9) -/* - If _LP64 is defined ptrace.h should be taken from /usr/include/asm-sparc64 - otherwise it should be from /usr/include/asm-sparc - These two files define pt_regs structure differently -*/ -#ifdef _LP64 -#include "asm-sparc64/ptrace.h" -#else -#include "asm-sparc/ptrace.h" -#endif - -#endif //sparc or sparcv9 // This C bool type must be int for compatibility with BSD calls and // it would be a mistake to equivalence it to C++ bool on many platforms diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java index fa13498f510..694b5b210bd 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java @@ -481,7 +481,7 @@ public class HSDB implements ObjectHistogramPanel.Listener, SAListener { panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); JTextArea ta = new JTextArea( "Enter the process ID of a currently-running HotSpot process. On " + - "Solaris and most Unix operating systems, this can be determined by " + + "most Unix operating systems, this can be determined by " + "typing \"ps -u | grep java\"; the process ID is the " + "first number which appears on the resulting line. On Windows, the " + "process ID is present in the Task Manager, which can be brought up " + diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotAgent.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotAgent.java index 78ddc182428..a9b2bbb85c9 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotAgent.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotAgent.java @@ -36,12 +36,9 @@ import sun.jvm.hotspot.debugger.MachineDescriptionAMD64; import sun.jvm.hotspot.debugger.MachineDescriptionPPC64; import sun.jvm.hotspot.debugger.MachineDescriptionAArch64; import sun.jvm.hotspot.debugger.MachineDescriptionIntelX86; -import sun.jvm.hotspot.debugger.MachineDescriptionSPARC32Bit; -import sun.jvm.hotspot.debugger.MachineDescriptionSPARC64Bit; import sun.jvm.hotspot.debugger.NoSuchSymbolException; import sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal; import sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal; -import sun.jvm.hotspot.debugger.proc.ProcDebuggerLocal; import sun.jvm.hotspot.debugger.remote.RemoteDebugger; import sun.jvm.hotspot.debugger.remote.RemoteDebuggerClient; import sun.jvm.hotspot.debugger.remote.RemoteDebuggerServer; @@ -357,9 +354,7 @@ public class HotSpotAgent { } catch (UnsupportedPlatformException e) { throw new DebuggerException(e); } - if (os.equals("solaris")) { - setupDebuggerSolaris(); - } else if (os.equals("win32")) { + if (os.equals("win32")) { setupDebuggerWin32(); } else if (os.equals("linux")) { setupDebuggerLinux(); @@ -411,11 +406,7 @@ public class HotSpotAgent { // configure the VM. try { - if (os.equals("solaris")) { - db = new HotSpotTypeDataBase(machDesc, - new HotSpotSolarisVtblAccess(debugger, jvmLibNames), - debugger, jvmLibNames); - } else if (os.equals("win32")) { + if (os.equals("win32")) { db = new HotSpotTypeDataBase(machDesc, new Win32VtblAccess(debugger, jvmLibNames), debugger, jvmLibNames); @@ -504,43 +495,6 @@ public class HotSpotAgent { System.err.println("Loaded alternate HotSpot SA Debugger: " + alternateName); } - // - // Solaris - // - - private void setupDebuggerSolaris() { - setupJVMLibNamesSolaris(); - ProcDebuggerLocal dbg = new ProcDebuggerLocal(null, true); - debugger = dbg; - attachDebugger(); - - // Set up CPU-dependent stuff - if (cpu.equals("x86")) { - machDesc = new MachineDescriptionIntelX86(); - } else if (cpu.equals("sparc")) { - int addressSize = dbg.getRemoteProcessAddressSize(); - if (addressSize == -1) { - throw new DebuggerException("Error occurred while trying to determine the remote process's " + - "address size"); - } - - if (addressSize == 32) { - machDesc = new MachineDescriptionSPARC32Bit(); - } else if (addressSize == 64) { - machDesc = new MachineDescriptionSPARC64Bit(); - } else { - throw new DebuggerException("Address size " + addressSize + " is not supported on SPARC"); - } - } else if (cpu.equals("amd64")) { - machDesc = new MachineDescriptionAMD64(); - } else { - throw new DebuggerException("Solaris only supported on sparc/sparcv9/x86/amd64"); - } - - dbg.setMachineDescription(machDesc); - return; - } - private void connectRemoteDebugger() throws DebuggerException { RemoteDebugger remote = (RemoteDebugger) RMIHelper.lookup(debugServerID); @@ -552,9 +506,7 @@ public class HotSpotAgent { } private void setupJVMLibNames(String os) { - if (os.equals("solaris")) { - setupJVMLibNamesSolaris(); - } else if (os.equals("win32")) { + if (os.equals("win32")) { setupJVMLibNamesWin32(); } else if (os.equals("linux")) { setupJVMLibNamesLinux(); @@ -567,10 +519,6 @@ public class HotSpotAgent { } } - private void setupJVMLibNamesSolaris() { - jvmLibNames = new String[] { "libjvm.so" }; - } - // // Win32 // @@ -616,12 +564,6 @@ public class HotSpotAgent { machDesc = new MachineDescriptionPPC64(); } else if (cpu.equals("aarch64")) { machDesc = new MachineDescriptionAArch64(); - } else if (cpu.equals("sparc")) { - if (LinuxDebuggerLocal.getAddressSize()==8) { - machDesc = new MachineDescriptionSPARC64Bit(); - } else { - machDesc = new MachineDescriptionSPARC32Bit(); - } } else { try { machDesc = (MachineDescription) diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotSolarisVtblAccess.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotSolarisVtblAccess.java deleted file mode 100644 index 3b52851d318..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HotSpotSolarisVtblAccess.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot; - -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.types.basic.*; - -/** This class implements the compiler-specific access to the vtbl for - a given C++ type. */ -public class HotSpotSolarisVtblAccess extends BasicVtblAccess { - - public HotSpotSolarisVtblAccess(SymbolLookup symbolLookup, - String[] jvmLibNames) { - super(symbolLookup, jvmLibNames); - } - - protected String vtblSymbolForType(Type type) { - String demangledSymbol = type.getName() + "::__vtbl"; - return mangle(demangledSymbol); - } - - //-------------------------------------------------------------------------------- - // Internals only below this point - // - - private String mangle(String symbol) { - String[] parts = symbol.split("::"); - StringBuffer mangled = new StringBuffer("__1c"); - for (int i = 0; i < parts.length; i++) { - int len = parts[i].length(); - if (len >= 26) { - mangled.append((char)('a' + (len / 26))); - len = len % 26; - } - mangled.append((char)('A' + len)); - mangled.append(parts[i]); - } - mangled.append("_"); - return mangled.toString(); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/Disassembler.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/Disassembler.java index 539db3a6873..a9522773471 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/Disassembler.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/Disassembler.java @@ -74,17 +74,6 @@ public class Disassembler { } path.append(sep + "bin" + sep); libname += ".dll"; - } else if (os.lastIndexOf("SunOS", 0) != -1) { - if (arch.equals("x86") || arch.equals("i386")) { - path.append(sep + "lib" + sep + "i386" + sep); - libname += "-i386" + ".so"; - } else if (arch.equals("amd64")) { - path.append(sep + "lib" + sep + "amd64" + sep); - libname += "-amd64" + ".so"; - } else { - path.append(sep + "lib" + sep + arch + sep); - libname += "-" + arch + ".so"; - } } else if (os.lastIndexOf("Linux", 0) != -1) { if (arch.equals("x86") || arch.equals("i386")) { path.append(sep + "lib" + sep + "i386" + sep); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/sparc/SPARCArgument.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/sparc/SPARCArgument.java deleted file mode 100644 index 77496c924a3..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/sparc/SPARCArgument.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.asm.sparc; - -import sun.jvm.hotspot.asm.*; -import sun.jvm.hotspot.utilities.*; - -/** SPARCArgument is an abstraction used to represent an outgoing - actual argument or an incoming formal parameter, whether it - resides in memory or in a register, in a manner consistent with - the SPARC Application Binary Interface, or ABI. This is often - referred to as the native or C calling convention. */ - -public class SPARCArgument { - private int number; - private boolean isIn; - - // FIXME: add 64-bit stuff here (support for FP registers) - - /** Only 6 registers may contain integer parameters */ - public static final int NUM_REGISTER_PARAMETERS = 6; - - public SPARCArgument(int number, boolean isIn) { - this.number = number; - this.isIn = isIn; - } - - int getNumber() { return number; } - boolean getIsIn() { return isIn; } - boolean getIsOut() { return !getIsIn(); } - - public SPARCArgument getSuccessor() { return new SPARCArgument(getNumber() + 1, getIsIn()); } - public SPARCArgument asIn() { return new SPARCArgument(getNumber(), true); } - public SPARCArgument asOut() { return new SPARCArgument(getNumber(), false); } - - /** Locating register-based arguments */ - public boolean isRegister() { return number < NUM_REGISTER_PARAMETERS; } - - public SPARCRegister asRegister() { - if (Assert.ASSERTS_ENABLED) { - Assert.that(isRegister(), "must be a register argument"); - } - return new SPARCRegister(getIsIn() ? SPARCRegisterType.IN : SPARCRegisterType.OUT, getNumber()); - } - - // locating memory-based arguments (FIXME: elided for now, will - // necessitate creating new SPARCAddress class) - // public SPARCAddress asAddress() { - // if (Assert.ASSERTS_ENABLED) { - // Assert.that(!isRegister(), "must be a memory argument"); - // } - // return addressInFrame(); - // } - // - // /** When applied to a register-based argument, give the corresponding address - // into the 6-word area "into which callee may store register arguments" - // (This is a different place than the corresponding register-save area location.) */ - // public SPARCAddress addressInFrame() const { - // return SPARCAddress( is_in() ? Address::extra_in_argument - // : Address::extra_out_argument, - // _number ); - // } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/sparc/SPARCRegister.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/sparc/SPARCRegister.java deleted file mode 100644 index b9f146f802c..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/sparc/SPARCRegister.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.asm.sparc; - -import sun.jvm.hotspot.asm.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.utilities.*; - -public class SPARCRegister extends Register { - private static final int nofRegisters = 32; // total number of registers - - private static final int GLOBAL_BASE = 0; - private static final int OUT_BASE = 8; - private static final int LOCAL_BASE = 16; - private static final int IN_BASE = 24; - - private static final int LOCAL_SP_WORD_OFFSET = 0; - private static final int IN_SP_WORD_OFFSET = 8; - - /** Constructor for an explicitly numbered register */ - public SPARCRegister(int number) { - super(number); - } - - /** Constructor for an I, G, O, or L register */ - public SPARCRegister(SPARCRegisterType type, int number) { - if (type == SPARCRegisterType.GLOBAL) { - this.number = number + GLOBAL_BASE; - } else if (type == SPARCRegisterType.OUT) { - this.number = number + OUT_BASE; - } else if (type == SPARCRegisterType.LOCAL) { - this.number = number + LOCAL_BASE; - } else if (type == SPARCRegisterType.IN) { - this.number = number + IN_BASE; - } else { - throw new IllegalArgumentException("Invalid SPARC register type"); - } - } - - public int getNumberOfRegisters() { - return nofRegisters; - } - - public boolean isIn() { - return (IN_BASE <= getNumber()); - } - - public boolean isLocal() { - return (LOCAL_BASE <= getNumber() && getNumber() < IN_BASE); - } - - public boolean isOut() { - return (OUT_BASE <= getNumber() && getNumber() < LOCAL_BASE); - } - - public boolean isGlobal() { - return (GLOBAL_BASE <= getNumber() && getNumber() < OUT_BASE); - } - - public SPARCRegister afterSave() { - if (Assert.ASSERTS_ENABLED) { - Assert.that(isOut() || isGlobal(), "register not visible after save"); - } - return isOut() ? new SPARCRegister(getNumber() + (IN_BASE - OUT_BASE)) : this; - } - - public SPARCRegister afterRestore() { - if (Assert.ASSERTS_ENABLED) { - Assert.that(isIn() || isGlobal(), "register not visible after save"); - } - return isIn() ? new SPARCRegister(getNumber() + (OUT_BASE - IN_BASE)) : this; - } - - /** NOTE: this returns an offset in BYTES in this system! */ - public long spOffsetInSavedWindow() { - if (isIn()) { - return VM.getVM().getAddressSize() * (getNumber() - IN_BASE + IN_SP_WORD_OFFSET); - } else if (isLocal()) { - return VM.getVM().getAddressSize() * (getNumber() - LOCAL_BASE + LOCAL_SP_WORD_OFFSET); - } - if (Assert.ASSERTS_ENABLED) { - Assert.that(isIn() || isLocal(), "only ins and locals are saved in my frame"); - } - return 0; - } - - public String toString() { - return SPARCRegisters.getRegisterName(number); - } - - public boolean isFramePointer() { - return number == 30; // is I6? - } - - public boolean isStackPointer() { - return number == 14; // is O6? - } - - public boolean isFloat() { - return false; - } - - public boolean isV9Only() { - return false; - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/sparc/SPARCRegisterType.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/sparc/SPARCRegisterType.java deleted file mode 100644 index d6f6e4ecc45..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/sparc/SPARCRegisterType.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.asm.sparc; - -/** A class providing the enums describing SPARC register types */ - -public class SPARCRegisterType { - private SPARCRegisterType() { - } - - public static final SPARCRegisterType GLOBAL = new SPARCRegisterType(); - public static final SPARCRegisterType OUT = new SPARCRegisterType(); - public static final SPARCRegisterType IN = new SPARCRegisterType(); - public static final SPARCRegisterType LOCAL = new SPARCRegisterType(); -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/sparc/SPARCRegisters.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/sparc/SPARCRegisters.java deleted file mode 100644 index 6cc543c808a..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/asm/sparc/SPARCRegisters.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.asm.sparc; - -import sun.jvm.hotspot.utilities.*; - -public class SPARCRegisters { - - public static final SPARCRegister G0; - public static final SPARCRegister G1; - public static final SPARCRegister G2; - public static final SPARCRegister G3; - public static final SPARCRegister G4; - public static final SPARCRegister G5; - public static final SPARCRegister G6; - public static final SPARCRegister G7; - public static final SPARCRegister O0; - public static final SPARCRegister O1; - public static final SPARCRegister O2; - public static final SPARCRegister O3; - public static final SPARCRegister O4; - public static final SPARCRegister O5; - public static final SPARCRegister O6; - public static final SPARCRegister O7; - public static final SPARCRegister L0; - public static final SPARCRegister L1; - public static final SPARCRegister L2; - public static final SPARCRegister L3; - public static final SPARCRegister L4; - public static final SPARCRegister L5; - public static final SPARCRegister L6; - public static final SPARCRegister L7; - public static final SPARCRegister I0; - public static final SPARCRegister I1; - public static final SPARCRegister I2; - public static final SPARCRegister I3; - public static final SPARCRegister I4; - public static final SPARCRegister I5; - public static final SPARCRegister I6; - public static final SPARCRegister I7; - - private static String registerNames[]; - public static final int NUM_REGISTERS = 32; - private static SPARCRegister registers[]; - - static { - G0 = new SPARCRegister(0); - G1 = new SPARCRegister(1); - G2 = new SPARCRegister(2); - G3 = new SPARCRegister(3); - G4 = new SPARCRegister(4); - G5 = new SPARCRegister(5); - G6 = new SPARCRegister(6); - G7 = new SPARCRegister(7); - O0 = new SPARCRegister(8); - O1 = new SPARCRegister(9); - O2 = new SPARCRegister(10); - O3 = new SPARCRegister(11); - O4 = new SPARCRegister(12); - O5 = new SPARCRegister(13); - O6 = new SPARCRegister(14); - O7 = new SPARCRegister(15); - L0 = new SPARCRegister(16); - L1 = new SPARCRegister(17); - L2 = new SPARCRegister(18); - L3 = new SPARCRegister(19); - L4 = new SPARCRegister(20); - L5 = new SPARCRegister(21); - L6 = new SPARCRegister(22); - L7 = new SPARCRegister(23); - I0 = new SPARCRegister(24); - I1 = new SPARCRegister(25); - I2 = new SPARCRegister(26); - I3 = new SPARCRegister(27); - I4 = new SPARCRegister(28); - I5 = new SPARCRegister(29); - I6 = new SPARCRegister(30); - I7 = new SPARCRegister(31); - registerNames = new String[NUM_REGISTERS]; - registerNames[G0.getNumber()] = "%g0"; - registerNames[G1.getNumber()] = "%g1"; - registerNames[G2.getNumber()] = "%g2"; - registerNames[G3.getNumber()] = "%g3"; - registerNames[G4.getNumber()] = "%g4"; - registerNames[G5.getNumber()] = "%g5"; - registerNames[G6.getNumber()] = "%g6"; - registerNames[G7.getNumber()] = "%g7"; - registerNames[O0.getNumber()] = "%o0"; - registerNames[O1.getNumber()] = "%o1"; - registerNames[O2.getNumber()] = "%o2"; - registerNames[O3.getNumber()] = "%o3"; - registerNames[O4.getNumber()] = "%o4"; - registerNames[O5.getNumber()] = "%o5"; - registerNames[O6.getNumber()] = "%sp"; - registerNames[O7.getNumber()] = "%o7"; - registerNames[I0.getNumber()] = "%i0"; - registerNames[I1.getNumber()] = "%i1"; - registerNames[I2.getNumber()] = "%i2"; - registerNames[I3.getNumber()] = "%i3"; - registerNames[I4.getNumber()] = "%i4"; - registerNames[I5.getNumber()] = "%i5"; - registerNames[I6.getNumber()] = "%fp"; - registerNames[I7.getNumber()] = "%i7"; - registerNames[L0.getNumber()] = "%l0"; - registerNames[L1.getNumber()] = "%l1"; - registerNames[L2.getNumber()] = "%l2"; - registerNames[L3.getNumber()] = "%l3"; - registerNames[L4.getNumber()] = "%l4"; - registerNames[L5.getNumber()] = "%l5"; - registerNames[L6.getNumber()] = "%l6"; - registerNames[L7.getNumber()] = "%l7"; - registers = (new SPARCRegister[] { - G0, G1, G2, G3, G4, G5, G6, G7, O0, O1, - O2, O3, O4, O5, O6, O7, L0, L1, L2, L3, - L4, L5, L6, L7, I0, I1, I2, I3, I4, I5, - I6, I7 - }); - } - - public static final SPARCRegister FP = I6; - public static final SPARCRegister SP = O6; - - // Interpreter frames - - public static final SPARCRegister Lesp = L0; // expression stack pointer - public static final SPARCRegister Lbcp = L1; // pointer to next bytecode - public static final SPARCRegister Lmethod = L2; - public static final SPARCRegister Llocals = L3; - public static final SPARCRegister Lmonitors = L4; - public static final SPARCRegister Lbyte_code = L5; - public static final SPARCRegister Lscratch = L5; - public static final SPARCRegister Lscratch2 = L6; - public static final SPARCRegister LcpoolCache = L6; // constant pool cache - - public static final SPARCRegister OparamAddr = O0; // Callers Parameter area address - public static final SPARCRegister IsavedSP = I5; // Saved SP before bumping for locals - public static final SPARCRegister IsizeCalleeParms = I4; // Saved size of Callee parms used to pop arguments - public static final SPARCRegister IdispatchAddress = I3; // Register which saves the dispatch address for each bytecode - public static final SPARCRegister IdispatchTables = I2; // Base address of the bytecode dispatch tables - - - /** Prefer to use this instead of the constant above */ - public static int getNumRegisters() { - return NUM_REGISTERS; - } - - - public static String getRegisterName(int regNum) { - if (regNum < 0 || regNum >= NUM_REGISTERS) { - return "[Illegal register " + regNum + "]"; - } - - if (Assert.ASSERTS_ENABLED) { - Assert.that(regNum > -1 && regNum < NUM_REGISTERS, "invalid integer register number!"); - } - - return registerNames[regNum]; - } - - public static SPARCRegister getRegister(int regNum) { - if (Assert.ASSERTS_ENABLED) { - Assert.that(regNum > -1 && regNum < NUM_REGISTERS, "invalid integer register number!"); - } - - return registers[regNum]; - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/Debugger.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/Debugger.java index 90f79a55485..f40c37abff2 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/Debugger.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/Debugger.java @@ -73,12 +73,12 @@ public interface Debugger extends SymbolLookup, ThreadAccess { /** Support for remote debugging. Get the name of the operating system on which this debugger is running (to be able to properly configure the local system). Typical return values are - "solaris", "linux", "win32"; see utilities/PlatformInfo.java. */ + "linux", "win32"; see utilities/PlatformInfo.java. */ public String getOS() throws DebuggerException; /** Support for remote debugging. Get the name of the CPU type on which this debugger is running (to be able to properly configure - the local system). Typical return values are "sparc", "x86"; see + the local system). Typical return value is "x86"; see utilities/PlatformInfo.java. */ public String getCPU() throws DebuggerException; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionSPARC32Bit.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionSPARC32Bit.java deleted file mode 100644 index 66bd7d588a8..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionSPARC32Bit.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.debugger; - -public class MachineDescriptionSPARC32Bit extends MachineDescriptionTwosComplement implements MachineDescription { - public long getAddressSize() { - return 4; - } - - public boolean isBigEndian() { - return true; - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionSPARC64Bit.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionSPARC64Bit.java deleted file mode 100644 index d71e135c8ee..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/MachineDescriptionSPARC64Bit.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.debugger; - -public class MachineDescriptionSPARC64Bit extends MachineDescriptionTwosComplement implements MachineDescription { - public long getAddressSize() { - return 8; - } - - - public boolean isBigEndian() { - return true; - } - - public boolean isLP64() { - return true; - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java index ea062622ed9..e18ff8d896c 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java @@ -33,11 +33,9 @@ import sun.jvm.hotspot.debugger.cdbg.*; import sun.jvm.hotspot.debugger.x86.*; import sun.jvm.hotspot.debugger.amd64.*; import sun.jvm.hotspot.debugger.aarch64.*; -import sun.jvm.hotspot.debugger.sparc.*; import sun.jvm.hotspot.debugger.ppc64.*; import sun.jvm.hotspot.debugger.linux.x86.*; import sun.jvm.hotspot.debugger.linux.amd64.*; -import sun.jvm.hotspot.debugger.linux.sparc.*; import sun.jvm.hotspot.debugger.linux.ppc64.*; import sun.jvm.hotspot.debugger.linux.aarch64.*; import sun.jvm.hotspot.utilities.*; @@ -93,13 +91,6 @@ class LinuxCDebugger implements CDebugger { Address pc = context.getRegisterAsAddress(AMD64ThreadContext.RIP); if (pc == null) return null; return LinuxAMD64CFrame.getTopFrame(dbg, pc, context); - } else if (cpu.equals("sparc")) { - SPARCThreadContext context = (SPARCThreadContext) thread.getContext(); - Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP); - if (sp == null) return null; - Address pc = context.getRegisterAsAddress(SPARCThreadContext.R_O7); - if (pc == null) return null; - return new LinuxSPARCCFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize()); } else if (cpu.equals("ppc64")) { PPC64ThreadContext context = (PPC64ThreadContext) thread.getContext(); Address sp = context.getRegisterAsAddress(PPC64ThreadContext.SP); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxThreadContextFactory.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxThreadContextFactory.java index 4b786eecc95..69a34fe2afa 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxThreadContextFactory.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/LinuxThreadContextFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,6 @@ import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.linux.amd64.*; import sun.jvm.hotspot.debugger.linux.x86.*; import sun.jvm.hotspot.debugger.linux.ppc64.*; -import sun.jvm.hotspot.debugger.linux.sparc.*; class LinuxThreadContextFactory { static ThreadContext createThreadContext(LinuxDebugger dbg) { @@ -38,8 +37,6 @@ class LinuxThreadContextFactory { return new LinuxX86ThreadContext(dbg); } else if (cpu.equals("amd64")) { return new LinuxAMD64ThreadContext(dbg); - } else if (cpu.equals("sparc")) { - return new LinuxSPARCThreadContext(dbg); } else if (cpu.equals("ppc64")) { return new LinuxPPC64ThreadContext(dbg); } else { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/sparc/LinuxSPARCCFrame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/sparc/LinuxSPARCCFrame.java deleted file mode 100644 index d52f6b35ee0..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/sparc/LinuxSPARCCFrame.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.debugger.linux.sparc; - -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.sparc.*; -import sun.jvm.hotspot.debugger.linux.*; -import sun.jvm.hotspot.debugger.cdbg.*; -import sun.jvm.hotspot.debugger.cdbg.basic.*; - -final public class LinuxSPARCCFrame extends BasicCFrame { - // package/class internals only - - public LinuxSPARCCFrame(LinuxDebugger dbg, Address sp, Address pc, int address_size) { - super(dbg.getCDebugger()); - this.sp = sp; - this.pc = pc; - this.dbg = dbg; - this.address_size=address_size; - if (address_size==8) SPARC_STACK_BIAS = 0x7ff; - else SPARC_STACK_BIAS = 0x0; - } - - // override base class impl to avoid ELF parsing - public ClosestSymbol closestSymbolToPC() { - // try native lookup in debugger. - return dbg.lookup(dbg.getAddressValue(pc())); - } - - public Address pc() { - return pc; - } - - public Address localVariableBase() { - return sp; - } - - public CFrame sender(ThreadProxy thread) { - if (sp == null) { - return null; - } - - Address nextSP = sp.getAddressAt( SPARCThreadContext.R_SP * address_size + SPARC_STACK_BIAS); - if (nextSP == null) { - return null; - } - Address nextPC = sp.getAddressAt(SPARCThreadContext.R_O7 * address_size + SPARC_STACK_BIAS); - if (nextPC == null) { - return null; - } - return new LinuxSPARCCFrame(dbg, nextSP, nextPC,address_size); - } - - public static int SPARC_STACK_BIAS; - private static int address_size; - private Address pc; - private Address sp; - private LinuxDebugger dbg; -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/sparc/LinuxSPARCThreadContext.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/sparc/LinuxSPARCThreadContext.java deleted file mode 100644 index 6983dba451b..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/sparc/LinuxSPARCThreadContext.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.debugger.linux.sparc; - -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.sparc.*; -import sun.jvm.hotspot.debugger.linux.*; - -public class LinuxSPARCThreadContext extends SPARCThreadContext { - private LinuxDebugger debugger; - - public LinuxSPARCThreadContext(LinuxDebugger debugger) { - super(); - this.debugger = debugger; - } - - public void setRegisterAsAddress(int index, Address value) { - setRegister(index, debugger.getAddressValue(value)); - } - - public Address getRegisterAsAddress(int index) { - return debugger.newAddress(getRegister(index)); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcDebuggerLocal.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcDebuggerLocal.java deleted file mode 100644 index 76dc4dc0485..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/ProcDebuggerLocal.java +++ /dev/null @@ -1,728 +0,0 @@ -/* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.debugger.proc; - -import java.io.*; -import java.net.*; -import java.util.*; -import java.lang.reflect.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.cdbg.*; -import sun.jvm.hotspot.debugger.proc.amd64.*; -import sun.jvm.hotspot.debugger.proc.aarch64.*; -import sun.jvm.hotspot.debugger.proc.sparc.*; -import sun.jvm.hotspot.debugger.proc.ppc64.*; -import sun.jvm.hotspot.debugger.proc.x86.*; -import sun.jvm.hotspot.debugger.ppc64.*; -import sun.jvm.hotspot.debugger.amd64.*; -import sun.jvm.hotspot.debugger.aarch64.*; -import sun.jvm.hotspot.debugger.sparc.*; -import sun.jvm.hotspot.debugger.x86.*; -import sun.jvm.hotspot.utilities.*; - -/**

    An implementation of the JVMDebugger interface which sits on - * top of proc and relies on the SA's proc import module for - * communication with the debugger.

    - * - *

    NOTE that since we have the notion of fetching "Java - * primitive types" from the remote process (which might have - * different sizes than we expect) we have a bootstrapping - * problem. We need to know the sizes of these types before we can - * fetch them. The current implementation solves this problem by - * requiring that it be configured with these type sizes before they - * can be fetched. The readJ(Type) routines here will throw a - * RuntimeException if they are called before the debugger is - * configured with the Java primitive type sizes.

    - */ - -public class ProcDebuggerLocal extends DebuggerBase implements ProcDebugger { - protected static final int cacheSize = 16 * 1024 * 1024; // 16 MB - - //------------------------------------------------------------------------ - // Implementation of Debugger interface - // - - /**

    machDesc may be null if it couldn't be determined yet; i.e., - * if we're on SPARC, we need to ask the remote process whether - * we're in 32- or 64-bit mode.

    - * - *

    useCache should be set to true if debugging is being done - * locally, and to false if the debugger is being created for the - * purpose of supporting remote debugging.

    */ - public ProcDebuggerLocal(MachineDescription machDesc, boolean useCache) { - this.machDesc = machDesc; - int cacheNumPages; - int cachePageSize; - - final String cpu = PlatformInfo.getCPU(); - if (cpu.equals("sparc")) { - threadFactory = new ProcSPARCThreadFactory(this); - pcRegIndex = SPARCThreadContext.R_PC; - fpRegIndex = SPARCThreadContext.R_I6; - } else if (cpu.equals("x86")) { - threadFactory = new ProcX86ThreadFactory(this); - pcRegIndex = X86ThreadContext.EIP; - fpRegIndex = X86ThreadContext.EBP; - unalignedAccessesOkay = true; - } else if (cpu.equals("amd64") || cpu.equals("x86_64")) { - threadFactory = new ProcAMD64ThreadFactory(this); - pcRegIndex = AMD64ThreadContext.RIP; - fpRegIndex = AMD64ThreadContext.RBP; - } else if (cpu.equals("aarch64")) { - threadFactory = new ProcAARCH64ThreadFactory(this); - pcRegIndex = AARCH64ThreadContext.PC; - fpRegIndex = AARCH64ThreadContext.FP; - } else if (cpu.equals("ppc64")) { - threadFactory = new ProcPPC64ThreadFactory(this); - pcRegIndex = PPC64ThreadContext.PC; - fpRegIndex = PPC64ThreadContext.SP; - } else { - try { - Class tfc = Class.forName("sun.jvm.hotspot.debugger.proc." + - cpu.toLowerCase() + ".Proc" + cpu.toUpperCase() + - "ThreadFactory"); - Constructor[] ctfc = tfc.getConstructors(); - threadFactory = (ProcThreadFactory)ctfc[0].newInstance(this); - } catch (Exception e) { - throw new RuntimeException("Thread access for CPU architecture " + PlatformInfo.getCPU() + " not yet supported"); - // Note: pcRegIndex and fpRegIndex do not appear to be referenced - } - } - if (useCache) { - // Cache portion of the remote process's address space. - // For now, this cache works best if it covers the entire - // heap of the remote process. FIXME: at least should make this - // tunable from the outside, i.e., via the UI. This is a 16 MB - // cache divided on SPARC into 2048 8K pages and on x86 into - // 4096 4K pages; the page size must be adjusted to be the OS's - // page size. - - cachePageSize = getPageSize(); - cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize); - initCache(cachePageSize, cacheNumPages); - } - - resetNativePointers(); - clearCacheFields(); - } - - /** FIXME: implement this with a Runtime.exec() of ps followed by - * parsing of its output */ - public boolean hasProcessList() throws DebuggerException { - return false; - } - - public List getProcessList() throws DebuggerException { - throw new DebuggerException("Not yet supported"); - } - - - /** From the Debugger interface via JVMDebugger */ - public synchronized void attach(int processID) throws DebuggerException { - checkAttached(); - isCore = false; - attach0(Integer.toString(processID)); - attached = true; - suspended = true; - } - - /** From the Debugger interface via JVMDebugger */ - public synchronized void attach - (String executableName, String coreFileName) throws DebuggerException { - checkAttached(); - isCore = true; - topFrameCache = new HashMap<>(); - attach0(executableName, coreFileName); - attached = true; - suspended = true; - } - - /** From the Debugger interface via JVMDebugger */ - public synchronized boolean detach() { - if (! attached) { - return false; - } - - try { - if (p_ps_prochandle == 0L) { - return false; - } - detach0(); - clearCache(); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } finally { - resetNativePointers(); - clearCacheFields(); - suspended = false; - attached = false; - } - } - - public synchronized void suspend() throws DebuggerException { - requireAttach(); - if (suspended) { - throw new DebuggerException("Process already suspended"); - } - suspend0(); - suspended = true; - enableCache(); - reresolveLoadObjects(); - } - - public synchronized void resume() throws DebuggerException { - requireAttach(); - if (!suspended) { - throw new DebuggerException("Process not suspended"); - } - resume0(); - disableCache(); - suspended = false; - } - - public synchronized boolean isSuspended() throws DebuggerException { - requireAttach(); - return suspended; - } - - /** From the Debugger interface via JVMDebugger */ - public Address parseAddress(String addressString) throws NumberFormatException { - long addr = utils.scanAddress(addressString); - if (addr == 0) { - return null; - } - return new ProcAddress(this, addr); - } - - /** From the Debugger interface via JVMDebugger */ - public String getOS() { - return PlatformInfo.getOS(); - } - - /** From the Debugger interface via JVMDebugger */ - public String getCPU() { - return PlatformInfo.getCPU(); - } - - public boolean hasConsole() throws DebuggerException { - return false; - } - - public String consoleExecuteCommand(String cmd) throws DebuggerException { - throw new DebuggerException("Can't execute console commands"); - } - - public String getConsolePrompt() throws DebuggerException { - return ""; - } - - public CDebugger getCDebugger() throws DebuggerException { - if (cdbg == null) { - cdbg = new ProcCDebugger(this); - } - return cdbg; - } - - /** From the SymbolLookup interface via Debugger and JVMDebugger */ - public synchronized Address lookup(String objectName, String symbol) { - requireAttach(); - long addr = lookupByName0(objectName, symbol); - if (addr == 0) { - return null; - } - return new ProcAddress(this, addr); - } - - /** From the SymbolLookup interface via Debugger and JVMDebugger */ - public synchronized OopHandle lookupOop(String objectName, String symbol) { - Address addr = lookup(objectName, symbol); - if (addr == null) { - return null; - } - return addr.addOffsetToAsOopHandle(0); - } - - /** From the ProcDebugger interface */ - public MachineDescription getMachineDescription() { - return machDesc; - } - - /** Internal routine supporting lazy setting of MachineDescription, - * since on SPARC we will need to query the remote process to ask - * it what its data model is (32- or 64-bit). - */ - - public void setMachineDescription(MachineDescription machDesc) { - this.machDesc = machDesc; - setBigEndian(machDesc.isBigEndian()); - utils = new DebuggerUtilities(machDesc.getAddressSize(), machDesc.isBigEndian()); - } - - public synchronized int getRemoteProcessAddressSize() - throws DebuggerException { - requireAttach(); - return getRemoteProcessAddressSize0(); - } - - //-------------------------------------------------------------------------------- - // Implementation of ThreadAccess interface - // - - /** From the ThreadAccess interface via Debugger and JVMDebugger */ - public ThreadProxy getThreadForIdentifierAddress(Address addr) { - return threadFactory.createThreadWrapper(addr); - } - - public ThreadProxy getThreadForThreadId(long id) { - return threadFactory.createThreadWrapper(id); - } - - //---------------------------------------------------------------------- - // Overridden from DebuggerBase because we need to relax alignment - // constraints on x86 - - public long readJLong(long address) - throws UnmappedAddressException, UnalignedAddressException { - checkJavaConfigured(); - // FIXME: allow this to be configurable. Undesirable to add a - // dependency on the runtime package here, though, since this - // package should be strictly underneath it. - if (unalignedAccessesOkay) { - utils.checkAlignment(address, jintSize); - } else { - utils.checkAlignment(address, jlongSize); - } - byte[] data = readBytes(address, jlongSize); - return utils.dataToJLong(data, jlongSize); - } - - //-------------------------------------------------------------------------------- - // Internal routines (for implementation of ProcAddress). - // These must not be called until the MachineDescription has been set up. - // - - /** From the ProcDebugger interface */ - public String addressValueToString(long address) { - return utils.addressValueToString(address); - } - - /** Need to override this to relax alignment checks on Solaris/x86. */ - public long readCInteger(long address, long numBytes, boolean isUnsigned) - throws UnmappedAddressException, UnalignedAddressException { - checkConfigured(); - if (!unalignedAccessesOkay) { - utils.checkAlignment(address, numBytes); - } else { - // Only slightly relaxed semantics -- this is a hack, but is - // necessary on Solaris/x86 where it seems the compiler is - // putting some global 64-bit data on 32-bit boundaries - if (numBytes == 8) { - utils.checkAlignment(address, 4); - } else { - utils.checkAlignment(address, numBytes); - } - } - byte[] data = readBytes(address, numBytes); - return utils.dataToCInteger(data, isUnsigned); - } - - /** From the ProcDebugger interface */ - public ProcAddress readAddress(long address) - throws UnmappedAddressException, UnalignedAddressException { - long value = readAddressValue(address); - return (value == 0 ? null : new ProcAddress(this, value)); - } - - public ProcAddress readCompOopAddress(long address) - throws UnmappedAddressException, UnalignedAddressException { - long value = readCompOopAddressValue(address); - return (value == 0 ? null : new ProcAddress(this, value)); - } - - public ProcAddress readCompKlassAddress(long address) - throws UnmappedAddressException, UnalignedAddressException { - long value = readCompKlassAddressValue(address); - return (value == 0 ? null : new ProcAddress(this, value)); - } - - /** From the ProcDebugger interface */ - public ProcOopHandle readOopHandle(long address) - throws UnmappedAddressException, UnalignedAddressException, NotInHeapException { - long value = readAddressValue(address); - return (value == 0 ? null : new ProcOopHandle(this, value)); - } - - public ProcOopHandle readCompOopHandle(long address) { - long value = readCompOopAddressValue(address); - return (value == 0 ? null : new ProcOopHandle(this, value)); - } - - public void writeBytesToProcess(long address, long numBytes, byte[] data) - throws UnmappedAddressException, DebuggerException { - if (isCore) { - throw new DebuggerException("Attached to a core file!"); - } - writeBytesToProcess0(address, numBytes, data); - } - - public synchronized ReadResult readBytesFromProcess(long address, long numBytes) - throws DebuggerException { - requireAttach(); - byte[] res = readBytesFromProcess0(address, numBytes); - if(res != null) - return new ReadResult(res); - else - return new ReadResult(address); - } - - protected int getPageSize() { - int pagesize = getPageSize0(); - if (pagesize == -1) { - // return the hard coded default value. - if (PlatformInfo.getCPU().equals("sparc") || - PlatformInfo.getCPU().equals("amd64") ) - pagesize = 8196; - else - pagesize = 4096; - } - return pagesize; - } - - //-------------------------------------------------------------------------------- - // Thread context access. Can not be package private, but should - // only be accessed by the architecture-specific subpackages. - - /** From the ProcDebugger interface. May have to redefine this later. */ - public synchronized long[] getThreadIntegerRegisterSet(int tid) { - requireAttach(); - return getThreadIntegerRegisterSet0(tid); - } - - //-------------------------------------------------------------------------------- - // Address access. Can not be package private, but should only be - // accessed by the architecture-specific subpackages. - - /** From the ProcDebugger interface */ - public long getAddressValue(Address addr) { - if (addr == null) return 0; - return ((ProcAddress) addr).getValue(); - } - - /** From the ProcDebugger interface */ - public Address newAddress(long value) { - if (value == 0) return null; - return new ProcAddress(this, value); - } - - /** From the ProcDebugger interface */ - public synchronized List getThreadList() throws DebuggerException { - requireAttach(); - List res = null; - if (isCore && (threadListCache != null)) { - res = threadListCache; - } else { - res = new ArrayList<>(); - fillThreadList0(res); - if (isCore) { - threadListCache = res; - } - } - return res; - } - - /** From the ProcDebugger interface */ - public synchronized List getLoadObjectList() throws DebuggerException { - requireAttach(); - if (!suspended) { - throw new DebuggerException("Process not suspended"); - } - - if (loadObjectCache == null) { - updateLoadObjectCache(); - } - return loadObjectCache; - } - - /** From the ProcDebugger interface */ - public synchronized CFrame topFrameForThread(ThreadProxy thread) - throws DebuggerException { - requireAttach(); - CFrame res = null; - if (isCore && ((res = (CFrame) topFrameCache.get(thread)) != null)) { - return res; - } else { - ThreadContext context = thread.getContext(); - int numRegs = context.getNumRegisters(); - long[] regs = new long[numRegs]; - for (int i = 0; i < numRegs; i++) { - regs[i] = context.getRegister(i); - } - res = fillCFrameList0(regs); - if (isCore) { - topFrameCache.put(thread, res); - } - return res; - } - } - - /** From the ProcDebugger interface */ - public synchronized ClosestSymbol lookup(long address) { - requireAttach(); - return lookupByAddress0(address); - } - - /** From the ProcDebugger interface */ - public String demangle(String name) { - return demangle0(name); - } - - //------------- Internals only below this point -------------------- - // - // - - private void updateLoadObjectCache() { - List res = new ArrayList<>(); - nameToDsoMap = new HashMap<>(); - fillLoadObjectList0(res); - loadObjectCache = sortLoadObjects(res); - } - - // sort load objects by base address - private static List sortLoadObjects(List in) { - // sort the list by base address - LoadObject[] arr = in.toArray(new LoadObject[0]); - Arrays.sort(arr, loadObjectComparator); - return Arrays.asList(arr); - } - - private long lookupByName(String objectName, String symbolName) - throws DebuggerException { - // NOTE: this assumes that process is suspended (which is probably - // necessary assumption given that DSOs can be loaded/unloaded as - // process runs). Should update documentation. - if (nameToDsoMap == null) { - getLoadObjectList(); - } - SharedObject dso = (SharedObject) nameToDsoMap.get(objectName); - // The DSO can be null because we use this to search through known - // DSOs in HotSpotTypeDataBase (for example) - if (dso != null) { - ProcAddress addr = (ProcAddress) dso.lookupSymbol(symbolName); - if (addr != null) { - return addr.getValue(); - } - } - return 0; - } - - private SharedObject findDSOByName(String fullPathName) { - if (loadObjectCache == null) - return null; - for (Iterator iter = loadObjectCache.iterator(); iter.hasNext(); ) { - SharedObject dso = (SharedObject) iter.next(); - if (dso.getName().equals(fullPathName)) { - return dso; - } - } - return null; - } - - private void reresolveLoadObjects() throws DebuggerException { - if (loadObjectCache == null) { - return; - } - updateLoadObjectCache(); - } - - - private void checkAttached() { - if (attached) { - if (isCore) { - throw new DebuggerException("already attached to a core file!"); - } else { - throw new DebuggerException("already attached to a process!"); - } - } - } - - private void requireAttach() { - if (! attached) { - throw new RuntimeException("not attached to a process or core file!"); - } - } - - private void clearCacheFields() { - loadObjectCache = null; - nameToDsoMap = null; - threadListCache = null; - topFrameCache = null; - } - - private void resetNativePointers() { - p_ps_prochandle = 0L; - - // reset thread_db pointers - libthread_db_handle = 0L; - p_td_thragent_t = 0L; - p_td_init = 0L; - p_td_ta_new = 0L; - p_td_ta_delete = 0L; - p_td_ta_thr_iter = 0L; - p_td_thr_get_info = 0L; - p_td_ta_map_id2thr = 0L; - p_td_thr_getgregs = 0L; - - // part of class sharing workaround - classes_jsa_fd = -1; - p_file_map_header = 0L; - } - - // native methods and native helpers - - // attach, detach - private native void attach0(String pid) throws DebuggerException; - private native void attach0(String executableFile, String coreFileName) throws DebuggerException; - private native void detach0() throws DebuggerException; - - // address size, page size - private native int getRemoteProcessAddressSize0() throws DebuggerException; - private native int getPageSize0() throws DebuggerException; - - // threads, stacks - private native long[] getThreadIntegerRegisterSet0(long tid) throws DebuggerException; - private native void fillThreadList0(List l) throws DebuggerException; - - // fills stack frame list given reg set of the top frame and top frame - private native ProcCFrame fillCFrameList0(long[] regs) throws DebuggerException; - - // helper called by fillCFrameList0 - private ProcCFrame createSenderFrame(ProcCFrame f, long pc, long fp) { - ProcCFrame sender = new ProcCFrame(this, newAddress(pc), newAddress(fp)); - if (f != null) { - f.setSender(sender); - } - return sender; - } - - // shared objects - private native void fillLoadObjectList0(List l) throws DebuggerException; - - // helper called by fillLoadObjectList0 - private LoadObject createLoadObject(String fileName, long textsize, long base) { - File f = new File(fileName); - Address baseAddr = newAddress(base); - SharedObject res = findDSOByName(fileName); - if (res != null) { - // already in cache. just change the base, if needed - Address oldBase = res.getBase(); - if (! baseAddr.equals(oldBase)) { - res.setBase(baseAddr); - } - } else { - // new shared object. - res = new SharedObject(this, fileName, f.length(), baseAddr); - } - nameToDsoMap.put(f.getName(), res); - return res; - } - - // symbol-to-pc - private native long lookupByName0(String objectName, String symbolName) throws DebuggerException; - private native ClosestSymbol lookupByAddress0(long address) throws DebuggerException; - - // helper called by lookupByAddress0 - private ClosestSymbol createClosestSymbol(String name, long offset) { - return new ClosestSymbol(name, offset); - } - - // process read/write - private native byte[] readBytesFromProcess0(long address, long numBytes) throws DebuggerException; - private native void writeBytesToProcess0(long address, long numBytes, byte[] data) throws DebuggerException; - - // process control - private native void suspend0() throws DebuggerException; - private native void resume0() throws DebuggerException; - - // demangle a C++ name - private native String demangle0(String name); - - // init JNI ids to fields, methods - private native static void initIDs() throws DebuggerException; - private static LoadObjectComparator loadObjectComparator; - - static { - System.loadLibrary("saproc"); - initIDs(); - loadObjectComparator = new LoadObjectComparator(); - } - - private boolean unalignedAccessesOkay; - private ProcThreadFactory threadFactory; - - // indices of PC and FP registers in gregset - private int pcRegIndex; - private int fpRegIndex; - - // Symbol lookup support - // This is a map of library names to DSOs - private Map nameToDsoMap; - - // C/C++ debugging support - private List loadObjects; - private CDebugger cdbg; - - // ProcessControl support - private boolean suspended; - - // libproc handle - private long p_ps_prochandle; - - // libthread.so's dlopen handle, thread agent - // and function pointers - private long libthread_db_handle; - private long p_td_thragent_t; - private long p_td_init; - private long p_td_ta_new; - private long p_td_ta_delete; - private long p_td_ta_thr_iter; - private long p_td_thr_get_info; - private long p_td_ta_map_id2thr; - private long p_td_thr_getgregs; - - // part of class sharing workaround - private int classes_jsa_fd; - private long p_file_map_header; - - private boolean attached = false; - private boolean isCore; - - // for core files, we cache load object list, thread list, top frames etc. - // for processes we cache load object list and sync. it during suspend. - private List threadListCache; - private List loadObjectCache; - private Map topFrameCache; -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/sparc/ProcSPARCThread.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/sparc/ProcSPARCThread.java deleted file mode 100644 index e49f1a72b84..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/sparc/ProcSPARCThread.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.debugger.proc.sparc; - -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.sparc.*; -import sun.jvm.hotspot.debugger.proc.*; -import sun.jvm.hotspot.utilities.*; - -public class ProcSPARCThread implements ThreadProxy { - private ProcDebugger debugger; - private int id; - - public ProcSPARCThread(ProcDebugger debugger, Address addr) { - this.debugger = debugger; - - // FIXME: the size here should be configurable. However, making it - // so would produce a dependency on the "types" package from the - // debugger package, which is not desired. - this.id = (int) addr.getCIntegerAt(0, 4, true); - } - - public ProcSPARCThread(ProcDebugger debugger, long id) { - this.debugger = debugger; - this.id = (int) id; - } - - public ThreadContext getContext() throws IllegalThreadStateException { - ProcSPARCThreadContext context = new ProcSPARCThreadContext(debugger); - long[] regs = debugger.getThreadIntegerRegisterSet(id); - if (Assert.ASSERTS_ENABLED) { - Assert.that(regs.length == SPARCThreadContext.NPRGREG, "size of register set must match"); - } - for (int i = 0; i < regs.length; i++) { - context.setRegister(i, regs[i]); - } - return context; - } - - public boolean canSetContext() throws DebuggerException { - return false; - } - - public void setContext(ThreadContext context) - throws IllegalThreadStateException, DebuggerException { - throw new DebuggerException("Unimplemented"); - } - - public String toString() { - return "t@" + id; - } - - public boolean equals(Object obj) { - if ((obj == null) || !(obj instanceof ProcSPARCThread)) { - return false; - } - - return (((ProcSPARCThread) obj).id == id); - } - - public int hashCode() { - return id; - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/sparc/ProcSPARCThreadContext.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/sparc/ProcSPARCThreadContext.java deleted file mode 100644 index 7a796a18e76..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/sparc/ProcSPARCThreadContext.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.debugger.proc.sparc; - -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.sparc.*; -import sun.jvm.hotspot.debugger.proc.*; - -public class ProcSPARCThreadContext extends SPARCThreadContext { - private ProcDebugger debugger; - - public ProcSPARCThreadContext(ProcDebugger debugger) { - super(); - this.debugger = debugger; - } - - public void setRegisterAsAddress(int index, Address value) { - setRegister(index, debugger.getAddressValue(value)); - } - - public Address getRegisterAsAddress(int index) { - return debugger.newAddress(getRegister(index)); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/sparc/ProcSPARCThreadFactory.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/sparc/ProcSPARCThreadFactory.java deleted file mode 100644 index 5456b3ba686..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/proc/sparc/ProcSPARCThreadFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.debugger.proc.sparc; - -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.proc.*; - -public class ProcSPARCThreadFactory implements ProcThreadFactory { - private ProcDebugger debugger; - - public ProcSPARCThreadFactory(ProcDebugger debugger) { - this.debugger = debugger; - } - - public ThreadProxy createThreadWrapper(Address threadIdentifierAddr) { - return new ProcSPARCThread(debugger, threadIdentifierAddr); - } - - public ThreadProxy createThreadWrapper(long id) { - return new ProcSPARCThread(debugger, id); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java index 0387672f85f..1a6bfd5b23c 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java @@ -30,7 +30,6 @@ import java.lang.reflect.*; import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.cdbg.*; -import sun.jvm.hotspot.debugger.remote.sparc.*; import sun.jvm.hotspot.debugger.remote.x86.*; import sun.jvm.hotspot.debugger.remote.amd64.*; import sun.jvm.hotspot.debugger.remote.ppc64.*; @@ -57,11 +56,7 @@ public class RemoteDebuggerClient extends DebuggerBase implements JVMDebugger { int cachePageSize; String cpu = remoteDebugger.getCPU(); // page size. (FIXME: should pick this up from the remoteDebugger.) - if (cpu.equals("sparc")) { - threadFactory = new RemoteSPARCThreadFactory(this); - cachePageSize = 8192; - cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize); - } else if (cpu.equals("x86")) { + if (cpu.equals("x86")) { threadFactory = new RemoteX86ThreadFactory(this); cachePageSize = 4096; cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/sparc/RemoteSPARCThread.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/sparc/RemoteSPARCThread.java deleted file mode 100644 index 068aea707e7..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/sparc/RemoteSPARCThread.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.debugger.remote.sparc; - -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.sparc.*; -import sun.jvm.hotspot.debugger.remote.*; -import sun.jvm.hotspot.utilities.*; - -public class RemoteSPARCThread extends RemoteThread { - public RemoteSPARCThread(RemoteDebuggerClient debugger, Address addr) { - super(debugger, addr); - } - - public RemoteSPARCThread(RemoteDebuggerClient debugger, long id) { - super(debugger, id); - } - - public ThreadContext getContext() throws IllegalThreadStateException { - RemoteSPARCThreadContext context = new RemoteSPARCThreadContext(debugger); - long[] regs = (addr != null)? debugger.getThreadIntegerRegisterSet(addr) : - debugger.getThreadIntegerRegisterSet(id); - - if (Assert.ASSERTS_ENABLED) { - Assert.that(regs.length == SPARCThreadContext.NPRGREG, "size of register set must match"); - } - for (int i = 0; i < regs.length; i++) { - context.setRegister(i, regs[i]); - } - return context; - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/sparc/RemoteSPARCThreadContext.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/sparc/RemoteSPARCThreadContext.java deleted file mode 100644 index 54584cf972c..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/sparc/RemoteSPARCThreadContext.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.debugger.remote.sparc; - -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.sparc.*; -import sun.jvm.hotspot.debugger.remote.*; - -public class RemoteSPARCThreadContext extends SPARCThreadContext { - private RemoteDebuggerClient debugger; - - public RemoteSPARCThreadContext(RemoteDebuggerClient debugger) { - super(); - this.debugger = debugger; - } - - /** This can't be implemented in this class since we would have to - tie the implementation to, for example, the debugging system */ - public void setRegisterAsAddress(int index, Address value) { - setRegister(index, debugger.getAddressValue(value)); - } - - /** This can't be implemented in this class since we would have to - tie the implementation to, for example, the debugging system */ - public Address getRegisterAsAddress(int index) { - return debugger.newAddress(getRegister(index)); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/sparc/RemoteSPARCThreadFactory.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/sparc/RemoteSPARCThreadFactory.java deleted file mode 100644 index 4e0174f5184..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/remote/sparc/RemoteSPARCThreadFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.debugger.remote.sparc; - -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.remote.*; - -public class RemoteSPARCThreadFactory implements RemoteThreadFactory { - private RemoteDebuggerClient debugger; - - public RemoteSPARCThreadFactory(RemoteDebuggerClient debugger) { - this.debugger = debugger; - } - - public ThreadProxy createThreadWrapper(Address threadIdentifierAddr) { - return new RemoteSPARCThread(debugger, threadIdentifierAddr); - } - - public ThreadProxy createThreadWrapper(long id) { - return new RemoteSPARCThread(debugger, id); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/sparc/SPARCThreadContext.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/sparc/SPARCThreadContext.java deleted file mode 100644 index 9f9ee37df5f..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/sparc/SPARCThreadContext.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.debugger.sparc; - -import java.lang.annotation.Native; - -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.cdbg.*; - -/** Currently provides just the minimal information necessary to get - stack traces working. FIXME: currently hardwired for v9 -- will - have to factor out v8/v9 specific code. FIXME: may want to try to - share code between this class and asm/sparc. */ - -public abstract class SPARCThreadContext implements ThreadContext { - // Taken from /usr/include/sys/procfs_isa.h - - // One instance of the Native annotation is enough to trigger header generation - // for this file. - @Native - public static final int R_G0 = 0; - public static final int R_G1 = 1; - public static final int R_G2 = 2; - public static final int R_G3 = 3; - public static final int R_G4 = 4; - public static final int R_G5 = 5; - public static final int R_G6 = 6; - public static final int R_G7 = 7; - public static final int R_O0 = 8; - public static final int R_O1 = 9; - public static final int R_O2 = 10; - public static final int R_O3 = 11; - public static final int R_O4 = 12; - public static final int R_O5 = 13; - public static final int R_O6 = 14; - public static final int R_O7 = 15; - public static final int R_L0 = 16; - public static final int R_L1 = 17; - public static final int R_L2 = 18; - public static final int R_L3 = 19; - public static final int R_L4 = 20; - public static final int R_L5 = 21; - public static final int R_L6 = 22; - public static final int R_L7 = 23; - public static final int R_I0 = 24; - public static final int R_I1 = 25; - public static final int R_I2 = 26; - public static final int R_I3 = 27; - public static final int R_I4 = 28; - public static final int R_I5 = 29; - public static final int R_I6 = 30; - public static final int R_I7 = 31; - - // sparc-v9 - public static final int R_CCR = 32; - // sparc-v8 - public static final int R_PSR = 32; - - public static final int R_PC = 33; - public static final int R_nPC = 34; - - public static final int R_SP = R_O6; - public static final int R_FP = R_I6; - - public static final int R_Y = 35; - - // sparc-v9 - public static final int R_ASI = 36; - public static final int R_FPRS = 37; - - // sparc-v8 - public static final int R_WIM = 36; - public static final int R_TBR = 37; - - public static final int NPRGREG = 38; - - private static final String[] regNames = { - "G0", "G1", "G2", "G3", - "G4", "G5", "G6", "G7", - "O0", "O1", "O2", "O3", - "O4", "O5", "O6/SP", "O7", - "L0", "L1", "L2", "L3", - "L4", "L5", "L6", "L7", - "I0", "I1", "I2", "I3", - "I4", "I5", "I6/FP", "I7", - "CCR/PSR", "PC", "nPC", "Y", - "ASI/WIM", "FPRS/TBR" - }; - - private long[] data; - - public SPARCThreadContext() { - data = new long[NPRGREG]; - } - - public int getNumRegisters() { - return NPRGREG; - } - - public String getRegisterName(int index) { - return regNames[index]; - } - - public void setRegister(int index, long value) { - data[index] = value; - } - - public long getRegister(int index) { - return data[index]; - } - - public CFrame getTopFrame(Debugger dbg) { - return null; - } - - /** This can't be implemented in this class since we would have to - tie the implementation to, for example, the debugging system */ - public abstract void setRegisterAsAddress(int index, Address value); - - /** This can't be implemented in this class since we would have to - tie the implementation to, for example, the debugging system */ - public abstract Address getRegisterAsAddress(int index); -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZAddress.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZAddress.java index 31e158b0dd5..beca1ed7cc1 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZAddress.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZAddress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,11 +56,6 @@ class ZAddress { } static Address address(long value) { - VM vm = VM.getVM(); - if (vm.getOS().equals("solaris") && vm.getCPU().equals("sparc")) { - value |= ZGlobals.ZAddressSpaceStart; - } - return ZUtils.longToAddress(value); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java index d751a02460e..59d089ef6bb 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java @@ -28,16 +28,12 @@ import java.util.*; import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.runtime.solaris_sparc.SolarisSPARCJavaThreadPDAccess; -import sun.jvm.hotspot.runtime.solaris_x86.SolarisX86JavaThreadPDAccess; -import sun.jvm.hotspot.runtime.solaris_amd64.SolarisAMD64JavaThreadPDAccess; import sun.jvm.hotspot.runtime.win32_amd64.Win32AMD64JavaThreadPDAccess; import sun.jvm.hotspot.runtime.win32_x86.Win32X86JavaThreadPDAccess; import sun.jvm.hotspot.runtime.linux_x86.LinuxX86JavaThreadPDAccess; import sun.jvm.hotspot.runtime.linux_amd64.LinuxAMD64JavaThreadPDAccess; import sun.jvm.hotspot.runtime.linux_aarch64.LinuxAARCH64JavaThreadPDAccess; import sun.jvm.hotspot.runtime.linux_ppc64.LinuxPPC64JavaThreadPDAccess; -import sun.jvm.hotspot.runtime.linux_sparc.LinuxSPARCJavaThreadPDAccess; import sun.jvm.hotspot.runtime.bsd_x86.BsdX86JavaThreadPDAccess; import sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess; import sun.jvm.hotspot.utilities.*; @@ -98,15 +94,7 @@ public class Threads { access = null; // FIXME: find the platform specific PD class by reflection? - if (os.equals("solaris")) { - if (cpu.equals("sparc")) { - access = new SolarisSPARCJavaThreadPDAccess(); - } else if (cpu.equals("x86")) { - access = new SolarisX86JavaThreadPDAccess(); - } else if (cpu.equals("amd64")) { - access = new SolarisAMD64JavaThreadPDAccess(); - } - } else if (os.equals("win32")) { + if (os.equals("win32")) { if (cpu.equals("x86")) { access = new Win32X86JavaThreadPDAccess(); } else if (cpu.equals("amd64")) { @@ -117,8 +105,6 @@ public class Threads { access = new LinuxX86JavaThreadPDAccess(); } else if (cpu.equals("amd64")) { access = new LinuxAMD64JavaThreadPDAccess(); - } else if (cpu.equals("sparc")) { - access = new LinuxSPARCJavaThreadPDAccess(); } else if (cpu.equals("ppc64")) { access = new LinuxPPC64JavaThreadPDAccess(); } else if (cpu.equals("aarch64")) { diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/linux_sparc/LinuxSPARCJavaThreadPDAccess.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/linux_sparc/LinuxSPARCJavaThreadPDAccess.java deleted file mode 100644 index fb7757b72d5..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/linux_sparc/LinuxSPARCJavaThreadPDAccess.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.runtime.linux_sparc; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.sparc.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.runtime.sparc.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; -import sun.jvm.hotspot.utilities.Observable; -import sun.jvm.hotspot.utilities.Observer; - -public class LinuxSPARCJavaThreadPDAccess implements JavaThreadPDAccess { - private static AddressField baseOfStackPointerField; - private static AddressField postJavaStateField; - private static AddressField osThreadField; - private static int isPC; - private static int hasFlushed; - - // Field from OSThread - private static CIntegerField osThreadThreadIDField; - - static { - VM.registerVMInitializedObserver(new Observer() { - public void update(Observable o, Object data) { - initialize(VM.getVM().getTypeDataBase()); - } - }); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("JavaThread"); - Type anchorType = db.lookupType("JavaFrameAnchor"); - - osThreadField = type.getAddressField("_osthread"); - hasFlushed = db.lookupIntConstant("JavaFrameAnchor::flushed").intValue(); - - type = db.lookupType("OSThread"); - osThreadThreadIDField = type.getCIntegerField("_thread_id"); - } - - public Address getLastJavaFP(Address addr) { - return null; - - } - - public Address getLastJavaPC(Address addr) { - return null; - } - - public Address getBaseOfStackPointer(Address addr) { - return baseOfStackPointerField.getValue(addr); - } - - public Frame getLastFramePD(JavaThread thread, Address addr) { - - // This assert doesn't work in the debugging case for threads - // which are running Java code and which haven't re-entered the - // runtime (e.g., through a Method.invoke() or otherwise). They - // haven't yet "decached" their last Java stack pointer to the - // thread. - - // if (Assert.ASSERTS_ENABLED) { - // Assert.that(hasLastJavaFrame(), "must have last_Java_sp() when suspended"); - // // FIXME: add assertion about flushing register windows for runtime system - // // (not appropriate for debugging system, though, unless at safepoin t) - // } - - // FIXME: I don't think this is necessary, but might be useful - // while debugging - if (thread.getLastJavaSP() == null) { - return null; - } - - // sparc does a lazy window flush. The _flags field of the JavaFrameAnchor - // encodes whether the windows have flushed. Whenever the windows have flushed - // there will be a last_Java_pc. - // In a relective system we'd have to do something to force the thread to flush - // its windows and give us the pc (or the younger_sp so we can find it ourselves) - // In a debugger situation (process or core) the flush should have happened and - // so if we don't have the younger sp we can find it - // - if (thread.getLastJavaPC() != null) { - return new SPARCFrame(SPARCFrame.biasSP(thread.getLastJavaSP()), thread.getLastJavaPC()); - } else { - Frame top = getCurrentFrameGuess(thread, addr); - return new SPARCFrame(SPARCFrame.biasSP(thread.getLastJavaSP()), - SPARCFrame.biasSP(SPARCFrame.findYoungerSP(top.getSP(), thread.getLastJavaSP())), - false); - } - - - } - - public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) { - return new SPARCRegisterMap(thread, updateMap); - } - - public Frame getCurrentFrameGuess(JavaThread thread, Address addr) { - ThreadProxy t = getThreadProxy(addr); - SPARCThreadContext context = (SPARCThreadContext) t.getContext(); - // For now, let's see what happens if we do a similar thing to - // what the runtime code does. I suspect this may cause us to lose - // the top frame from the stack. - Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP); - Address pc = context.getRegisterAsAddress(SPARCThreadContext.R_PC); - - if ((sp == null) || (pc == null)) { - // Problems (have not hit this case so far, but would be bad to continue if we did) - return null; - } - - return new SPARCFrame(sp, pc); - } - - - public void printThreadIDOn(Address addr, PrintStream tty) { - tty.print(getThreadProxy(addr)); - } - - public Address getLastSP(Address addr) { - ThreadProxy t = getThreadProxy(addr); - SPARCThreadContext context = (SPARCThreadContext) t.getContext(); - return SPARCFrame.unBiasSP(context.getRegisterAsAddress(SPARCThreadContext.R_SP)); - } - - public void printInfoOn(Address threadAddr, PrintStream tty) { - } - - public ThreadProxy getThreadProxy(Address addr) { - // Fetch the OSThread (for now and for simplicity, not making a - // separate "OSThread" class in this package) - Address osThreadAddr = osThreadField.getValue(addr); - // Get the address of the thread ID from the OSThread - Address tidAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset()); - - JVMDebugger debugger = VM.getVM().getDebugger(); - return debugger.getThreadForIdentifierAddress(tidAddr); - } - - -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_amd64/SolarisAMD64JavaThreadPDAccess.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_amd64/SolarisAMD64JavaThreadPDAccess.java deleted file mode 100644 index b17faed2bf3..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_amd64/SolarisAMD64JavaThreadPDAccess.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.runtime.solaris_amd64; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.amd64.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.runtime.amd64.*; -import sun.jvm.hotspot.runtime.x86.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; -import sun.jvm.hotspot.utilities.Observable; -import sun.jvm.hotspot.utilities.Observer; - -public class SolarisAMD64JavaThreadPDAccess implements JavaThreadPDAccess { - private static AddressField lastJavaFPField; - private static AddressField osThreadField; - private static AddressField baseOfStackPointerField; - - // Field from OSThread - private static CIntegerField osThreadThreadIDField; - - // This is currently unneeded but is being kept in case we change - // the currentFrameGuess algorithm - private static final long GUESS_SCAN_RANGE = 128 * 1024; - - - static { - VM.registerVMInitializedObserver(new Observer() { - public void update(Observable o, Object data) { - initialize(VM.getVM().getTypeDataBase()); - } - }); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("JavaThread"); - Type anchorType = db.lookupType("JavaFrameAnchor"); - - lastJavaFPField = anchorType.getAddressField("_last_Java_fp"); - osThreadField = type.getAddressField("_osthread"); - - type = db.lookupType("OSThread"); - osThreadThreadIDField = type.getCIntegerField("_thread_id"); - } - - public Address getLastJavaFP(Address addr) { - return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset())); - } - - public Address getLastJavaPC(Address addr) { - return null; - } - - public Address getBaseOfStackPointer(Address addr) { - return null; - } - - public Frame getLastFramePD(JavaThread thread, Address addr) { - Address fp = thread.getLastJavaFP(); - if (fp == null) { - return null; // no information - } - Address pc = thread.getLastJavaPC(); - if ( pc != null ) { - return new X86Frame(thread.getLastJavaSP(), fp, pc); - } else { - return new X86Frame(thread.getLastJavaSP(), fp); - } - } - - public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) { - return new X86RegisterMap(thread, updateMap); - } - - public Frame getCurrentFrameGuess(JavaThread thread, Address addr) { - ThreadProxy t = getThreadProxy(addr); - AMD64ThreadContext context = (AMD64ThreadContext) t.getContext(); - AMD64CurrentFrameGuess guesser = new AMD64CurrentFrameGuess(context, thread); - if (!guesser.run(GUESS_SCAN_RANGE)) { - return null; - } - if (guesser.getPC() == null) { - return new X86Frame(guesser.getSP(), guesser.getFP()); - } else { - return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC()); - } - } - - - public void printThreadIDOn(Address addr, PrintStream tty) { - tty.print(getThreadProxy(addr)); - } - - - public void printInfoOn(Address threadAddr, PrintStream tty) { - } - - public Address getLastSP(Address addr) { - ThreadProxy t = getThreadProxy(addr); - AMD64ThreadContext context = (AMD64ThreadContext) t.getContext(); - return context.getRegisterAsAddress(AMD64ThreadContext.RSP); - } - - public ThreadProxy getThreadProxy(Address addr) { - // Fetch the OSThread (for now and for simplicity, not making a - // separate "OSThread" class in this package) - Address osThreadAddr = osThreadField.getValue(addr); - // Get the address of the thread ID from the OSThread - Address tidAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset()); - - JVMDebugger debugger = VM.getVM().getDebugger(); - return debugger.getThreadForIdentifierAddress(tidAddr); - } - -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_sparc/SolarisSPARCJavaThreadPDAccess.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_sparc/SolarisSPARCJavaThreadPDAccess.java deleted file mode 100644 index b50efb0d565..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_sparc/SolarisSPARCJavaThreadPDAccess.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.runtime.solaris_sparc; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.sparc.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.runtime.sparc.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; -import sun.jvm.hotspot.utilities.Observable; -import sun.jvm.hotspot.utilities.Observer; - -public class SolarisSPARCJavaThreadPDAccess implements JavaThreadPDAccess { - private static AddressField baseOfStackPointerField; - private static AddressField postJavaStateField; - private static AddressField osThreadField; - private static int isPC; - private static int hasFlushed; - - // Field from OSThread - private static CIntegerField osThreadThreadIDField; - - static { - VM.registerVMInitializedObserver(new Observer() { - public void update(Observable o, Object data) { - initialize(VM.getVM().getTypeDataBase()); - } - }); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("JavaThread"); - Type anchorType = db.lookupType("JavaFrameAnchor"); - - baseOfStackPointerField = type.getAddressField("_base_of_stack_pointer"); - osThreadField = type.getAddressField("_osthread"); - hasFlushed = db.lookupIntConstant("JavaFrameAnchor::flushed").intValue(); - - type = db.lookupType("OSThread"); - osThreadThreadIDField = type.getCIntegerField("_thread_id"); - } - - public Address getLastJavaFP(Address addr) { - return null; - - } - - public Address getLastJavaPC(Address addr) { - return null; - } - - public Address getBaseOfStackPointer(Address addr) { - return baseOfStackPointerField.getValue(addr); - } - - public Frame getLastFramePD(JavaThread thread, Address addr) { - - // This assert doesn't work in the debugging case for threads - // which are running Java code and which haven't re-entered the - // runtime (e.g., through a Method.invoke() or otherwise). They - // haven't yet "decached" their last Java stack pointer to the - // thread. - - // if (Assert.ASSERTS_ENABLED) { - // Assert.that(hasLastJavaFrame(), "must have last_Java_sp() when suspended"); - // // FIXME: add assertion about flushing register windows for runtime system - // // (not appropriate for debugging system, though, unless at safepoin t) - // } - - // FIXME: I don't think this is necessary, but might be useful - // while debugging - if (thread.getLastJavaSP() == null) { - return null; - } - - // sparc does a lazy window flush. The _flags field of the JavaFrameAnchor - // encodes whether the windows have flushed. Whenever the windows have flushed - // there will be a last_Java_pc. - // In a relective system we'd have to do something to force the thread to flush - // its windows and give us the pc (or the younger_sp so we can find it ourselves) - // In a debugger situation (process or core) the flush should have happened and - // so if we don't have the younger sp we can find it - // - if (thread.getLastJavaPC() != null) { - return new SPARCFrame(SPARCFrame.biasSP(thread.getLastJavaSP()), thread.getLastJavaPC()); - } else { - Frame top = getCurrentFrameGuess(thread, addr); - return new SPARCFrame(SPARCFrame.biasSP(thread.getLastJavaSP()), - SPARCFrame.biasSP(SPARCFrame.findYoungerSP(top.getSP(), thread.getLastJavaSP())), - false); - } - - - } - - public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) { - return new SPARCRegisterMap(thread, updateMap); - } - - public Frame getCurrentFrameGuess(JavaThread thread, Address addr) { - - // If java stack is walkable then both last_Java_sp and last_Java_pc are - // non null and we can start stack walk from this frame. - if (thread.getLastJavaSP() != null && thread.getLastJavaPC() != null) { - return new SPARCFrame(SPARCFrame.biasSP(thread.getLastJavaSP()), thread.getLastJavaPC()); - } - - ThreadProxy t = getThreadProxy(addr); - SPARCThreadContext context = (SPARCThreadContext) t.getContext(); - // For now, let's see what happens if we do a similar thing to - // what the runtime code does. I suspect this may cause us to lose - // the top frame from the stack. - Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP); - Address pc = context.getRegisterAsAddress(SPARCThreadContext.R_PC); - - if ((sp == null) || (pc == null)) { - // Problems (have not hit this case so far, but would be bad to continue if we did) - return null; - } - - return new SPARCFrame(sp, pc); - } - - - public void printThreadIDOn(Address addr, PrintStream tty) { - tty.print(getThreadProxy(addr)); - } - - public Address getLastSP(Address addr) { - ThreadProxy t = getThreadProxy(addr); - SPARCThreadContext context = (SPARCThreadContext) t.getContext(); - return SPARCFrame.unBiasSP(context.getRegisterAsAddress(SPARCThreadContext.R_SP)); - } - - public void printInfoOn(Address threadAddr, PrintStream tty) { - } - - public ThreadProxy getThreadProxy(Address addr) { - // Fetch the OSThread (for now and for simplicity, not making a - // separate "OSThread" class in this package) - Address osThreadAddr = osThreadField.getValue(addr); - // Get the address of the thread ID from the OSThread - Address tidAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset()); - - JVMDebugger debugger = VM.getVM().getDebugger(); - return debugger.getThreadForIdentifierAddress(tidAddr); - } - - -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_x86/SolarisX86JavaThreadPDAccess.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_x86/SolarisX86JavaThreadPDAccess.java deleted file mode 100644 index 48899eaef4f..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/solaris_x86/SolarisX86JavaThreadPDAccess.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.runtime.solaris_x86; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.x86.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.runtime.x86.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; -import sun.jvm.hotspot.utilities.Observable; -import sun.jvm.hotspot.utilities.Observer; - -/** Placeholder for now to allow us to start the SA without support - for stack traces */ - -public class SolarisX86JavaThreadPDAccess implements JavaThreadPDAccess { - private static AddressField lastJavaFPField; - private static AddressField osThreadField; - private static AddressField baseOfStackPointerField; - - // Field from OSThread - private static CIntegerField osThreadThreadIDField; - - // This is currently unneeded but is being kept in case we change - // the currentFrameGuess algorithm - private static final long GUESS_SCAN_RANGE = 128 * 1024; - - - static { - VM.registerVMInitializedObserver(new Observer() { - public void update(Observable o, Object data) { - initialize(VM.getVM().getTypeDataBase()); - } - }); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("JavaThread"); - Type anchorType = db.lookupType("JavaFrameAnchor"); - - lastJavaFPField = anchorType.getAddressField("_last_Java_fp"); - osThreadField = type.getAddressField("_osthread"); - - type = db.lookupType("OSThread"); - osThreadThreadIDField = type.getCIntegerField("_thread_id"); - } - - public Address getLastJavaFP(Address addr) { - return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset())); - } - - public Address getLastJavaPC(Address addr) { - return null; - } - - public Address getBaseOfStackPointer(Address addr) { - return null; - } - - public Frame getLastFramePD(JavaThread thread, Address addr) { - Address fp = thread.getLastJavaFP(); - if (fp == null) { - return null; // no information - } - Address pc = thread.getLastJavaPC(); - if ( pc != null ) { - return new X86Frame(thread.getLastJavaSP(), fp, pc); - } else { - return new X86Frame(thread.getLastJavaSP(), fp); - } - } - - public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) { - return new X86RegisterMap(thread, updateMap); - } - - public Frame getCurrentFrameGuess(JavaThread thread, Address addr) { - ThreadProxy t = getThreadProxy(addr); - X86ThreadContext context = (X86ThreadContext) t.getContext(); - X86CurrentFrameGuess guesser = new X86CurrentFrameGuess(context, thread); - if (!guesser.run(GUESS_SCAN_RANGE)) { - return null; - } - if (guesser.getPC() == null) { - return new X86Frame(guesser.getSP(), guesser.getFP()); - } else { - return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC()); - } - } - - - public void printThreadIDOn(Address addr, PrintStream tty) { - tty.print(getThreadProxy(addr)); - } - - - public void printInfoOn(Address threadAddr, PrintStream tty) { - } - - public Address getLastSP(Address addr) { - ThreadProxy t = getThreadProxy(addr); - X86ThreadContext context = (X86ThreadContext) t.getContext(); - return context.getRegisterAsAddress(X86ThreadContext.ESP); - } - - public ThreadProxy getThreadProxy(Address addr) { - // Fetch the OSThread (for now and for simplicity, not making a - // separate "OSThread" class in this package) - Address osThreadAddr = osThreadField.getValue(addr); - // Get the address of the thread ID from the OSThread - Address tidAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset()); - - JVMDebugger debugger = VM.getVM().getDebugger(); - return debugger.getThreadForIdentifierAddress(tidAddr); - } - -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCFrame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCFrame.java deleted file mode 100644 index 65568fdd794..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCFrame.java +++ /dev/null @@ -1,1073 +0,0 @@ -/* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.runtime.sparc; - -import sun.jvm.hotspot.asm.sparc.*; -import sun.jvm.hotspot.code.*; -import sun.jvm.hotspot.compiler.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.debugger.cdbg.*; -import sun.jvm.hotspot.oops.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.runtime.posix.*; -import sun.jvm.hotspot.utilities.*; - -/** Specialization of and implementation of abstract methods of the - Frame class for the SPARC CPU. (FIXME: this is as quick a port as - possible to get things running; will have to do a better job right - away.) */ - -public class SPARCFrame extends Frame { - // The pc value is the raw return address, plus 8 (pcReturnOffset()). - // the value of sp and youngerSP that is stored in this object - // is always, always, always the value that would be found in the - // register (or window save area) while the target VM was executing. - // The caller of the constructor will alwasy know if has a biased or - // unbiased version of the stack pointer and can convert real (unbiased) - // value via a helper routine we supply. - // Whenever we return sp or youngerSP values we do not return the internal - // value but the real (unbiased) pointers since these are the true, usable - // memory addresses. The outlier case is that of the null pointer. The current - // mechanism makes null pointers always look null whether biased or not. - // This seems to cause no problems. In theory null real pointers could be biased - // just like other values however this has impact on things like addOffsetTo() - // to be able to take an Address that represents null and add an offset to it. - // This doesn't seem worth the bother and the impact on the rest of the code - // when the biasSP and unbiasSP can make this invisible. - // - // The general rule in this code is that when we have a variable like FP, youngerSP, SP - // that these are real (i.e. unbiased) addresses. The instance variables in a Frame are - // always raw values. The other rule is that it except for the frame constructors and - // the unBiasSP helper all methods accept parameters that are real addresses. - // - - /** Optional next-younger SP (used to locate O7, the PC) */ - private Address raw_youngerSP; - - /** Intepreter adjusts the stack pointer to make all locals contiguous */ - private long interpreterSPAdjustmentOffset; - - /** Number of stack entries for longs */ - private static final int WORDS_PER_LONG = 2; - - /** Normal SPARC return is 2 words past PC */ - public static final int PC_RETURN_OFFSET = 8; - - /** Size of each block, in order of increasing address */ - public static final int REGISTER_SAVE_WORDS = 16; - // FIXME: read these from the remote process - //#ifdef _LP64 - // callee_aggregate_return_pointer_words = 0, - //#else - // callee_aggregate_return_pointer_words = 1, - //#endif - public static final int CALLEE_AGGREGATE_RETURN_POINTER_WORDS = 1; - public static final int CALLEE_REGISTER_ARGUMENT_SAVE_AREA_WORDS = 6; - - // offset of each block, in order of increasing address: - public static final int REGISTER_SAVE_WORDS_SP_OFFSET = 0; - public static final int CALLEE_AGGREGATE_RETURN_POINTER_SP_OFFSET = REGISTER_SAVE_WORDS_SP_OFFSET + REGISTER_SAVE_WORDS; - public static final int CALLEE_REGISTER_ARGUMENT_SAVE_AREA_SP_OFFSET = (CALLEE_AGGREGATE_RETURN_POINTER_SP_OFFSET + - CALLEE_AGGREGATE_RETURN_POINTER_WORDS); - public static final int MEMORY_PARAMETER_WORD_SP_OFFSET = (CALLEE_REGISTER_ARGUMENT_SAVE_AREA_SP_OFFSET + - CALLEE_REGISTER_ARGUMENT_SAVE_AREA_WORDS); - public static final int VARARGS_OFFSET = MEMORY_PARAMETER_WORD_SP_OFFSET; - - private static final boolean DEBUG = System.getProperty("sun.jvm.hotspot.runtime.sparc.SPARCFrame.DEBUG") != null; - - public static Address unBiasSP(Address raw_sp) { - if (raw_sp != null) { - return raw_sp.addOffsetTo(VM.getVM().getStackBias()); - } else { - return null; - } - } - - public static Address biasSP(Address real_sp) { - if (real_sp != null) { - if (DEBUG) { - System.out.println("biasing realsp: " + real_sp + " biased: " + real_sp.addOffsetTo(-VM.getVM().getStackBias()) ); - } - return real_sp.addOffsetTo(-VM.getVM().getStackBias()); - } else { - if (DEBUG) { - System.out.println("biasing null realsp"); - } - return null; - } - } - // - // This is used to find the younger sp for a thread thatn has stopped but hasn't - // conveniently told us the information where we can find the pc or the frame - // containing the pc that corresponds to last_java_sp. This method will walk - // the frames trying to find the frame which we contains the data we need. - // - public static Address findYoungerSP(Address top, Address find) { - // top and find are unBiased sp values - // we return an unBiased value - Address findRaw = biasSP(find); - if (top == null || find == null || findRaw == null) { - throw new RuntimeException("bad values for findYoungerSP top: " + top + " find: " + find); - } - // It would be unusual to find more than 20 native frames before we find the java frame - // we are looking for. - final int maxFrames = 20; - int count = 0; - Address search = top; - Address next; - Address pc; - if (DEBUG) { - System.out.println("findYoungerSP top: " + top + " find: " + find + " findRaw: " + findRaw); - } - while ( count != maxFrames && search != null) { - next = search.getAddressAt(SPARCRegisters.I6.spOffsetInSavedWindow()); - pc = search.getAddressAt(SPARCRegisters.I7.spOffsetInSavedWindow()); - if (DEBUG) { - System.out.println("findYoungerSP next: " + next + " pc: " + pc); - } - if (next.equals(findRaw)) { - return search; - } - search = unBiasSP(next); - } - if (DEBUG) { - System.out.println("findYoungerSP: never found younger, top: " + top + " find: " + find); - } - return null; - } - - public Address getSP() { - if (DEBUG) { - System.out.println("getSP raw: " + raw_sp + " unbiased: " + unBiasSP(raw_sp)); - } - return unBiasSP(raw_sp); - } - - public Address getID() { - return getSP(); - } - - public Address getYoungerSP() { - if (DEBUG) { - System.out.println("getYoungerSP: " + raw_youngerSP + " unbiased: " + unBiasSP(raw_youngerSP)); - } - return unBiasSP(raw_youngerSP); - } - - /** This constructor relies on the fact that the creator of a frame - has flushed register windows which the frame will refer to, and - that those register windows will not be reloaded until the frame - is done reading and writing the stack. Moreover, if the - "younger_pc" argument points into the register save area of the - next younger frame (though it need not), the register window for - that next younger frame must also stay flushed. (The caller is - responsible for ensuring this.) */ - public SPARCFrame(Address raw_sp, Address raw_youngerSP, boolean youngerFrameIsInterpreted) { - super(); - if (DEBUG) { - System.out.println("Constructing frame(1) raw_sp: " + raw_sp + " raw_youngerSP: " + raw_youngerSP); - } - if (Assert.ASSERTS_ENABLED) { - Assert.that((unBiasSP(raw_sp).andWithMask(VM.getVM().getAddressSize() - 1) == null), - "Expected raw sp likely got real sp, value was " + raw_sp); - if (raw_youngerSP != null) { - Assert.that((unBiasSP(raw_youngerSP).andWithMask(VM.getVM().getAddressSize() - 1) == null), - "Expected raw youngerSP likely got real youngerSP, value was " + raw_youngerSP); - } - } - this.raw_sp = raw_sp; - this.raw_youngerSP = raw_youngerSP; - if (raw_youngerSP == null) { - // make a deficient frame which doesn't know where its PC is - pc = null; - } else { - Address youngerSP = unBiasSP(raw_youngerSP); - pc = youngerSP.getAddressAt(SPARCRegisters.I7.spOffsetInSavedWindow()).addOffsetTo(PC_RETURN_OFFSET); - - if (Assert.ASSERTS_ENABLED) { - Assert.that(youngerSP.getAddressAt(SPARCRegisters.FP.spOffsetInSavedWindow()). - equals(raw_sp), - "youngerSP must be valid"); - } - } - - if (youngerFrameIsInterpreted) { - long IsavedSP = SPARCRegisters.IsavedSP.spOffsetInSavedWindow(); - // compute adjustment to this frame's SP made by its interpreted callee - interpreterSPAdjustmentOffset = 0; - Address savedSP = unBiasSP(getYoungerSP().getAddressAt(IsavedSP)); - if (savedSP == null) { - if ( DEBUG) { - System.out.println("WARNING: IsavedSP was null for frame " + this); - } - } else { - interpreterSPAdjustmentOffset = savedSP.minus(getSP()); - } - } else { - interpreterSPAdjustmentOffset = 0; - } - if ( pc != null) { - // Look for a deopt pc and if it is deopted convert to original pc - CodeBlob cb = VM.getVM().getCodeCache().findBlob(pc); - if (cb != null && cb.isJavaMethod()) { - NMethod nm = (NMethod) cb; - if (pc.equals(nm.deoptHandlerBegin())) { - // adjust pc if frame is deoptimized. - pc = this.getUnextendedSP().getAddressAt(nm.origPCOffset()); - deoptimized = true; - } - } - } - } - - /** Make a deficient frame which doesn't know where its PC is (note - no youngerSP argument) */ - public SPARCFrame(Address raw_sp, Address pc) { - super(); - if (DEBUG) { - System.out.println("Constructing frame(2) raw_sp: " + raw_sp ); - } - this.raw_sp = raw_sp; - if (Assert.ASSERTS_ENABLED) { - Assert.that((unBiasSP(raw_sp).andWithMask(VM.getVM().getAddressSize() - 1) == null), - "Expected raw sp likely got real sp, value was " + raw_sp); - } - raw_youngerSP = null; - this.pc = pc; - interpreterSPAdjustmentOffset = 0; - } - - /** Only used internally */ - private SPARCFrame() { - } - - public Object clone() { - SPARCFrame frame = new SPARCFrame(); - frame.raw_sp = raw_sp; - frame.pc = pc; - frame.raw_youngerSP = raw_youngerSP; - frame.interpreterSPAdjustmentOffset = interpreterSPAdjustmentOffset; - frame.deoptimized = deoptimized; - return frame; - } - - public boolean equals(Object arg) { - if (arg == null) { - return false; - } - - if (!(arg instanceof SPARCFrame)) { - return false; - } - - SPARCFrame other = (SPARCFrame) arg; - - return (AddressOps.equal(getSP(), other.getSP()) && - AddressOps.equal(getFP(), other.getFP()) && - AddressOps.equal(getPC(), other.getPC())); - } - - public int hashCode() { - if (raw_sp == null) { - return 0; - } - - return raw_sp.hashCode(); - } - - public String toString() { - Address fp = getFP(); - Address sp = getSP(); - Address youngerSP = getYoungerSP(); - - return "sp: " + (sp == null? "null" : sp.toString()) + - ", younger_sp: " + (youngerSP == null? "null" : youngerSP.toString()) + - ", fp: " + (fp == null? "null" : fp.toString()) + - ", pc: " + (pc == null? "null" : pc.toString()); - } - - /**

    Identifies a signal handler frame on the stack.

    - -

    There are a few different algorithms for doing this, and - they vary from platform to platform. For example, based on a - conversation with Dave Dice, Solaris/x86 will be substantially - simpler to handle than Solaris/SPARC because the signal handler - frame can be identified because of a program counter == -1.

    - -

    The dbx group provided code and advice on these topics; the - code below evolved from theirs, but is not correct/robust. - Without going into too many details, it seems that looking for - the incoming argument to the sigacthandler frame (which is what - this code identifies) is not guaranteed to be stable across - versions of Solaris, since that function is supplied by - libthread and is not guaranteed not to clobber I2 before it - calls __sighndlr later. From discussions, it sounds like a - robust algorithm which wouldn't require traversal of the - ucontext chain (used by dbx, but which Dave Dice thinks isn't - robust in the face of libthread -- need to follow up) would be - to be able to properly identify the __sighndlr frame, then get - I2 and treat that as a ucontext. To identify __sighndlr we would - need to look up that symbol in the remote process and look for a - program counter within a certain (small) distance.

    - -

    If the underlying Debugger supports CDebugger interface, we - take the approach of __sighnldr symbol. This approach is more robust - compared to the original hueristic approach. Of course, if there - is no CDebugger support, we fallback to the hueristic approach.

    - -

    The current implementation seems to work with Solaris 2.8. - A nice property of this system is that if we find a core file - this algorithm doesn't work on, we can change the code and try - again, so I'm putting this in as the current mechanism for - finding signal handler frames on Solaris/SPARC.

    */ - public boolean isSignalHandlerFrameDbg() { - CDebugger cdbg = VM.getVM().getDebugger().getCDebugger(); - if (cdbg != null) { - LoadObject dso = cdbg.loadObjectContainingPC(getPC()); - if (dso != null) { - ClosestSymbol cs = dso.closestSymbolToPC(getPC()); - if (cs != null && cs.getName().equals("__sighndlr")) { - return true; - } else { - return false; - } - } else { - return false; - } - } else { - if (getYoungerSP() == null) { - // System.err.println(" SPARCFrame.isSignalHandlerFrameDbg: youngerSP = " + getYoungerSP()); - return false; - } - Address i2 = getSP().getAddressAt(SPARCRegisters.I2.spOffsetInSavedWindow()); - if (i2 == null) { - return false; - } - Address fp = getFP(); - // My (mistaken) understanding of the dbx group's code was that - // the signal handler frame could be identified by testing the - // incoming argument to see whether it was a certain distance - // below the frame pointer; in fact, their code did substantially - // more than this (traversal of the ucontext chain, which this - // code can't do because the topmost ucontext is not currently - // available via the proc_service APIs in dbx). The current code - // appears to work, but is probably not robust. - int MAJOR_HACK_OFFSET = 8; // Difference between expected location of the ucontext and reality - // System.err.println(" SPARCFrame.isSignalHandlerFrameDbg: I2 = " + i2 + - // ", fp = " + fp + ", raw_youngerSP = " + getYoungerSP()); - boolean res = i2.equals(fp.addOffsetTo(VM.getVM().getAddressSize() * (REGISTER_SAVE_WORDS + MAJOR_HACK_OFFSET))); - if (res) { - // Qualify this with another test (FIXME: this is a gross heuristic found while testing) - Address sigInfoAddr = getSP().getAddressAt(SPARCRegisters.I5.spOffsetInSavedWindow()); - if (sigInfoAddr == null) { - System.err.println("Frame with fp = " + fp + " looked like a signal handler frame but wasn't"); - res = false; - } - } - return res; - } - } - - public int getSignalNumberDbg() { - // From looking at the stack trace in dbx, it looks like the - // siginfo* comes into sigacthandler in I5. It would be much more - // robust to look at the __sighndlr frame instead, but we can't - // currently identify that frame. - - Address sigInfoAddr = getSP().getAddressAt(SPARCRegisters.I5.spOffsetInSavedWindow()); - // Read si_signo out of siginfo* - return (int) sigInfoAddr.getCIntegerAt(0, 4, false); - } - - public String getSignalNameDbg() { - return POSIXSignals.getSignalName(getSignalNumberDbg()); - } - - public boolean isInterpretedFrameValid() { - if (Assert.ASSERTS_ENABLED) { - Assert.that(isInterpretedFrame(), "Not an interpreted frame"); - } - // These are reasonable sanity checks - if (getFP() == null || (getFP().andWithMask(2 * VM.getVM().getAddressSize() - 1)) != null) { - return false; - } - if (getSP() == null || (getSP().andWithMask(2 * VM.getVM().getAddressSize() - 1)) != null) { - return false; - } - if (getFP().addOffsetTo(INTERPRETER_FRAME_VM_LOCAL_WORDS * VM.getVM().getAddressSize()).lessThan(getSP())) { - return false; - } - - Address methodHandle = addressOfInterpreterFrameMethod().getAddressAt(0); - - if (VM.getVM().getObjectHeap().isValidMethod(methodHandle) == false) { - return false; - } - - // These are hacks to keep us out of trouble. - // The problem with these is that they mask other problems - if (getFP().lessThanOrEqual(getSP())) { // this attempts to deal with unsigned comparison above - return false; - } - if (getFP().minus(getSP()) > 4096 * VM.getVM().getAddressSize()) { // stack frames shouldn't be large. - return false; - } - // FIXME: this is not atomic with respect to GC and is unsuitable - // for use in a non-debugging, or reflective, system. Need to - // figure out how to express this. - Address bcx = addressOfInterpreterFrameBCX().getAddressAt(0); - - Method method; - try { - method = (Method)Metadata.instantiateWrapperFor(methodHandle); - } catch (UnknownOopException ex) { - return false; - } - int bci = bcpToBci(bcx, method); - //validate bci - if (bci < 0) return false; - - return true; - } - - //-------------------------------------------------------------------------------- - // Accessors: - // - - /** Accessors */ - - public long frameSize() { - return (getSenderSP().minus(getSP()) / VM.getVM().getAddressSize()); - } - - public Address getLink() { - return unBiasSP(getFP().getAddressAt(SPARCRegisters.FP.spOffsetInSavedWindow())); - } - - // FIXME: not implementable yet - // public void setLink(Address addr) { - // if (Assert.ASSERTS_ENABLED) { - // Assert.that(getLink().equals(addr), "frame nesting is controlled by hardware"); - // } - // } - - public Frame sender(RegisterMap regMap, CodeBlob cb) { - SPARCRegisterMap map = (SPARCRegisterMap) regMap; - - if (Assert.ASSERTS_ENABLED) { - Assert.that(map != null, "map must be set"); - } - - // Default is we don't have to follow them. The sender_for_xxx - // will update it accordingly - map.setIncludeArgumentOops(false); - - if (isEntryFrame()) { - return senderForEntryFrame(map); - } - - Address youngerSP = getSP(); - Address sp = getSenderSP(); - boolean isInterpreted = false; - - // FIXME: this is a hack to get stackwalking to work in the face - // of a signal like a SEGV. For debugging purposes it's important - // that (a) we are able to traverse the stack if we take a signal - // and (b) that we get the correct program counter in this - // situation. If we are not using alternate signal stacks then (a) - // seems to work all the time (on SPARC), but (b) is violated for - // the frame just below the signal handler. - - // The mechanism for finding the ucontext is not robust. In - // addition, we may find that we need to be able to fetch more - // registers from the ucontext than just the program counter, - // since the register windows on the stack are "stale". This will - // require substantial restructuring of this frame code, so has - // been avoided for now. - - // It is difficult to find a clean solution for mixing debugging - // situations with VM frame traversal. One could consider - // implementing generic frame traversal in the dbx style and only - // using the VM's stack walking mechanism on a per-frame basis, - // for example to traverse Java-level activations in a compiled - // frame. However, this will probably not interact well with the - // mechanism for finding oops on the stack. - - if (VM.getVM().isDebugging()) { - // If we are a signal handler frame, use a trick: make the - // youngerSP of the caller frame point to the top of the - // ucontext's contained register set. This should allow fetching - // of the registers for the frame just below the signal handler - // frame in the usual fashion. - if (isSignalHandlerFrameDbg()) { - - if (DEBUG) { - System.out.println("SPARCFrame.sender: found signal handler frame"); - } - - // Try to give a valid SP and PC for a "deficient frame" since - // we don't have a real register save area; making this class - // work by reading its information from a ucontext as well as - // a register save area is a major undertaking and has been - // deferred for now. It is very important that the PC is - // correct, which is why we don't just fall through to the - // other code (which would read the PC from the stale register - // window and thereby fail to get the actual location of the - // fault). - - long offset = getMContextAreaOffsetInUContext(); - Address fp = sp; - // System.out.println(" FP: " + fp); - fp = fp.addOffsetTo(getUContextOffset() + getMContextAreaOffsetInUContext()); - // System.out.println(" start of mcontext: " + fp); - // FIXME: put these elsewhere. These are the register numbers - // in /usr/include/sys/regset.h. They might belong in - // SPARCReigsters.java, but we currently don't have that list - // of numbers in the SA code (because all of the registers are - // listed as instances of SPARCRegister) and it appears that - // our numbering of the registers and this one don't match up. - int PC_OFFSET_IN_GREGSET = 1; - int SP_OFFSET_IN_GREGSET = 17; - raw_sp = fp.getAddressAt(VM.getVM().getAddressSize() * SP_OFFSET_IN_GREGSET); - Address pc = fp.getAddressAt(VM.getVM().getAddressSize() * PC_OFFSET_IN_GREGSET); - return new SPARCFrame(raw_sp, pc); - } - } - - // Note: The version of this operation on any platform with callee-save - // registers must update the register map (if not null). - // In order to do this correctly, the various subtypes of - // of frame (interpreted, compiled, glue, native), - // must be distinguished. There is no need on SPARC for - // such distinctions, because all callee-save registers are - // preserved for all frames via SPARC-specific mechanisms. - // - // *** HOWEVER, *** if and when we make any floating-point - // registers callee-saved, then we will have to copy over - // the RegisterMap update logic from the Intel code. - - // The constructor of the sender must know whether this frame is interpreted so it can set the - // sender's _interpreter_sp_adjustment field. - if (VM.getVM().getInterpreter().contains(pc)) { - isInterpreted = true; - map.makeIntegerRegsUnsaved(); - map.shiftWindow(sp, youngerSP); - } else { - // Find a CodeBlob containing this frame's pc or elide the lookup and use the - // supplied blob which is already known to be associated with this frame. - cb = VM.getVM().getCodeCache().findBlob(pc); - if (cb != null) { - // Update the location of all implicitly saved registers - // as the address of these registers in the register save - // area (for %o registers we use the address of the %i - // register in the next younger frame) - map.shiftWindow(sp, youngerSP); - if (map.getUpdateMap()) { - if (cb.callerMustGCArguments()) { - map.setIncludeArgumentOops(true); - } - if (cb.getOopMaps() != null) { - ImmutableOopMapSet.updateRegisterMap(this, cb, map, VM.getVM().isDebugging()); - } - } - } - } - - return new SPARCFrame(biasSP(sp), biasSP(youngerSP), isInterpreted); - } - - protected boolean hasSenderPD() { - try { - // FIXME: should not happen!!! - if (getSP() == null) { - return false; - } - if ( unBiasSP(getSP().getAddressAt(SPARCRegisters.FP.spOffsetInSavedWindow())) == null ) { - return false; - } - return true; - } catch (RuntimeException e) { - if (DEBUG) { - System.out.println("Bad frame " + this); - } - throw e; - } - } - - //-------------------------------------------------------------------------------- - // Return address: - // - - public Address getSenderPC() { - return addressOfI7().getAddressAt(0).addOffsetTo(PC_RETURN_OFFSET); - } - - // FIXME: currently unimplementable - // inline void frame::set_sender_pc(address addr) { *I7_addr() = addr - pc_return_offset; } - - public Address getUnextendedSP() { - return getSP().addOffsetTo(interpreterSPAdjustmentOffset); - } - - public Address getSenderSP() { - return getFP(); - } - - /** Given the next-younger sp for a given frame's sp, compute the - frame. We need the next-younger sp, because its register save - area holds the flushed copy of its I7, which is the PC of the - frame we are interested in. */ - public SPARCFrame afterSave() { - return new SPARCFrame(biasSP(getYoungerSP()), null); - } - - /** Accessors for the instance variables */ - public Address getFP() { - Address sp = getSP(); - if (sp == null) { - System.out.println("SPARCFrame.getFP(): sp == null"); - } - Address fpAddr = sp.addOffsetTo(SPARCRegisters.FP.spOffsetInSavedWindow()); - try { - Address fp = unBiasSP(fpAddr.getAddressAt(0)); - if (fp == null) { - System.out.println("SPARCFrame.getFP(): fp == null (&fp == " + fpAddr + ")"); - } - return fp; - } catch (RuntimeException e) { - System.out.println("SPARCFrame.getFP(): is bad (&fp == " + fpAddr + " sp = " + sp + ")"); - return null; - } - } - - private Address addressOfFPSlot(int index) { - return getFP().addOffsetTo(index * VM.getVM().getAddressSize()); - } - - // FIXME: temporarily elided - // // All frames - // - // intptr_t* fp_addr_at(int index) const { return &fp()[index]; } - // intptr_t* sp_addr_at(int index) const { return &sp()[index]; } - // intptr_t fp_at( int index) const { return *fp_addr_at(index); } - // intptr_t sp_at( int index) const { return *sp_addr_at(index); } - // - // private: - // inline address* I7_addr() const; - // inline address* O7_addr() const; - // - // inline address* I0_addr() const; - // inline address* O0_addr() const; - // - // public: - // // access to SPARC arguments and argument registers - // - // intptr_t* register_addr(Register reg) const { - // return sp_addr_at(reg.sp_offset_in_saved_window()); - // } - // intptr_t* memory_param_addr(int param_ix, bool is_in) const { - // int offset = callee_register_argument_save_area_sp_offset + param_ix; - // if (is_in) - // return fp_addr_at(offset); - // else - // return sp_addr_at(offset); - // } - // intptr_t* param_addr(int param_ix, bool is_in) const { - // if (param_ix >= callee_register_argument_save_area_words) - // return memory_param_addr(param_ix, is_in); - // else if (is_in) - // return register_addr(Argument(param_ix, true).as_register()); - // else { - // // the registers are stored in the next younger frame - // // %%% is this really necessary? - // frame next_younger = after_save(); - // return next_younger.register_addr(Argument(param_ix, true).as_register()); - // } - // } - - //-------------------------------------------------------------------------------- - // Interpreter frames: - // - - /** 2 words, also used to save float regs across calls to C */ - public static final int INTERPRETER_FRAME_D_SCRATCH_FP_OFFSET = -2; - public static final int INTERPRETER_FRAME_L_SCRATCH_FP_OFFSET = -4; - public static final int INTERPRETER_FRAME_MIRROR_OFFSET = -5; - public static final int INTERPRETER_FRAME_VM_LOCALS_FP_OFFSET = -6; - public static final int INTERPRETER_FRAME_VM_LOCAL_WORDS = -INTERPRETER_FRAME_VM_LOCALS_FP_OFFSET; - - /** Interpreter frame set-up needs to save 2 extra words in outgoing - param area for class and jnienv arguments for native stubs (see - nativeStubGen_sparc.cpp) */ - public static final int INTERPRETER_FRAME_EXTRA_OUTGOING_ARGUMENT_WORDS = 2; - - // FIXME: elided for now - // - // // the compiler frame has many of the same fields as the interpreter frame - // // %%%%% factor out declarations of the shared fields - // enum compiler_frame_fixed_locals { - // compiler_frame_d_scratch_fp_offset = -2, - // compiler_frame_vm_locals_fp_offset = -2, // should be same as above - // - // compiler_frame_vm_local_words = -compiler_frame_vm_locals_fp_offset - // }; - // - // private: - // - // // where LcpoolCache is saved: - // ConstantPoolCache** interpreter_frame_cpoolcache_addr() const { - // return (ConstantPoolCache**)sp_addr_at( LcpoolCache.sp_offset_in_saved_window()); - // } - // - // // where Lmonitors is saved: - // BasicObjectLock** interpreter_frame_monitors_addr() const { - // return (BasicObjectLock**) sp_addr_at( Lmonitors.sp_offset_in_saved_window()); - // } - // intptr_t** interpreter_frame_esp_addr() const { - // return (intptr_t**)sp_addr_at( Lesp.sp_offset_in_saved_window()); - // } - // - // inline void interpreter_frame_set_tos_address(intptr_t* x); - // - // // next two fns read and write Lmonitors value, - // private: - // BasicObjectLock* interpreter_frame_monitors() const { return *interpreter_frame_monitors_addr(); } - // void interpreter_frame_set_monitors(BasicObjectLock* monitors) { *interpreter_frame_monitors_addr() = monitors; } - // - //#ifndef CORE - //inline oop *frame::pd_compiled_argument_to_location(VMReg::Name reg, RegisterMap reg_map, int arg_size) const { - // COMPILER1_ONLY(return (oop *) (arg_size - 1 - reg + sp() + memory_parameter_word_sp_offset); ) - // COMPILER2_ONLY(return oopmapreg_to_location(reg, ®_map); ) - //} - //#endif - - // FIXME: NOT FINISHED - public Address addressOfInterpreterFrameLocals() { - return getSP().addOffsetTo(SPARCRegisters.Llocals.spOffsetInSavedWindow()); - } - - // FIXME: this is not atomic with respect to GC and is unsuitable - // for use in a non-debugging, or reflective, system. - private Address addressOfInterpreterFrameBCX() { - // %%%%% reinterpreting Lbcp as a bcx - return getSP().addOffsetTo(SPARCRegisters.Lbcp.spOffsetInSavedWindow()); - } - - public int getInterpreterFrameBCI() { - // FIXME: this is not atomic with respect to GC and is unsuitable - // for use in a non-debugging, or reflective, system. Need to - // figure out how to express this. - Address bcp = addressOfInterpreterFrameBCX().getAddressAt(0); - Address methodHandle = addressOfInterpreterFrameMethod().getAddressAt(0); - Method method = (Method)Metadata.instantiateWrapperFor(methodHandle); - return bcpToBci(bcp, method); - } - - public Address addressOfInterpreterFrameExpressionStack() { - return addressOfInterpreterFrameMonitors().addOffsetTo(-1 * VM.getVM().getAddressSize()); - } - - public int getInterpreterFrameExpressionStackDirection() { - return -1; - } - - /** Top of expression stack */ - public Address addressOfInterpreterFrameTOS() { - return getSP().getAddressAt(SPARCRegisters.Lesp.spOffsetInSavedWindow()).addOffsetTo(VM.getVM().getAddressSize()); - } - - /** Expression stack from top down */ - public Address addressOfInterpreterFrameTOSAt(int slot) { - return addressOfInterpreterFrameTOS().addOffsetTo(slot * VM.getVM().getAddressSize()); - } - - public Address getInterpreterFrameSenderSP() { - if (Assert.ASSERTS_ENABLED) { - Assert.that(isInterpretedFrame(), "interpreted frame expected"); - } - return getFP(); - } - - // FIXME: elided for now - //inline void frame::interpreter_frame_set_tos_address( intptr_t* x ) { - // *interpreter_frame_esp_addr() = x - 1; - //} - - //-------------------------------------------------------------------------------- - // Monitors: - // - - private Address addressOfInterpreterFrameMonitors() { - return getSP().addOffsetTo(SPARCRegisters.Lmonitors.spOffsetInSavedWindow()).getAddressAt(0); - } - - // Monitors - public BasicObjectLock interpreterFrameMonitorBegin() { - int roundedVMLocalWords = Bits.roundTo(INTERPRETER_FRAME_VM_LOCAL_WORDS, WORDS_PER_LONG); - return new BasicObjectLock(addressOfFPSlot(-1 * roundedVMLocalWords)); - } - - public BasicObjectLock interpreterFrameMonitorEnd() { - return new BasicObjectLock(addressOfInterpreterFrameMonitors()); - } - - public int interpreterFrameMonitorSize() { - return Bits.roundTo(BasicObjectLock.size(), WORDS_PER_LONG * (int) VM.getVM().getAddressSize()); - } - - // FIXME: elided for now - // // monitor elements - // - // // in keeping with Intel side: end is lower in memory than begin; - // // and beginning element is oldest element - // // Also begin is one past last monitor. - // - // inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const { - // int rounded_vm_local_words = align_up(frame::interpreter_frame_vm_local_words, WordsPerLong); - // return (BasicObjectLock *)fp_addr_at(-rounded_vm_local_words); - // } - // - // inline BasicObjectLock* frame::interpreter_frame_monitor_end() const { - // return interpreter_frame_monitors(); - // } - // - // - // inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* value) { - // interpreter_frame_set_monitors(value); - // } - // - // - // inline int frame::interpreter_frame_monitor_size() { - // return align_up(BasicObjectLock::size(), WordsPerLong); - // } - - public Address addressOfInterpreterFrameMethod() { - return getSP().addOffsetTo(SPARCRegisters.Lmethod.spOffsetInSavedWindow()); - } - - public Address addressOfInterpreterFrameCPCache() { - return getSP().addOffsetTo(SPARCRegisters.LcpoolCache.spOffsetInSavedWindow()); - } - - //-------------------------------------------------------------------------------- - // Entry frames: - // - - public JavaCallWrapper getEntryFrameCallWrapper() { - // Note: adjust this code if the link argument in StubGenerator::call_stub() changes! - SPARCArgument link = new SPARCArgument(0, false); - return (JavaCallWrapper) VMObjectFactory.newObject(JavaCallWrapper.class, - getSP().getAddressAt(link.asIn().asRegister().spOffsetInSavedWindow())); - } - - // - // - // inline JavaCallWrapper* frame::entry_frame_call_wrapper() const { - // // note: adjust this code if the link argument in StubGenerator::call_stub() changes! - // const Argument link = Argument(0, false); - // return (JavaCallWrapper*)sp()[link.as_in().as_register().sp_offset_in_saved_window()]; - // } - - //-------------------------------------------------------------------------------- - // Safepoints: - // - - protected Address addressOfSavedOopResult() { - return addressOfO0(); - } - - protected Address addressOfSavedReceiver() { - return addressOfO0(); - } - - - //-------------------------------------------------------------------------------- - // Internals only below this point - // - - private Address addressOfI7() { - return getSP().addOffsetTo(SPARCRegisters.I7.spOffsetInSavedWindow()); - } - - private Address addressOfO7() { - return afterSave().addressOfI7(); - } - - private Address addressOfI0() { - return getSP().addOffsetTo(SPARCRegisters.I0.spOffsetInSavedWindow()); - } - - private Address addressOfO0() { - return afterSave().addressOfI0(); - } - - private static boolean addressesEqual(Address a1, Address a2) { - if ((a1 == null) && (a2 == null)) { - return true; - } - - if ((a1 == null) || (a2 == null)) { - return false; - } - - return (a1.equals(a2)); - } - - - private Frame senderForEntryFrame(RegisterMap regMap) { - SPARCRegisterMap map = (SPARCRegisterMap) regMap; - - if (Assert.ASSERTS_ENABLED) { - Assert.that(map != null, "map must be set"); - } - // Java frame called from C; skip all C frames and return top C - // frame of that chunk as the sender - JavaCallWrapper jcw = getEntryFrameCallWrapper(); - if (Assert.ASSERTS_ENABLED) { - Assert.that(!entryFrameIsFirst(), "next Java fp must be non zero"); - Assert.that(jcw.getLastJavaSP().greaterThan(getSP()), "must be above this frame on stack"); - } - Address lastJavaSP = jcw.getLastJavaSP(); - Address lastJavaPC = jcw.getLastJavaPC(); - map.clear(); - - map.makeIntegerRegsUnsaved(); - map.shiftWindow(lastJavaSP, null); - - if (Assert.ASSERTS_ENABLED) { - Assert.that(map.getIncludeArgumentOops(), "should be set by clear"); - } - - if (lastJavaPC != null) { - return new SPARCFrame(biasSP(lastJavaSP), lastJavaPC); - } else { - Address youngerSP = getNextYoungerSP(lastJavaSP, getSP()); - return new SPARCFrame(biasSP(lastJavaSP), biasSP(youngerSP), false); - } - } - - private static Address getNextYoungerSP(Address oldSP, Address youngSP) { - Address sp = getNextYoungerSPOrNull(oldSP, youngSP, null); - if (Assert.ASSERTS_ENABLED) { - Assert.that(sp != null, "missed the SP"); - } - return sp; - } - - private static Address getNextYoungerSPOrNull(Address oldSP, Address youngSP, Address sp) { - if (youngSP == null) { - // FIXME - throw new RuntimeException("can not handle null youngSP in debugging system (seems to require register window flush)"); - } - - if (sp == null) { - sp = youngSP; - } - - Address previousSP = null; - - /** Minimum frame size is 16 */ - int maxFrames = (int) (oldSP.minus(sp) / (16 * VM.getVM().getAddressSize())); - - while(!sp.equals(oldSP) && spIsValid(oldSP, youngSP, sp)) { - if (maxFrames-- <= 0) { - // too many frames have gone by; invalid parameters given to this function - break; - } - previousSP = sp; - sp = unBiasSP(sp.getAddressAt(SPARCRegisters.FP.spOffsetInSavedWindow())); - } - - return (sp.equals(oldSP) ? previousSP : null); - } - - private static boolean spIsValid(Address oldSP, Address youngSP, Address sp) { - long mask = VM.getVM().getAddressSize(); - mask = 2 * mask - 1; - return ((sp.andWithMask(mask) == null) && - (sp.lessThanOrEqual(oldSP)) && - (sp.greaterThanOrEqual(youngSP))); - } - - // FIXME: this is a hopefully temporary hack (not sure what is going on) - public long getUContextOffset() { - // FIXME: there is something I clearly don't understand about the - // way the signal handler frame is laid out, because I shouldn't need this extra offset - int MAJOR_HACK_OFFSET = 8; - // System.out.println(" SPARCFrame.isSignalHandlerFrameDbg: I2 = " + i2 + ", fp = " + fp + ", youngerSP = " + youngerSP); - return VM.getVM().getAddressSize() * (REGISTER_SAVE_WORDS + MAJOR_HACK_OFFSET); - } - - public long getMContextAreaOffsetInUContext() { - // From dbx-related sources: - // /* - // * struct sigframe is declaredf in the kernel sources in - // * .../uts/sun4c/os/machdep.c/sendsig() - // * unfortunately we only get a pointer to the 'uc' passed - // * to the sighandler so we need to do this stuff to get - // * to 'rwin'. - // * Have to do it like this to take account of alignment. - // */ - // static struct sigframe { - // struct rwindow rwin; - // ucontext_t uc; - // } sf_help; - - // From /usr/include/sys/ucontext.h: - // #if !defined(_XPG4_2) || defined(__EXTENSIONS__) - // struct ucontext { - // #else - // struct __ucontext { - // #endif - // uint_t uc_flags; - // ucontext_t *uc_link; - // sigset_t uc_sigmask; - // stack_t uc_stack; - // mcontext_t uc_mcontext; - // #ifdef __sparcv9 - // long uc_filler[4]; - // #else /* __sparcv9 */ - // long uc_filler[23]; - // #endif /* __sparcv9 */ - // }; - - // This walks to the start of the gregs in the mcontext_t - // (first entry in that data structure). Really should read - // this from header file. - - // Also not sure exactly how alignment works...maybe should read these offsets from the target VM - // (When you have a hammer, everything looks like a nail) - long offset = VM.getVM().alignUp(4, VM.getVM().getAddressSize()); // uc_flags - offset = VM.getVM().alignUp(offset + VM.getVM().getAddressSize(), 8); // uc_link plus - // doubleword alignment for structs? - offset += 16 + // uc_sigmask - 2 * VM.getVM().getAddressSize() + 4; // uc_stack - offset = VM.getVM().alignUp(offset + VM.getVM().getAddressSize(), 8); // doubleword alignment for structs? - - // System.out.println("SPARCFrame.getMContextAreaOffsetInUContext: offset = " + offset); - - return offset; - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCRegisterMap.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCRegisterMap.java deleted file mode 100644 index bcd240d6c42..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCRegisterMap.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.runtime.sparc; - -import java.util.*; - -import sun.jvm.hotspot.asm.sparc.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; -import sun.jvm.hotspot.utilities.Observable; -import sun.jvm.hotspot.utilities.Observer; - -public class SPARCRegisterMap extends RegisterMap { - /** Register window save area (for L and I regs) */ - private Address window; - /** Previous save area (for O regs, if needed) */ - private Address youngerWindow; - - private static int registerImplNumberOfRegisters; - - // Unified register numbering scheme: each 32-bits counts as a register - // number, so all the V9 registers take 2 slots. - private static int[] R_L_nums = new int[] {0+040,2+040,4+040,6+040,8+040,10+040,12+040,14+040}; - private static int[] R_I_nums = new int[] {0+060,2+060,4+060,6+060,8+060,10+060,12+060,14+060}; - private static int[] R_O_nums = new int[] {0+020,2+020,4+020,6+020,8+020,10+020,12+020,14+020}; - private static int[] R_G_nums = new int[] {0+000,2+000,4+000,6+000,8+000,10+000,12+000,14+000}; - - private static long badMask; - private static long R_LIO_mask; - - private static int sizeofJint; - - static { - VM.registerVMInitializedObserver(new Observer() { - public void update(Observable o, Object data) { - initialize(VM.getVM().getTypeDataBase()); - } - }); - } - - private static void initialize(TypeDataBase db) { - badMask = 0; - R_LIO_mask = 0; - - sizeofJint = (int) db.lookupType("jint").getSize(); - registerImplNumberOfRegisters = db.lookupIntConstant("RegisterImpl::number_of_registers").intValue(); - - for (int i = 0; i < 8; i++) { - Assert.that(R_L_nums[i] < locationValidTypeSize, "in first chunk"); - Assert.that(R_I_nums[i] < locationValidTypeSize, "in first chunk"); - Assert.that(R_O_nums[i] < locationValidTypeSize, "in first chunk"); - Assert.that(R_G_nums[i] < locationValidTypeSize, "in first chunk"); - } - - badMask |= ((long) 1 << R_O_nums[6]); // SP - badMask |= ((long) 1 << R_O_nums[7]); // cPC - badMask |= ((long) 1 << R_I_nums[6]); // FP - badMask |= ((long) 1 << R_I_nums[7]); // rPC - badMask |= ((long) 1 << R_G_nums[2]); // TLS - badMask |= ((long) 1 << R_G_nums[7]); // reserved by libthread - - for (int i = 0; i < 8; i++) { - R_LIO_mask |= ((long) 1 << R_L_nums[i]); - R_LIO_mask |= ((long) 1 << R_I_nums[i]); - R_LIO_mask |= ((long) 1 << R_O_nums[i]); - } - } - - /** This is the only public constructor, and is only called by - SolarisSPARCJavaThread */ - public SPARCRegisterMap(JavaThread thread, boolean updateMap) { - super(thread, updateMap); - } - - protected SPARCRegisterMap(RegisterMap map) { - super(map); - } - - public Object clone() { - SPARCRegisterMap retval = new SPARCRegisterMap(this); - return retval; - } - - protected void clearPD() { - if (thread.hasLastJavaFrame()) { - Frame fr = thread.getLastFrame(); - window = fr.getSP(); - } else { - window = null; - if (VM.getVM().isDebugging()) { - Frame fr = thread.getCurrentFrameGuess(); - if (fr != null) { - window = fr.getSP(); - } - } - } - youngerWindow = null; - } - - protected Address getLocationPD(VMReg vmreg) { - VM vm = VM.getVM(); - int regname = vmreg.getValue(); - if (Assert.ASSERTS_ENABLED) { - Assert.that(0 <= regname && regname < regCount, "sanity check"); - } - - // Only the GPRs get handled this way - if (regname >= (registerImplNumberOfRegisters << 1)) { - return null; - } - - // don't talk about bad registers - if ((badMask & ((long) 1 << regname)) != 0) { - return null; - } - - // Convert to a GPR - int secondWord = 0; - // 32-bit registers for in, out and local - if (!isEven(regname)) { - if (vm.isLP64()) { - secondWord = sizeofJint; - } else { - return null; - } - } - - SPARCRegister reg = new SPARCRegister(regname >> 1); - if (reg.isOut()) { - if (Assert.ASSERTS_ENABLED) { - Assert.that(youngerWindow != null, "Younger window should be available"); - } - return youngerWindow.addOffsetTo(reg.afterSave().spOffsetInSavedWindow() + secondWord); - } - if (reg.isLocal() || reg.isIn()) { - if (Assert.ASSERTS_ENABLED) { - Assert.that(window != null, "Window should be available"); - } - return window.addOffsetTo(reg.spOffsetInSavedWindow() + secondWord); - } - - // Only the window'd GPRs get handled this way; not the globals. - return null; - } - - protected void initializePD() { - window = null; - youngerWindow = null; - // avoid the shift_individual_registers game - makeIntegerRegsUnsaved(); - } - - protected void initializeFromPD(RegisterMap map) { - SPARCRegisterMap srm = (SPARCRegisterMap) map; - window = srm.window; - youngerWindow = srm.youngerWindow; - // avoid the shift_individual_registers game - makeIntegerRegsUnsaved(); - } - - public void shiftWindow(Address sp, Address youngerSP) { - window = sp; - youngerWindow = youngerSP; - // Throw away locations for %i, %o, and %l registers: - // But do not throw away %g register locs. - if (locationValid[0] != 0) { - shiftIndividualRegisters(); - } - } - - /** When popping out of compiled frames, we make all IRegs disappear. */ - public void makeIntegerRegsUnsaved() { - locationValid[0] = 0; - } - - //-------------------------------------------------------------------------------- - // Internals only below this point - // - - private void shiftIndividualRegisters() { - if (!getUpdateMap()) { - return; - } - - checkLocationValid(); - - long lv = locationValid[0]; - long lv0 = lv; - - lv &= ~R_LIO_mask; // clear %l, %o, %i regs - - // if we cleared some non-%g locations, we may have to do some shifting - if (lv != lv0) { - // copy %i0-%i5 to %o0-%o5, if they have special locations - // This can happen in within stubs which spill argument registers - // around a dynamic link operation, such as resolve_opt_virtual_call. - for (int i = 0; i < 8; i++) { - if ((lv0 & ((long) 1 << R_I_nums[i])) != 0) { - location[R_O_nums[i]] = location[R_I_nums[i]]; - lv |= ((long) 1 << R_O_nums[i]); - } - } - } - - locationValid[0] = lv; - checkLocationValid(); - } - - private boolean isEven(int i) { - return (i & 1) == 0; - } - - private void checkLocationValid() { - if (Assert.ASSERTS_ENABLED) { - Assert.that((locationValid[0] & badMask) == 0, "cannot have special locations for SP,FP,TLS,etc."); - } - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java index cea3f6504ef..3e66e24700b 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PlatformInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,14 +28,10 @@ package sun.jvm.hotspot.utilities; system. */ public class PlatformInfo { - /* Returns "solaris" if on Solaris; "win32" if Windows; "linux" if - Linux. Used to determine location of dbx and import module, or - possible debugger agent on win32. */ + /* Returns "win32" if Windows; "linux" if Linux. */ public static String getOS() throws UnsupportedPlatformException { String os = System.getProperty("os.name"); - if (os.equals("SunOS")) { - return "solaris"; - } else if (os.equals("Linux")) { + if (os.equals("Linux")) { return "linux"; } else if (os.equals("FreeBSD")) { return "bsd"; @@ -54,7 +50,7 @@ public class PlatformInfo { public static boolean knownCPU(String cpu) { final String[] KNOWN = - new String[] {"i386", "x86", "x86_64", "amd64", "sparc", "sparcv9", "ppc64", "ppc64le", "aarch64"}; + new String[] {"i386", "x86", "x86_64", "amd64", "ppc64", "ppc64le", "aarch64"}; for(String s : KNOWN) { if(s.equals(cpu)) @@ -64,10 +60,10 @@ public class PlatformInfo { return false; } - /* Returns "sparc" for SPARC based platforms "x86" for x86 based - platforms and x86_64 for 64bit x86 based platform. Otherwise - returns the value of os.arch. If the value is not recognized as supported, - an exception is thrown instead. */ + /* Returns "x86" for x86 based platforms and x86_64 for 64bit x86 + based platform. Otherwise returns the value of os.arch. If the + value is not recognized as supported, an exception is thrown + instead. */ public static String getCPU() throws UnsupportedPlatformException { String cpu = System.getProperty("os.arch"); @@ -81,9 +77,6 @@ public class PlatformInfo { if (cpu.equals("i386")) return "x86"; - if (cpu.equals("sparcv9")) - return "sparc"; - if (cpu.equals("x86_64")) return "amd64"; diff --git a/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c b/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c index d07d63a8124..57eb2f2e175 100644 --- a/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c +++ b/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,8 +22,6 @@ * */ -#include // just include something, or else solaris compiler will complain that this file is empty - #if defined(LINUX) || defined(__APPLE__) #include #include diff --git a/src/jdk.hotspot.agent/share/native/libsaproc/sadis.c b/src/jdk.hotspot.agent/share/native/libsaproc/sadis.c index 5fa2b3fdcf7..540f13ad5b6 100644 --- a/src/jdk.hotspot.agent/share/native/libsaproc/sadis.c +++ b/src/jdk.hotspot.agent/share/native/libsaproc/sadis.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ /* * This file implements a binding between Java and the hsdis - * disassembler. It should compile on Linux/Solaris and Windows. + * disassembler. It should compile on Linux and Windows. * The only platform dependent pieces of the code for doing * dlopen/dlsym to find the entry point in hsdis. All the rest is * standard JNI code. diff --git a/src/jdk.hotspot.agent/solaris/native/libsaproc/libproc.h b/src/jdk.hotspot.agent/solaris/native/libsaproc/libproc.h deleted file mode 100644 index b926ad94102..00000000000 --- a/src/jdk.hotspot.agent/solaris/native/libsaproc/libproc.h +++ /dev/null @@ -1,483 +0,0 @@ -/* - * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -/* - * Interfaces available from the process control library, libproc. - * - * libproc provides process control functions for the /proc tools - * (commands in /usr/proc/bin), /usr/bin/truss, and /usr/bin/gcore. - * libproc is a private support library for these commands only. - * It is _not_ a public interface, although it might become one - * in the fullness of time, when the interfaces settle down. - * - * In the meantime, be aware that any program linked with libproc in this - * release of Solaris is almost guaranteed to break in the next release. - * - * In short, do not use this header file or libproc for any purpose. - */ - -#ifndef _LIBPROC_H -#define _LIBPROC_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Opaque structure tag reference to a process control structure. - * Clients of libproc cannot look inside the process control structure. - * The implementation of struct ps_prochandle can change w/o affecting clients. - */ -struct ps_prochandle; - -extern int _libproc_debug; /* set non-zero to enable debugging fprintfs */ - -#if defined(sparc) || defined(__sparc) -#define R_RVAL1 R_O0 /* register holding a function return value */ -#define R_RVAL2 R_O1 /* 32 more bits for a 64-bit return value */ -#define SYSCALL32 0x91d02008 /* 32-bit syscall (ta 8) instruction */ -#define SYSCALL64 0x91d02040 /* 64-bit syscall (ta 64) instruction */ -typedef uint32_t syscall_t; /* holds a syscall instruction */ -#endif /* sparc */ - -#if defined(__i386) -#define R_PC EIP -#define R_SP UESP -#define R_RVAL1 EAX /* register holding a function return value */ -#define R_RVAL2 EDX /* 32 more bits for a 64-bit return value */ -#define SYSCALL 0x9a /* syscall (lcall) instruction opcode */ -typedef uchar_t syscall_t[7]; /* holds a syscall instruction */ -#endif /* __i386 */ - -#define R_RVAL R_RVAL1 /* simple function return value register */ - -/* maximum sizes of things */ -#define PRMAXSIG (32 * sizeof (sigset_t) / sizeof (uint32_t)) -#define PRMAXFAULT (32 * sizeof (fltset_t) / sizeof (uint32_t)) -#define PRMAXSYS (32 * sizeof (sysset_t) / sizeof (uint32_t)) - -/* State values returned by Pstate() */ -#define PS_RUN 1 /* process is running */ -#define PS_STOP 2 /* process is stopped */ -#define PS_LOST 3 /* process is lost to control (EAGAIN) */ -#define PS_UNDEAD 4 /* process is terminated (zombie) */ -#define PS_DEAD 5 /* process is terminated (core file) */ - -/* Flags accepted by Pgrab() */ -#define PGRAB_RETAIN 0x01 /* Retain tracing flags, else clear flags */ -#define PGRAB_FORCE 0x02 /* Open the process w/o O_EXCL */ -#define PGRAB_RDONLY 0x04 /* Open the process or core w/ O_RDONLY */ -#define PGRAB_NOSTOP 0x08 /* Open the process but do not stop it */ - -/* Error codes from Pcreate() */ -#define C_STRANGE -1 /* Unanticipated error, errno is meaningful */ -#define C_FORK 1 /* Unable to fork */ -#define C_PERM 2 /* No permission (file set-id or unreadable) */ -#define C_NOEXEC 3 /* Cannot find executable file */ -#define C_INTR 4 /* Interrupt received while creating */ -#define C_LP64 5 /* Program is _LP64, self is _ILP32 */ - -/* Error codes from Pgrab(), Pfgrab_core(), and Pgrab_core() */ -#define G_STRANGE -1 /* Unanticipated error, errno is meaningful */ -#define G_NOPROC 1 /* No such process */ -#define G_NOCORE 2 /* No such core file */ -#define G_NOPROCORCORE 3 /* No such proc or core (for proc_arg_grab) */ -#define G_NOEXEC 4 /* Cannot locate executable file */ -#define G_ZOMB 5 /* Zombie process */ -#define G_PERM 6 /* No permission */ -#define G_BUSY 7 /* Another process has control */ -#define G_SYS 8 /* System process */ -#define G_SELF 9 /* Process is self */ -#define G_INTR 10 /* Interrupt received while grabbing */ -#define G_LP64 11 /* Process is _LP64, self is ILP32 */ -#define G_FORMAT 12 /* File is not an ELF format core file */ -#define G_ELF 13 /* Libelf error, elf_errno() is meaningful */ -#define G_NOTE 14 /* Required PT_NOTE Phdr not present in core */ - -/* Flags accepted by Prelease */ -#define PRELEASE_CLEAR 0x10 /* Clear all tracing flags */ -#define PRELEASE_RETAIN 0x20 /* Retain final tracing flags */ -#define PRELEASE_HANG 0x40 /* Leave the process stopped */ -#define PRELEASE_KILL 0x80 /* Terminate the process */ - -typedef struct { /* argument descriptor for system call (Psyscall) */ - long arg_value; /* value of argument given to system call */ - void *arg_object; /* pointer to object in controlling process */ - char arg_type; /* AT_BYVAL, AT_BYREF */ - char arg_inout; /* AI_INPUT, AI_OUTPUT, AI_INOUT */ - ushort_t arg_size; /* if AT_BYREF, size of object in bytes */ -} argdes_t; - -typedef struct { /* return values from system call (Psyscall) */ - int sys_errno; /* syscall error number */ - long sys_rval1; /* primary return value from system call */ - long sys_rval2; /* second return value from system call */ -} sysret_t; - -/* values for type */ -#define AT_BYVAL 1 -#define AT_BYREF 2 - -/* values for inout */ -#define AI_INPUT 1 -#define AI_OUTPUT 2 -#define AI_INOUT 3 - -/* maximum number of syscall arguments */ -#define MAXARGS 8 - -/* maximum size in bytes of a BYREF argument */ -#define MAXARGL (4*1024) - -/* Kludges to make things work on Solaris 2.6 */ -#if !defined(_LP64) && !defined(PR_MODEL_UNKNOWN) -#define PR_MODEL_UNKNOWN 0 -#define PR_MODEL_ILP32 0 /* process data model is ILP32 */ -#define PR_MODEL_LP64 2 /* process data model is LP64 */ -#define PR_MODEL_NATIVE PR_MODEL_ILP32 -#define pr_dmodel pr_filler[0] -#define STACK_BIAS 0 -#endif - -/* - * Function prototypes for routines in the process control package. - */ -extern struct ps_prochandle *Pcreate(const char *, char *const *, - int *, char *, size_t); - -extern const char *Pcreate_error(int); - -extern struct ps_prochandle *Pgrab(pid_t, int, int *); -extern struct ps_prochandle *Pgrab_core(const char *, const char *, int, int *); -extern struct ps_prochandle *Pfgrab_core(int, const char *, int *); - -extern const char *Pgrab_error(int); - -extern int Preopen(struct ps_prochandle *); -extern void Prelease(struct ps_prochandle *, int); -extern void Pfree(struct ps_prochandle *); - -extern int Pasfd(struct ps_prochandle *); -extern int Pctlfd(struct ps_prochandle *); -extern int Pcreate_agent(struct ps_prochandle *); -extern void Pdestroy_agent(struct ps_prochandle *); -extern int Pwait(struct ps_prochandle *, uint_t); -extern int Pstop(struct ps_prochandle *, uint_t); -extern int Pstate(struct ps_prochandle *); -extern const psinfo_t *Ppsinfo(struct ps_prochandle *); -extern const pstatus_t *Pstatus(struct ps_prochandle *); -extern int Pcred(struct ps_prochandle *, prcred_t *, int); -extern int Pgetareg(struct ps_prochandle *, int, prgreg_t *); -extern int Pputareg(struct ps_prochandle *, int, prgreg_t); -extern int Psetrun(struct ps_prochandle *, int, int); -extern ssize_t Pread(struct ps_prochandle *, void *, size_t, uintptr_t); -extern ssize_t Pread_string(struct ps_prochandle *, char *, size_t, uintptr_t); -extern ssize_t Pwrite(struct ps_prochandle *, const void *, size_t, uintptr_t); -extern int Pclearsig(struct ps_prochandle *); -extern int Pclearfault(struct ps_prochandle *); -extern int Psetbkpt(struct ps_prochandle *, uintptr_t, ulong_t *); -extern int Pdelbkpt(struct ps_prochandle *, uintptr_t, ulong_t); -extern int Pxecbkpt(struct ps_prochandle *, ulong_t); -extern int Psetflags(struct ps_prochandle *, long); -extern int Punsetflags(struct ps_prochandle *, long); -extern int Psignal(struct ps_prochandle *, int, int); -extern int Pfault(struct ps_prochandle *, int, int); -extern int Psysentry(struct ps_prochandle *, int, int); -extern int Psysexit(struct ps_prochandle *, int, int); -extern void Psetsignal(struct ps_prochandle *, const sigset_t *); -extern void Psetfault(struct ps_prochandle *, const fltset_t *); -extern void Psetsysentry(struct ps_prochandle *, const sysset_t *); -extern void Psetsysexit(struct ps_prochandle *, const sysset_t *); -extern void Psync(struct ps_prochandle *); -extern sysret_t Psyscall(struct ps_prochandle *, int, uint_t, argdes_t *); -extern int Pisprocdir(struct ps_prochandle *, const char *); - -/* - * Function prototypes for system calls forced on the victim process. - */ -extern int pr_open(struct ps_prochandle *, const char *, int, mode_t); -extern int pr_creat(struct ps_prochandle *, const char *, mode_t); -extern int pr_close(struct ps_prochandle *, int); -extern int pr_door_info(struct ps_prochandle *, int, struct door_info *); -extern void *pr_mmap(struct ps_prochandle *, - void *, size_t, int, int, int, off_t); -extern void *pr_zmap(struct ps_prochandle *, - void *, size_t, int, int); -extern int pr_munmap(struct ps_prochandle *, void *, size_t); -extern int pr_memcntl(struct ps_prochandle *, - caddr_t, size_t, int, caddr_t, int, int); -extern int pr_sigaction(struct ps_prochandle *, - int, const struct sigaction *, struct sigaction *); -extern int pr_getitimer(struct ps_prochandle *, - int, struct itimerval *); -extern int pr_setitimer(struct ps_prochandle *, - int, const struct itimerval *, struct itimerval *); -extern int pr_ioctl(struct ps_prochandle *, int, int, void *, size_t); -extern int pr_fcntl(struct ps_prochandle *, int, int, void *); -extern int pr_stat(struct ps_prochandle *, const char *, struct stat *); -extern int pr_lstat(struct ps_prochandle *, const char *, struct stat *); -extern int pr_fstat(struct ps_prochandle *, int, struct stat *); -extern int pr_statvfs(struct ps_prochandle *, const char *, statvfs_t *); -extern int pr_fstatvfs(struct ps_prochandle *, int, statvfs_t *); -extern int pr_getrlimit(struct ps_prochandle *, - int, struct rlimit *); -extern int pr_setrlimit(struct ps_prochandle *, - int, const struct rlimit *); -#if defined(_LARGEFILE64_SOURCE) -extern int pr_getrlimit64(struct ps_prochandle *, - int, struct rlimit64 *); -extern int pr_setrlimit64(struct ps_prochandle *, - int, const struct rlimit64 *); -#endif /* _LARGEFILE64_SOURCE */ -extern int pr_lwp_exit(struct ps_prochandle *); -extern int pr_exit(struct ps_prochandle *, int); -extern int pr_waitid(struct ps_prochandle *, - idtype_t, id_t, siginfo_t *, int); -extern off_t pr_lseek(struct ps_prochandle *, int, off_t, int); -extern offset_t pr_llseek(struct ps_prochandle *, int, offset_t, int); -extern int pr_rename(struct ps_prochandle *, const char *, const char *); -extern int pr_link(struct ps_prochandle *, const char *, const char *); -extern int pr_unlink(struct ps_prochandle *, const char *); -extern int pr_getpeername(struct ps_prochandle *, - int, struct sockaddr *, socklen_t *); -extern int pr_getsockname(struct ps_prochandle *, - int, struct sockaddr *, socklen_t *); - -/* - * Function prototypes for accessing per-LWP register information. - */ -extern int Plwp_getregs(struct ps_prochandle *, lwpid_t, prgregset_t); -extern int Plwp_setregs(struct ps_prochandle *, lwpid_t, const prgregset_t); - -extern int Plwp_getfpregs(struct ps_prochandle *, lwpid_t, prfpregset_t *); -extern int Plwp_setfpregs(struct ps_prochandle *, lwpid_t, - const prfpregset_t *); - -#if defined(sparc) || defined(__sparc) - -extern int Plwp_getxregs(struct ps_prochandle *, lwpid_t, prxregset_t *); -extern int Plwp_setxregs(struct ps_prochandle *, lwpid_t, const prxregset_t *); - -#if defined(__sparcv9) -extern int Plwp_getasrs(struct ps_prochandle *, lwpid_t, asrset_t); -extern int Plwp_setasrs(struct ps_prochandle *, lwpid_t, const asrset_t); -#endif /* __sparcv9 */ - -#endif /* __sparc */ - -extern int Plwp_getpsinfo(struct ps_prochandle *, lwpid_t, lwpsinfo_t *); - -/* - * LWP iteration interface. - */ -typedef int proc_lwp_f(void *, const lwpstatus_t *); -extern int Plwp_iter(struct ps_prochandle *, proc_lwp_f *, void *); - -/* - * Symbol table interfaces. - */ - -/* - * Pseudo-names passed to Plookup_by_name() for well-known load objects. - * NOTE: It is required that PR_OBJ_EXEC and PR_OBJ_LDSO exactly match - * the definitions of PS_OBJ_EXEC and PS_OBJ_LDSO from . - */ -#define PR_OBJ_EXEC ((const char *)0) /* search the executable file */ -#define PR_OBJ_LDSO ((const char *)1) /* search ld.so.1 */ -#define PR_OBJ_EVERY ((const char *)-1) /* search every load object */ - -/* - * 'object_name' is the name of a load object obtained from an - * iteration over the process's address space mappings (Pmapping_iter), - * or an iteration over the process's mapped objects (Pobject_iter), - * or else it is one of the special PR_OBJ_* values above. - */ -extern int Plookup_by_name(struct ps_prochandle *, - const char *, const char *, GElf_Sym *); - -extern int Plookup_by_addr(struct ps_prochandle *, - uintptr_t, char *, size_t, GElf_Sym *); - -typedef int proc_map_f(void *, const prmap_t *, const char *); - -extern int Pmapping_iter(struct ps_prochandle *, proc_map_f *, void *); -extern int Pobject_iter(struct ps_prochandle *, proc_map_f *, void *); - -extern const prmap_t *Paddr_to_map(struct ps_prochandle *, uintptr_t); -extern const prmap_t *Paddr_to_text_map(struct ps_prochandle *, uintptr_t); -extern const prmap_t *Pname_to_map(struct ps_prochandle *, const char *); - -extern char *Pplatform(struct ps_prochandle *, char *, size_t); -extern int Puname(struct ps_prochandle *, struct utsname *); - -extern char *Pexecname(struct ps_prochandle *, char *, size_t); -extern char *Pobjname(struct ps_prochandle *, uintptr_t, char *, size_t); - -extern char *Pgetenv(struct ps_prochandle *, const char *, char *, size_t); -extern long Pgetauxval(struct ps_prochandle *, int); - -/* - * Symbol table iteration interface. - */ -typedef int proc_sym_f(void *, const GElf_Sym *, const char *); - -extern int Psymbol_iter(struct ps_prochandle *, - const char *, int, int, proc_sym_f *, void *); - -/* - * 'which' selects which symbol table and can be one of the following. - */ -#define PR_SYMTAB 1 -#define PR_DYNSYM 2 -/* - * 'type' selects the symbols of interest by binding and type. It is a bit- - * mask of one or more of the following flags, whose order MUST match the - * order of STB and STT constants in . - */ -#define BIND_LOCAL 0x0001 -#define BIND_GLOBAL 0x0002 -#define BIND_WEAK 0x0004 -#define BIND_ANY (BIND_LOCAL|BIND_GLOBAL|BIND_WEAK) -#define TYPE_NOTYPE 0x0100 -#define TYPE_OBJECT 0x0200 -#define TYPE_FUNC 0x0400 -#define TYPE_SECTION 0x0800 -#define TYPE_FILE 0x1000 -#define TYPE_ANY (TYPE_NOTYPE|TYPE_OBJECT|TYPE_FUNC|TYPE_SECTION|TYPE_FILE) - -/* - * This returns the rtld_db agent handle for the process. - * The handle will become invalid at the next successful exec() and - * must not be used beyond that point (see Preset_maps(), below). - */ -extern rd_agent_t *Prd_agent(struct ps_prochandle *); - -/* - * This should be called when an RD_DLACTIVITY event with the - * RD_CONSISTENT state occurs via librtld_db's event mechanism. - * This makes libproc's address space mappings and symbol tables current. - */ -extern void Pupdate_maps(struct ps_prochandle *); - -/* - * This must be called after the victim process performs a successful - * exec() if any of the symbol table interface functions have been called - * prior to that point. This is essential because an exec() invalidates - * all previous symbol table and address space mapping information. - * It is always safe to call, but if it is called other than after an - * exec() by the victim process it just causes unnecessary overhead. - * - * The rtld_db agent handle obtained from a previous call to Prd_agent() is - * made invalid by Preset_maps() and Prd_agent() must be called again to get - * the new handle. - */ -extern void Preset_maps(struct ps_prochandle *); - -/* - * Given an address, Ppltdest() determines if this is part of a PLT, and if - * so returns the target address of this PLT entry and a flag indicating - * whether or not this PLT entry has been bound by the run-time linker. - */ -extern uintptr_t Ppltdest(struct ps_prochandle *, uintptr_t, int *); - -/* - * Stack frame iteration interface. - */ -typedef int proc_stack_f( - void *, /* the cookie given to Pstack_iter() */ - const prgregset_t, /* the frame's registers */ - uint_t, /* argc for the frame's function */ - const long *, /* argv for the frame's function */ - int, /* bitwise flags describing the frame (see below) */ - int); /* a signal number */ - -#define PR_SIGNAL_FRAME 1 /* called by a signal handler */ -#define PR_FOUND_SIGNAL 2 /* we found the corresponding signal number */ - -extern int Pstack_iter(struct ps_prochandle *, - const prgregset_t, proc_stack_f *, void *); - -/* - * Compute the full pathname of a named directory without using chdir(). - * This is useful for dealing with /proc//cwd. - */ -extern char *proc_dirname(const char *, char *, size_t); - -/* - * Remove unprintable characters from psinfo.pr_psargs and replace with - * whitespace characters so it is safe for printing. - */ -extern void proc_unctrl_psinfo(psinfo_t *); - -/* - * Utility functions for processing arguments which should be /proc files, - * pids, and/or core files. The returned error code can be passed to - * Pgrab_error() in order to convert it to an error string. - */ -#define PR_ARG_PIDS 0x1 /* Allow pid and /proc file arguments */ -#define PR_ARG_CORES 0x2 /* Allow core file arguments */ - -#define PR_ARG_ANY (PR_ARG_PIDS | PR_ARG_CORES) - -extern struct ps_prochandle *proc_arg_grab(const char *, int, int, int *); -extern pid_t proc_arg_psinfo(const char *, int, psinfo_t *, int *); - -/* - * Utility functions for obtaining information via /proc without actually - * performing a Pcreate() or Pgrab(): - */ -extern int proc_get_auxv(pid_t, auxv_t *, int); -extern int proc_get_cred(pid_t, prcred_t *, int); -extern int proc_get_psinfo(pid_t, psinfo_t *); -extern int proc_get_status(pid_t, pstatus_t *); - -/* - * Utility functions for debugging tools to convert numeric fault, - * signal, and system call numbers to symbolic names: - */ -extern char *proc_fltname(int, char *, size_t); -extern char *proc_signame(int, char *, size_t); -extern char *proc_sysname(int, char *, size_t); - -#ifdef __cplusplus -} -#endif - -#endif /* _LIBPROC_H */ diff --git a/src/jdk.hotspot.agent/solaris/native/libsaproc/salibproc.h b/src/jdk.hotspot.agent/solaris/native/libsaproc/salibproc.h deleted file mode 100644 index 8bd6b1076ab..00000000000 --- a/src/jdk.hotspot.agent/solaris/native/libsaproc/salibproc.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -#ifndef _SALIBPROC_H_ -#define _SALIBPROC_H_ - -/* - * The following definitions, prototypes are from Solaris libproc.h. - * We used to use the copy of it from Solaris 8.0. But there are - * problems with that approach in building this library across Solaris - * versions. Solaris 10 has libproc.h in /usr/include. And libproc.h - * varies slightly across Solaris versions. On Solaris 9, we get - * 'sysret_t multiply defined' error. This is common minimum subset we - * really need from libproc.h. The libproc.h in the current dir has - * been left for reference and not used in build. - */ - -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* extended symbol table information */ -typedef struct { - const char *prs_object; /* object name */ - const char *prs_name; /* symbol name */ - Lmid_t prs_lmid; /* link map id */ - uint_t prs_id; /* symbol id */ - uint_t prs_table; /* symbol table id */ -} prsyminfo_t; - -typedef struct ps_prochandle ps_prochandle_t; - -/* - * 'object_name' is the name of a load object obtained from an - * iteration over the process's address space mappings (Pmapping_iter), - * or an iteration over the process's mapped objects (Pobject_iter), - * or else it is one of the special PR_OBJ_* values above. - */ - -extern int Plookup_by_addr(ps_prochandle_t *, uintptr_t, char *, - size_t, GElf_Sym *, prsyminfo_t *); -extern ps_prochandle_t *proc_arg_grab(const char *, int, int, - int *, const char **); - -typedef int proc_map_f(void *, const prmap_t *, const char *); -extern int Pobject_iter(struct ps_prochandle *, proc_map_f *, void *); - -/* - * Utility functions for processing arguments which should be /proc files, - * pids, and/or core files. The returned error code can be passed to - * Pgrab_error() in order to convert it to an error string. - */ -#define PR_ARG_PIDS 0x1 /* Allow pid and /proc file arguments */ -#define PR_ARG_CORES 0x2 /* Allow core file arguments */ -#define PR_ARG_ANY (PR_ARG_PIDS | PR_ARG_CORES) - -/* Flags accepted by Pgrab() (partial) */ -#define PGRAB_FORCE 0x02 /* Open the process w/o O_EXCL */ - -/* Error codes from Pgrab(), Pfgrab_core(), and Pgrab_core() */ -#define G_STRANGE -1 /* Unanticipated error, errno is meaningful */ -#define G_NOPROC 1 /* No such process */ -#define G_NOCORE 2 /* No such core file */ -#define G_NOPROCORCORE 3 /* No such proc or core (for proc_arg_grab) */ -#define G_NOEXEC 4 /* Cannot locate executable file */ -#define G_ZOMB 5 /* Zombie process */ -#define G_PERM 6 /* No permission */ -#define G_BUSY 7 /* Another process has control */ -#define G_SYS 8 /* System process */ -#define G_SELF 9 /* Process is self */ -#define G_INTR 10 /* Interrupt received while grabbing */ -#define G_LP64 11 /* Process is _LP64, self is ILP32 */ -#define G_FORMAT 12 /* File is not an ELF format core file */ -#define G_ELF 13 /* Libelf error, elf_errno() is meaningful */ -#define G_NOTE 14 /* Required PT_NOTE Phdr not present in core */ - -extern const pstatus_t *Pstatus(struct ps_prochandle *); - -/* Flags accepted by Prelease (partial) */ -#define PRELEASE_CLEAR 0x10 /* Clear all tracing flags */ - -extern void Prelease(struct ps_prochandle *, int); -extern int Psetrun(struct ps_prochandle *, int, int); -extern int Pstop(struct ps_prochandle *, uint_t); - -/* - * Stack frame iteration interface. - */ -typedef int proc_stack_f( - void *, /* the cookie given to Pstack_iter() */ - const prgregset_t, /* the frame's registers */ - uint_t, /* argc for the frame's function */ - const long *, /* argv for the frame's function */ - int, /* bitwise flags describing the frame (see below) */ - int); /* a signal number */ - -#define PR_SIGNAL_FRAME 1 /* called by a signal handler */ -#define PR_FOUND_SIGNAL 2 /* we found the corresponding signal number */ - -extern int Pstack_iter(struct ps_prochandle *, - const prgregset_t, proc_stack_f *, void *); - -#define PR_OBJ_EVERY ((const char *)-1) /* search every load object */ - - -#ifdef __cplusplus -} -#endif - -#endif /* _SALIBPROC_H_ */ diff --git a/src/jdk.hotspot.agent/solaris/native/libsaproc/saproc.cpp b/src/jdk.hotspot.agent/solaris/native/libsaproc/saproc.cpp deleted file mode 100644 index 5a054d0266c..00000000000 --- a/src/jdk.hotspot.agent/solaris/native/libsaproc/saproc.cpp +++ /dev/null @@ -1,1337 +0,0 @@ -/* - * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "salibproc.h" -#include "sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal.h" -#include -#include -#include -#include -#include -#include -#include -#include "cds.h" - -#define CHECK_EXCEPTION_(value) if(env->ExceptionOccurred()) { return value; } -#define CHECK_EXCEPTION if(env->ExceptionOccurred()) { return;} -#define THROW_NEW_DEBUGGER_EXCEPTION_(str, value) { throwNewDebuggerException(env, str); return value; } -#define THROW_NEW_DEBUGGER_EXCEPTION(str) { throwNewDebuggerException(env, str); return;} - -#define SYMBOL_BUF_SIZE 256 -#define ERR_MSG_SIZE (PATH_MAX + 256) - -// debug modes -static int _libsaproc_debug = 0; - -static void print_debug(const char* format,...) { - if (_libsaproc_debug) { - va_list alist; - - va_start(alist, format); - fputs("libsaproc DEBUG: ", stderr); - vfprintf(stderr, format, alist); - va_end(alist); - } -} - -struct Debugger { - JNIEnv* env; - jobject this_obj; -}; - -struct DebuggerWithObject : Debugger { - jobject obj; -}; - -struct DebuggerWith2Objects : DebuggerWithObject { - jobject obj2; -}; - -/* -* Portions of user thread level detail gathering code is from pstack source -* code. See pstack.c in Solaris 2.8 user commands source code. -*/ - -static void throwNewDebuggerException(JNIEnv* env, const char* errMsg) { - jclass clazz = env->FindClass("sun/jvm/hotspot/debugger/DebuggerException"); - CHECK_EXCEPTION; - env->ThrowNew(clazz, errMsg); -} - -// JNI ids for some fields, methods - -// libproc handler pointer -static jfieldID p_ps_prochandle_ID = 0; - -// libthread.so dlopen handle, thread agent ptr and function pointers -static jfieldID libthread_db_handle_ID = 0; -static jfieldID p_td_thragent_t_ID = 0; -static jfieldID p_td_init_ID = 0; -static jfieldID p_td_ta_new_ID = 0; -static jfieldID p_td_ta_delete_ID = 0; -static jfieldID p_td_ta_thr_iter_ID = 0; -static jfieldID p_td_thr_get_info_ID = 0; -static jfieldID p_td_ta_map_id2thr_ID = 0; -static jfieldID p_td_thr_getgregs_ID = 0; - -// reg index fields -static jfieldID pcRegIndex_ID = 0; -static jfieldID fpRegIndex_ID = 0; - -// part of the class sharing workaround -static jfieldID classes_jsa_fd_ID = 0; -static jfieldID p_file_map_header_ID = 0; - -// method ids - -static jmethodID getThreadForThreadId_ID = 0; -static jmethodID createSenderFrame_ID = 0; -static jmethodID createLoadObject_ID = 0; -static jmethodID createClosestSymbol_ID = 0; -static jmethodID listAdd_ID = 0; - -/* - * Functions we need from libthread_db - */ -typedef td_err_e - (*p_td_init_t)(void); -typedef td_err_e - (*p_td_ta_new_t)(void *, td_thragent_t **); -typedef td_err_e - (*p_td_ta_delete_t)(td_thragent_t *); -typedef td_err_e - (*p_td_ta_thr_iter_t)(const td_thragent_t *, td_thr_iter_f *, void *, - td_thr_state_e, int, sigset_t *, unsigned); -typedef td_err_e - (*p_td_thr_get_info_t)(const td_thrhandle_t *, td_thrinfo_t *); -typedef td_err_e - (*p_td_ta_map_id2thr_t)(const td_thragent_t *, thread_t, td_thrhandle_t *); -typedef td_err_e - (*p_td_thr_getgregs_t)(const td_thrhandle_t *, prgregset_t); - -static void -clear_libthread_db_ptrs(JNIEnv* env, jobject this_obj) { - // release libthread_db agent, if we had created - p_td_ta_delete_t p_td_ta_delete = 0; - p_td_ta_delete = (p_td_ta_delete_t) env->GetLongField(this_obj, p_td_ta_delete_ID); - - td_thragent_t *p_td_thragent_t = 0; - p_td_thragent_t = (td_thragent_t*) env->GetLongField(this_obj, p_td_thragent_t_ID); - if (p_td_thragent_t != 0 && p_td_ta_delete != 0) { - p_td_ta_delete(p_td_thragent_t); - } - - // dlclose libthread_db.so - void* libthread_db_handle = (void*) env->GetLongField(this_obj, libthread_db_handle_ID); - if (libthread_db_handle != 0) { - dlclose(libthread_db_handle); - } - - env->SetLongField(this_obj, libthread_db_handle_ID, (jlong)0); - env->SetLongField(this_obj, p_td_init_ID, (jlong)0); - env->SetLongField(this_obj, p_td_ta_new_ID, (jlong)0); - env->SetLongField(this_obj, p_td_ta_delete_ID, (jlong)0); - env->SetLongField(this_obj, p_td_ta_thr_iter_ID, (jlong)0); - env->SetLongField(this_obj, p_td_thr_get_info_ID, (jlong)0); - env->SetLongField(this_obj, p_td_ta_map_id2thr_ID, (jlong)0); - env->SetLongField(this_obj, p_td_thr_getgregs_ID, (jlong)0); -} - - -static void detach_internal(JNIEnv* env, jobject this_obj) { - // clear libthread_db stuff - clear_libthread_db_ptrs(env, this_obj); - - // release ptr to ps_prochandle - jlong p_ps_prochandle; - p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID); - if (p_ps_prochandle != 0L) { - Prelease((struct ps_prochandle*) p_ps_prochandle, PRELEASE_CLEAR); - } - - // part of the class sharing workaround - int classes_jsa_fd = env->GetIntField(this_obj, classes_jsa_fd_ID); - if (classes_jsa_fd != -1) { - close(classes_jsa_fd); - CDSFileMapHeaderBase* pheader = (CDSFileMapHeaderBase*) env->GetLongField(this_obj, p_file_map_header_ID); - if (pheader != NULL) { - free(pheader); - } - } -} - -// Is it okay to ignore libthread_db failure? Set env var to ignore -// libthread_db failure. You can still debug, but will miss threads -// related functionality. -static bool sa_ignore_threaddb = (getenv("SA_IGNORE_THREADDB") != 0); - -#define HANDLE_THREADDB_FAILURE(msg) \ - if (sa_ignore_threaddb) { \ - printf("libsaproc WARNING: %s\n", msg); \ - return; \ - } else { \ - THROW_NEW_DEBUGGER_EXCEPTION(msg); \ - } - -#define HANDLE_THREADDB_FAILURE_(msg, ret) \ - if (sa_ignore_threaddb) { \ - printf("libsaproc WARNING: %s\n", msg); \ - return ret; \ - } else { \ - THROW_NEW_DEBUGGER_EXCEPTION_(msg, ret); \ - } - -static const char * alt_root = NULL; -static int alt_root_len = -1; - -#define SA_ALTROOT "SA_ALTROOT" - -static void init_alt_root() { - if (alt_root_len == -1) { - alt_root = getenv(SA_ALTROOT); - if (alt_root) - alt_root_len = strlen(alt_root); - else - alt_root_len = 0; - } -} - -// This function is a complete substitute for the open system call -// since it's also used to override open calls from libproc to -// implement as a pathmap style facility for the SA. If libproc -// starts using other interfaces then this might have to extended to -// cover other calls. -extern "C" JNIEXPORT int JNICALL -libsaproc_open(const char * name, int oflag, ...) { - if (oflag == O_RDONLY) { - init_alt_root(); - - if (_libsaproc_debug) { - printf("libsaproc DEBUG: libsaproc_open %s\n", name); - } - - if (alt_root_len > 0) { - int fd = -1; - char alt_path[PATH_MAX+1]; - - strcpy(alt_path, alt_root); - strcat(alt_path, name); - fd = open(alt_path, O_RDONLY); - if (fd >= 0) { - if (_libsaproc_debug) { - printf("libsaproc DEBUG: libsaproc_open substituted %s\n", alt_path); - } - return fd; - } - - if (strrchr(name, '/')) { - strcpy(alt_path, alt_root); - strcat(alt_path, strrchr(name, '/')); - fd = open(alt_path, O_RDONLY); - if (fd >= 0) { - if (_libsaproc_debug) { - printf("libsaproc DEBUG: libsaproc_open substituted %s\n", alt_path); - } - return fd; - } - } - } - } - - { - mode_t mode; - va_list ap; - va_start(ap, oflag); - mode = va_arg(ap, mode_t); - va_end(ap); - - return open(name, oflag, mode); - } -} - - -static void * pathmap_dlopen(const char * name, int mode) { - init_alt_root(); - - if (_libsaproc_debug) { - printf("libsaproc DEBUG: pathmap_dlopen %s\n", name); - } - - void * handle = NULL; - if (alt_root_len > 0) { - char alt_path[PATH_MAX+1]; - strcpy(alt_path, alt_root); - strcat(alt_path, name); - handle = dlopen(alt_path, mode); - if (_libsaproc_debug && handle) { - printf("libsaproc DEBUG: pathmap_dlopen substituted %s\n", alt_path); - } - - if (handle == NULL && strrchr(name, '/')) { - strcpy(alt_path, alt_root); - strcat(alt_path, strrchr(name, '/')); - handle = dlopen(alt_path, mode); - if (_libsaproc_debug && handle) { - printf("libsaproc DEBUG: pathmap_dlopen substituted %s\n", alt_path); - } - } - } - if (handle == NULL) { - handle = dlopen(name, mode); - } - if (_libsaproc_debug) { - printf("libsaproc DEBUG: pathmap_dlopen %s return 0x%lx\n", name, (unsigned long) handle); - } - return handle; -} - -// libproc and libthread_db callback functions - -extern "C" { - -static int -init_libthread_db_ptrs(void *cd, const prmap_t *pmp, const char *object_name) { - Debugger* dbg = (Debugger*) cd; - JNIEnv* env = dbg->env; - jobject this_obj = dbg->this_obj; - struct ps_prochandle* ph = (struct ps_prochandle*) env->GetLongField(this_obj, p_ps_prochandle_ID); - - char *s1 = 0, *s2 = 0; - char libthread_db[PATH_MAX]; - - if (strstr(object_name, "/libthread.so.") == NULL) - return (0); - - /* - * We found a libthread. - * dlopen() the matching libthread_db and get the thread agent handle. - */ - if (Pstatus(ph)->pr_dmodel == PR_MODEL_NATIVE) { - (void) strcpy(libthread_db, object_name); - s1 = (char*) strstr(object_name, ".so."); - s2 = (char*) strstr(libthread_db, ".so."); - (void) strcpy(s2, "_db"); - s2 += 3; - (void) strcpy(s2, s1); - } else { -#ifdef _LP64 - /* - * The victim process is 32-bit, we are 64-bit. - * We have to find the 64-bit version of libthread_db - * that matches the victim's 32-bit version of libthread. - */ - (void) strcpy(libthread_db, object_name); - s1 = (char*) strstr(object_name, "/libthread.so."); - s2 = (char*) strstr(libthread_db, "/libthread.so."); - (void) strcpy(s2, "/64"); - s2 += 3; - (void) strcpy(s2, s1); - s1 = (char*) strstr(s1, ".so."); - s2 = (char*) strstr(s2, ".so."); - (void) strcpy(s2, "_db"); - s2 += 3; - (void) strcpy(s2, s1); -#else - return (0); -#endif /* _LP64 */ - } - - void* libthread_db_handle = 0; - if ((libthread_db_handle = pathmap_dlopen(libthread_db, RTLD_LAZY|RTLD_LOCAL)) == NULL) { - char errMsg[PATH_MAX + 256]; - sprintf(errMsg, "Can't load %s!", libthread_db); - HANDLE_THREADDB_FAILURE_(errMsg, 0); - } - env->SetLongField(this_obj, libthread_db_handle_ID, (jlong)(uintptr_t)libthread_db_handle); - - void* tmpPtr = 0; - tmpPtr = dlsym(libthread_db_handle, "td_init"); - if (tmpPtr == 0) { - HANDLE_THREADDB_FAILURE_("dlsym failed on td_init!", 0); - } - env->SetLongField(this_obj, p_td_init_ID, (jlong)(uintptr_t) tmpPtr); - - tmpPtr =dlsym(libthread_db_handle, "td_ta_new"); - if (tmpPtr == 0) { - HANDLE_THREADDB_FAILURE_("dlsym failed on td_ta_new!", 0); - } - env->SetLongField(this_obj, p_td_ta_new_ID, (jlong)(uintptr_t) tmpPtr); - - tmpPtr = dlsym(libthread_db_handle, "td_ta_delete"); - if (tmpPtr == 0) { - HANDLE_THREADDB_FAILURE_("dlsym failed on td_ta_delete!", 0); - } - env->SetLongField(this_obj, p_td_ta_delete_ID, (jlong)(uintptr_t) tmpPtr); - - tmpPtr = dlsym(libthread_db_handle, "td_ta_thr_iter"); - if (tmpPtr == 0) { - HANDLE_THREADDB_FAILURE_("dlsym failed on td_ta_thr_iter!", 0); - } - env->SetLongField(this_obj, p_td_ta_thr_iter_ID, (jlong)(uintptr_t) tmpPtr); - - tmpPtr = dlsym(libthread_db_handle, "td_thr_get_info"); - if (tmpPtr == 0) { - HANDLE_THREADDB_FAILURE_("dlsym failed on td_thr_get_info!", 0); - } - env->SetLongField(this_obj, p_td_thr_get_info_ID, (jlong)(uintptr_t) tmpPtr); - - tmpPtr = dlsym(libthread_db_handle, "td_ta_map_id2thr"); - if (tmpPtr == 0) { - HANDLE_THREADDB_FAILURE_("dlsym failed on td_ta_map_id2thr!", 0); - } - env->SetLongField(this_obj, p_td_ta_map_id2thr_ID, (jlong)(uintptr_t) tmpPtr); - - tmpPtr = dlsym(libthread_db_handle, "td_thr_getgregs"); - if (tmpPtr == 0) { - HANDLE_THREADDB_FAILURE_("dlsym failed on td_thr_getgregs!", 0); - } - env->SetLongField(this_obj, p_td_thr_getgregs_ID, (jlong)(uintptr_t) tmpPtr); - - return 1; -} - -static int -fill_thread_list(const td_thrhandle_t *p_td_thragent_t, void* cd) { - DebuggerWithObject* dbgo = (DebuggerWithObject*) cd; - JNIEnv* env = dbgo->env; - jobject this_obj = dbgo->this_obj; - jobject list = dbgo->obj; - - td_thrinfo_t thrinfo; - p_td_thr_get_info_t p_td_thr_get_info = (p_td_thr_get_info_t) env->GetLongField(this_obj, p_td_thr_get_info_ID); - - if (p_td_thr_get_info(p_td_thragent_t, &thrinfo) != TD_OK) - return (0); - - jobject threadProxy = env->CallObjectMethod(this_obj, getThreadForThreadId_ID, (jlong)(uintptr_t) thrinfo.ti_tid); - CHECK_EXCEPTION_(1); - env->CallBooleanMethod(list, listAdd_ID, threadProxy); - CHECK_EXCEPTION_(1); - return 0; -} - -static int -fill_load_object_list(void *cd, const prmap_t* pmp, const char* obj_name) { - - if (obj_name) { - DebuggerWithObject* dbgo = (DebuggerWithObject*) cd; - JNIEnv* env = dbgo->env; - jobject this_obj = dbgo->this_obj; - jobject list = dbgo->obj; - - jstring objectName = env->NewStringUTF(obj_name); - CHECK_EXCEPTION_(1); - - jlong mapSize = (jlong) pmp->pr_size; - jobject sharedObject = env->CallObjectMethod(this_obj, createLoadObject_ID, - objectName, mapSize, (jlong)(uintptr_t)pmp->pr_vaddr); - CHECK_EXCEPTION_(1); - env->CallBooleanMethod(list, listAdd_ID, sharedObject); - CHECK_EXCEPTION_(1); - } - - return 0; -} - -// Pstack_iter() proc_stack_f callback prior to Nevada-B159 -static int -fill_cframe_list(void *cd, const prgregset_t regs, uint_t argc, const long *argv) { - DebuggerWith2Objects* dbgo2 = (DebuggerWith2Objects*) cd; - JNIEnv* env = dbgo2->env; - jobject this_obj = dbgo2->this_obj; - jobject curFrame = dbgo2->obj2; - - jint pcRegIndex = env->GetIntField(this_obj, pcRegIndex_ID); - jint fpRegIndex = env->GetIntField(this_obj, fpRegIndex_ID); - - jlong pc = (jlong) (uintptr_t) regs[pcRegIndex]; - jlong fp = (jlong) (uintptr_t) regs[fpRegIndex]; - - dbgo2->obj2 = env->CallObjectMethod(this_obj, createSenderFrame_ID, - curFrame, pc, fp); - CHECK_EXCEPTION_(1); - if (dbgo2->obj == 0) { - dbgo2->obj = dbgo2->obj2; - } - return 0; -} - -// Pstack_iter() proc_stack_f callback in Nevada-B159 or later -/*ARGSUSED*/ -static int -wrapper_fill_cframe_list(void *cd, const prgregset_t regs, uint_t argc, - const long *argv, int frame_flags, int sig) { - return(fill_cframe_list(cd, regs, argc, argv)); -} - -//--------------------------------------------------------------- -// Part of the class sharing workaround: -// -// With class sharing, pages are mapped from classes.jsa file. -// The read-only class sharing pages are mapped as MAP_SHARED, -// PROT_READ pages. These pages are not dumped into core dump. -// With this workaround, these pages are read from classes.jsa. - -static bool -read_jboolean(struct ps_prochandle* ph, psaddr_t addr, jboolean* pvalue) { - jboolean i; - if (ps_pread(ph, addr, &i, sizeof(i)) == PS_OK) { - *pvalue = i; - return true; - } else { - return false; - } -} - -static bool -read_pointer(struct ps_prochandle* ph, psaddr_t addr, uintptr_t* pvalue) { - uintptr_t uip; - if (ps_pread(ph, addr, &uip, sizeof(uip)) == PS_OK) { - *pvalue = uip; - return true; - } else { - return false; - } -} - -static bool -read_string(struct ps_prochandle* ph, psaddr_t addr, char* buf, size_t size) { - char ch = ' '; - size_t i = 0; - - while (ch != '\0') { - if (ps_pread(ph, addr, &ch, sizeof(ch)) != PS_OK) - return false; - - if (i < size - 1) { - buf[i] = ch; - } else { // smaller buffer - return false; - } - - i++; addr++; - } - - buf[i] = '\0'; - return true; -} - -#define USE_SHARED_SPACES_SYM "UseSharedSpaces" -#define SHARED_BASE_ADDRESS_SYM "SharedBaseAddress" -// mangled symbol name for Arguments::SharedArchivePath -#define SHARED_ARCHIVE_PATH_SYM "__1cJArgumentsRSharedArchivePath_" - -static uintptr_t sharedBaseAddress = 0; -static int -init_classsharing_workaround(void *cd, const prmap_t* pmap, const char* obj_name) { - Debugger* dbg = (Debugger*) cd; - JNIEnv* env = dbg->env; - jobject this_obj = dbg->this_obj; - const char* jvm_name = 0; - if ((jvm_name = strstr(obj_name, "libjvm.so")) != NULL) { - jvm_name = obj_name; - } else { - return 0; - } - - struct ps_prochandle* ph = (struct ps_prochandle*) env->GetLongField(this_obj, p_ps_prochandle_ID); - - // initialize classes.jsa file descriptor field. - dbg->env->SetIntField(this_obj, classes_jsa_fd_ID, -1); - - // check whether class sharing is on by reading variable "UseSharedSpaces" - psaddr_t useSharedSpacesAddr = 0; - ps_pglobal_lookup(ph, jvm_name, USE_SHARED_SPACES_SYM, &useSharedSpacesAddr); - if (useSharedSpacesAddr == 0) { - THROW_NEW_DEBUGGER_EXCEPTION_("can't find 'UseSharedSpaces' flag\n", 1); - } - - // read the value of the flag "UseSharedSpaces" - // Since hotspot types are not available to build this library. So - // equivalent type "jboolean" is used to read the value of "UseSharedSpaces" - // which is same as hotspot type "bool". - jboolean value = 0; - if (read_jboolean(ph, useSharedSpacesAddr, &value) != true) { - THROW_NEW_DEBUGGER_EXCEPTION_("can't read 'UseSharedSpaces' flag", 1); - } else if ((int)value == 0) { - print_debug("UseSharedSpaces is false, assuming -Xshare:off!\n"); - return 1; - } - - psaddr_t sharedBaseAddressAddr = 0; - ps_pglobal_lookup(ph, jvm_name, SHARED_ARCHIVE_PATH_SYM, &sharedBaseAddressAddr); - if (sharedBaseAddressAddr == 0) { - print_debug("can't find symbol 'SharedBaseAddress'\n"); - THROW_NEW_DEBUGGER_EXCEPTION_("can't find 'SharedBaseAddress' flag\n", 1); - } - - sharedBaseAddress = 0; - if (read_pointer(ph, sharedBaseAddressAddr, &sharedBaseAddress) != true) { - print_debug("can't read the value of 'SharedBaseAddress' flag\n"); - THROW_NEW_DEBUGGER_EXCEPTION_("can't get SharedBaseAddress from debuggee", 1); - } - - char classes_jsa[PATH_MAX]; - psaddr_t sharedArchivePathAddrAddr = 0; - ps_pglobal_lookup(ph, jvm_name, SHARED_ARCHIVE_PATH_SYM, &sharedArchivePathAddrAddr); - if (sharedArchivePathAddrAddr == 0) { - print_debug("can't find symbol 'Arguments::SharedArchivePath'\n"); - THROW_NEW_DEBUGGER_EXCEPTION_("can't get shared archive path from debuggee", 1); - } - - uintptr_t sharedArchivePathAddr = 0; - if (read_pointer(ph, sharedArchivePathAddrAddr, &sharedArchivePathAddr) != true) { - print_debug("can't find read pointer 'Arguments::SharedArchivePath'\n"); - THROW_NEW_DEBUGGER_EXCEPTION_("can't get shared archive path from debuggee", 1); - } - - if (read_string(ph, (psaddr_t)sharedArchivePathAddr, classes_jsa, sizeof(classes_jsa)) != true) { - print_debug("can't find read 'Arguments::SharedArchivePath' value\n"); - THROW_NEW_DEBUGGER_EXCEPTION_("can't get shared archive path from debuggee", 1); - } - - print_debug("looking for %s\n", classes_jsa); - - // open the classes.jsa - int fd = libsaproc_open(classes_jsa, O_RDONLY); - if (fd < 0) { - char errMsg[ERR_MSG_SIZE]; - sprintf(errMsg, "can't open shared archive file %s", classes_jsa); - THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1); - } else { - print_debug("opened shared archive file %s\n", classes_jsa); - } - - // parse classes.jsa - CDSFileMapHeaderBase* pheader = (CDSFileMapHeaderBase*) malloc(sizeof(CDSFileMapHeaderBase)); - if (pheader == NULL) { - close(fd); - THROW_NEW_DEBUGGER_EXCEPTION_("can't allocate memory for shared file map header", 1); - } - - memset(pheader, 0, sizeof(CDSFileMapHeaderBase)); - // read CDSFileMapHeaderBase - size_t n = read(fd, pheader, sizeof(CDSFileMapHeaderBase)); - if (n != sizeof(CDSFileMapHeaderBase)) { - char errMsg[ERR_MSG_SIZE]; - sprintf(errMsg, "unable to read shared archive file map header from %s", classes_jsa); - close(fd); - free(pheader); - THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1); - } - - // check file magic - if (pheader->_magic != CDS_ARCHIVE_MAGIC) { - char errMsg[ERR_MSG_SIZE]; - sprintf(errMsg, "%s has bad shared archive magic 0x%x, expecting 0x%x", - classes_jsa, pheader->_magic, CDS_ARCHIVE_MAGIC); - close(fd); - free(pheader); - THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1); - } - - // check version - if (pheader->_version != CURRENT_CDS_ARCHIVE_VERSION) { - char errMsg[ERR_MSG_SIZE]; - sprintf(errMsg, "%s has wrong shared archive version %d, expecting %d", - classes_jsa, pheader->_version, CURRENT_CDS_ARCHIVE_VERSION); - close(fd); - free(pheader); - THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 1); - } - - if (_libsaproc_debug) { - for (int m = 0; m < NUM_CDS_REGIONS; m++) { - if (!pheader->_space[m]._is_heap_region && - !pheader->_space[m]._is_bitmap_region) { - jlong mapping_offset = pheader->_space[m]._mapping_offset; - jlong baseAddress = mapping_offset + (jlong)sharedBaseAddress; - print_debug("shared file offset %d mapped at 0x%lx, size = %ld, read only? = %d\n", - pheader->_space[m]._file_offset, baseAddress, - pheader->_space[m]._used, pheader->_space[m]._read_only); - } - } - } - - // FIXME: For now, omitting other checks such as VM version etc. - - // store class archive file fd and map header in debugger object fields - dbg->env->SetIntField(this_obj, classes_jsa_fd_ID, fd); - dbg->env->SetLongField(this_obj, p_file_map_header_ID, (jlong)(uintptr_t) pheader); - return 1; -} - -} // extern "C" - -// error messages for proc_arg_grab failure codes. The messages are -// modified versions of comments against corresponding #defines in -// libproc.h. -static const char* proc_arg_grab_errmsgs[] = { - "", - /* G_NOPROC */ "No such process", - /* G_NOCORE */ "No such core file", - /* G_NOPROCORCORE */ "No such process or core", - /* G_NOEXEC */ "Cannot locate executable file", - /* G_ZOMB */ "Zombie processs", - /* G_PERM */ "No permission to attach", - /* G_BUSY */ "Another process has already attached", - /* G_SYS */ "System process - can not attach", - /* G_SELF */ "Process is self - can't debug myself!", - /* G_INTR */ "Interrupt received while grabbing", - /* G_LP64 */ "debuggee is 64 bit, use java -d64 for debugger", - /* G_FORMAT */ "File is not an ELF format core file - corrupted core?", - /* G_ELF */ "Libelf error while parsing an ELF file", - /* G_NOTE */ "Required PT_NOTE Phdr not present - corrupted core?", -}; - -static void attach_internal(JNIEnv* env, jobject this_obj, jstring cmdLine, jboolean isProcess) { - jboolean isCopy; - int gcode; - const char* cmdLine_cstr = env->GetStringUTFChars(cmdLine, &isCopy); - char errMsg[ERR_MSG_SIZE]; - td_err_e te; - CHECK_EXCEPTION; - if (cmdLine_cstr == NULL) { - return; - } - - // some older versions of libproc.so crash when trying to attach 32 bit - // debugger to 64 bit core file. check and throw error. -#ifndef _LP64 - errno = 0; - strtol(cmdLine_cstr, NULL, 10); - if (errno) { - // core file - int core_fd; - if ((core_fd = open64(cmdLine_cstr, O_RDONLY)) >= 0) { - Elf32_Ehdr e32; - if (pread64(core_fd, &e32, sizeof (e32), 0) == sizeof (e32) && - memcmp(&e32.e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0 && - e32.e_type == ET_CORE && e32.e_ident[EI_CLASS] == ELFCLASS64) { - close(core_fd); - env->ReleaseStringUTFChars(cmdLine, cmdLine_cstr); - THROW_NEW_DEBUGGER_EXCEPTION("debuggee is 64 bit, use java -d64 for debugger"); - } - close(core_fd); - } - // all other conditions are handled by libproc.so. - } -#endif - - // connect to process/core - ps_prochandle_t* ph = proc_arg_grab(cmdLine_cstr, (isProcess? PR_ARG_PIDS : PR_ARG_CORES), PGRAB_FORCE, &gcode, NULL); - - env->ReleaseStringUTFChars(cmdLine, cmdLine_cstr); - - if (! ph) { - if (gcode > 0 && gcode < sizeof(proc_arg_grab_errmsgs)/sizeof(const char*)) { - snprintf(errMsg, ERR_MSG_SIZE, "Attach failed : %s", proc_arg_grab_errmsgs[gcode]); - THROW_NEW_DEBUGGER_EXCEPTION(errMsg); - } else { - if (_libsaproc_debug && gcode == G_STRANGE) { - perror("libsaproc DEBUG: "); - } - if (isProcess) { - THROW_NEW_DEBUGGER_EXCEPTION("Not able to attach to process!"); - } else { - THROW_NEW_DEBUGGER_EXCEPTION("Not able to attach to core file!"); - } - } - } - - // even though libproc.so supports 64 bit debugger and 32 bit debuggee, we don't - // support such cross-bit-debugging. check for that combination and throw error. -#ifdef _LP64 - int data_model; - if (ps_pdmodel(ph, &data_model) != PS_OK) { - Prelease(ph, PRELEASE_CLEAR); - THROW_NEW_DEBUGGER_EXCEPTION("can't determine debuggee data model (ILP32? or LP64?)"); - } - if (data_model == PR_MODEL_ILP32) { - Prelease(ph, PRELEASE_CLEAR); - THROW_NEW_DEBUGGER_EXCEPTION("debuggee is 32 bit, use 32 bit java for debugger"); - } -#endif - - env->SetLongField(this_obj, p_ps_prochandle_ID, (jlong)(uintptr_t)ph); - - Debugger dbg; - dbg.env = env; - dbg.this_obj = this_obj; - jthrowable exception = 0; - if (! isProcess) { - /* - * With class sharing, shared perm. gen heap is allocated in with MAP_SHARED|PROT_READ. - * These pages are mapped from the file "classes.jsa". MAP_SHARED pages are not dumped - * in Solaris core.To read shared heap pages, we have to read classes.jsa file. - */ - Pobject_iter(ph, init_classsharing_workaround, &dbg); - exception = env->ExceptionOccurred(); - if (exception) { - env->ExceptionClear(); - detach_internal(env, this_obj); - env->Throw(exception); - return; - } - } - - /* - * Iterate over the process mappings looking - * for libthread and then dlopen the appropriate - * libthread_db and get function pointers. - */ - Pobject_iter(ph, init_libthread_db_ptrs, &dbg); - exception = env->ExceptionOccurred(); - if (exception) { - env->ExceptionClear(); - if (!sa_ignore_threaddb) { - detach_internal(env, this_obj); - env->Throw(exception); - } - return; - } - - // init libthread_db and create thread_db agent - p_td_init_t p_td_init = (p_td_init_t) env->GetLongField(this_obj, p_td_init_ID); - if (p_td_init == 0) { - if (!sa_ignore_threaddb) { - detach_internal(env, this_obj); - } - HANDLE_THREADDB_FAILURE("Did not find libthread in target process/core!"); - } - - te = p_td_init(); - if (te != TD_OK) { - if (!sa_ignore_threaddb) { - detach_internal(env, this_obj); - } - snprintf(errMsg, ERR_MSG_SIZE, "Can't initialize thread_db! td_init failed: %d", te); - HANDLE_THREADDB_FAILURE(errMsg); - } - - p_td_ta_new_t p_td_ta_new = (p_td_ta_new_t) env->GetLongField(this_obj, p_td_ta_new_ID); - - td_thragent_t *p_td_thragent_t = 0; - te = p_td_ta_new(ph, &p_td_thragent_t); - if (te != TD_OK) { - if (!sa_ignore_threaddb) { - detach_internal(env, this_obj); - } - snprintf(errMsg, ERR_MSG_SIZE, "Can't create thread_db agent! td_ta_new failed: %d", te); - HANDLE_THREADDB_FAILURE(errMsg); - } - env->SetLongField(this_obj, p_td_thragent_t_ID, (jlong)(uintptr_t) p_td_thragent_t); - -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: attach0 - * Signature: (Ljava/lang/String;)V - * Description: process detach - */ -JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_attach0__Ljava_lang_String_2 - (JNIEnv *env, jobject this_obj, jstring pid) { - attach_internal(env, this_obj, pid, JNI_TRUE); -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: attach0 - * Signature: (Ljava/lang/String;Ljava/lang/String;)V - * Description: core file detach - */ -JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_attach0__Ljava_lang_String_2Ljava_lang_String_2 - (JNIEnv *env, jobject this_obj, jstring executable, jstring corefile) { - // ignore executable file name, libproc.so can detect a.out name anyway. - attach_internal(env, this_obj, corefile, JNI_FALSE); -} - - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: detach0 - * Signature: ()V - * Description: process/core file detach - */ -JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_detach0 - (JNIEnv *env, jobject this_obj) { - detach_internal(env, this_obj); -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: getRemoteProcessAddressSize0 - * Signature: ()I - * Description: get process/core address size - */ -JNIEXPORT jint JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_getRemoteProcessAddressSize0 - (JNIEnv *env, jobject this_obj) { - jlong p_ps_prochandle; - p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID); - int data_model = PR_MODEL_ILP32; - ps_pdmodel((struct ps_prochandle*) p_ps_prochandle, &data_model); - print_debug("debuggee is %d bit\n", data_model == PR_MODEL_ILP32? 32 : 64); - return (jint) data_model == PR_MODEL_ILP32? 32 : 64; -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: getPageSize0 - * Signature: ()I - * Description: get process/core page size - */ -JNIEXPORT jint JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_getPageSize0 - (JNIEnv *env, jobject this_obj) { - -/* - We are not yet attached to a java process or core file. getPageSize is called from - the constructor of ProcDebuggerLocal. The following won't work! - - jlong p_ps_prochandle; - p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID); - CHECK_EXCEPTION_(-1); - struct ps_prochandle* prochandle = (struct ps_prochandle*) p_ps_prochandle; - return (Pstate(prochandle) == PS_DEAD) ? Pgetauxval(prochandle, AT_PAGESZ) - : getpagesize(); - - So even though core may have been generated with a different page size settings, for now - call getpagesize. -*/ - - return getpagesize(); -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: getThreadIntegerRegisterSet0 - * Signature: (J)[J - * Description: get gregset for a given thread specified by thread id - */ -JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_getThreadIntegerRegisterSet0 - (JNIEnv *env, jobject this_obj, jlong tid) { - char errMsg[ERR_MSG_SIZE]; - td_err_e te; - // map the thread id to thread handle - p_td_ta_map_id2thr_t p_td_ta_map_id2thr = (p_td_ta_map_id2thr_t) env->GetLongField(this_obj, p_td_ta_map_id2thr_ID); - - td_thragent_t* p_td_thragent_t = (td_thragent_t*) env->GetLongField(this_obj, p_td_thragent_t_ID); - if (p_td_thragent_t == 0) { - return 0; - } - - td_thrhandle_t thr_handle; - te = p_td_ta_map_id2thr(p_td_thragent_t, (thread_t) tid, &thr_handle); - if (te != TD_OK) { - snprintf(errMsg, ERR_MSG_SIZE, "can't map thread id to thread handle! td_ta_map_id2thr failed: %d", te); - THROW_NEW_DEBUGGER_EXCEPTION_(errMsg, 0); - } - - p_td_thr_getgregs_t p_td_thr_getgregs = (p_td_thr_getgregs_t) env->GetLongField(this_obj, p_td_thr_getgregs_ID); - prgregset_t gregs; - p_td_thr_getgregs(&thr_handle, gregs); - - jlongArray res = env->NewLongArray(NPRGREG); - CHECK_EXCEPTION_(0); - jboolean isCopy; - jlong* ptr = env->GetLongArrayElements(res, &isCopy); - CHECK_EXCEPTION_(NULL); - for (int i = 0; i < NPRGREG; i++) { - ptr[i] = (jlong) (uintptr_t) gregs[i]; - } - env->ReleaseLongArrayElements(res, ptr, JNI_COMMIT); - return res; -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: fillThreadList0 - * Signature: (Ljava/util/List;)V - * Description: fills thread list of the debuggee process/core - */ -JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_fillThreadList0 - (JNIEnv *env, jobject this_obj, jobject list) { - - td_thragent_t* p_td_thragent_t = (td_thragent_t*) env->GetLongField(this_obj, p_td_thragent_t_ID); - if (p_td_thragent_t == 0) { - return; - } - - p_td_ta_thr_iter_t p_td_ta_thr_iter = (p_td_ta_thr_iter_t) env->GetLongField(this_obj, p_td_ta_thr_iter_ID); - - DebuggerWithObject dbgo; - dbgo.env = env; - dbgo.this_obj = this_obj; - dbgo.obj = list; - - p_td_ta_thr_iter(p_td_thragent_t, fill_thread_list, &dbgo, - TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS); -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: fillCFrameList0 - * Signature: ([J)Lsun/jvm/hotspot/debugger/proc/ProcCFrame; - * Description: fills CFrame list for a given thread - */ -JNIEXPORT jobject JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_fillCFrameList0 - (JNIEnv *env, jobject this_obj, jlongArray regsArray) { - jlong p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID); - - DebuggerWith2Objects dbgo2; - dbgo2.env = env; - dbgo2.this_obj = this_obj; - dbgo2.obj = NULL; - dbgo2.obj2 = NULL; - - jboolean isCopy; - jlong* ptr = env->GetLongArrayElements(regsArray, &isCopy); - CHECK_EXCEPTION_(0); - - prgregset_t gregs; - for (int i = 0; i < NPRGREG; i++) { - gregs[i] = (uintptr_t) ptr[i]; - } - - env->ReleaseLongArrayElements(regsArray, ptr, JNI_ABORT); - CHECK_EXCEPTION_(0); - - Pstack_iter((struct ps_prochandle*) p_ps_prochandle, gregs, - wrapper_fill_cframe_list, &dbgo2); - return dbgo2.obj; -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: fillLoadObjectList0 - * Signature: (Ljava/util/List;)V - * Description: fills shared objects of the debuggee process/core - */ -JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_fillLoadObjectList0 - (JNIEnv *env, jobject this_obj, jobject list) { - DebuggerWithObject dbgo; - dbgo.env = env; - dbgo.this_obj = this_obj; - dbgo.obj = list; - - jlong p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID); - Pobject_iter((struct ps_prochandle*) p_ps_prochandle, fill_load_object_list, &dbgo); -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: readBytesFromProcess0 - * Signature: (JJ)[B - * Description: read bytes from debuggee process/core - */ -JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_readBytesFromProcess0 - (JNIEnv *env, jobject this_obj, jlong address, jlong numBytes) { - - jbyteArray array = env->NewByteArray(numBytes); - CHECK_EXCEPTION_(0); - jboolean isCopy; - jbyte* bufPtr = env->GetByteArrayElements(array, &isCopy); - CHECK_EXCEPTION_(0); - - jlong p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID); - ps_err_e ret = ps_pread((struct ps_prochandle*) p_ps_prochandle, - (psaddr_t)address, bufPtr, (size_t)numBytes); - - if (ret != PS_OK) { - // part of the class sharing workaround. try shared heap area - int classes_jsa_fd = env->GetIntField(this_obj, classes_jsa_fd_ID); - if (classes_jsa_fd != -1 && address != (jlong)0) { - print_debug("read failed at 0x%lx, attempting shared heap area\n", (long) address); - - CDSFileMapHeaderBase* pheader = (CDSFileMapHeaderBase*) env->GetLongField(this_obj, p_file_map_header_ID); - // walk through the shared mappings -- we just have 9 of them. - // so, linear walking is okay. - for (int m = 0; m < NUM_CDS_REGIONS; m++) { - - // We can skip the non-read-only maps. These are mapped as MAP_PRIVATE - // and hence will be read by libproc. Besides, the file copy may be - // stale because the process might have modified those pages. - if (pheader->_space[m]._read_only && - !pheader->_space[m]._is_heap_region && - !pheader->_space[m]._is_bitmap_region) { - jlong mapping_offset = (jlong) (uintptr_t) pheader->_space[m]._mapping_offset; - jlong baseAddress = mapping_offset + (jlong)sharedBaseAddress; - size_t usedSize = pheader->_space[m]._used; - if (address >= baseAddress && address < (baseAddress + usedSize)) { - // the given address falls in this shared metadata area - print_debug("found shared map at 0x%lx\n", (long) baseAddress); - - - // If more data is asked than actually mapped from file, we need to zero fill - // till the end-of-page boundary. But, java array new does that for us. we just - // need to read as much as data available. - -#define MIN2(x, y) (((x) < (y))? (x) : (y)) - - jlong diff = address - baseAddress; - jlong bytesToRead = MIN2(numBytes, usedSize - diff); - off_t offset = pheader->_space[m]._file_offset + off_t(diff); - ssize_t bytesRead = pread(classes_jsa_fd, bufPtr, bytesToRead, offset); - if (bytesRead != bytesToRead) { - env->ReleaseByteArrayElements(array, bufPtr, JNI_ABORT); - print_debug("shared map read failed\n"); - return jbyteArray(0); - } else { - print_debug("shared map read succeeded\n"); - env->ReleaseByteArrayElements(array, bufPtr, 0); - return array; - } - } // is in current map - } // is read only map - } // for shared maps - } // classes_jsa_fd != -1 - env->ReleaseByteArrayElements(array, bufPtr, JNI_ABORT); - return jbyteArray(0); - } else { - env->ReleaseByteArrayElements(array, bufPtr, 0); - return array; - } -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: writeBytesToProcess0 - * Signature: (JJ[B)V - * Description: write bytes into debugger process - */ -JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_writeBytesToProcess0 - (JNIEnv *env, jobject this_obj, jlong address, jlong numBytes, jbyteArray data) { - char errMsg[ERR_MSG_SIZE]; - ps_err_e pe; - jlong p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID); - jboolean isCopy; - jbyte* ptr = env->GetByteArrayElements(data, &isCopy); - CHECK_EXCEPTION; - - pe = ps_pwrite((struct ps_prochandle*) p_ps_prochandle, address, ptr, numBytes); - if (pe != PS_OK) { - snprintf(errMsg, ERR_MSG_SIZE, "Process write failed! ps_pwrite failed: %d", pe); - env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); - THROW_NEW_DEBUGGER_EXCEPTION(errMsg); - } - - env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: suspend0 - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_suspend0 - (JNIEnv *env, jobject this_obj) { - jlong p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID); - // for now don't check return value. revisit this again. - Pstop((struct ps_prochandle*) p_ps_prochandle, 1000); -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: resume0 - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_resume0 - (JNIEnv *env, jobject this_obj) { - jlong p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID); - // for now don't check return value. revisit this again. - Psetrun((struct ps_prochandle*) p_ps_prochandle, 0, PRCFAULT|PRSTOP); -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: lookupByName0 - * Signature: (Ljava/lang/String;Ljava/lang/String;)J - * Description: symbol lookup by name -*/ -JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_lookupByName0 - (JNIEnv *env, jobject this_obj, jstring objectName, jstring symbolName) { - jlong p_ps_prochandle; - p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID); - - jboolean isCopy; - const char* objectName_cstr = NULL; - if (objectName != NULL) { - objectName_cstr = env->GetStringUTFChars(objectName, &isCopy); - CHECK_EXCEPTION_(0); - } else { - objectName_cstr = PR_OBJ_EVERY; - } - - const char* symbolName_cstr = env->GetStringUTFChars(symbolName, &isCopy); - if (env->ExceptionOccurred()) { - if (objectName_cstr != PR_OBJ_EVERY) { - env->ReleaseStringUTFChars(objectName, objectName_cstr); - } - return 0; - } - - psaddr_t symbol_addr = (psaddr_t) 0; - ps_pglobal_lookup((struct ps_prochandle*) p_ps_prochandle, objectName_cstr, - symbolName_cstr, &symbol_addr); - - if (symbol_addr == 0) { - print_debug("lookup for %s in %s failed\n", symbolName_cstr, objectName_cstr); - } - - if (objectName_cstr != PR_OBJ_EVERY) { - env->ReleaseStringUTFChars(objectName, objectName_cstr); - } - env->ReleaseStringUTFChars(symbolName, symbolName_cstr); - return (jlong) (uintptr_t) symbol_addr; -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: lookupByAddress0 - * Signature: (J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol; - * Description: lookup symbol name for a given address - */ -JNIEXPORT jobject JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_lookupByAddress0 - (JNIEnv *env, jobject this_obj, jlong address) { - jlong p_ps_prochandle; - p_ps_prochandle = env->GetLongField(this_obj, p_ps_prochandle_ID); - - char nameBuf[SYMBOL_BUF_SIZE + 1]; - GElf_Sym sym; - int res = Plookup_by_addr((struct ps_prochandle*) p_ps_prochandle, (uintptr_t) address, - nameBuf, sizeof(nameBuf), &sym, NULL); - - if (res != 0) { // failed - return 0; - } - - jstring resSym = env->NewStringUTF(nameBuf); - CHECK_EXCEPTION_(0); - - return env->CallObjectMethod(this_obj, createClosestSymbol_ID, resSym, (address - sym.st_value)); -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: demangle0 - * Signature: (Ljava/lang/String;)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_demangle0 - (JNIEnv *env, jobject this_object, jstring name) { - jboolean isCopy; - const char* ptr = env->GetStringUTFChars(name, &isCopy); - CHECK_EXCEPTION_(NULL); - char buf[2*SYMBOL_BUF_SIZE + 1]; - jstring res = 0; - if (cplus_demangle((char*) ptr, buf, sizeof(buf)) != DEMANGLE_ESPACE) { - res = env->NewStringUTF(buf); - } else { - res = name; - } - env->ReleaseStringUTFChars(name, ptr); - return res; -} - -/* - * Class: sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal - * Method: initIDs - * Signature: ()V - * Description: get JNI ids for fields and methods of ProcDebuggerLocal class - */ -JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_initIDs - (JNIEnv *env, jclass clazz) { - _libsaproc_debug = getenv("LIBSAPROC_DEBUG") != NULL; - if (_libsaproc_debug) { - // propagate debug mode to libproc.so - static const char* var = "LIBPROC_DEBUG=1"; - putenv((char*)var); - } - - void* libproc_handle = dlopen("libproc.so", RTLD_LAZY | RTLD_GLOBAL); - if (libproc_handle == 0) - THROW_NEW_DEBUGGER_EXCEPTION("can't load libproc.so, if you are using Solaris 5.7 or below, copy libproc.so from 5.8!"); - - p_ps_prochandle_ID = env->GetFieldID(clazz, "p_ps_prochandle", "J"); - CHECK_EXCEPTION; - - libthread_db_handle_ID = env->GetFieldID(clazz, "libthread_db_handle", "J"); - CHECK_EXCEPTION; - - p_td_thragent_t_ID = env->GetFieldID(clazz, "p_td_thragent_t", "J"); - CHECK_EXCEPTION; - - p_td_init_ID = env->GetFieldID(clazz, "p_td_init", "J"); - CHECK_EXCEPTION; - - p_td_ta_new_ID = env->GetFieldID(clazz, "p_td_ta_new", "J"); - CHECK_EXCEPTION; - - p_td_ta_delete_ID = env->GetFieldID(clazz, "p_td_ta_delete", "J"); - CHECK_EXCEPTION; - - p_td_ta_thr_iter_ID = env->GetFieldID(clazz, "p_td_ta_thr_iter", "J"); - CHECK_EXCEPTION; - - p_td_thr_get_info_ID = env->GetFieldID(clazz, "p_td_thr_get_info", "J"); - CHECK_EXCEPTION; - - p_td_ta_map_id2thr_ID = env->GetFieldID(clazz, "p_td_ta_map_id2thr", "J"); - CHECK_EXCEPTION; - - p_td_thr_getgregs_ID = env->GetFieldID(clazz, "p_td_thr_getgregs", "J"); - CHECK_EXCEPTION; - - getThreadForThreadId_ID = env->GetMethodID(clazz, - "getThreadForThreadId", "(J)Lsun/jvm/hotspot/debugger/ThreadProxy;"); - CHECK_EXCEPTION; - - pcRegIndex_ID = env->GetFieldID(clazz, "pcRegIndex", "I"); - CHECK_EXCEPTION; - - fpRegIndex_ID = env->GetFieldID(clazz, "fpRegIndex", "I"); - CHECK_EXCEPTION; - - createSenderFrame_ID = env->GetMethodID(clazz, - "createSenderFrame", "(Lsun/jvm/hotspot/debugger/proc/ProcCFrame;JJ)Lsun/jvm/hotspot/debugger/proc/ProcCFrame;"); - CHECK_EXCEPTION; - - createLoadObject_ID = env->GetMethodID(clazz, - "createLoadObject", "(Ljava/lang/String;JJ)Lsun/jvm/hotspot/debugger/cdbg/LoadObject;"); - CHECK_EXCEPTION; - - createClosestSymbol_ID = env->GetMethodID(clazz, - "createClosestSymbol", "(Ljava/lang/String;J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol;"); - CHECK_EXCEPTION; - - jclass list_clazz = env->FindClass("java/util/List"); - CHECK_EXCEPTION; - listAdd_ID = env->GetMethodID(list_clazz, "add", "(Ljava/lang/Object;)Z"); - CHECK_EXCEPTION; - - // part of the class sharing workaround - classes_jsa_fd_ID = env->GetFieldID(clazz, "classes_jsa_fd", "I"); - CHECK_EXCEPTION; - p_file_map_header_ID = env->GetFieldID(clazz, "p_file_map_header", "J"); - CHECK_EXCEPTION; -} diff --git a/src/jdk.hotspot.agent/test/libproc/libproctest.sh b/src/jdk.hotspot.agent/test/libproc/libproctest.sh index 9eed0a2db5e..0ed1d1a4cf4 100644 --- a/src/jdk.hotspot.agent/test/libproc/libproctest.sh +++ b/src/jdk.hotspot.agent/test/libproc/libproctest.sh @@ -1,7 +1,7 @@ #!/bin/ksh # -# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -59,10 +59,8 @@ gcore $pid kill -9 $pid -OPTIONS="-Djava.library.path=$STARTDIR/../src/os/solaris/proc/`uname -p`:$STARTDIR/../solaris/`uname -p`" - # run libproc client -$SA_JAVA -showversion ${OPTIONS} -cp $STARTDIR/../../build/classes::$STARTDIR/../sa.jar:$STARTDIR LibprocClient x core.$pid +$SA_JAVA -showversion -cp $STARTDIR/../../build/classes::$STARTDIR/../sa.jar:$STARTDIR LibprocClient x core.$pid # delete core rm -f core.$pid diff --git a/src/jdk.hotspot.agent/test/libproc/libproctest64.sh b/src/jdk.hotspot.agent/test/libproc/libproctest64.sh index 05706d90791..7791190743b 100644 --- a/src/jdk.hotspot.agent/test/libproc/libproctest64.sh +++ b/src/jdk.hotspot.agent/test/libproc/libproctest64.sh @@ -1,7 +1,7 @@ #!/bin/ksh # -# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -58,10 +58,8 @@ done gcore $pid kill -9 $pid -OPTIONS="-Djava.library.path=$STARTDIR/../src/os/solaris/proc/sparcv9:$STARTDIR/../solaris/sparcv9" - # run libproc client -$SA_JAVA -d64 -showversion ${OPTIONS} -cp $STARTDIR/../../build/classes::$STARTDIR/../sa.jar:$STARTDIR LibprocClient x core.$pid +$SA_JAVA -d64 -showversion -cp $STARTDIR/../../build/classes::$STARTDIR/../sa.jar:$STARTDIR LibprocClient x core.$pid # delete core rm -f core.$pid diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/Architecture.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/Architecture.java index 81baaa57c45..ee95e1683d4 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/Architecture.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/Architecture.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ public abstract class Architecture { private final PlatformKind wordKind; /** - * The name of this architecture (e.g. "AMD64", "SPARCv9"). + * The name of this architecture (e.g. "AMD64"). */ private final String name; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java deleted file mode 100644 index 37f8f4b5f8a..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.sparc; - -import static jdk.vm.ci.common.InitTimer.timer; - -import java.util.EnumSet; - -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.stack.StackIntrospection; -import jdk.vm.ci.common.InitTimer; -import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; -import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; -import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; -import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; -import jdk.vm.ci.hotspot.HotSpotStackIntrospection; -import jdk.vm.ci.runtime.JVMCIBackend; -import jdk.vm.ci.sparc.SPARC; -import jdk.vm.ci.sparc.SPARC.CPUFeature; - -public class SPARCHotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { - - private static TargetDescription createTarget(SPARCHotSpotVMConfig config) { - final int stackFrameAlignment = 16; - final int implicitNullCheckLimit = 4096; - final boolean inlineObjects = false; - Architecture arch = new SPARC(computeFeatures(config)); - return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); - } - - protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntime runtime, TargetDescription target, RegisterConfig regConfig) { - return new HotSpotCodeCacheProvider(runtime, target, regConfig); - } - - private static EnumSet computeFeatures(SPARCHotSpotVMConfig config) { - EnumSet features = EnumSet.noneOf(CPUFeature.class); - - if ((config.vmVersionFeatures & 1L << config.sparc_ADI) != 0) { - features.add(CPUFeature.ADI); - } - if ((config.vmVersionFeatures & 1L << config.sparc_AES) != 0) { - features.add(CPUFeature.AES); - } - if ((config.vmVersionFeatures & 1L << config.sparc_BLK_INIT) != 0) { - features.add(CPUFeature.BLK_INIT); - } - if ((config.vmVersionFeatures & 1L << config.sparc_CAMELLIA) != 0) { - features.add(CPUFeature.CAMELLIA); - } - if ((config.vmVersionFeatures & 1L << config.sparc_CBCOND) != 0) { - features.add(CPUFeature.CBCOND); - } - if ((config.vmVersionFeatures & 1L << config.sparc_CRC32C) != 0) { - features.add(CPUFeature.CRC32C); - } - if ((config.vmVersionFeatures & 1L << config.sparc_DES) != 0) { - features.add(CPUFeature.DES); - } - if ((config.vmVersionFeatures & 1L << config.sparc_DICTUNP) != 0) { - features.add(CPUFeature.DICTUNP); - } - if ((config.vmVersionFeatures & 1L << config.sparc_FMAF) != 0) { - features.add(CPUFeature.FMAF); - } - if ((config.vmVersionFeatures & 1L << config.sparc_FPCMPSHL) != 0) { - features.add(CPUFeature.FPCMPSHL); - } - if ((config.vmVersionFeatures & 1L << config.sparc_HPC) != 0) { - features.add(CPUFeature.HPC); - } - if ((config.vmVersionFeatures & 1L << config.sparc_IMA) != 0) { - features.add(CPUFeature.IMA); - } - if ((config.vmVersionFeatures & 1L << config.sparc_KASUMI) != 0) { - features.add(CPUFeature.KASUMI); - } - if ((config.vmVersionFeatures & 1L << config.sparc_MD5) != 0) { - features.add(CPUFeature.MD5); - } - if ((config.vmVersionFeatures & 1L << config.sparc_MME) != 0) { - features.add(CPUFeature.MME); - } - if ((config.vmVersionFeatures & 1L << config.sparc_MONT) != 0) { - features.add(CPUFeature.MONT); - } - if ((config.vmVersionFeatures & 1L << config.sparc_MPMUL) != 0) { - features.add(CPUFeature.MPMUL); - } - if ((config.vmVersionFeatures & 1L << config.sparc_MWAIT) != 0) { - features.add(CPUFeature.MWAIT); - } - if ((config.vmVersionFeatures & 1L << config.sparc_PAUSE) != 0) { - features.add(CPUFeature.PAUSE); - } - if ((config.vmVersionFeatures & 1L << config.sparc_PAUSE_NSEC) != 0) { - features.add(CPUFeature.PAUSE_NSEC); - } - if ((config.vmVersionFeatures & 1L << config.sparc_POPC) != 0) { - features.add(CPUFeature.POPC); - } - if ((config.vmVersionFeatures & 1L << config.sparc_RLE) != 0) { - features.add(CPUFeature.RLE); - } - if ((config.vmVersionFeatures & 1L << config.sparc_SHA1) != 0) { - features.add(CPUFeature.SHA1); - } - if ((config.vmVersionFeatures & 1L << config.sparc_SHA256) != 0) { - features.add(CPUFeature.SHA256); - } - if ((config.vmVersionFeatures & 1L << config.sparc_SHA3) != 0) { - features.add(CPUFeature.SHA3); - } - if ((config.vmVersionFeatures & 1L << config.sparc_SHA512) != 0) { - features.add(CPUFeature.SHA512); - } - if ((config.vmVersionFeatures & 1L << config.sparc_SPARC5) != 0) { - features.add(CPUFeature.SPARC5); - } - if ((config.vmVersionFeatures & 1L << config.sparc_SPARC5B) != 0) { - features.add(CPUFeature.SPARC5B); - } - if ((config.vmVersionFeatures & 1L << config.sparc_SPARC6) != 0) { - features.add(CPUFeature.SPARC6); - } - if ((config.vmVersionFeatures & 1L << config.sparc_V9) != 0) { - features.add(CPUFeature.V9); - } - if ((config.vmVersionFeatures & 1L << config.sparc_VAMASK) != 0) { - features.add(CPUFeature.VAMASK); - } - if ((config.vmVersionFeatures & 1L << config.sparc_VIS1) != 0) { - features.add(CPUFeature.VIS1); - } - if ((config.vmVersionFeatures & 1L << config.sparc_VIS2) != 0) { - features.add(CPUFeature.VIS2); - } - if ((config.vmVersionFeatures & 1L << config.sparc_VIS3) != 0) { - features.add(CPUFeature.VIS3); - } - if ((config.vmVersionFeatures & 1L << config.sparc_VIS3B) != 0) { - features.add(CPUFeature.VIS3B); - } - if ((config.vmVersionFeatures & 1L << config.sparc_VIS3C) != 0) { - features.add(CPUFeature.VIS3C); - } - if ((config.vmVersionFeatures & 1L << config.sparc_XMONT) != 0) { - features.add(CPUFeature.XMONT); - } - if ((config.vmVersionFeatures & 1L << config.sparc_XMPMUL) != 0) { - features.add(CPUFeature.XMPMUL); - } - - if ((config.vmVersionFeatures & 1L << config.sparc_BLK_ZEROING) != 0) { - features.add(CPUFeature.BLK_ZEROING); - } - if ((config.vmVersionFeatures & 1L << config.sparc_FAST_BIS) != 0) { - features.add(CPUFeature.FAST_BIS); - } - if ((config.vmVersionFeatures & 1L << config.sparc_FAST_CMOVE) != 0) { - features.add(CPUFeature.FAST_CMOVE); - } - if ((config.vmVersionFeatures & 1L << config.sparc_FAST_IDIV) != 0) { - features.add(CPUFeature.FAST_IDIV); - } - if ((config.vmVersionFeatures & 1L << config.sparc_FAST_IND_BR) != 0) { - features.add(CPUFeature.FAST_IND_BR); - } - if ((config.vmVersionFeatures & 1L << config.sparc_FAST_LD) != 0) { - features.add(CPUFeature.FAST_LD); - } - if ((config.vmVersionFeatures & 1L << config.sparc_FAST_RDPC) != 0) { - features.add(CPUFeature.FAST_RDPC); - } - - return features; - } - - @Override - public String getArchitecture() { - return "SPARC"; - } - - @Override - public String toString() { - return "JVMCIBackend:" + getArchitecture(); - } - - @Override - @SuppressWarnings("try") - public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntime runtime, JVMCIBackend host) { - assert host == null; - SPARCHotSpotVMConfig config = new SPARCHotSpotVMConfig(runtime.getConfigStore()); - TargetDescription target = createTarget(config); - - HotSpotMetaAccessProvider metaAccess = new HotSpotMetaAccessProvider(runtime); - RegisterConfig regConfig = new SPARCHotSpotRegisterConfig(target, config.useCompressedOops); - HotSpotCodeCacheProvider codeCache = createCodeCache(runtime, target, regConfig); - HotSpotConstantReflectionProvider constantReflection = new HotSpotConstantReflectionProvider(runtime); - StackIntrospection stackIntrospection = new HotSpotStackIntrospection(runtime); - try (InitTimer rt = timer("instantiate backend")) { - return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); - } - } - - protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, HotSpotConstantReflectionProvider constantReflection, - StackIntrospection stackIntrospection) { - return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java deleted file mode 100644 index 3b07a90d352..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotRegisterConfig.java +++ /dev/null @@ -1,385 +0,0 @@ -/* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.sparc; - -import static jdk.vm.ci.meta.JavaKind.Void; -import static jdk.vm.ci.meta.Value.ILLEGAL; -import static jdk.vm.ci.sparc.SPARC.REGISTER_SAFE_AREA_SIZE; -import static jdk.vm.ci.sparc.SPARC.d0; -import static jdk.vm.ci.sparc.SPARC.d10; -import static jdk.vm.ci.sparc.SPARC.d12; -import static jdk.vm.ci.sparc.SPARC.d14; -import static jdk.vm.ci.sparc.SPARC.d16; -import static jdk.vm.ci.sparc.SPARC.d18; -import static jdk.vm.ci.sparc.SPARC.d2; -import static jdk.vm.ci.sparc.SPARC.d20; -import static jdk.vm.ci.sparc.SPARC.d22; -import static jdk.vm.ci.sparc.SPARC.d24; -import static jdk.vm.ci.sparc.SPARC.d26; -import static jdk.vm.ci.sparc.SPARC.d28; -import static jdk.vm.ci.sparc.SPARC.d30; -import static jdk.vm.ci.sparc.SPARC.d4; -import static jdk.vm.ci.sparc.SPARC.d6; -import static jdk.vm.ci.sparc.SPARC.d8; -import static jdk.vm.ci.sparc.SPARC.f0; -import static jdk.vm.ci.sparc.SPARC.f1; -import static jdk.vm.ci.sparc.SPARC.f11; -import static jdk.vm.ci.sparc.SPARC.f13; -import static jdk.vm.ci.sparc.SPARC.f15; -import static jdk.vm.ci.sparc.SPARC.f17; -import static jdk.vm.ci.sparc.SPARC.f19; -import static jdk.vm.ci.sparc.SPARC.f2; -import static jdk.vm.ci.sparc.SPARC.f21; -import static jdk.vm.ci.sparc.SPARC.f23; -import static jdk.vm.ci.sparc.SPARC.f25; -import static jdk.vm.ci.sparc.SPARC.f27; -import static jdk.vm.ci.sparc.SPARC.f29; -import static jdk.vm.ci.sparc.SPARC.f3; -import static jdk.vm.ci.sparc.SPARC.f31; -import static jdk.vm.ci.sparc.SPARC.f4; -import static jdk.vm.ci.sparc.SPARC.f5; -import static jdk.vm.ci.sparc.SPARC.f6; -import static jdk.vm.ci.sparc.SPARC.f7; -import static jdk.vm.ci.sparc.SPARC.f9; -import static jdk.vm.ci.sparc.SPARC.g0; -import static jdk.vm.ci.sparc.SPARC.g2; -import static jdk.vm.ci.sparc.SPARC.g6; -import static jdk.vm.ci.sparc.SPARC.i0; -import static jdk.vm.ci.sparc.SPARC.i1; -import static jdk.vm.ci.sparc.SPARC.i2; -import static jdk.vm.ci.sparc.SPARC.i3; -import static jdk.vm.ci.sparc.SPARC.i4; -import static jdk.vm.ci.sparc.SPARC.i5; -import static jdk.vm.ci.sparc.SPARC.i6; -import static jdk.vm.ci.sparc.SPARC.i7; -import static jdk.vm.ci.sparc.SPARC.l0; -import static jdk.vm.ci.sparc.SPARC.l1; -import static jdk.vm.ci.sparc.SPARC.l2; -import static jdk.vm.ci.sparc.SPARC.l3; -import static jdk.vm.ci.sparc.SPARC.l4; -import static jdk.vm.ci.sparc.SPARC.l5; -import static jdk.vm.ci.sparc.SPARC.l6; -import static jdk.vm.ci.sparc.SPARC.l7; -import static jdk.vm.ci.sparc.SPARC.o0; -import static jdk.vm.ci.sparc.SPARC.o1; -import static jdk.vm.ci.sparc.SPARC.o2; -import static jdk.vm.ci.sparc.SPARC.o3; -import static jdk.vm.ci.sparc.SPARC.o4; -import static jdk.vm.ci.sparc.SPARC.o5; -import static jdk.vm.ci.sparc.SPARC.sp; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CallingConvention; -import jdk.vm.ci.code.CallingConvention.Type; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; -import jdk.vm.ci.code.RegisterAttributes; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.ValueKindFactory; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotCallingConventionType; -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.PlatformKind; -import jdk.vm.ci.meta.ValueKind; -import jdk.vm.ci.sparc.SPARC; - -public class SPARCHotSpotRegisterConfig implements RegisterConfig { - - private final TargetDescription target; - - private final RegisterArray allocatable; - - private final RegisterAttributes[] attributesMap; - - @Override - public RegisterArray getAllocatableRegisters() { - return allocatable; - } - - @Override - public RegisterArray filterAllocatableRegisters(PlatformKind kind, RegisterArray registers) { - ArrayList list = new ArrayList<>(); - for (Register reg : registers) { - if (target.arch.canStoreValue(reg.getRegisterCategory(), kind)) { - list.add(reg); - } - } - return new RegisterArray(list); - } - - @Override - public RegisterAttributes[] getAttributesMap() { - return attributesMap.clone(); - } - - private final RegisterArray cpuCallerParameterRegisters = new RegisterArray(o0, o1, o2, o3, o4, o5); - private final RegisterArray cpuCalleeParameterRegisters = new RegisterArray(i0, i1, i2, i3, i4, i5); - - private final RegisterArray fpuFloatJavaParameterRegisters = new RegisterArray(f0, f1, f2, f3, f4, f5, f6, f7); - private final RegisterArray fpuDoubleJavaParameterRegisters = new RegisterArray(d0, null, d2, null, d4, null, d6, null); - - // @formatter:off - private final RegisterArray fpuFloatNativeParameterRegisters = new RegisterArray( - f1, f3, f5, f7, f9, f11, f13, f15, - f17, f19, f21, f23, f25, f27, f29, f31); - - private final RegisterArray fpuDoubleNativeParameterRegisters = new RegisterArray( - d0, d2, d4, d6, d8, d10, d12, d14, - d16, d18, d20, d22, d24, d26, d28, d30); - - private final RegisterArray callerSaveRegisters; - - /** - * This lists all L and I registers which are saved in the register window. - */ - private final RegisterArray windowSaveRegisters = new RegisterArray( - l0, l1, l2, l3, l4, l5, l6, l7, - i0, i1, i2, i3, i4, i5, i6, i7); - // @formatter:on - - private static final RegisterArray reservedRegisters = new RegisterArray(sp, g0, g2); - - private static RegisterArray initAllocatable(Architecture arch, boolean reserveForHeapBase) { - RegisterArray allRegisters = arch.getAvailableValueRegisters(); - Register[] registers = new Register[allRegisters.size() - reservedRegisters.size() - (reserveForHeapBase ? 1 : 0)]; - List reservedRegistersList = reservedRegisters.asList(); - - int idx = 0; - for (Register reg : allRegisters) { - if (reservedRegistersList.contains(reg)) { - // skip reserved registers - continue; - } - if (reserveForHeapBase && reg.equals(g6)) { - // skip heap base register - continue; - } - - registers[idx++] = reg; - } - - assert idx == registers.length; - return new RegisterArray(registers); - } - - public SPARCHotSpotRegisterConfig(TargetDescription target, boolean useCompressedOops) { - this(target, initAllocatable(target.arch, useCompressedOops)); - } - - public SPARCHotSpotRegisterConfig(TargetDescription target, RegisterArray allocatable) { - this.target = target; - this.allocatable = allocatable; - HashSet callerSaveSet = new HashSet<>(target.arch.getAvailableValueRegisters().asList()); - for (Register cs : windowSaveRegisters) { - callerSaveSet.remove(cs); - } - this.callerSaveRegisters = new RegisterArray(callerSaveSet); - attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters); - } - - @Override - public RegisterArray getCallerSaveRegisters() { - return callerSaveRegisters; - } - - @Override - public RegisterArray getCalleeSaveRegisters() { - return null; - } - - @Override - public boolean areAllAllocatableRegistersCallerSaved() { - return false; - } - - @Override - public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, ValueKindFactory valueKindFactory) { - HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; - if (type == HotSpotCallingConventionType.JavaCall || type == HotSpotCallingConventionType.NativeCall) { - return callingConvention(cpuCallerParameterRegisters, returnType, parameterTypes, hotspotType, valueKindFactory); - } - if (type == HotSpotCallingConventionType.JavaCallee) { - return callingConvention(cpuCalleeParameterRegisters, returnType, parameterTypes, hotspotType, valueKindFactory); - } - throw JVMCIError.shouldNotReachHere(); - } - - @Override - public RegisterArray getCallingConventionRegisters(Type type, JavaKind kind) { - HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; - switch (kind) { - case Boolean: - case Byte: - case Short: - case Char: - case Int: - case Long: - case Object: - return hotspotType == HotSpotCallingConventionType.JavaCallee ? cpuCalleeParameterRegisters : cpuCallerParameterRegisters; - case Double: - case Float: - return fpuFloatJavaParameterRegisters; - default: - throw JVMCIError.shouldNotReachHere("Unknown JavaKind " + kind); - } - } - - private CallingConvention callingConvention(RegisterArray generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, - ValueKindFactory valueKindFactory) { - AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; - - int currentGeneral = 0; - int currentFloating = 0; - int currentStackOffset = 0; - boolean isNative = type == HotSpotCallingConventionType.NativeCall; - - for (int i = 0; i < parameterTypes.length; i++) { - final JavaKind kind = parameterTypes[i].getJavaKind().getStackKind(); - if (isNative) { - RegisterArray registerSet; - switch (kind) { - case Byte: - case Boolean: - case Short: - case Char: - case Int: - case Long: - case Object: - registerSet = generalParameterRegisters; - break; - case Double: - registerSet = fpuDoubleNativeParameterRegisters; - break; - case Float: - registerSet = fpuFloatNativeParameterRegisters; - break; - default: - throw JVMCIError.shouldNotReachHere(); - } - if (i < registerSet.size()) { - locations[i] = registerSet.get(i).asValue(valueKindFactory.getValueKind(kind)); - currentStackOffset += target.arch.getWordSize(); - } - } else { - switch (kind) { - case Byte: - case Boolean: - case Short: - case Char: - case Int: - case Long: - case Object: - if (currentGeneral < generalParameterRegisters.size()) { - Register register = generalParameterRegisters.get(currentGeneral++); - locations[i] = register.asValue(valueKindFactory.getValueKind(kind)); - } - break; - case Double: - if (currentFloating < fpuFloatJavaParameterRegisters.size()) { - if (currentFloating % 2 != 0) { - // Make register number even to be a double reg - currentFloating++; - } - Register register = fpuDoubleJavaParameterRegisters.get(currentFloating); - currentFloating += 2; // Only every second is a double register - locations[i] = register.asValue(valueKindFactory.getValueKind(kind)); - } - break; - case Float: - if (currentFloating < fpuFloatJavaParameterRegisters.size()) { - Register register = fpuFloatJavaParameterRegisters.get(currentFloating++); - locations[i] = register.asValue(valueKindFactory.getValueKind(kind)); - } - break; - default: - throw JVMCIError.shouldNotReachHere(); - } - } - - if (locations[i] == null) { - ValueKind valueKind = valueKindFactory.getValueKind(kind); - int typeSize = valueKind.getPlatformKind().getSizeInBytes(); - if (isNative) { - currentStackOffset += target.arch.getWordSize() - typeSize; - } - currentStackOffset = roundUp(currentStackOffset, typeSize); - int slotOffset = currentStackOffset + REGISTER_SAFE_AREA_SIZE; - locations[i] = StackSlot.get(valueKind, slotOffset, !type.out); - currentStackOffset += typeSize; - } - } - - JavaKind returnKind = returnType == null ? Void : returnType.getJavaKind(); - AllocatableValue returnLocation = returnKind == Void ? ILLEGAL : getReturnRegister(returnKind, type).asValue(valueKindFactory.getValueKind(returnKind.getStackKind())); - return new CallingConvention(currentStackOffset, returnLocation, locations); - } - - private static int roundUp(int number, int mod) { - return ((number + mod - 1) / mod) * mod; - } - - @Override - public Register getReturnRegister(JavaKind kind) { - return getReturnRegister(kind, HotSpotCallingConventionType.JavaCallee); - } - - private static Register getReturnRegister(JavaKind kind, HotSpotCallingConventionType type) { - switch (kind) { - case Boolean: - case Byte: - case Char: - case Short: - case Int: - case Long: - case Object: - return type == HotSpotCallingConventionType.JavaCallee ? i0 : o0; - case Float: - return f0; - case Double: - return d0; - case Void: - case Illegal: - return null; - default: - throw new UnsupportedOperationException("no return register for type " + kind); - } - } - - @Override - public Register getFrameRegister() { - return sp; - } - - @Override - public String toString() { - return String.format("Allocatable: " + getAllocatableRegisters() + "%n" + "CallerSave: " + getCallerSaveRegisters() + "%n"); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotVMConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotVMConfig.java deleted file mode 100644 index b7c5b937d55..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotVMConfig.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.sparc; - -import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; -import jdk.vm.ci.hotspot.HotSpotVMConfigStore; - -/** - * Used to access native configuration details. - * - * All non-static, public fields in this class are so that they can be compiled as constants. - */ -class SPARCHotSpotVMConfig extends HotSpotVMConfigAccess { - - SPARCHotSpotVMConfig(HotSpotVMConfigStore config) { - super(config); - } - - final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); - - // @formatter:off - // CPU capabilities: - // - // FIXME: Using a 64-bit value is insufficient to support future capability - // sets (including co-processor capabilities such as DAX). - final long vmVersionFeatures = getFieldValue("Abstract_VM_Version::_features", Long.class, "uint64_t"); - - // - // SPARC specific values: - // - // NOTE: Values changed into an enumeration (that do indeed fit within a - // 32-bit integer) instead of the exported (64-bit wide) bit-masks. - final int sparc_ADI = getConstant("VM_Version::ISA_ADI", Integer.class); - final int sparc_AES = getConstant("VM_Version::ISA_AES", Integer.class); - final int sparc_BLK_INIT = getConstant("VM_Version::ISA_BLK_INIT", Integer.class); - final int sparc_CAMELLIA = getConstant("VM_Version::ISA_CAMELLIA", Integer.class); - final int sparc_CBCOND = getConstant("VM_Version::ISA_CBCOND", Integer.class); - final int sparc_CRC32C = getConstant("VM_Version::ISA_CRC32C", Integer.class); - final int sparc_DES = getConstant("VM_Version::ISA_DES", Integer.class); - final int sparc_DICTUNP = getConstant("VM_Version::ISA_DICTUNP", Integer.class); - final int sparc_FMAF = getConstant("VM_Version::ISA_FMAF", Integer.class); - final int sparc_FPCMPSHL = getConstant("VM_Version::ISA_FPCMPSHL", Integer.class); - final int sparc_HPC = getConstant("VM_Version::ISA_HPC", Integer.class); - final int sparc_IMA = getConstant("VM_Version::ISA_IMA", Integer.class); - final int sparc_KASUMI = getConstant("VM_Version::ISA_KASUMI", Integer.class); - final int sparc_MD5 = getConstant("VM_Version::ISA_MD5", Integer.class); - final int sparc_MME = getConstant("VM_Version::ISA_MME", Integer.class); - final int sparc_MONT = getConstant("VM_Version::ISA_MONT", Integer.class); - final int sparc_MPMUL = getConstant("VM_Version::ISA_MPMUL", Integer.class); - final int sparc_MWAIT = getConstant("VM_Version::ISA_MWAIT", Integer.class); - final int sparc_PAUSE = getConstant("VM_Version::ISA_PAUSE", Integer.class); - final int sparc_PAUSE_NSEC = getConstant("VM_Version::ISA_PAUSE_NSEC", Integer.class); - final int sparc_POPC = getConstant("VM_Version::ISA_POPC", Integer.class); - final int sparc_RLE = getConstant("VM_Version::ISA_RLE", Integer.class); - final int sparc_SHA1 = getConstant("VM_Version::ISA_SHA1", Integer.class); - final int sparc_SHA256 = getConstant("VM_Version::ISA_SHA256", Integer.class); - final int sparc_SHA3 = getConstant("VM_Version::ISA_SHA3", Integer.class); - final int sparc_SHA512 = getConstant("VM_Version::ISA_SHA512", Integer.class); - final int sparc_SPARC5 = getConstant("VM_Version::ISA_SPARC5", Integer.class); - final int sparc_SPARC5B = getConstant("VM_Version::ISA_SPARC5B", Integer.class); - final int sparc_SPARC6 = getConstant("VM_Version::ISA_SPARC6", Integer.class); - final int sparc_V9 = getConstant("VM_Version::ISA_V9", Integer.class); - final int sparc_VAMASK = getConstant("VM_Version::ISA_VAMASK", Integer.class); - final int sparc_VIS1 = getConstant("VM_Version::ISA_VIS1", Integer.class); - final int sparc_VIS2 = getConstant("VM_Version::ISA_VIS2", Integer.class); - final int sparc_VIS3 = getConstant("VM_Version::ISA_VIS3", Integer.class); - final int sparc_VIS3B = getConstant("VM_Version::ISA_VIS3B", Integer.class); - final int sparc_VIS3C = getConstant("VM_Version::ISA_VIS3C", Integer.class); - final int sparc_XMONT = getConstant("VM_Version::ISA_XMONT", Integer.class); - final int sparc_XMPMUL = getConstant("VM_Version::ISA_XMPMUL", Integer.class); - - final int sparc_BLK_ZEROING = getConstant("VM_Version::CPU_BLK_ZEROING", Integer.class); - final int sparc_FAST_BIS = getConstant("VM_Version::CPU_FAST_BIS", Integer.class); - final int sparc_FAST_CMOVE = getConstant("VM_Version::CPU_FAST_CMOVE", Integer.class); - final int sparc_FAST_IDIV = getConstant("VM_Version::CPU_FAST_IDIV", Integer.class); - final int sparc_FAST_IND_BR = getConstant("VM_Version::CPU_FAST_IND_BR", Integer.class); - final int sparc_FAST_LD = getConstant("VM_Version::CPU_FAST_LD", Integer.class); - final int sparc_FAST_RDPC = getConstant("VM_Version::CPU_FAST_RDPC", Integer.class); - - final boolean useBlockZeroing = getFlag("UseBlockZeroing", Boolean.class); - final int blockZeroingLowLimit = getFlag("BlockZeroingLowLimit", Integer.class); - // @formatter:on -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/package-info.java deleted file mode 100644 index df41bddc164..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * The SPARC HotSpot specific portions of the JVMCI API. - */ -package jdk.vm.ci.hotspot.sparc; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java index 438a20d4e8d..ad45016bafe 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java @@ -58,8 +58,6 @@ class HotSpotVMConfig extends HotSpotVMConfigAccess { case "x86_64": return "amd64"; - case "sparcv9": - return "sparc"; default: return arch; } diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/SPARC.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/SPARC.java deleted file mode 100644 index d68bb956f42..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/SPARC.java +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.sparc; - -import static java.nio.ByteOrder.BIG_ENDIAN; -import static jdk.vm.ci.code.MemoryBarriers.LOAD_LOAD; -import static jdk.vm.ci.code.MemoryBarriers.LOAD_STORE; -import static jdk.vm.ci.code.MemoryBarriers.STORE_STORE; - -import java.util.Set; - -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.Register.RegisterCategory; -import jdk.vm.ci.code.RegisterArray; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.PlatformKind; - -/** - * Represents the SPARC architecture. - */ -public class SPARC extends Architecture { - - public static final RegisterCategory CPU = new RegisterCategory("CPU"); - public static final RegisterCategory FPUs = new RegisterCategory("FPUs"); - public static final RegisterCategory FPUd = new RegisterCategory("FPUd"); - public static final RegisterCategory FPUq = new RegisterCategory("FPUq"); - - // General purpose registers - public static final Register g0 = new Register(0, 0, "g0", CPU); - public static final Register g1 = new Register(1, 1, "g1", CPU); - public static final Register g2 = new Register(2, 2, "g2", CPU); - public static final Register g3 = new Register(3, 3, "g3", CPU); - public static final Register g4 = new Register(4, 4, "g4", CPU); - public static final Register g5 = new Register(5, 5, "g5", CPU); - public static final Register g6 = new Register(6, 6, "g6", CPU); - public static final Register g7 = new Register(7, 7, "g7", CPU); - - public static final Register o0 = new Register(8, 8, "o0", CPU); - public static final Register o1 = new Register(9, 9, "o1", CPU); - public static final Register o2 = new Register(10, 10, "o2", CPU); - public static final Register o3 = new Register(11, 11, "o3", CPU); - public static final Register o4 = new Register(12, 12, "o4", CPU); - public static final Register o5 = new Register(13, 13, "o5", CPU); - public static final Register o6 = new Register(14, 14, "o6", CPU); - public static final Register o7 = new Register(15, 15, "o7", CPU); - - public static final Register l0 = new Register(16, 16, "l0", CPU); - public static final Register l1 = new Register(17, 17, "l1", CPU); - public static final Register l2 = new Register(18, 18, "l2", CPU); - public static final Register l3 = new Register(19, 19, "l3", CPU); - public static final Register l4 = new Register(20, 20, "l4", CPU); - public static final Register l5 = new Register(21, 21, "l5", CPU); - public static final Register l6 = new Register(22, 22, "l6", CPU); - public static final Register l7 = new Register(23, 23, "l7", CPU); - - public static final Register i0 = new Register(24, 24, "i0", CPU); - public static final Register i1 = new Register(25, 25, "i1", CPU); - public static final Register i2 = new Register(26, 26, "i2", CPU); - public static final Register i3 = new Register(27, 27, "i3", CPU); - public static final Register i4 = new Register(28, 28, "i4", CPU); - public static final Register i5 = new Register(29, 29, "i5", CPU); - public static final Register i6 = new Register(30, 30, "i6", CPU); - public static final Register i7 = new Register(31, 31, "i7", CPU); - - public static final Register sp = o6; - public static final Register fp = i6; - - // Floating point registers - public static final Register f0 = new Register(32, 0, "f0", FPUs); - public static final Register f1 = new Register(33, 1, "f1", FPUs); - public static final Register f2 = new Register(34, 2, "f2", FPUs); - public static final Register f3 = new Register(35, 3, "f3", FPUs); - public static final Register f4 = new Register(36, 4, "f4", FPUs); - public static final Register f5 = new Register(37, 5, "f5", FPUs); - public static final Register f6 = new Register(38, 6, "f6", FPUs); - public static final Register f7 = new Register(39, 7, "f7", FPUs); - - public static final Register f8 = new Register(40, 8, "f8", FPUs); - public static final Register f9 = new Register(41, 9, "f9", FPUs); - public static final Register f10 = new Register(42, 10, "f10", FPUs); - public static final Register f11 = new Register(43, 11, "f11", FPUs); - public static final Register f12 = new Register(44, 12, "f12", FPUs); - public static final Register f13 = new Register(45, 13, "f13", FPUs); - public static final Register f14 = new Register(46, 14, "f14", FPUs); - public static final Register f15 = new Register(47, 15, "f15", FPUs); - - public static final Register f16 = new Register(48, 16, "f16", FPUs); - public static final Register f17 = new Register(49, 17, "f17", FPUs); - public static final Register f18 = new Register(50, 18, "f18", FPUs); - public static final Register f19 = new Register(51, 19, "f19", FPUs); - public static final Register f20 = new Register(52, 20, "f20", FPUs); - public static final Register f21 = new Register(53, 21, "f21", FPUs); - public static final Register f22 = new Register(54, 22, "f22", FPUs); - public static final Register f23 = new Register(55, 23, "f23", FPUs); - - public static final Register f24 = new Register(56, 24, "f24", FPUs); - public static final Register f25 = new Register(57, 25, "f25", FPUs); - public static final Register f26 = new Register(58, 26, "f26", FPUs); - public static final Register f27 = new Register(59, 27, "f27", FPUs); - public static final Register f28 = new Register(60, 28, "f28", FPUs); - public static final Register f29 = new Register(61, 29, "f29", FPUs); - public static final Register f30 = new Register(62, 30, "f30", FPUs); - public static final Register f31 = new Register(63, 31, "f31", FPUs); - - // Double precision registers - public static final Register d0 = new Register(64, getDoubleEncoding(0), "d0", FPUd); - public static final Register d2 = new Register(65, getDoubleEncoding(2), "d2", FPUd); - public static final Register d4 = new Register(66, getDoubleEncoding(4), "d4", FPUd); - public static final Register d6 = new Register(67, getDoubleEncoding(6), "d6", FPUd); - public static final Register d8 = new Register(68, getDoubleEncoding(8), "d8", FPUd); - public static final Register d10 = new Register(69, getDoubleEncoding(10), "d10", FPUd); - public static final Register d12 = new Register(70, getDoubleEncoding(12), "d12", FPUd); - public static final Register d14 = new Register(71, getDoubleEncoding(14), "d14", FPUd); - - public static final Register d16 = new Register(72, getDoubleEncoding(16), "d16", FPUd); - public static final Register d18 = new Register(73, getDoubleEncoding(18), "d18", FPUd); - public static final Register d20 = new Register(74, getDoubleEncoding(20), "d20", FPUd); - public static final Register d22 = new Register(75, getDoubleEncoding(22), "d22", FPUd); - public static final Register d24 = new Register(76, getDoubleEncoding(24), "d24", FPUd); - public static final Register d26 = new Register(77, getDoubleEncoding(26), "d26", FPUd); - public static final Register d28 = new Register(78, getDoubleEncoding(28), "d28", FPUd); - public static final Register d30 = new Register(79, getDoubleEncoding(28), "d28", FPUd); - - public static final Register d32 = new Register(80, getDoubleEncoding(32), "d32", FPUd); - public static final Register d34 = new Register(81, getDoubleEncoding(34), "d34", FPUd); - public static final Register d36 = new Register(82, getDoubleEncoding(36), "d36", FPUd); - public static final Register d38 = new Register(83, getDoubleEncoding(38), "d38", FPUd); - public static final Register d40 = new Register(84, getDoubleEncoding(40), "d40", FPUd); - public static final Register d42 = new Register(85, getDoubleEncoding(42), "d42", FPUd); - public static final Register d44 = new Register(86, getDoubleEncoding(44), "d44", FPUd); - public static final Register d46 = new Register(87, getDoubleEncoding(46), "d46", FPUd); - - public static final Register d48 = new Register(88, getDoubleEncoding(48), "d48", FPUd); - public static final Register d50 = new Register(89, getDoubleEncoding(50), "d50", FPUd); - public static final Register d52 = new Register(90, getDoubleEncoding(52), "d52", FPUd); - public static final Register d54 = new Register(91, getDoubleEncoding(54), "d54", FPUd); - public static final Register d56 = new Register(92, getDoubleEncoding(56), "d56", FPUd); - public static final Register d58 = new Register(93, getDoubleEncoding(58), "d58", FPUd); - public static final Register d60 = new Register(94, getDoubleEncoding(60), "d60", FPUd); - public static final Register d62 = new Register(95, getDoubleEncoding(62), "d62", FPUd); - - // Quad precision registers - public static final Register q0 = new Register(96, getQuadncoding(0), "q0", FPUq); - public static final Register q4 = new Register(97, getQuadncoding(4), "q4", FPUq); - public static final Register q8 = new Register(98, getQuadncoding(8), "q8", FPUq); - public static final Register q12 = new Register(99, getQuadncoding(12), "q12", FPUq); - public static final Register q16 = new Register(100, getQuadncoding(16), "q16", FPUq); - public static final Register q20 = new Register(101, getQuadncoding(20), "q20", FPUq); - public static final Register q24 = new Register(102, getQuadncoding(24), "q24", FPUq); - public static final Register q28 = new Register(103, getQuadncoding(28), "q28", FPUq); - - public static final Register q32 = new Register(104, getQuadncoding(32), "q32", FPUq); - public static final Register q36 = new Register(105, getQuadncoding(36), "q36", FPUq); - public static final Register q40 = new Register(106, getQuadncoding(40), "q40", FPUq); - public static final Register q44 = new Register(107, getQuadncoding(44), "q44", FPUq); - public static final Register q48 = new Register(108, getQuadncoding(48), "q48", FPUq); - public static final Register q52 = new Register(109, getQuadncoding(52), "q52", FPUq); - public static final Register q56 = new Register(110, getQuadncoding(56), "q56", FPUq); - public static final Register q60 = new Register(111, getQuadncoding(60), "q60", FPUq); - - // @formatter:off - public static final RegisterArray cpuRegisters = new RegisterArray( - g0, g1, g2, g3, g4, g5, g6, g7, - o0, o1, o2, o3, o4, o5, o6, o7, - l0, l1, l2, l3, l4, l5, l6, l7, - i0, i1, i2, i3, i4, i5, i6, i7 - ); - - public static final RegisterArray fpusRegisters = new RegisterArray( - f0, f1, f2, f3, f4, f5, f6, f7, - f8, f9, f10, f11, f12, f13, f14, f15, - f16, f17, f18, f19, f20, f21, f22, f23, - f24, f25, f26, f27, f28, f29, f30, f31 - ); - - public static final RegisterArray fpudRegisters = new RegisterArray( - d0, d2, d4, d6, d8, d10, d12, d14, - d16, d18, d20, d22, d24, d26, d28, d30, - d32, d34, d36, d38, d40, d42, d44, d46, - d48, d50, d52, d54, d56, d58, d60, d62 - ); - - public static final RegisterArray fpuqRegisters = new RegisterArray( - q0, q4, q8, q12, - q16, q20, q24, q28, - q32, q36, q40, q44, - q48, q52, q56, q60 - ); - - public static final RegisterArray allRegisters = new RegisterArray( - g0, g1, g2, g3, g4, g5, g6, g7, - o0, o1, o2, o3, o4, o5, o6, o7, - l0, l1, l2, l3, l4, l5, l6, l7, - i0, i1, i2, i3, i4, i5, i6, i7, - - f0, f1, f2, f3, f4, f5, f6, f7, - f8, f9, f10, f11, f12, f13, f14, f15, - f16, f17, f18, f19, f20, f21, f22, f23, - f24, f25, f26, f27, f28, f29, f30, f31, - - d0, d2, d4, d6, d8, d10, d12, d14, - d16, d18, d20, d22, d24, d26, d28, d30, - d32, d34, d36, d38, d40, d42, d44, d46, - d48, d50, d52, d54, d56, d58, d60, d62, - - q0, q4, q8, q12, - q16, q20, q24, q28, - q32, q36, q40, q44, - q48, q52, q56, q60 - ); - // @formatter:on - - /** - * Stack bias for stack and frame pointer loads. - */ - public static final int STACK_BIAS = 0x7ff; - - /** - * Size to keep free for flushing the register-window to stack. - */ - public static final int REGISTER_SAFE_AREA_SIZE = 128; - - public final Set features; - - public SPARC(Set features) { - super("SPARC", SPARCKind.XWORD, BIG_ENDIAN, false, allRegisters, LOAD_LOAD | LOAD_STORE | STORE_STORE, 1, 8); - this.features = features; - } - - @Override - public RegisterArray getAvailableValueRegisters() { - return allRegisters; - } - - @Override - public boolean canStoreValue(RegisterCategory category, PlatformKind kind) { - SPARCKind sparcKind = (SPARCKind) kind; - switch (sparcKind) { - case BYTE: - case HWORD: - case WORD: - case XWORD: - return CPU.equals(category); - case SINGLE: - case V32_BYTE: - case V32_HWORD: - return FPUs.equals(category); - case DOUBLE: - case V64_BYTE: - case V64_HWORD: - case V64_WORD: - case V64_SINGLE: - return FPUd.equals(category); - case QUAD: - return FPUq.equals(category); - default: - return false; - } - } - - @Override - public PlatformKind getLargestStorableKind(RegisterCategory category) { - if (category.equals(CPU)) { - return SPARCKind.XWORD; - } else if (category.equals(FPUd)) { - return SPARCKind.DOUBLE; - } else if (category.equals(FPUs)) { - return SPARCKind.SINGLE; - } else if (category.equals(FPUq)) { - return SPARCKind.QUAD; - } else { - throw new IllegalArgumentException("Unknown register category: " + category); - } - } - - @Override - public PlatformKind getPlatformKind(JavaKind javaKind) { - switch (javaKind) { - case Boolean: - case Byte: - return SPARCKind.BYTE; - case Short: - case Char: - return SPARCKind.HWORD; - case Int: - return SPARCKind.WORD; - case Long: - case Object: - return SPARCKind.XWORD; - case Float: - return SPARCKind.SINGLE; - case Double: - return SPARCKind.DOUBLE; - default: - return null; - } - } - - private static int getDoubleEncoding(int reg) { - assert reg < 64 && ((reg & 1) == 0); - return (reg & 0x1e) | ((reg & 0x20) >> 5); - } - - private static int getQuadncoding(int reg) { - assert reg < 64 && ((reg & 1) == 0); - return (reg & 0x1c) | ((reg & 0x20) >> 5); - } - - public Set getFeatures() { - return features; - } - - public boolean hasFeature(CPUFeature feature) { - return features.contains(feature); - } - - public enum CPUFeature { - // ISA determined properties: - ADI, - AES, - BLK_INIT, - CAMELLIA, - CBCOND, - CRC32C, - DES, - DICTUNP, - FMAF, - FPCMPSHL, - HPC, - IMA, - KASUMI, - MD5, - MME, - MONT, - MPMUL, - MWAIT, - PAUSE, - PAUSE_NSEC, - POPC, - RLE, - SHA1, - SHA256, - SHA3, - SHA512, - SPARC5, - SPARC5B, - SPARC6, - V9, - VAMASK, - VIS1, - VIS2, - VIS3, - VIS3B, - VIS3C, - XMONT, - XMPMUL, - // Synthesised CPU properties: - BLK_ZEROING, - FAST_BIS, - FAST_CMOVE, - FAST_IDIV, - FAST_IND_BR, - FAST_LD, - FAST_RDPC - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/SPARCKind.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/SPARCKind.java deleted file mode 100644 index 8e7c6f2c78b..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/SPARCKind.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.sparc; - -import jdk.vm.ci.meta.PlatformKind; - -public enum SPARCKind implements PlatformKind { - BYTE(1), - HWORD(2), - WORD(4), - XWORD(8), - SINGLE(4), - DOUBLE(8), - QUAD(16), - - V32_BYTE(4, BYTE), - V32_HWORD(4, HWORD), - - V64_BYTE(8, BYTE), - V64_HWORD(8, HWORD), - V64_WORD(8, WORD), - V64_SINGLE(8, SINGLE); - - private final int size; - private final int vectorLength; - - private final SPARCKind scalar; - private final EnumKey key = new EnumKey<>(this); - - SPARCKind(int size) { - this.size = size; - this.scalar = this; - this.vectorLength = 1; - } - - SPARCKind(int size, SPARCKind scalar) { - this.size = size; - this.scalar = scalar; - - assert size % scalar.size == 0; - this.vectorLength = size / scalar.size; - } - - public SPARCKind getScalar() { - return scalar; - } - - @Override - public int getSizeInBytes() { - return size; - } - - public int getSizeInBits() { - return getSizeInBytes() * 8; - } - - @Override - public int getVectorLength() { - return vectorLength; - } - - @Override - public Key getKey() { - return key; - } - - public boolean isInteger() { - switch (this) { - case BYTE: - case HWORD: - case WORD: - case XWORD: - return true; - default: - return false; - } - } - - public boolean isFloat() { - return !isInteger(); - } - - @Override - public char getTypeChar() { - switch (this) { - case BYTE: - return 'b'; - case HWORD: - return 'h'; - case WORD: - return 'w'; - case XWORD: - return 'd'; - case SINGLE: - return 'S'; - case DOUBLE: - case V64_BYTE: - case V64_HWORD: - case V64_WORD: - return 'D'; - default: - return '-'; - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/package-info.java deleted file mode 100644 index 76329e52726..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * The SPARC platform independent portions of the JVMCI API. - */ -package jdk.vm.ci.sparc; diff --git a/src/jdk.internal.vm.ci/share/classes/module-info.java b/src/jdk.internal.vm.ci/share/classes/module-info.java index ad3e7288af6..cae83e49a51 100644 --- a/src/jdk.internal.vm.ci/share/classes/module-info.java +++ b/src/jdk.internal.vm.ci/share/classes/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,5 @@ module jdk.internal.vm.ci { provides jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory with jdk.vm.ci.hotspot.aarch64.AArch64HotSpotJVMCIBackendFactory, - jdk.vm.ci.hotspot.amd64.AMD64HotSpotJVMCIBackendFactory, - jdk.vm.ci.hotspot.sparc.SPARCHotSpotJVMCIBackendFactory; + jdk.vm.ci.hotspot.amd64.AMD64HotSpotJVMCIBackendFactory; } diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.asm.sparc.test/src/org/graalvm/compiler/asm/sparc/test/BitSpecTest.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.asm.sparc.test/src/org/graalvm/compiler/asm/sparc/test/BitSpecTest.java deleted file mode 100644 index c53ac325c16..00000000000 --- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.asm.sparc.test/src/org/graalvm/compiler/asm/sparc/test/BitSpecTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -package org.graalvm.compiler.asm.sparc.test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import org.graalvm.compiler.asm.sparc.SPARCAssembler.BitSpec; -import org.graalvm.compiler.asm.sparc.SPARCAssembler.CompositeBitSpec; -import org.graalvm.compiler.asm.sparc.SPARCAssembler.ContinousBitSpec; - -public class BitSpecTest { - - private static final BitSpec d4hi = new ContinousBitSpec(23, 20, true, "d4hi"); - private static final BitSpec d4lo = new ContinousBitSpec(7, 4, false, "d4lo"); - private static final BitSpec d8 = new CompositeBitSpec(d4hi, d4lo); - - @Test - public void testContinousSignExtend() { - testSetGet(d4hi, 0x00700000, 0x00000007); - testSetGet(d4hi, 0x00800000, 0xFFFFFFF8); - } - - @Test - public void testContinousZeroExtend() { - testSetGet(d4lo, 0x000000F0, 0x0000000F); - testSetGet(d4lo, 0x00000070, 0x00000007); - } - - public void testSetGet(BitSpec bs, int encoded, int decoded) { - assertTrue(bs.valueFits(decoded)); - assertEquals(encoded, bs.setBits(0, decoded)); - assertEquals(decoded, bs.getBits(encoded)); - } - - @Test - public void testContinousSignExtendValueFits() { - assertFalse(d4hi.valueFits(0xf)); - assertFalse(d4hi.valueFits(0x10)); - assertFalse(d4hi.valueFits(0x17)); - } - - @Test - public void testContinousZeroExtendValueFits() { - assertFalse(d4lo.valueFits(0x10)); - } - - @Test(expected = AssertionError.class) - public void testContinousSignExtendSetFail1() { - d4hi.setBits(0, 0xf); - } - - @Test(expected = AssertionError.class) - public void testContinousSignExtendSetFail2() { - d4hi.setBits(0, 0xFFFFFFF0); - } - - @Test(expected = AssertionError.class) - public void testContinousZeroExtendSetFail1() { - d4lo.setBits(0, 0x10); - } - - @Test - public void testCompositeSignExtended() { - testSetGet(d8, 0x00f000c0, 0xfffffffc); - testSetGet(d8, 0x008000c0, 0xffffff8c); - testSetGet(d8, 0x007000c0, 0x7c); - } - - @Test(expected = AssertionError.class) - public void testCompositeSignExtendedFail1() { - d8.setBits(0, 0x00000080); - } - - @Test(expected = AssertionError.class) - public void testCompositeSignExtendedFail2() { - d8.setBits(0, 0xEFFFFF80); - } - - @Test - public void testCompositeValueFits() { - assertTrue(d8.valueFits(0xfffffffc)); - assertTrue(d8.valueFits(0xffffff8c)); - assertTrue(d8.valueFits(0x7c)); - assertFalse(d8.valueFits(0x8c)); - assertFalse(d8.valueFits(0xEFFFFF80)); - } -} diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.asm.sparc.test/src/org/graalvm/compiler/asm/sparc/test/SPARCAssemblerTest.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.asm.sparc.test/src/org/graalvm/compiler/asm/sparc/test/SPARCAssemblerTest.java deleted file mode 100644 index 84708b7fa52..00000000000 --- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.asm.sparc.test/src/org/graalvm/compiler/asm/sparc/test/SPARCAssemblerTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -package org.graalvm.compiler.asm.sparc.test; - -import static org.graalvm.compiler.asm.sparc.SPARCAssembler.BPCC; -import static org.graalvm.compiler.asm.sparc.SPARCAssembler.BPR; -import static org.graalvm.compiler.asm.sparc.SPARCAssembler.BR; -import static org.graalvm.compiler.asm.sparc.SPARCAssembler.CBCOND; -import static org.graalvm.compiler.asm.sparc.SPARCAssembler.Annul.ANNUL; -import static org.graalvm.compiler.asm.sparc.SPARCAssembler.BranchPredict.PREDICT_NOT_TAKEN; -import static org.graalvm.compiler.asm.sparc.SPARCAssembler.CC.Xcc; -import static org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag.CarryClear; -import static org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag.Equal; -import static org.graalvm.compiler.asm.sparc.SPARCAssembler.RCondition.Rc_z; -import static jdk.vm.ci.sparc.SPARC.g0; - -import java.util.EnumSet; -import java.util.function.Consumer; - -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.BailoutException; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.sparc.SPARC; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import org.graalvm.compiler.asm.Label; -import org.graalvm.compiler.asm.sparc.SPARCAssembler; -import org.graalvm.compiler.asm.sparc.SPARCAssembler.ControlTransferOp; -import org.graalvm.compiler.asm.sparc.SPARCAssembler.SPARCOp; -import org.graalvm.compiler.asm.sparc.SPARCMacroAssembler; -import org.graalvm.compiler.test.GraalTest; - -public class SPARCAssemblerTest extends GraalTest { - private SPARCMacroAssembler masm; - - private static EnumSet computeFeatures() { - EnumSet features = EnumSet.noneOf(SPARC.CPUFeature.class); - features.add(SPARC.CPUFeature.CBCOND); - return features; - } - - private static TargetDescription createTarget() { - final int stackFrameAlignment = 16; - final int implicitNullCheckLimit = 4096; - final boolean inlineObjects = true; - Architecture arch = new SPARC(computeFeatures()); - return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); - } - - @Before - public void setup() { - TargetDescription target = createTarget(); - masm = new SPARCMacroAssembler(target); - } - - @Test - public void testPatchCbcod() { - testControlTransferOp(l -> CBCOND.emit(masm, CarryClear, false, g0, 3, l), -512, 511); - } - - @Test - public void testPatchBpcc() { - int maxDisp = 1 << 18; - testControlTransferOp(l -> BPCC.emit(masm, Xcc, Equal, ANNUL, PREDICT_NOT_TAKEN, l), -maxDisp, - maxDisp - 1); - } - - @Test - public void testPatchBpr() { - int maxDisp = 1 << 15; - testControlTransferOp(l -> BPR.emit(masm, Rc_z, ANNUL, PREDICT_NOT_TAKEN, g0, l), -maxDisp, - maxDisp - 1); - } - - @Test - public void testPatchBr() { - int maxDisp = 1 << 21; - testControlTransferOp(l -> BR.emit(masm, Equal, ANNUL, l), -maxDisp, - maxDisp - 1); - } - - @Test(expected = BailoutException.class) - public void testControlTransferInvalidDisp() { - int cbcondInstruction = 0x12f83f60; - CBCOND.setDisp(cbcondInstruction, 0x2ff); - } - - public void testControlTransferOp(Consumer