1 /*
2 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2015, Red Hat Inc.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
73 long size = ob.getSize();
74 if ( pc.greaterThanOrEqual(base) && pc.lessThan(base.addOffsetTo(size))) {
75 return ob;
76 }
77 }
78
79 return null;
80 }
81
82 public CFrame topFrameForThread(ThreadProxy thread) throws DebuggerException {
83 String cpu = dbg.getCPU();
84 if (cpu.equals("x86")) {
85 X86ThreadContext context = (X86ThreadContext) thread.getContext();
86 Address ebp = context.getRegisterAsAddress(X86ThreadContext.EBP);
87 if (ebp == null) return null;
88 Address pc = context.getRegisterAsAddress(X86ThreadContext.EIP);
89 if (pc == null) return null;
90 return new LinuxX86CFrame(dbg, ebp, pc);
91 } else if (cpu.equals("amd64")) {
92 AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext();
93 Address rbp = context.getRegisterAsAddress(AMD64ThreadContext.RBP);
94 if (rbp == null) return null;
95 Address pc = context.getRegisterAsAddress(AMD64ThreadContext.RIP);
96 if (pc == null) return null;
97 return new LinuxAMD64CFrame(dbg, rbp, pc);
98 } else if (cpu.equals("sparc")) {
99 SPARCThreadContext context = (SPARCThreadContext) thread.getContext();
100 Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP);
101 if (sp == null) return null;
102 Address pc = context.getRegisterAsAddress(SPARCThreadContext.R_O7);
103 if (pc == null) return null;
104 return new LinuxSPARCCFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize());
105 } else if (cpu.equals("ppc64")) {
106 PPC64ThreadContext context = (PPC64ThreadContext) thread.getContext();
107 Address sp = context.getRegisterAsAddress(PPC64ThreadContext.SP);
108 if (sp == null) return null;
109 Address pc = context.getRegisterAsAddress(PPC64ThreadContext.PC);
110 if (pc == null) return null;
111 return new LinuxPPC64CFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize());
112 } else if (cpu.equals("aarch64")) {
113 AARCH64ThreadContext context = (AARCH64ThreadContext) thread.getContext();
114 Address fp = context.getRegisterAsAddress(AARCH64ThreadContext.FP);
115 if (fp == null) return null;
116 Address pc = context.getRegisterAsAddress(AARCH64ThreadContext.PC);
117 if (pc == null) return null;
|
1 /*
2 * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2015, Red Hat Inc.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
73 long size = ob.getSize();
74 if ( pc.greaterThanOrEqual(base) && pc.lessThan(base.addOffsetTo(size))) {
75 return ob;
76 }
77 }
78
79 return null;
80 }
81
82 public CFrame topFrameForThread(ThreadProxy thread) throws DebuggerException {
83 String cpu = dbg.getCPU();
84 if (cpu.equals("x86")) {
85 X86ThreadContext context = (X86ThreadContext) thread.getContext();
86 Address ebp = context.getRegisterAsAddress(X86ThreadContext.EBP);
87 if (ebp == null) return null;
88 Address pc = context.getRegisterAsAddress(X86ThreadContext.EIP);
89 if (pc == null) return null;
90 return new LinuxX86CFrame(dbg, ebp, pc);
91 } else if (cpu.equals("amd64")) {
92 AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext();
93 Address pc = context.getRegisterAsAddress(AMD64ThreadContext.RIP);
94 if (pc == null) return null;
95 return LinuxAMD64CFrame.getTopFrame(dbg, pc, context);
96 } else if (cpu.equals("sparc")) {
97 SPARCThreadContext context = (SPARCThreadContext) thread.getContext();
98 Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP);
99 if (sp == null) return null;
100 Address pc = context.getRegisterAsAddress(SPARCThreadContext.R_O7);
101 if (pc == null) return null;
102 return new LinuxSPARCCFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize());
103 } else if (cpu.equals("ppc64")) {
104 PPC64ThreadContext context = (PPC64ThreadContext) thread.getContext();
105 Address sp = context.getRegisterAsAddress(PPC64ThreadContext.SP);
106 if (sp == null) return null;
107 Address pc = context.getRegisterAsAddress(PPC64ThreadContext.PC);
108 if (pc == null) return null;
109 return new LinuxPPC64CFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize());
110 } else if (cpu.equals("aarch64")) {
111 AARCH64ThreadContext context = (AARCH64ThreadContext) thread.getContext();
112 Address fp = context.getRegisterAsAddress(AARCH64ThreadContext.FP);
113 if (fp == null) return null;
114 Address pc = context.getRegisterAsAddress(AARCH64ThreadContext.PC);
115 if (pc == null) return null;
|