Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java @ 6842:b9a9ed0f8eeb
7197424: update copyright year to match last edit in jdk8 hotspot repository
Summary: Update copyright year to 2012 for relevant files
Reviewed-by: dholmes, coleenp
author | mikael |
---|---|
date | Tue, 09 Oct 2012 10:09:34 -0700 |
parents | a9fed06c01d2 |
children | d7cb88bd7046 |
rev | line source |
---|---|
0 | 1 /* |
6641
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
1552
diff
changeset
|
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.debugger.linux; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 import sun.jvm.hotspot.debugger.*; | |
30 import sun.jvm.hotspot.debugger.cdbg.*; | |
31 import sun.jvm.hotspot.debugger.x86.*; | |
32 import sun.jvm.hotspot.debugger.amd64.*; | |
33 import sun.jvm.hotspot.debugger.sparc.*; | |
34 import sun.jvm.hotspot.debugger.linux.x86.*; | |
35 import sun.jvm.hotspot.debugger.linux.amd64.*; | |
36 import sun.jvm.hotspot.debugger.linux.sparc.*; | |
37 import sun.jvm.hotspot.utilities.*; | |
38 | |
39 class LinuxCDebugger implements CDebugger { | |
40 private LinuxDebugger dbg; | |
41 | |
42 LinuxCDebugger(LinuxDebugger dbg) { | |
43 this.dbg = dbg; | |
44 } | |
45 | |
46 public List getThreadList() throws DebuggerException { | |
47 return dbg.getThreadList(); | |
48 } | |
49 | |
50 public List/*<LoadObject>*/ getLoadObjectList() throws DebuggerException { | |
51 return dbg.getLoadObjectList(); | |
52 } | |
53 | |
54 public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException { | |
55 if (pc == null) { | |
56 return null; | |
57 } | |
58 List objs = getLoadObjectList(); | |
59 Object[] arr = objs.toArray(); | |
60 // load objects are sorted by base address, do binary search | |
61 int mid = -1; | |
62 int low = 0; | |
63 int high = arr.length - 1; | |
64 | |
65 while (low <= high) { | |
66 mid = (low + high) >> 1; | |
67 LoadObject midVal = (LoadObject) arr[mid]; | |
68 long cmp = pc.minus(midVal.getBase()); | |
69 if (cmp < 0) { | |
70 high = mid - 1; | |
71 } else if (cmp > 0) { | |
72 long size = midVal.getSize(); | |
73 if (cmp >= size) { | |
74 low = mid + 1; | |
75 } else { | |
76 return (LoadObject) arr[mid]; | |
77 } | |
78 } else { // match found | |
79 return (LoadObject) arr[mid]; | |
80 } | |
81 } | |
82 // no match found. | |
83 return null; | |
84 } | |
85 | |
86 public CFrame topFrameForThread(ThreadProxy thread) throws DebuggerException { | |
87 String cpu = dbg.getCPU(); | |
88 if (cpu.equals("x86")) { | |
89 X86ThreadContext context = (X86ThreadContext) thread.getContext(); | |
90 Address ebp = context.getRegisterAsAddress(X86ThreadContext.EBP); | |
91 if (ebp == null) return null; | |
92 Address pc = context.getRegisterAsAddress(X86ThreadContext.EIP); | |
93 if (pc == null) return null; | |
94 return new LinuxX86CFrame(dbg, ebp, pc); | |
95 } else if (cpu.equals("amd64")) { | |
96 AMD64ThreadContext context = (AMD64ThreadContext) thread.getContext(); | |
97 Address rbp = context.getRegisterAsAddress(AMD64ThreadContext.RBP); | |
98 if (rbp == null) return null; | |
99 Address pc = context.getRegisterAsAddress(AMD64ThreadContext.RIP); | |
100 if (pc == null) return null; | |
101 return new LinuxAMD64CFrame(dbg, rbp, pc); | |
102 } else if (cpu.equals("sparc")) { | |
103 SPARCThreadContext context = (SPARCThreadContext) thread.getContext(); | |
104 Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP); | |
105 if (sp == null) return null; | |
106 Address pc = context.getRegisterAsAddress(SPARCThreadContext.R_O7); | |
107 if (pc == null) return null; | |
108 return new LinuxSPARCCFrame(dbg, sp, pc, LinuxDebuggerLocal.getAddressSize()); | |
109 } else { | |
6641
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
1552
diff
changeset
|
110 // Runtime exception thrown by LinuxThreadContextFactory if unknown cpu |
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
1552
diff
changeset
|
111 ThreadContext context = (ThreadContext) thread.getContext(); |
a9fed06c01d2
7154641: Servicability agent should work on platforms other than x86, sparc
bpittore
parents:
1552
diff
changeset
|
112 return context.getTopFrame(dbg); |
0 | 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 | |
129 public String demangle(String sym) { | |
130 throw new UnsupportedOperationException(); | |
131 } | |
132 } |