001: /*BEGIN_COPYRIGHT_BLOCK
002: *
003: * Copyright (c) 2001-2007, JavaPLT group at Rice University (javaplt@rice.edu)
004: * All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions are met:
008: * * Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: * * Redistributions in binary form must reproduce the above copyright
011: * notice, this list of conditions and the following disclaimer in the
012: * documentation and/or other materials provided with the distribution.
013: * * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
014: * names of its contributors may be used to endorse or promote products
015: * derived from this software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
018: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
019: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
020: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
021: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
022: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
023: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
024: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
025: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
026: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028: *
029: * This software is Open Source Initiative approved Open Source Software.
030: * Open Source Initative Approved is a trademark of the Open Source Initiative.
031: *
032: * This file is part of DrJava. Download the current version of this project
033: * from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
034: *
035: * END_COPYRIGHT_BLOCK*/
036:
037: package edu.rice.cs.drjava.model.debug.jpda;
038:
039: import edu.rice.cs.drjava.DrJava;
040: import edu.rice.cs.drjava.config.OptionConstants;
041: import edu.rice.cs.drjava.model.debug.DebugException;
042:
043: import java.util.StringTokenizer;
044:
045: import com.sun.jdi.*;
046: import com.sun.jdi.request.*;
047:
048: /** The breakpoint object which has references to its OpenDefinitionsDocument and its StepRequest */
049: public class Step extends DebugAction<StepRequest> implements
050: OptionConstants {
051: private final ThreadReference _thread;
052: private final int _size;
053: private final int _depth;
054:
055: // Java class patterns for which we may not want events
056: private final String[] _javaExcludes = { "java.*", "javax.*",
057: "sun.*", "com.sun.*", "com.apple.eawt.*", "com.apple.eio.*" };
058:
059: /** @throws IllegalStateException if the document does not have a file */
060: public Step(JPDADebugger manager, int size, int depth)
061: throws DebugException, IllegalStateException {
062: super (manager);
063: _suspendPolicy = EventRequest.SUSPEND_EVENT_THREAD;
064: _thread = _manager.getCurrentThread();
065: _size = size;
066: _depth = depth;
067: _countFilter = 1; //only step once.
068: _initializeRequests();
069: }
070:
071: //public boolean createRequest(ReferenceType rt) throws DebugException {
072: // return false;
073: //}
074:
075: /**
076: * Creates an appropriate EventRequest from the EventRequestManager and
077: * stores it in the _request field.
078: * @throws DebugException if the request could not be created.
079: */
080: protected void _createRequests() throws DebugException {
081: boolean stepJava = DrJava.getConfig().getSetting(
082: DEBUG_STEP_JAVA).booleanValue();
083: boolean stepInterpreter = DrJava.getConfig().getSetting(
084: DEBUG_STEP_INTERPRETER).booleanValue();
085: boolean stepDrJava = DrJava.getConfig().getSetting(
086: DEBUG_STEP_DRJAVA).booleanValue();
087: String exclude = DrJava.getConfig().getSetting(
088: DEBUG_STEP_EXCLUDE);
089:
090: StepRequest request = _manager.getEventRequestManager()
091: .createStepRequest(_thread, _size, _depth);
092: if (!stepJava) {
093: for (int i = 0; i < _javaExcludes.length; i++) {
094: request.addClassExclusionFilter(_javaExcludes[i]);
095: }
096: }
097: if (!stepInterpreter) {
098: request.addClassExclusionFilter("koala.*");
099: }
100: if (!stepDrJava) {
101: request.addClassExclusionFilter("edu.rice.cs.drjava.*");
102: request.addClassExclusionFilter("edu.rice.cs.util.*");
103: }
104: StringTokenizer st = new StringTokenizer(exclude, ",");
105: while (st.hasMoreTokens()) {
106: request.addClassExclusionFilter(st.nextToken().trim());
107: }
108:
109: // Add this request (the only one) to the list
110: _requests.add(request);
111: }
112:
113: public String toString() {
114: return "Step[thread: " + _thread + "]";
115: }
116: }
|