comparison agent/src/share/classes/sun/jvm/hotspot/debugger/cdbg/basic/BasicDebugEvent.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 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.cdbg.basic;
26
27 import sun.jvm.hotspot.debugger.*;
28 import sun.jvm.hotspot.debugger.cdbg.*;
29
30 public class BasicDebugEvent implements DebugEvent {
31 private DebugEvent.Type type;
32 private ThreadProxy thread;
33 private Address pc;
34 private Address address;
35 private boolean wasWrite;
36 private String detail;
37
38 public BasicDebugEvent(DebugEvent.Type type, ThreadProxy thread) {
39 this.type = type;
40 this.thread = thread;
41 }
42
43 public DebugEvent.Type getType() { return type; }
44 public ThreadProxy getThread() { return thread; }
45 public Address getPC() { return pc; }
46 public boolean getWasWrite() { return wasWrite; }
47 public Address getAddress() { return address; }
48 public String getUnknownEventDetail() { return detail; }
49
50 /** Mutators for convenience */
51 public void setType(DebugEvent.Type type) { this.type = type; }
52 public void setThread(ThreadProxy thread) { this.thread = thread; }
53 public void setPC(Address pc) { this.pc = pc; }
54 public void setWasWrite(boolean val) { wasWrite = val; }
55 public void setAddress(Address address) { this.address = address; }
56 public void setUnknownEventDetail(String msg) { detail = msg; }
57
58 /** Factory methods for convenience */
59 public static BasicDebugEvent newLoadObjectLoadEvent(ThreadProxy thread, Address base) {
60 return newAddressEvent(DebugEvent.Type.LOADOBJECT_LOAD, thread, base);
61 }
62
63 public static BasicDebugEvent newLoadObjectUnloadEvent(ThreadProxy thread, Address base) {
64 return newAddressEvent(DebugEvent.Type.LOADOBJECT_UNLOAD, thread, base);
65 }
66
67 public static BasicDebugEvent newBreakpointEvent(ThreadProxy thread, Address pc) {
68 return newPCEvent(DebugEvent.Type.BREAKPOINT, thread, pc);
69 }
70
71 public static BasicDebugEvent newSingleStepEvent(ThreadProxy thread, Address pc) {
72 return newPCEvent(DebugEvent.Type.BREAKPOINT, thread, pc);
73 }
74
75 public static BasicDebugEvent newAccessViolationEvent(ThreadProxy thread,
76 Address pc,
77 boolean wasWrite,
78 Address addr) {
79 BasicDebugEvent ev = newPCEvent(DebugEvent.Type.ACCESS_VIOLATION, thread, pc);
80 ev.setWasWrite(wasWrite);
81 ev.setAddress(addr);
82 return ev;
83 }
84
85 public static BasicDebugEvent newUnknownEvent(ThreadProxy thread, String detail) {
86 BasicDebugEvent ev = new BasicDebugEvent(DebugEvent.Type.UNKNOWN, thread);
87 ev.setUnknownEventDetail(detail);
88 return ev;
89 }
90
91 //----------------------------------------------------------------------
92 // Internals only below this point
93 //
94
95 private static BasicDebugEvent newAddressEvent(DebugEvent.Type type, ThreadProxy thread, Address addr) {
96 BasicDebugEvent ev = new BasicDebugEvent(type, thread);
97 ev.setAddress(addr);
98 return ev;
99 }
100
101 private static BasicDebugEvent newPCEvent(DebugEvent.Type type, ThreadProxy thread, Address pc) {
102 BasicDebugEvent ev = new BasicDebugEvent(type, thread);
103 ev.setPC(pc);
104 return ev;
105 }
106 }