8351194: Clean up Hotspot SA after 32-bit x86 removal

Reviewed-by: cjplummer, shade, ayang, dholmes
This commit is contained in:
Kerem Kat 2025-11-06 15:00:37 +00:00 committed by Aleksey Shipilev
parent df414e0d19
commit 2d924ad358
43 changed files with 84 additions and 1578 deletions

View File

@ -32,7 +32,7 @@ Available commands:
class name <font color="red">find a Java class from debuggee and print oop</font>
classes <font color="red">print all loaded Java classes with Klass*</font>
detach <font color="red">detach SA from current target</font>
dis address [ length ] <font color="red">disassemble (x86) specified number of instructions from given address</font>
dis address [ length ] <font color="red">disassemble (requires hsdis) specified number of instructions from given address</font>
dissemble address <font color="red">disassemble nmethod</font>
dumpcfg -a | id <font color="red">Dump the PhaseCFG for every compiler thread that has one live</font>
dumpclass { address | name } [ directory ] <font color="red">dump .class file for given Klass* or class name</font>

View File

@ -31,7 +31,7 @@ HSDB was launched without debuggee, empty screen is shown.
<li> Object Histogram and inspection of objects and liveness analysis therein.
<li> Class Browser - view Java classes, bytecode disassembly,
or create .class files for selected classes
<li> native disassembly (x86 only) and nmethod disassembly with annotations for safepoint details.
<li> native disassembly (requires hsdis) and nmethod disassembly with annotations for safepoint details.
<li> view -XX flags, System properties, VM version of debuggee
</ul>
<p>Windows sub-menu options include:</p>

View File

@ -40,14 +40,6 @@
#define amd64 1
#endif
#if defined(i386) && !defined(i586)
#define i586 1
#endif
#ifdef i586
#include "sun_jvm_hotspot_debugger_x86_X86ThreadContext.h"
#endif
#ifdef amd64
#include "sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext.h"
#endif
@ -411,7 +403,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLo
return (err == PS_OK)? array : 0;
}
#if defined(i586) || defined(amd64) || defined(ppc64) || defined(ppc64le) || defined(aarch64) || defined(riscv64)
#if defined(amd64) || defined(ppc64) || defined(ppc64le) || defined(aarch64) || defined(riscv64)
extern "C"
JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLocal_getThreadIntegerRegisterSet0
(JNIEnv *env, jobject this_obj, jint lwp_id) {
@ -433,9 +425,6 @@ JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLo
}
#undef NPRGREG
#ifdef i586
#define NPRGREG sun_jvm_hotspot_debugger_x86_X86ThreadContext_NPRGREG
#endif
#ifdef amd64
#define NPRGREG sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_NPRGREG
#endif
@ -456,27 +445,6 @@ JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_linux_LinuxDebuggerLo
#undef REG_INDEX
#ifdef i586
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_x86_X86ThreadContext_##reg
regs[REG_INDEX(GS)] = (uintptr_t) gregs.xgs;
regs[REG_INDEX(FS)] = (uintptr_t) gregs.xfs;
regs[REG_INDEX(ES)] = (uintptr_t) gregs.xes;
regs[REG_INDEX(DS)] = (uintptr_t) gregs.xds;
regs[REG_INDEX(EDI)] = (uintptr_t) gregs.edi;
regs[REG_INDEX(ESI)] = (uintptr_t) gregs.esi;
regs[REG_INDEX(FP)] = (uintptr_t) gregs.ebp;
regs[REG_INDEX(SP)] = (uintptr_t) gregs.esp;
regs[REG_INDEX(EBX)] = (uintptr_t) gregs.ebx;
regs[REG_INDEX(EDX)] = (uintptr_t) gregs.edx;
regs[REG_INDEX(ECX)] = (uintptr_t) gregs.ecx;
regs[REG_INDEX(EAX)] = (uintptr_t) gregs.eax;
regs[REG_INDEX(PC)] = (uintptr_t) gregs.eip;
regs[REG_INDEX(CS)] = (uintptr_t) gregs.xcs;
regs[REG_INDEX(SS)] = (uintptr_t) gregs.xss;
#endif /* i586 */
#ifdef amd64
#define REG_INDEX(reg) sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_##reg

View File

