01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdi.internal.request;
11:
12: import java.io.ByteArrayOutputStream;
13: import java.io.DataInputStream;
14: import java.io.DataOutputStream;
15: import java.io.IOException;
16:
17: import org.eclipse.jdi.internal.VirtualMachineImpl;
18: import org.eclipse.jdi.internal.event.EventImpl;
19: import org.eclipse.jdi.internal.jdwp.JdwpCommandPacket;
20: import org.eclipse.jdi.internal.jdwp.JdwpReplyPacket;
21:
22: /**
23: * this class implements the corresponding interfaces
24: * declared by the OTI Hot Code Replacement extentions of the
25: * JDI specification.
26: */
27:
28: public class ReenterStepRequestImpl extends StepRequestImpl implements
29: org.eclipse.jdi.hcr.ReenterStepRequest {
30: /**
31: * Creates new ReenterStepRequestImpl.
32: */
33: public ReenterStepRequestImpl(VirtualMachineImpl vmImpl) {
34: super ("ReenterStepRequest", vmImpl); //$NON-NLS-1$
35: }
36:
37: /**
38: * @return Returns JDWP constant for step depth.
39: */
40: public int threadStepDepthJDWP(int threadStepDepth) {
41: return STEP_DEPTH_REENTER_JDWP_HCR;
42: }
43:
44: /**
45: * Enables event request.
46: */
47: public void enable() {
48: if (isEnabled())
49: return;
50:
51: initJdwpRequest();
52: try {
53: ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
54: DataOutputStream outData = new DataOutputStream(outBytes);
55: writeByte(eventKind(),
56: "event kind", EventImpl.eventKindMap(), outData); // Always 01 for Step event. //$NON-NLS-1$
57: writeByte(suspendPolicyJDWP(), "suspend policy", outData); //$NON-NLS-1$
58: writeInt(modifierCount(), "modifiers", outData); //$NON-NLS-1$
59: writeModifiers(outData);
60:
61: JdwpReplyPacket replyPacket = requestVM(
62: JdwpCommandPacket.HCR_REENTER_ON_EXIT, outBytes);
63: defaultReplyErrorHandler(replyPacket.errorCode());
64: DataInputStream replyData = replyPacket.dataInStream();
65: fRequestID = RequestID.read(this , replyData);
66: virtualMachineImpl().eventRequestManagerImpl()
67: .addRequestIDMapping(this );
68: } catch (IOException e) {
69: defaultIOExceptionHandler(e);
70: } finally {
71: handledJdwpRequest();
72: }
73: }
74: }
|