1 /*
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 package sun.jvm.hotspot.debugger.linux;
26
27 import java.io.*;
28 import java.util.*;
29
30 import sun.jvm.hotspot.debugger.*;
31 import sun.jvm.hotspot.debugger.cdbg.*;
32 import sun.jvm.hotspot.debugger.x86.*;
33 import sun.jvm.hotspot.debugger.amd64.*;
34 import sun.jvm.hotspot.debugger.sparc.*;
35 import sun.jvm.hotspot.debugger.ppc64.*;
36 import sun.jvm.hotspot.debugger.linux.x86.*;
37 import sun.jvm.hotspot.debugger.linux.amd64.*;
38 import sun.jvm.hotspot.debugger.linux.sparc.*;
39 import sun.jvm.hotspot.debugger.linux.ppc64.*;
40 import sun.jvm.hotspot.utilities.*;
41
42 class LinuxCDebugger implements CDebugger {
43 private LinuxDebugger dbg;
44
45 LinuxCDebugger(LinuxDebugger dbg) {
46 this.dbg = dbg;
47 }
48
49 public List getThreadList() throws DebuggerException {
50 return dbg.getThreadList();
51 }
52
53 public List/*<LoadObject>*/ getLoadObjectList() throws DebuggerException {
54 return dbg.getLoadObjectList();
55 }
56
57 public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException {
58 if (pc == null) {
59 return null;
89 AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext();
90 Address rbp = context.getRegisterAsAddress(AMD64ThreadContext.RBP);
91 if (rbp == null) return null;
92 Address pc = context.getRegisterAsAddress(AMD64ThreadContext.RIP);
93 if (pc == null) return null;
94 return new LinuxAMD64CFrame(dbg, rbp, pc);
95 } else if (cpu.equals("sparc")) {
96 SPARCThreadContext context = (SPARCThreadContext) thread.getContext();
97 Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP);
98 if (sp == null) return null;
99 Address pc = context.getRegisterAsAddress(SPARCThreadContext.R_O7);
100 if (pc == null) return null;
101 return new LinuxSPARCCFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize());
102 } else if (cpu.equals("ppc64")) {
103 PPC64ThreadContext context = (PPC64ThreadContext) thread.getContext();
104 Address sp = context.getRegisterAsAddress(PPC64ThreadContext.SP);
105 if (sp == null) return null;
106 Address pc = context.getRegisterAsAddress(PPC64ThreadContext.PC);
107 if (pc == null) return null;
108 return new LinuxPPC64CFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize());
109 } else {
110 // Runtime exception thrown by LinuxThreadContextFactory if unknown cpu
111 ThreadContext context = (ThreadContext) thread.getContext();
112 return context.getTopFrame(dbg);
113 }
114 }
115
116 public String getNameOfFile(String fileName) {
117 return new File(fileName).getName();
118 }
119
120 public ProcessControl getProcessControl() throws DebuggerException {
121 // FIXME: after stabs parser
122 return null;
123 }
124
125 public boolean canDemangle() {
126 return false;
127 }
128
|
1 /*
2 * Copyright (c) 2003, 2012, 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.
23 *
24 */
25
26 package sun.jvm.hotspot.debugger.linux;
27
28 import java.io.*;
29 import java.util.*;
30
31 import sun.jvm.hotspot.debugger.*;
32 import sun.jvm.hotspot.debugger.cdbg.*;
33 import sun.jvm.hotspot.debugger.x86.*;
34 import sun.jvm.hotspot.debugger.amd64.*;
35 import sun.jvm.hotspot.debugger.aarch64.*;
36 import sun.jvm.hotspot.debugger.sparc.*;
37 import sun.jvm.hotspot.debugger.ppc64.*;
38 import sun.jvm.hotspot.debugger.linux.x86.*;
39 import sun.jvm.hotspot.debugger.linux.amd64.*;
40 import sun.jvm.hotspot.debugger.linux.sparc.*;
41 import sun.jvm.hotspot.debugger.linux.ppc64.*;
42 import sun.jvm.hotspot.debugger.linux.aarch64.*;
43 import sun.jvm.hotspot.utilities.*;
44
45 class LinuxCDebugger implements CDebugger {
46 private LinuxDebugger dbg;
47
48 LinuxCDebugger(LinuxDebugger dbg) {
49 this.dbg = dbg;
50 }
51
52 public List getThreadList() throws DebuggerException {
53 return dbg.getThreadList();
54 }
55
56 public List/*<LoadObject>*/ getLoadObjectList() throws DebuggerException {
57 return dbg.getLoadObjectList();
58 }
59
60 public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException {
61 if (pc == null) {
62 return null;
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;
118 return new LinuxAARCH64CFrame(dbg, fp, pc);
119 } else {
120 // Runtime exception thrown by LinuxThreadContextFactory if unknown cpu
121 ThreadContext context = (ThreadContext) thread.getContext();
122 return context.getTopFrame(dbg);
123 }
124 }
125
126 public String getNameOfFile(String fileName) {
127 return new File(fileName).getName();
128 }
129
130 public ProcessControl getProcessControl() throws DebuggerException {
131 // FIXME: after stabs parser
132 return null;
133 }
134
135 public boolean canDemangle() {
136 return false;
137 }
138
|