1:
38:
39:
40: package ;
41:
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50: import ;
51: import ;
52: import ;
53: import ;
54: import ;
55: import ;
56: import ;
57: import ;
58: import ;
59: import ;
60: import ;
61: import ;
62: import ;
63: import ;
64: import ;
65:
66: import ;
67: import ;
68: import ;
69:
70:
75: public class EventRequestCommandSet
76: extends CommandSet
77: {
78: public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command)
79: throws JdwpException
80: {
81: try
82: {
83: switch (command)
84: {
85: case JdwpConstants.CommandSet.EventRequest.SET:
86: executeSet(bb, os);
87: break;
88: case JdwpConstants.CommandSet.EventRequest.CLEAR:
89: executeClear(bb, os);
90: break;
91: case JdwpConstants.CommandSet.EventRequest.CLEAR_ALL_BREAKPOINTS:
92: executeClearAllBreakpoints(bb, os);
93: break;
94: default:
95: throw new NotImplementedException("Command " + command +
96: " not found in EventRequest Reference Command Set.");
97: }
98: }
99: catch (IOException ex)
100: {
101:
102:
103: throw new JdwpInternalErrorException(ex);
104: }
105:
106: return false;
107: }
108:
109: private void executeSet(ByteBuffer bb, DataOutputStream os)
110: throws JdwpException, IOException
111: {
112: byte eventKind = bb.get();
113: byte suspendPolicy = bb.get();
114: int modifiers = bb.getInt();
115:
116: EventRequest eventReq = new EventRequest(eventKind, suspendPolicy);
117: IEventFilter filter = null;
118: ReferenceTypeId refId;
119: for (int i = 0; i < modifiers; i++)
120: {
121: byte modKind = bb.get();
122: switch (modKind)
123: {
124: case JdwpConstants.ModKind.COUNT:
125: filter = new CountFilter(bb.getInt());
126: break;
127: case JdwpConstants.ModKind.CONDITIONAL:
128: filter = new ConditionalFilter(idMan.readObjectId(bb));
129: break;
130: case JdwpConstants.ModKind.THREAD_ONLY:
131: filter = new ThreadOnlyFilter((ThreadId) idMan.readObjectId(bb));
132: break;
133: case JdwpConstants.ModKind.CLASS_ONLY:
134: filter = new ClassOnlyFilter(idMan.readReferenceTypeId(bb));
135: break;
136: case JdwpConstants.ModKind.CLASS_MATCH:
137: filter = new ClassMatchFilter(JdwpString.readString(bb));
138: break;
139: case JdwpConstants.ModKind.CLASS_EXCLUDE:
140: filter = new ClassExcludeFilter(JdwpString.readString(bb));
141: break;
142: case JdwpConstants.ModKind.LOCATION_ONLY:
143: filter = new LocationOnlyFilter(new Location(bb));
144: break;
145: case JdwpConstants.ModKind.EXCEPTION_ONLY:
146: long id = bb.getLong();
147: if (id == 0)
148: refId = null;
149: else
150: refId = idMan.getReferenceType(id);
151: boolean caught = (bb.get() == 0) ? false : true;
152: boolean unCaught = (bb.get() == 0) ? false : true;
153: filter = new ExceptionOnlyFilter(refId, caught, unCaught);
154: break;
155: case JdwpConstants.ModKind.FIELD_ONLY:
156: refId = idMan.readReferenceTypeId(bb);
157: ReferenceTypeId fieldId = idMan.readReferenceTypeId(bb);
158: filter = new FieldOnlyFilter(refId, fieldId);
159: break;
160: case JdwpConstants.ModKind.STEP:
161: ThreadId tid = (ThreadId) idMan.readObjectId(bb);
162: int size = bb.getInt();
163: int depth = bb.getInt();
164: filter = new StepFilter(tid, size, depth);
165: break;
166: case JdwpConstants.ModKind.INSTANCE_ONLY:
167: ObjectId oid = idMan.readObjectId(bb);
168: filter = new InstanceOnlyFilter(oid);
169: break;
170: default:
171: throw new NotImplementedException("modKind " + modKind
172: + " is not implemented.");
173: }
174: eventReq.addFilter(filter);
175: }
176:
177: EventManager.getDefault().requestEvent(eventReq);
178: os.writeInt(eventReq.getId());
179:
180: }
181:
182: private void executeClear(ByteBuffer bb, DataOutputStream os)
183: throws JdwpException, IOException
184: {
185: byte eventKind = bb.get();
186: int requestId = bb.getInt();
187: EventManager.getDefault().deleteRequest(eventKind, requestId);
188: }
189:
190: private void executeClearAllBreakpoints(ByteBuffer bb, DataOutputStream os)
191: throws JdwpException, IOException
192: {
193: byte eventKind = bb.get ();
194: EventManager.getDefault().clearRequests (eventKind);
195: }
196:
197: }