@ -200,18 +200,6 @@ static bool core_handle_prstatus(struct ps_prochandle* ph, const char* buf, size
if (is_debug()) {
print_debug("integer regset\n");
#ifdef i386
// print the regset
print_debug("\teax = 0x%x\n", newthr->regs.eax);
print_debug("\tebx = 0x%x\n", newthr->regs.ebx);
print_debug("\tecx = 0x%x\n", newthr->regs.ecx);
print_debug("\tedx = 0x%x\n", newthr->regs.edx);
print_debug("\tesp = 0x%x\n", newthr->regs.esp);
print_debug("\tebp = 0x%x\n", newthr->regs.ebp);
print_debug("\tesi = 0x%x\n", newthr->regs.esi);
print_debug("\tedi = 0x%x\n", newthr->regs.edi);
print_debug("\teip = 0x%x\n", newthr->regs.eip);
#endif
#if defined(amd64) || defined(x86_64)
// print the regset

View File

@ -814,18 +814,6 @@ static bool core_handle_prstatus(struct ps_prochandle* ph, const char* buf, size
if (is_debug()) {
print_debug("integer regset\n");
#if defined(i586) || defined(i386)
// print the regset
print_debug("\teax = 0x%x\n", newthr->regs.r_eax);
print_debug("\tebx = 0x%x\n", newthr->regs.r_ebx);
print_debug("\tecx = 0x%x\n", newthr->regs.r_ecx);
print_debug("\tedx = 0x%x\n", newthr->regs.r_edx);
print_debug("\tesp = 0x%x\n", newthr->regs.r_esp);
print_debug("\tebp = 0x%x\n", newthr->regs.r_ebp);
print_debug("\tesi = 0x%x\n", newthr->regs.r_esi);
print_debug("\tedi = 0x%x\n", newthr->regs.r_edi);
print_debug("\teip = 0x%x\n", newthr->regs.r_eip);
#endif
#if defined(amd64) || defined(x86_64)
// print the regset

View File

@ -1007,7 +1007,7 @@ public class HSDB implements ObjectHistogramPanel.Listener, SAListener {
curFrame.getFP(),
anno));
} else {
// For C2, which has null frame pointers on x86/amd64/aarch64
// For C2, which has null frame pointers on amd64/aarch64
CodeBlob cb = VM.getVM().getCodeCache().findBlob(curFrame.getPC());
Address sp = curFrame.getSP();
if (Assert.ASSERTS_ENABLED) {

View File

@ -37,7 +37,6 @@ import sun.jvm.hotspot.debugger.MachineDescriptionAMD64;
import sun.jvm.hotspot.debugger.MachineDescriptionPPC64;
import sun.jvm.hotspot.debugger.MachineDescriptionAArch64;
import sun.jvm.hotspot.debugger.MachineDescriptionRISCV64;
import sun.jvm.hotspot.debugger.MachineDescriptionIntelX86;
import sun.jvm.hotspot.debugger.NoSuchSymbolException;
import sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal;
import sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal;
@ -522,14 +521,12 @@ public class HotSpotAgent {
private void setupDebuggerWin32() {
setupJVMLibNamesWin32();
if (cpu.equals("x86")) {
machDesc = new MachineDescriptionIntelX86();
} else if (cpu.equals("amd64")) {
if (cpu.equals("amd64")) {
machDesc = new MachineDescriptionAMD64();
} else if (cpu.equals("aarch64")) {
machDesc = new MachineDescriptionAArch64();
} else {
throw new DebuggerException("Win32 supported under x86, amd64 and aarch64 only");
throw new DebuggerException("Win32 supported under amd64 and aarch64 only");
}
// Note we do not use a cache for the local debugger in server
@ -554,9 +551,7 @@ public class HotSpotAgent {
private void setupDebuggerLinux() {
setupJVMLibNamesLinux();
if (cpu.equals("x86")) {
machDesc = new MachineDescriptionIntelX86();
} else if (cpu.equals("amd64")) {
if (cpu.equals("amd64")) {
machDesc = new MachineDescriptionAMD64();
} else if (cpu.equals("ppc64")) {
machDesc = new MachineDescriptionPPC64();
@ -592,12 +587,10 @@ public class HotSpotAgent {
private void setupDebuggerBsd() {
setupJVMLibNamesBsd();
if (cpu.equals("x86")) {
machDesc = new MachineDescriptionIntelX86();
} else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
if (cpu.equals("amd64") || cpu.equals("x86_64")) {
machDesc = new MachineDescriptionAMD64();
} else {
throw new DebuggerException("BSD only supported on x86/x86_64. Current arch: " + cpu);
throw new DebuggerException("BSD only supported on x86_64. Current arch: " + cpu);
}
BsdDebuggerLocal dbg = new BsdDebuggerLocal(machDesc, !isServer);

View File

@ -78,7 +78,7 @@ public interface Debugger extends SymbolLookup, ThreadAccess {
/** 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 value is "x86"; see
the local system). Typical return value is "amd64"; see
utilities/PlatformInfo.java. */
public String getCPU() throws DebuggerException;

View File

@ -1,39 +0,0 @@
/*
* Copyright (c) 2000, 2022, 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 MachineDescriptionIntelX86 extends MachineDescriptionTwosComplement implements MachineDescription {
public long getAddressSize() {
return 4;
}
public boolean isBigEndian() {
return false;
}
public boolean supports32bitAlignmentOf64bitTypes() {
return true;
}
}

View File

@ -29,10 +29,8 @@ import java.io.*;
import java.util.*;
import sun.jvm.hotspot.debugger.*;
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.bsd.x86.*;
import sun.jvm.hotspot.debugger.bsd.amd64.*;
import sun.jvm.hotspot.debugger.bsd.aarch64.*;
import sun.jvm.hotspot.utilities.*;
@ -86,14 +84,7 @@ class BsdCDebugger implements CDebugger {
public CFrame topFrameForThread(ThreadProxy thread) throws DebuggerException {
String cpu = dbg.getCPU();
if (cpu.equals("x86")) {
X86ThreadContext context = (X86ThreadContext) thread.getContext();
Address ebp = context.getRegisterAsAddress(X86ThreadContext.EBP);
if (ebp == null) return null;
Address pc = context.getRegisterAsAddress(X86ThreadContext.EIP);
if (pc == null) return null;
return new BsdX86CFrame(dbg, ebp, pc);
} else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
if (cpu.equals("amd64") || cpu.equals("x86_64")) {
AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext();
Address rbp = context.getRegisterAsAddress(AMD64ThreadContext.RBP);
if (rbp == null) return null;

View File

@ -27,14 +27,11 @@ package sun.jvm.hotspot.debugger.bsd;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.bsd.aarch64.*;
import sun.jvm.hotspot.debugger.bsd.amd64.*;
import sun.jvm.hotspot.debugger.bsd.x86.*;
class BsdThreadContextFactory {
static ThreadContext createThreadContext(BsdDebugger dbg) {
String cpu = dbg.getCPU();
if (cpu.equals("x86")) {
return new BsdX86ThreadContext(dbg);
} else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
if (cpu.equals("amd64") || cpu.equals("x86_64")) {
return new BsdAMD64ThreadContext(dbg);
} else if (cpu.equals("aarch64")) {
return new BsdAARCH64ThreadContext(dbg);

View File

@ -1,79 +0,0 @@
/*
* Copyright (c) 2003, 2021, 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.bsd.x86;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.bsd.*;
import sun.jvm.hotspot.debugger.cdbg.*;
import sun.jvm.hotspot.debugger.cdbg.basic.*;
import sun.jvm.hotspot.debugger.x86.*;
public final class BsdX86CFrame extends BasicCFrame {
// package/class internals only
public BsdX86CFrame(BsdDebugger dbg, Address ebp, Address pc) {
super(dbg.getCDebugger());
this.ebp = ebp;
this.pc = pc;
this.dbg = dbg;
}
// 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 ebp;
}
public CFrame sender(ThreadProxy thread) {
X86ThreadContext context = (X86ThreadContext) thread.getContext();
Address esp = context.getRegisterAsAddress(X86ThreadContext.ESP);
if ( (ebp == null) || ebp.lessThan(esp) ) {
return null;
}
Address nextEBP = ebp.getAddressAt( 0 * ADDRESS_SIZE);
if (nextEBP == null) {
return null;
}
Address nextPC = ebp.getAddressAt( 1 * ADDRESS_SIZE);
if (nextPC == null) {
return null;
}
return new BsdX86CFrame(dbg, nextEBP, nextPC);
}
private static final int ADDRESS_SIZE = 4;
private Address pc;
private Address ebp;
private BsdDebugger dbg;
}

View File

@ -1,46 +0,0 @@
/*
* Copyright (c) 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.bsd.x86;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.x86.*;
import sun.jvm.hotspot.debugger.bsd.*;
public class BsdX86ThreadContext extends X86ThreadContext {
private BsdDebugger debugger;
public BsdX86ThreadContext(BsdDebugger 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));
}
}

View File

@ -64,7 +64,7 @@ public interface CFrame {
/** Gets the base pointer in this frame from which local variable
offsets in the debug info are based. Typically this is the
base-of-frame pointer (EBP on x86, FP/I6 on SPARC). */
base-of-frame pointer (RBP on amd64, FP/I6 on SPARC). */
public Address localVariableBase();
/** Visit all local variables in this frame if debug information is

View File

@ -30,12 +30,10 @@ import java.util.*;
import sun.jvm.hotspot.debugger.*;
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.riscv64.*;
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.ppc64.*;
import sun.jvm.hotspot.debugger.linux.aarch64.*;
@ -81,14 +79,7 @@ class LinuxCDebugger implements CDebugger {
public CFrame topFrameForThread(ThreadProxy thread) throws DebuggerException {
String cpu = dbg.getCPU();
if (cpu.equals("x86")) {
X86ThreadContext context = (X86ThreadContext) thread.getContext();
Address ebp = context.getRegisterAsAddress(X86ThreadContext.EBP);
if (ebp == null) return null;
Address pc = context.getRegisterAsAddress(X86ThreadContext.EIP);
if (pc == null) return null;
return new LinuxX86CFrame(dbg, ebp, pc);
} else if (cpu.equals("amd64")) {
if (cpu.equals("amd64")) {
AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext();
Address pc = context.getRegisterAsAddress(AMD64ThreadContext.RIP);
if (pc == null) return null;

View File

@ -27,15 +27,12 @@ package sun.jvm.hotspot.debugger.linux;
import java.lang.reflect.*;
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.*;
class LinuxThreadContextFactory {
static ThreadContext createThreadContext(LinuxDebugger dbg) {
String cpu = dbg.getCPU();
if (cpu.equals("x86")) {
return new LinuxX86ThreadContext(dbg);
} else if (cpu.equals("amd64")) {
if (cpu.equals("amd64")) {
return new LinuxAMD64ThreadContext(dbg);
} else if (cpu.equals("ppc64")) {
return new LinuxPPC64ThreadContext(dbg);

View File

@ -1,92 +0,0 @@
/*
* Copyright (c) 2003, 2021, 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.x86;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.linux.*;
import sun.jvm.hotspot.debugger.cdbg.*;
import sun.jvm.hotspot.debugger.cdbg.basic.*;
import sun.jvm.hotspot.debugger.x86.*;
public final class LinuxX86CFrame extends BasicCFrame {
// package/class internals only
public LinuxX86CFrame(LinuxDebugger dbg, Address ebp, Address pc) {
super(dbg.getCDebugger());
this.ebp = ebp;
this.pc = pc;
this.dbg = dbg;
}
// 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 ebp;
}
public CFrame sender(ThreadProxy thread) {
X86ThreadContext context = (X86ThreadContext) thread.getContext();
/*
* Native code fills in the stack pointer register value using index
* X86ThreadContext.SP.
* See file LinuxDebuggerLocal.c macro REG_INDEX(reg).
*
* Be sure to use SP, or UESP which is aliased to SP in Java code,
* for the frame pointer validity check.
*/
Address esp = context.getRegisterAsAddress(X86ThreadContext.SP);
if ( (ebp == null) || ebp.lessThan(esp) ) {
return null;
}
// Check alignment of ebp
if ( dbg.getAddressValue(ebp) % ADDRESS_SIZE != 0) {
return null;
}
Address nextEBP = ebp.getAddressAt( 0 * ADDRESS_SIZE);
if (nextEBP == null || nextEBP.lessThanOrEqual(ebp)) {
return null;
}
Address nextPC = ebp.getAddressAt( 1 * ADDRESS_SIZE);
if (nextPC == null) {
return null;
}
return new LinuxX86CFrame(dbg, nextEBP, nextPC);
}
private static final int ADDRESS_SIZE = 4;
private Address pc;
private Address ebp;
private LinuxDebugger dbg;
}

View File

@ -1,46 +0,0 @@
/*
* Copyright (c) 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.linux.x86;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.x86.*;
import sun.jvm.hotspot.debugger.linux.*;
public class LinuxX86ThreadContext extends X86ThreadContext {
private LinuxDebugger debugger;
public LinuxX86ThreadContext(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));
}
}

View File

@ -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.x86.*;
import sun.jvm.hotspot.debugger.remote.amd64.*;
import sun.jvm.hotspot.debugger.remote.ppc64.*;
@ -55,9 +54,7 @@ public class RemoteDebuggerClient extends DebuggerBase implements JVMDebugger {
int cachePageSize = 4096;
int cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize);
String cpu = remoteDebugger.getCPU();
if (cpu.equals("x86")) {
threadFactory = new RemoteX86ThreadFactory(this);
} else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
if (cpu.equals("amd64") || cpu.equals("x86_64")) {
threadFactory = new RemoteAMD64ThreadFactory(this);
} else if (cpu.equals("ppc64")) {
threadFactory = new RemotePPC64ThreadFactory(this);

View File

@ -1,53 +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.x86;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.x86.*;
import sun.jvm.hotspot.debugger.remote.*;
import sun.jvm.hotspot.utilities.*;
public class RemoteX86Thread extends RemoteThread {
public RemoteX86Thread(RemoteDebuggerClient debugger, Address addr) {
super(debugger, addr);
}
public RemoteX86Thread(RemoteDebuggerClient debugger, long id) {
super(debugger, id);
}
public ThreadContext getContext() throws IllegalThreadStateException {
RemoteX86ThreadContext context = new RemoteX86ThreadContext(debugger);
long[] regs = (addr != null)? debugger.getThreadIntegerRegisterSet(addr) :
debugger.getThreadIntegerRegisterSet(id);
if (Assert.ASSERTS_ENABLED) {
Assert.that(regs.length == X86ThreadContext.NPRGREG, "size of register set must match");
}
for (int i = 0; i < regs.length; i++) {
context.setRegister(i, regs[i]);
}
return context;
}
}

View File

@ -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.x86;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.x86.*;
import sun.jvm.hotspot.debugger.remote.*;
public class RemoteX86ThreadContext extends X86ThreadContext {
private RemoteDebuggerClient debugger;
public RemoteX86ThreadContext(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));
}
}

View File

@ -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.x86;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.remote.*;
public class RemoteX86ThreadFactory implements RemoteThreadFactory {
private RemoteDebuggerClient debugger;
public RemoteX86ThreadFactory(RemoteDebuggerClient debugger) {
this.debugger = debugger;
}
public ThreadProxy createThreadWrapper(Address threadIdentifierAddr) {
return new RemoteX86Thread(debugger, threadIdentifierAddr);
}
public ThreadProxy createThreadWrapper(long id) {
return new RemoteX86Thread(debugger, id);
}
}

View File

@ -1,111 +0,0 @@
/*
* Copyright (c) 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.debugger.win32.coff;
public interface DebugVC50X86RegisterEnums {
/** 8-bit registers */
public static final int NONE = 0;
public static final int AL = 1;
public static final int CL = 2;
public static final int DL = 3;
public static final int BL = 4;
public static final int AH = 5;
public static final int CH = 6;
public static final int DH = 7;
public static final int BH = 8;
/** 16-bit registers */
public static final int AX = 9;
public static final int CX = 10;
public static final int DX = 11;
public static final int BX = 12;
public static final int SP = 13;
public static final int BP = 14;
public static final int SI = 15;
public static final int DI = 16;
/** 32-bit registers */
public static final int EAX = 17;
public static final int ECX = 18;
public static final int EDX = 19;
public static final int EBX = 20;
public static final int ESP = 21;
public static final int EBP = 22;
public static final int ESI = 23;
public static final int EDI = 24;
/** Segment registers */
public static final int ES = 25;
public static final int CS = 26;
public static final int SS = 27;
public static final int DS = 28;
public static final int FS = 29;
public static final int GS = 30;
/** Special cases */
public static final int IP = 31;
public static final int FLAGS = 32;
public static final int EIP = 33;
public static final int EFLAGS = 34;
/** PCODE Registers */
public static final int TEMP = 40;
public static final int TEMPH = 41;
public static final int QUOTE = 42;
/** System Registers */
public static final int CR0 = 80;
public static final int CR1 = 81;
public static final int CR2 = 82;
public static final int CR3 = 83;
public static final int DR0 = 90;
public static final int DR1 = 91;
public static final int DR2 = 92;
public static final int DR3 = 93;
public static final int DR4 = 94;
public static final int DR5 = 95;
public static final int DR6 = 96;
public static final int DR7 = 97;
/** Register extensions for 80x87 */
public static final int ST0 = 128;
public static final int ST1 = 129;
public static final int ST2 = 130;
public static final int ST3 = 131;
public static final int ST4 = 132;
public static final int ST5 = 133;
public static final int ST6 = 134;
public static final int ST7 = 135;
public static final int CONTROL = 136;
public static final int STATUS = 137;
public static final int TAG = 138;
public static final int FPIP = 139;
public static final int FPCS = 140;
public static final int FPDO = 141;
public static final int FPDS = 142;
public static final int ISEM = 143;
public static final int FPEIP = 144;
public static final int FPEDO = 145;
}

View File

@ -49,11 +49,6 @@ public interface WindbgDebugger extends JVMDebugger {
public WindbgAddress readCompKlassAddress(long address) throws DebuggerException;
public WindbgOopHandle readOopHandle(long address) throws DebuggerException;
public WindbgOopHandle readCompOopHandle(long address) throws DebuggerException;
// The returned array of register contents is guaranteed to be in
// the same order as in the DbxDebugger for Solaris/x86 or amd64; that is,
// the indices match those in debugger/x86/X86ThreadContext.java or
// debugger/amd64/AMD64ThreadContext.java.
public long[] getThreadIntegerRegisterSet(long threadId) throws DebuggerException;
public long getThreadIdFromSysId(long sysId) throws DebuggerException;

View File

@ -523,9 +523,7 @@ public class WindbgDebuggerLocal extends DebuggerBase implements WindbgDebugger
// Only add the search path for the current CPU architecture:
String cpu = PlatformInfo.getCPU();
if (cpu.equals("x86")) {
searchList.add(DTFWHome + " (x86)");
} else if (cpu.equals("amd64")) {
if (cpu.equals("amd64")) {
searchList.add(DTFWHome + " (x64)");
}
// The last place to search is the system directory:

View File

@ -1,129 +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.x86;
import java.lang.annotation.Native;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.cdbg.*;
/** Specifies the thread context on x86 platforms; only a sub-portion
of the context is guaranteed to be present on all operating
systems. */
public abstract class X86ThreadContext implements ThreadContext {
// Taken from /usr/include/ia32/sys/reg.h on Solaris/x86
// NOTE: the indices for the various registers must be maintained as
// listed across various operating systems. However, only a small
// subset of the registers' values are guaranteed to be present (and
// must be present for the SA's stack walking to work): EAX, EBX,
// ECX, EDX, ESI, EDI, EBP, ESP, and EIP.
// One instance of the Native annotation is enough to trigger header generation
// for this file.
@Native
public static final int GS = 0;
public static final int FS = 1;
public static final int ES = 2;
public static final int DS = 3;
public static final int EDI = 4;
public static final int ESI = 5;
public static final int EBP = 6;
public static final int ESP = 7;
public static final int EBX = 8;
public static final int EDX = 9;
public static final int ECX = 10;
public static final int EAX = 11;
public static final int TRAPNO = 12;
public static final int ERR = 13;
public static final int EIP = 14;
public static final int CS = 15;
public static final int EFL = 16;
public static final int UESP = 17;
public static final int SS = 18;
// Additional state (not in reg.h) for debug registers
public static final int DR0 = 19;
public static final int DR1 = 20;
public static final int DR2 = 21;
public static final int DR3 = 22;
public static final int DR6 = 23;
public static final int DR7 = 24;
public static final int PC = EIP;
public static final int FP = EBP;
public static final int SP = UESP;
public static final int PS = EFL;
public static final int R0 = EAX;
public static final int R1 = EDX;
public static final int NPRGREG = 25;
private static final String[] regNames = {
"GS", "FS", "ES", "DS",
"EDI", "ESI", "EBP", "ESP",
"EBX", "EDX", "ECX", "EAX",
"TRAPNO", "ERR", "EIP", "CS",
"EFLAGS", "UESP", "SS",
"DR0", "DR1", "DR2", "DR3",
"DR6", "DR7"
};
// Ought to be int on x86 but we're stuck
private long[] data;
public X86ThreadContext() {
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);
}

View File

@ -41,7 +41,7 @@ public class StackValueCollection {
public StackValue get(int i) { return list.get(i); }
// Get typed locals/expressions
// FIXME: must figure out whether word swapping is necessary on x86
// FIXME: must figure out whether word swapping is necessary on amd64
public boolean booleanAt(int slot) { return (int)get(slot).getInteger() != 0; }
public byte byteAt(int slot) { return (byte) get(slot).getInteger(); }
public char charAt(int slot) { return (char) get(slot).getInteger(); }

View File

@ -30,12 +30,10 @@ import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.types.*;
import sun.jvm.hotspot.runtime.win32_amd64.Win32AMD64JavaThreadPDAccess;
import sun.jvm.hotspot.runtime.win32_aarch64.Win32AARCH64JavaThreadPDAccess;
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_riscv64.LinuxRISCV64JavaThreadPDAccess;
import sun.jvm.hotspot.runtime.linux_ppc64.LinuxPPC64JavaThreadPDAccess;
import sun.jvm.hotspot.runtime.bsd_x86.BsdX86JavaThreadPDAccess;
import sun.jvm.hotspot.runtime.bsd_amd64.BsdAMD64JavaThreadPDAccess;
import sun.jvm.hotspot.runtime.bsd_aarch64.BsdAARCH64JavaThreadPDAccess;
import sun.jvm.hotspot.utilities.*;
@ -101,9 +99,7 @@ public class Threads {
access = new Win32AARCH64JavaThreadPDAccess();
}
} else if (os.equals("linux")) {
if (cpu.equals("x86")) {
access = new LinuxX86JavaThreadPDAccess();
} else if (cpu.equals("amd64")) {
if (cpu.equals("amd64")) {
access = new LinuxAMD64JavaThreadPDAccess();
} else if (cpu.equals("ppc64")) {
access = new LinuxPPC64JavaThreadPDAccess();
@ -123,9 +119,7 @@ public class Threads {
}
}
} else if (os.equals("bsd")) {
if (cpu.equals("x86")) {
access = new BsdX86JavaThreadPDAccess();
} else if (cpu.equals("amd64") || cpu.equals("x86_64")) {
if (cpu.equals("amd64") || cpu.equals("x86_64")) {
access = new BsdAMD64JavaThreadPDAccess();
}
} else if (os.equals("darwin")) {

View File

@ -879,9 +879,7 @@ public class VM {
}
/** Indicates whether a given program counter is in Java code. This
includes but is not spanned by the interpreter and code cache.
Only used in the debugging system, for implementing
JavaThread.currentFrameGuess() on x86. */
includes but is not spanned by the interpreter and code cache. */
public boolean isJavaPCDbg(Address addr) {
// FIXME: this is not a complete enough set: must include areas
// like vtable stubs

View File

@ -30,7 +30,7 @@ import sun.jvm.hotspot.code.*;
import sun.jvm.hotspot.interpreter.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.runtime.x86.*;
import sun.jvm.hotspot.runtime.amd64.*;
import sun.jvm.hotspot.types.*;
import sun.jvm.hotspot.utilities.*;
@ -67,7 +67,7 @@ public class AMD64CurrentFrameGuess {
private boolean validateInterpreterFrame(Address sp, Address fp, Address pc) {
VM vm = VM.getVM();
X86Frame f = new X86Frame(sp, fp, pc);
AMD64Frame f = new AMD64Frame(sp, fp, pc);
// First validate that frame->method is really a Method*
Method method = null;
@ -263,7 +263,7 @@ public class AMD64CurrentFrameGuess {
offset += vm.getAddressSize()) {
try {
Address curSP = sp.addOffsetTo(offset);
Frame frame = new X86Frame(curSP, null, pc);
Frame frame = new AMD64Frame(curSP, null, pc);
RegisterMap map = thread.newRegisterMap(false);
while (frame != null) {
if (frame.isEntryFrame() && frame.entryFrameIsFirst()) {

View File

@ -22,7 +22,7 @@
*
*/
package sun.jvm.hotspot.runtime.x86;
package sun.jvm.hotspot.runtime.amd64;
import java.util.*;
import sun.jvm.hotspot.code.*;
@ -36,12 +36,12 @@ import sun.jvm.hotspot.utilities.Observable;
import sun.jvm.hotspot.utilities.Observer;
/** Specialization of and implementation of abstract methods of the
Frame class for the x86 family of CPUs. */
Frame class for the x86_64 family of CPUs. */
public class X86Frame extends Frame {
public class AMD64Frame extends Frame {
private static final boolean DEBUG;
static {
DEBUG = System.getProperty("sun.jvm.hotspot.runtime.x86.X86Frame.DEBUG") != null;
DEBUG = System.getProperty("sun.jvm.hotspot.runtime.amd64.AMD64Frame.DEBUG") != null;
}
// All frames
@ -99,7 +99,7 @@ public class X86Frame extends Frame {
private Address raw_unextendedSP;
private Address live_bcp;
private X86Frame() {
private AMD64Frame() {
}
private void initFrame(Address raw_sp, Address raw_fp, Address pc, Address raw_unextendedSp, Address live_bcp) {
@ -122,44 +122,44 @@ public class X86Frame extends Frame {
}
public X86Frame(Address raw_sp, Address raw_fp, Address pc) {
public AMD64Frame(Address raw_sp, Address raw_fp, Address pc) {
initFrame(raw_sp, raw_fp, pc, null, null);
if (DEBUG) {
System.out.println("X86Frame(sp, fp, pc): " + this);
System.out.println("AMD64Frame(sp, fp, pc): " + this);
dumpStack();
}
}
public X86Frame(Address raw_sp, Address raw_fp) {
public AMD64Frame(Address raw_sp, Address raw_fp) {
initFrame(raw_sp, raw_fp, null, null, null);
if (DEBUG) {
System.out.println("X86Frame(sp, fp): " + this);
System.out.println("AMD64Frame(sp, fp): " + this);
dumpStack();
}
}
public X86Frame(Address raw_sp, Address raw_unextendedSp, Address raw_fp, Address pc) {
public AMD64Frame(Address raw_sp, Address raw_unextendedSp, Address raw_fp, Address pc) {
initFrame(raw_sp, raw_fp, pc, raw_unextendedSp, null);
if (DEBUG) {
System.out.println("X86Frame(sp, unextendedSP, fp, pc): " + this);
System.out.println("AMD64Frame(sp, unextendedSP, fp, pc): " + this);
dumpStack();
}
}
public X86Frame(Address raw_sp, Address raw_fp, Address pc, Address raw_unextendedSp, Address live_bcp) {
public AMD64Frame(Address raw_sp, Address raw_fp, Address pc, Address raw_unextendedSp, Address live_bcp) {
initFrame(raw_sp, raw_fp, pc, raw_unextendedSp, live_bcp);
if (DEBUG) {
System.out.println("X86Frame(sp, fp, pc, unextendedSP, live_bcp): " + this);
System.out.println("AMD64Frame(sp, fp, pc, unextendedSP, live_bcp): " + this);
dumpStack();
}
}
public Object clone() {
X86Frame frame = new X86Frame();
AMD64Frame frame = new AMD64Frame();
frame.raw_sp = raw_sp;
frame.raw_unextendedSP = raw_unextendedSP;
frame.raw_fp = raw_fp;
@ -174,11 +174,11 @@ public class X86Frame extends Frame {
return false;
}
if (!(arg instanceof X86Frame)) {
if (!(arg instanceof AMD64Frame)) {
return false;
}
X86Frame other = (X86Frame) arg;
AMD64Frame other = (AMD64Frame) arg;
return (AddressOps.equal(getSP(), other.getSP()) &&
AddressOps.equal(getUnextendedSP(), other.getUnextendedSP()) &&
@ -206,7 +206,7 @@ public class X86Frame extends Frame {
public Address getSP() { return raw_sp; }
public Address getID() { return raw_sp; }
// FIXME: not implemented yet (should be done for Solaris/X86)
// FIXME: not implemented yet (should be done for Solaris)
public boolean isSignalHandlerFrameDbg() { return false; }
public int getSignalNumberDbg() { return 0; }
public String getSignalNameDbg() { return null; }
@ -248,7 +248,7 @@ public class X86Frame extends Frame {
// void patch_pc(Thread* thread, address pc);
public Frame sender(RegisterMap regMap, CodeBlob cb) {
X86RegisterMap map = (X86RegisterMap) regMap;
AMD64RegisterMap map = (AMD64RegisterMap) regMap;
if (Assert.ASSERTS_ENABLED) {
Assert.that(map != null, "map must be set");
@ -281,10 +281,10 @@ public class X86Frame extends Frame {
// Must be native-compiled frame, i.e. the marshaling code for native
// methods that exists in the core system.
return new X86Frame(getSenderSP(), getLink(), getSenderPC());
return new AMD64Frame(getSenderSP(), getLink(), getSenderPC());
}
private Frame senderForEntryFrame(X86RegisterMap map) {
private Frame senderForEntryFrame(AMD64RegisterMap map) {
if (DEBUG) {
System.out.println("senderForEntryFrame");
}
@ -293,16 +293,16 @@ public class X86Frame extends Frame {
}
// Java frame called from C; skip all C frames and return top C
// frame of that chunk as the sender
X86JavaCallWrapper jcw = (X86JavaCallWrapper) getEntryFrameCallWrapper();
AMD64JavaCallWrapper jcw = (AMD64JavaCallWrapper) 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");
}
X86Frame fr;
AMD64Frame fr;
if (jcw.getLastJavaPC() != null) {
fr = new X86Frame(jcw.getLastJavaSP(), jcw.getLastJavaFP(), jcw.getLastJavaPC());
fr = new AMD64Frame(jcw.getLastJavaSP(), jcw.getLastJavaFP(), jcw.getLastJavaPC());
} else {
fr = new X86Frame(jcw.getLastJavaSP(), jcw.getLastJavaFP());
fr = new AMD64Frame(jcw.getLastJavaSP(), jcw.getLastJavaFP());
}
map.clear();
if (Assert.ASSERTS_ENABLED) {
@ -311,7 +311,7 @@ public class X86Frame extends Frame {
return fr;
}
private Frame senderForUpcallStub(X86RegisterMap map, UpcallStub stub) {
private Frame senderForUpcallStub(AMD64RegisterMap map, UpcallStub stub) {
if (DEBUG) {
System.out.println("senderForUpcallStub");
}
@ -326,11 +326,11 @@ public class X86Frame extends Frame {
if (Assert.ASSERTS_ENABLED) {
Assert.that(lastJavaSP.greaterThan(getSP()), "must be above this frame on stack");
}
X86Frame fr;
AMD64Frame fr;
if (lastJavaPC != null) {
fr = new X86Frame(lastJavaSP, lastJavaFP, lastJavaPC);
fr = new AMD64Frame(lastJavaSP, lastJavaFP, lastJavaPC);
} else {
fr = new X86Frame(lastJavaSP, lastJavaFP);
fr = new AMD64Frame(lastJavaSP, lastJavaFP);
}
map.clear();
if (Assert.ASSERTS_ENABLED) {
@ -339,7 +339,7 @@ public class X86Frame extends Frame {
return fr;
}
private Frame senderForInterpreterFrame(X86RegisterMap map) {
private Frame senderForInterpreterFrame(AMD64RegisterMap map) {
if (DEBUG) {
System.out.println("senderForInterpreterFrame");
}
@ -355,32 +355,28 @@ public class X86Frame extends Frame {
if (map.getUpdateMap())
updateMapWithSavedLink(map, addressOfStackSlot(LINK_OFFSET));
return new X86Frame(sp, unextendedSP, getLink(), getSenderPC());
return new AMD64Frame(sp, unextendedSP, getLink(), getSenderPC());
}
private void updateMapWithSavedLink(RegisterMap map, Address savedFPAddr) {
map.setLocation(rbp, savedFPAddr);
}
private Frame senderForContinuationStub(X86RegisterMap map, CodeBlob cb) {
private Frame senderForContinuationStub(AMD64RegisterMap map, CodeBlob cb) {
var contEntry = map.getThread().getContEntry();
Address senderSP = contEntry.getEntrySP();
Address senderPC = contEntry.getEntryPC();
Address senderFP = contEntry.getEntryFP();
return new X86Frame(senderSP, senderFP, senderPC);
return new AMD64Frame(senderSP, senderFP, senderPC);
}
private Frame senderForCompiledFrame(X86RegisterMap map, CodeBlob cb) {
private Frame senderForCompiledFrame(AMD64RegisterMap map, CodeBlob cb) {
if (DEBUG) {
System.out.println("senderForCompiledFrame");
}
//
// NOTE: some of this code is (unfortunately) duplicated in X86CurrentFrameGuess
//
if (Assert.ASSERTS_ENABLED) {
Assert.that(map != null, "map must be set");
}
@ -414,7 +410,7 @@ public class X86Frame extends Frame {
updateMapWithSavedLink(map, savedFPAddr);
}
return new X86Frame(senderSP, savedFPAddr.getAddressAt(0), senderPC);
return new AMD64Frame(senderSP, savedFPAddr.getAddressAt(0), senderPC);
}
protected boolean hasSenderPD() {
@ -545,7 +541,7 @@ public class X86Frame extends Frame {
// Entry frames
public JavaCallWrapper getEntryFrameCallWrapper() {
return new X86JavaCallWrapper(addressOfStackSlot(ENTRY_FRAME_CALL_WRAPPER_OFFSET).getAddressAt(0));
return new AMD64JavaCallWrapper(addressOfStackSlot(ENTRY_FRAME_CALL_WRAPPER_OFFSET).getAddressAt(0));
}
protected Address addressOfSavedOopResult() {

View File

@ -22,24 +22,24 @@
*
*/
package sun.jvm.hotspot.runtime.x86;
package sun.jvm.hotspot.runtime.amd64;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
public class X86RegisterMap extends RegisterMap {
public class AMD64RegisterMap extends RegisterMap {
/** This is the only public constructor */
public X86RegisterMap(JavaThread thread, boolean updateMap) {
public AMD64RegisterMap(JavaThread thread, boolean updateMap) {
super(thread, updateMap);
}
protected X86RegisterMap(RegisterMap map) {
protected AMD64RegisterMap(RegisterMap map) {
super(map);
}
public Object clone() {
X86RegisterMap retval = new X86RegisterMap(this);
AMD64RegisterMap retval = new AMD64RegisterMap(this);
return retval;
}

View File

@ -32,7 +32,6 @@ import sun.jvm.hotspot.debugger.bsd.BsdDebugger;
import sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal;
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;
@ -87,11 +86,11 @@ public class BsdAMD64JavaThreadPDAccess implements JavaThreadPDAccess {
if (fp == null) {
return null; // no information
}
return new X86Frame(thread.getLastJavaSP(), fp);
return new AMD64Frame(thread.getLastJavaSP(), fp);
}
public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) {
return new X86RegisterMap(thread, updateMap);
return new AMD64RegisterMap(thread, updateMap);
}
public Frame getCurrentFrameGuess(JavaThread thread, Address addr) {
@ -102,13 +101,13 @@ public class BsdAMD64JavaThreadPDAccess implements JavaThreadPDAccess {
return null;
}
if (guesser.getPC() == null) {
return new X86Frame(guesser.getSP(), guesser.getFP());
return new AMD64Frame(guesser.getSP(), guesser.getFP());
} else if (VM.getVM().getInterpreter().contains(guesser.getPC())) {
// pass the value of R13 which contains the bcp for the top level frame
Address bcp = context.getRegisterAsAddress(AMD64ThreadContext.R13);
return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC(), null, bcp);
return new AMD64Frame(guesser.getSP(), guesser.getFP(), guesser.getPC(), null, bcp);
} else {
return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
return new AMD64Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
}
}

View File

@ -1,70 +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.runtime.bsd_x86;
public class BsdSignals {
private static String[] signalNames = {
"", /* No signal 0 */
"SIGHUP", /* hangup */
"SIGINT", /* interrupt */
"SIGQUIT", /* quit */
"SIGILL", /* illegal instr. (not reset when caught) */
"SIGTRAP", /* trace trap (not reset when caught) */
"SIGABRT", /* abort() */
"SIGEMT", /* EMT instruction */
"SIGFPE", /* floating point exception */
"SIGKILL", /* kill (cannot be caught or ignored) */
"SIGBUS", /* bus error */
"SIGSEGV", /* segmentation violation */
"SIGSYS", /* non-existent system call invoked */
"SIGPIPE", /* write on a pipe with no one to read it */
"SIGALRM", /* alarm clock */
"SIGTERM", /* software termination signal from kill */
"SIGURG", /* urgent condition on IO channel */
"SIGSTOP", /* sendable stop signal not from tty */
"SIGTSTP", /* stop signal from tty */
"SIGCONT", /* continue a stopped process */
"SIGCHLD", /* to parent on child stop or exit */
"SIGTTIN", /* to readers pgrp upon background tty read */
"SIGTTOU", /* like TTIN if (tp->t_local&LTOSTOP) */
"SIGIO", /* input/output possible signal */
"SIGXCPU", /* exceeded CPU time limit */
"SIGXFSZ", /* exceeded file size limit */
"SIGVTALRM", /* virtual time alarm */
"SIGPROF", /* profiling time alarm */
"SIGWINCH", /* window size changes */
"SIGINFO", /* information request */
"SIGUSR1", /* user defined signal 1 */
"SIGUSR2" /* user defined signal 2 */
};
public static String getSignalName(int sigNum) {
if ((sigNum <= 0) || (sigNum >= signalNames.length)) {
// Probably best to fail in a non-destructive way
return "<Error: Illegal signal number " + sigNum + ">";
}
return signalNames[sigNum];
}
}

View File

@ -1,133 +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.
*
*/
package sun.jvm.hotspot.runtime.bsd_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;
public class BsdX86JavaThreadPDAccess implements JavaThreadPDAccess {
private static AddressField lastJavaFPField;
private static AddressField osThreadField;
// 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");
osThreadField = type.getAddressField("_osthread");
Type anchorType = db.lookupType("JavaFrameAnchor");
lastJavaFPField = anchorType.getAddressField("_last_Java_fp");
Type osThreadType = db.lookupType("OSThread");
osThreadThreadIDField = osThreadType.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
}
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) {
tty.print("Thread id: ");
printThreadIDOn(threadAddr, tty);
// tty.println("\nPostJavaState: " + getPostJavaState(threadAddr));
}
public Address getLastSP(Address addr) {
ThreadProxy t = getThreadProxy(addr);
X86ThreadContext context = (X86ThreadContext) t.getContext();
return context.getRegisterAsAddress(X86ThreadContext.ESP);
}
public ThreadProxy getThreadProxy(Address addr) {
// Addr is the address of the JavaThread.
// 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 threadIdAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset());
JVMDebugger debugger = VM.getVM().getDebugger();
return debugger.getThreadForIdentifierAddress(threadIdAddr);
}
}

View File

@ -30,7 +30,6 @@ 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;
@ -83,11 +82,11 @@ public class LinuxAMD64JavaThreadPDAccess implements JavaThreadPDAccess {
if (fp == null) {
return null; // no information
}
return new X86Frame(thread.getLastJavaSP(), fp);
return new AMD64Frame(thread.getLastJavaSP(), fp);
}
public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) {
return new X86RegisterMap(thread, updateMap);
return new AMD64RegisterMap(thread, updateMap);
}
public Frame getCurrentFrameGuess(JavaThread thread, Address addr) {
@ -98,13 +97,13 @@ public class LinuxAMD64JavaThreadPDAccess implements JavaThreadPDAccess {
return null;
}
if (guesser.getPC() == null) {
return new X86Frame(guesser.getSP(), guesser.getFP());
return new AMD64Frame(guesser.getSP(), guesser.getFP());
} else if (VM.getVM().getInterpreter().contains(guesser.getPC())) {
// pass the value of R13 which contains the bcp for the top level frame
Address bcp = context.getRegisterAsAddress(AMD64ThreadContext.R13);
return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC(), null, bcp);
return new AMD64Frame(guesser.getSP(), guesser.getFP(), guesser.getPC(), null, bcp);
} else {
return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
return new AMD64Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
}
}

View File

@ -1,71 +0,0 @@
/*
* Copyright (c) 2002, 2022, 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_x86;
public class LinuxSignals {
private static String[] signalNames = {
"", /* No signal 0 */
"SIGHUP", /* hangup */
"SIGINT", /* interrupt (rubout) */
"SIGQUIT", /* quit (ASCII FS) */
"SIGILL", /* illegal instruction (not reset when caught) */
"SIGTRAP", /* trace trap (not reset when caught) */
"SIGABRT", /* used by abort, replace SIGIOT in the future */
"SIGIOT",
"SIGBUS",
"SIGFPE", /* floating point exception */
"SIGKILL", /* kill (cannot be caught or ignored) */
"SIGUSR1", /* user defined signal 1 */
"SIGSEGV", /* segmentation violation */
"SIGUSR2", /* user defined signal 2 */
"SIGPIPE", /* write on a pipe with no one to read it */
"SIGALRM", /* alarm clock */
"SIGTERM", /* software termination signal from kill */
"SIGSTKFLT",
"SIGCHLD", /* child status change alias */
"SIGCONT", /* stopped process has been continued */
"SIGSTOP", /* stop (cannot be caught or ignored) */
"SIGTSTP", /* user stop requested from tty */
"SIGTTIN", /* background tty read attempted */
"SIGTTOU", /* background tty write attempted */
"SIGURG", /* urgent socket condition */
"SIGXCPU", /* exceeded cpu limit */
"SIGXFSZ", /* exceeded file size limit */
"SIGVTALRM", /* virtual timer expired */
"SIGPROF", /* profiling timer expired */
"SIGWINCH", /* window size change */
"SIGPOLL", /* pollable event occurred */
"SIGPWR", /* power-fail restart */
"SIGSYS"
};
public static String getSignalName(int sigNum) {
if ((sigNum <= 0) || (sigNum >= signalNames.length)) {
// Probably best to fail in a non-destructive way
return "<Error: Illegal signal number " + sigNum + ">";
}
return signalNames[sigNum];
}
}

View File

@ -1,133 +0,0 @@
/*
* Copyright (c) 2002, 2022, 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_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;
public class LinuxX86JavaThreadPDAccess implements JavaThreadPDAccess {
private static AddressField lastJavaFPField;
private static AddressField osThreadField;
// 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");
osThreadField = type.getAddressField("_osthread");
Type anchorType = db.lookupType("JavaFrameAnchor");
lastJavaFPField = anchorType.getAddressField("_last_Java_fp");
Type osThreadType = db.lookupType("OSThread");
osThreadThreadIDField = osThreadType.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
}
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) {
tty.print("Thread id: ");
printThreadIDOn(threadAddr, tty);
// tty.println("\nPostJavaState: " + getPostJavaState(threadAddr));
}
public Address getLastSP(Address addr) {
ThreadProxy t = getThreadProxy(addr);
X86ThreadContext context = (X86ThreadContext) t.getContext();
return context.getRegisterAsAddress(X86ThreadContext.SP);
}
public ThreadProxy getThreadProxy(Address addr) {
// Addr is the address of the JavaThread.
// 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 threadIdAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset());
JVMDebugger debugger = VM.getVM().getDebugger();
return debugger.getThreadForIdentifierAddress(threadIdAddr);
}
}

View File

@ -30,7 +30,6 @@ 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;
@ -88,14 +87,14 @@ public class Win32AMD64JavaThreadPDAccess implements JavaThreadPDAccess {
}
Address pc = thread.getLastJavaPC();
if ( pc != null ) {
return new X86Frame(thread.getLastJavaSP(), fp, pc);
return new AMD64Frame(thread.getLastJavaSP(), fp, pc);
} else {
return new X86Frame(thread.getLastJavaSP(), fp);
return new AMD64Frame(thread.getLastJavaSP(), fp);
}
}
public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) {
return new X86RegisterMap(thread, updateMap);
return new AMD64RegisterMap(thread, updateMap);
}
public Frame getCurrentFrameGuess(JavaThread thread, Address addr) {
@ -106,13 +105,13 @@ public class Win32AMD64JavaThreadPDAccess implements JavaThreadPDAccess {
return null;
}
if (guesser.getPC() == null) {
return new X86Frame(guesser.getSP(), guesser.getFP());
return new AMD64Frame(guesser.getSP(), guesser.getFP());
} else if (VM.getVM().getInterpreter().contains(guesser.getPC())) {
// pass the value of R13 which contains the bcp for the top level frame
Address bcp = context.getRegisterAsAddress(AMD64ThreadContext.R13);
return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC(), null, bcp);
return new AMD64Frame(guesser.getSP(), guesser.getFP(), guesser.getPC(), null, bcp);
} else {
return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
return new AMD64Frame(guesser.getSP(), guesser.getFP(), guesser.getPC());
}
}

View File

@ -1,225 +0,0 @@
/*
* Copyright (c) 2001, 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 sun.jvm.hotspot.runtime.x86;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.debugger.x86.*;
import sun.jvm.hotspot.code.*;
import sun.jvm.hotspot.interpreter.*;
import sun.jvm.hotspot.runtime.*;
/** <P> Should be able to be used on all x86 platforms we support
(Win32, Solaris/x86, and soon Linux) to implement JavaThread's
"currentFrameGuess()" functionality. Input is an X86ThreadContext;
output is SP, FP, and PC for an X86Frame. Instantiation of the
X86Frame is left to the caller, since we may need to subclass
X86Frame to support signal handler frames on Unix platforms. </P>
<P> Algorithm is to walk up the stack within a given range (say,
512K at most) looking for a plausible PC and SP for a Java frame,
also considering those coming in from the context. If we find a PC
that belongs to the VM (i.e., in generated code like the
interpreter or CodeCache) then we try to find an associated EBP.
We repeat this until we either find a complete frame or run out of
stack to look at. </P> */
public class X86CurrentFrameGuess {
private X86ThreadContext context;
private JavaThread thread;
private Address spFound;
private Address fpFound;
private Address pcFound;
private static final boolean DEBUG = System.getProperty("sun.jvm.hotspot.runtime.x86.X86Frame.DEBUG")
!= null;
public X86CurrentFrameGuess(X86ThreadContext context,
JavaThread thread) {
this.context = context;
this.thread = thread;
}
/** Returns false if not able to find a frame within a reasonable range. */
public boolean run(long regionInBytesToSearch) {
Address sp = context.getRegisterAsAddress(X86ThreadContext.SP);
Address pc = context.getRegisterAsAddress(X86ThreadContext.PC);
Address fp = context.getRegisterAsAddress(X86ThreadContext.FP);
if (sp == null) {
// Bail out if no last java frame eithe
if (thread.getLastJavaSP() != null) {
setValues(thread.getLastJavaSP(), thread.getLastJavaFP(), null);
return true;
}
// Bail out
return false;
}
Address end = sp.addOffsetTo(regionInBytesToSearch);
VM vm = VM.getVM();
setValues(null, null, null); // Assume we're not going to find anything
if (vm.isJavaPCDbg(pc)) {
if (vm.isClientCompiler()) {
// If the topmost frame is a Java frame, we are (pretty much)
// guaranteed to have a viable EBP. We should be more robust
// than this (we have the potential for losing entire threads'
// stack traces) but need to see how much work we really have
// to do here. Searching the stack for an (SP, FP) pair is
// hard since it's easy to misinterpret inter-frame stack
// pointers as base-of-frame pointers; we also don't know the
// sizes of C1 frames (not registered in the nmethod) so can't
// derive them from ESP.
setValues(sp, fp, pc);
return true;
} else {
if (vm.getInterpreter().contains(pc)) {
if (DEBUG) {
System.out.println("CurrentFrameGuess: choosing interpreter frame: sp = " +
sp + ", fp = " + fp + ", pc = " + pc);
}
setValues(sp, fp, pc);
return true;
}
// For the server compiler, EBP is not guaranteed to be valid
// for compiled code. In addition, an earlier attempt at a
// non-searching algorithm (see below) failed because the
// stack pointer from the thread context was pointing
// (considerably) beyond the ostensible end of the stack, into
// garbage; walking from the topmost frame back caused a crash.
//
// This algorithm takes the current PC as a given and tries to
// find the correct corresponding SP by walking up the stack
// and repeatedly performing stackwalks (very inefficient).
//
// FIXME: there is something wrong with stackwalking across
// adapter frames...this is likely to be the root cause of the
// failure with the simpler algorithm below.
for (long offset = 0;
offset < regionInBytesToSearch;
offset += vm.getAddressSize()) {
try {
Address curSP = sp.addOffsetTo(offset);
Frame frame = new X86Frame(curSP, null, pc);
RegisterMap map = thread.newRegisterMap(false);
while (frame != null) {
if (frame.isEntryFrame() && frame.entryFrameIsFirst()) {
// We were able to traverse all the way to the
// bottommost Java frame.
// This sp looks good. Keep it.
if (DEBUG) {
System.out.println("CurrentFrameGuess: Choosing sp = " + curSP + ", pc = " + pc);
}
setValues(curSP, null, pc);
return true;
}
Frame oldFrame = frame;
frame = frame.sender(map);
if (frame.getSP().lessThanOrEqual(oldFrame.getSP())) {
// Frame points to itself or to a location in the wrong direction.
// Break the loop and move on to next offset.
if (DEBUG) {
System.out.println("X86CurrentFrameGuess.run: frame <= oldFrame: " + frame);
}
break;
}
}
} catch (Exception e) {
if (DEBUG) {
System.out.println("CurrentFrameGuess: Exception " + e + " at offset " + offset);
}
// Bad SP. Try another.
}
}
// Were not able to find a plausible SP to go with this PC.
// Bail out.
return false;
/*
// Original algorithm which does not work because SP was
// pointing beyond where it should have:
// For the server compiler, EBP is not guaranteed to be valid
// for compiled code. We see whether the PC is in the
// interpreter and take care of that, otherwise we run code
// (unfortunately) duplicated from X86Frame.senderForCompiledFrame.
CodeCache cc = vm.getCodeCache();
if (cc.contains(pc)) {
CodeBlob cb = cc.findBlob(pc);
// See if we can derive a frame pointer from SP and PC
// NOTE: This is the code duplicated from X86Frame
Address saved_fp = null;
int llink_offset = cb.getLinkOffset();
if (llink_offset >= 0) {
// Restore base-pointer, since next frame might be an interpreter frame.
Address fp_addr = sp.addOffsetTo(VM.getVM().getAddressSize() * llink_offset);
saved_fp = fp_addr.getAddressAt(0);
}
setValues(sp, saved_fp, pc);
return true;
}
*/
}
} else {
// If the current program counter was not known to us as a Java
// PC, we currently assume that we are in the run-time system
// and attempt to look to thread-local storage for saved ESP and
// EBP. Note that if these are null (because we were, in fact,
// in Java code, i.e., vtable stubs or similar, and the SA
// didn't have enough insight into the target VM to understand
// that) then we are going to lose the entire stack trace for
// the thread, which is sub-optimal. FIXME.
if (DEBUG) {
System.out.println("CurrentFrameGuess: choosing last Java frame: sp = " +
thread.getLastJavaSP() + ", fp = " + thread.getLastJavaFP());
}
if (thread.getLastJavaSP() == null) {
return false; // No known Java frames on stack
}
setValues(thread.getLastJavaSP(), thread.getLastJavaFP(), null);
return true;
}
}
public Address getSP() { return spFound; }
public Address getFP() { return fpFound; }
/** May be null if getting values from thread-local storage; take
care to call the correct X86Frame constructor to recover this if
necessary */
public Address getPC() { return pcFound; }
private void setValues(Address sp, Address fp, Address pc) {
spFound = sp;
fpFound = fp;
pcFound = pc;
}
}

View File

@ -1,58 +0,0 @@
/*
* Copyright (c) 2001, 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.x86;
import java.util.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.types.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.utilities.Observable;
import sun.jvm.hotspot.utilities.Observer;
public class X86JavaCallWrapper extends JavaCallWrapper {
private static AddressField lastJavaFPField;
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("JavaFrameAnchor");
lastJavaFPField = type.getAddressField("_last_Java_fp");
}
public X86JavaCallWrapper(Address addr) {
super(addr);
}
public Address getLastJavaFP() {
return lastJavaFPField.getValue(addr.addOffsetTo(anchorField.getOffset()));
}
}

View File

@ -626,7 +626,7 @@ public class AnnotatedMemoryPanel extends JPanel {
public static void main(String[] args) {
JFrame frame = new JFrame();
DummyDebugger debugger = new DummyDebugger(new MachineDescriptionIntelX86());
DummyDebugger debugger = new DummyDebugger(new MachineDescriptionAMD64());
AnnotatedMemoryPanel anno = new AnnotatedMemoryPanel(debugger);
frame.getContentPane().add(anno);
anno.addAnnotation(new Annotation(debugger.parseAddress("0x80000000"),

View File

@ -50,7 +50,7 @@ public class PlatformInfo {
public static boolean knownCPU(String cpu) {
final String[] KNOWN =
new String[] {"i386", "x86", "x86_64", "amd64", "ppc64", "ppc64le", "aarch64", "riscv64"};
new String[] {"x86_64", "amd64", "ppc64", "ppc64le", "aarch64", "riscv64"};
for(String s : KNOWN) {
if(s.equals(cpu))
@ -60,8 +60,8 @@ public class PlatformInfo {
return false;
}
/* Returns "x86" for x86 based platforms and x86_64 for 64bit x86
based platform. Otherwise returns the value of os.arch. If the
/* Returns "amd64" for x86_64 based platforms.
Otherwise returns the value of os.arch. If the
value is not recognized as supported, an exception is thrown
instead. */
@ -74,9 +74,6 @@ public class PlatformInfo {
}
// Tweeks
if (cpu.equals("i386"))
return "x86";
if (cpu.equals("x86_64"))
return "amd64";