comparison agent/src/share/classes/sun/jvm/hotspot/debugger/win32/Win32CDebugger.java @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children c18cbe5936b8
comparison
equal deleted inserted replaced
-1:000000000000 0:a61af66fc99e
1 /*
2 * Copyright 2001-2003 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25 package sun.jvm.hotspot.debugger.win32;
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.cdbg.basic.x86.*;
32 import sun.jvm.hotspot.debugger.x86.*;
33 import sun.jvm.hotspot.utilities.AddressOps;
34
35 class Win32CDebugger implements CDebugger, ProcessControl {
36 // FIXME: think about how to make this work in a remote debugging
37 // scenario; who should keep open DLLs? Need local copies of these
38 // DLLs on the debugging machine?
39 private Win32Debugger dbg;
40
41 Win32CDebugger(Win32Debugger dbg) {
42 this.dbg = dbg;
43 }
44
45 public List getThreadList() throws DebuggerException {
46 return dbg.getThreadList();
47 }
48
49 public List/*<LoadObject>*/ getLoadObjectList() throws DebuggerException{
50 return dbg.getLoadObjectList();
51 }
52
53 public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException {
54 // FIXME: could keep sorted list of these to be able to do binary
55 // searches, for better scalability
56 if (pc == null) {
57 return null;
58 }
59 List objs = getLoadObjectList();
60 for (Iterator iter = objs.iterator(); iter.hasNext(); ) {
61 LoadObject obj = (LoadObject) iter.next();
62 if (AddressOps.lte(obj.getBase(), pc) && (pc.minus(obj.getBase()) < obj.getSize())) {
63 return obj;
64 }
65 }
66 return null;
67 }
68
69 public CFrame topFrameForThread(ThreadProxy thread) throws DebuggerException {
70 X86ThreadContext context = (X86ThreadContext) thread.getContext();
71 Address ebp = context.getRegisterAsAddress(X86ThreadContext.EBP);
72 if (ebp == null) return null;
73 Address pc = context.getRegisterAsAddress(X86ThreadContext.EIP);
74 if (pc == null) return null;
75 return new X86CFrame(this, ebp, pc);
76 }
77
78 public String getNameOfFile(String fileName) {
79 return new File(fileName).getName();
80 }
81
82 public ProcessControl getProcessControl() throws DebuggerException {
83 return this;
84 }
85
86 // C++ name demangling
87 public boolean canDemangle() {
88 return false;
89 }
90
91 public String demangle(String sym) {
92 throw new UnsupportedOperationException();
93 }
94
95 //
96 // Support for ProcessControl interface
97 //
98
99 public void suspend() throws DebuggerException {
100 dbg.suspend();
101 }
102 public void resume() throws DebuggerException {
103 dbg.resume();
104 }
105 public boolean isSuspended() throws DebuggerException {
106 return dbg.isSuspended();
107 }
108 public void setBreakpoint(Address addr) throws DebuggerException {
109 dbg.setBreakpoint(addr);
110 }
111 public void clearBreakpoint(Address addr) throws DebuggerException {
112 dbg.clearBreakpoint(addr);
113 }
114 public boolean isBreakpointSet(Address addr) throws DebuggerException {
115 return dbg.isBreakpointSet(addr);
116 }
117 public DebugEvent debugEventPoll() throws DebuggerException {
118 return dbg.debugEventPoll();
119 }
120 public void debugEventContinue() throws DebuggerException {
121 dbg.debugEventContinue();
122 }
123 }