diff options
Diffstat (limited to 'org.eclipse.debug.examples.core')
63 files changed, 2375 insertions, 2375 deletions
diff --git a/org.eclipse.debug.examples.core/pdavm/src/org/eclipse/debug/examples/pdavm/PDAVirtualMachine.java b/org.eclipse.debug.examples.core/pdavm/src/org/eclipse/debug/examples/pdavm/PDAVirtualMachine.java index f0b3659b2..226aa6015 100644 --- a/org.eclipse.debug.examples.core/pdavm/src/org/eclipse/debug/examples/pdavm/PDAVirtualMachine.java +++ b/org.eclipse.debug.examples.core/pdavm/src/org/eclipse/debug/examples/pdavm/PDAVirtualMachine.java @@ -45,416 +45,416 @@ import java.util.regex.Pattern; public class PDAVirtualMachine { static class Stack extends LinkedList<Object> { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - @Override + @Override public Object pop() { - return isEmpty() ? Integer.valueOf(0) : remove(size() - 1); - } + return isEmpty() ? Integer.valueOf(0) : remove(size() - 1); + } - @Override + @Override public void push(Object value) { - add(value); - } - } - - static class Register { - Register(String name) { - fName = name; - } - String fName; - String fGroup = "<no_group>"; //$NON-NLS-1$ - boolean fIsWriteable = true; + add(value); + } + } + + static class Register { + Register(String name) { + fName = name; + } + String fName; + String fGroup = "<no_group>"; //$NON-NLS-1$ + boolean fIsWriteable = true; Map<String, BitField> fBitFields = new LinkedHashMap<>(0); - int fValue; - } - - static class BitField { - BitField(String name) { - fName = name; - } - String fName; - int fBitOffset; - int fBitCount; + int fValue; + } + + static class BitField { + BitField(String name) { + fName = name; + } + String fName; + int fBitOffset; + int fBitCount; Map<String, Integer> fMnemonics = new LinkedHashMap<>(0); - } + } Map<String, Register> fRegisters = new LinkedHashMap<>(0); - class Args { - final String[] fArgs; - - int next = 0; - - Args(String[] args) { - fArgs = args; - } - - boolean hasNextArg() { - return fArgs.length > next; - } - - String getNextStringArg() { - if (fArgs.length > next) { - return fArgs[next++]; - } - return ""; //$NON-NLS-1$ - } - - int getNextIntArg() { - String arg = getNextStringArg(); - try { - return Integer.parseInt(arg); - } catch (NumberFormatException e) { - } - return 0; - } - - boolean getNextBooleanArg() { - String arg = getNextStringArg(); - try { - return Boolean.getBoolean(arg); - } catch (NumberFormatException e) { - } - return false; - } - - Object getNextIntOrStringArg() { - String arg = getNextStringArg(); - try { - return Integer.valueOf(arg); - } catch (NumberFormatException e) { - } - return arg; - } - - PDAThread getThreadArg() { - int id = getNextIntArg(); - return fThreads.get( Integer.valueOf(id) ); - } - } - - class PDAThread { - final int fID; - - /** The push down automata data stack (the data stack). */ - final Stack fStack = new Stack(); - - /** - * PDAThread copy of the code. It can differ from the program if - * performing an evaluation. - */ - String[] fThreadCode; - - /** PDAThread copy of the labels. */ + class Args { + final String[] fArgs; + + int next = 0; + + Args(String[] args) { + fArgs = args; + } + + boolean hasNextArg() { + return fArgs.length > next; + } + + String getNextStringArg() { + if (fArgs.length > next) { + return fArgs[next++]; + } + return ""; //$NON-NLS-1$ + } + + int getNextIntArg() { + String arg = getNextStringArg(); + try { + return Integer.parseInt(arg); + } catch (NumberFormatException e) { + } + return 0; + } + + boolean getNextBooleanArg() { + String arg = getNextStringArg(); + try { + return Boolean.getBoolean(arg); + } catch (NumberFormatException e) { + } + return false; + } + + Object getNextIntOrStringArg() { + String arg = getNextStringArg(); + try { + return Integer.valueOf(arg); + } catch (NumberFormatException e) { + } + return arg; + } + + PDAThread getThreadArg() { + int id = getNextIntArg(); + return fThreads.get( Integer.valueOf(id) ); + } + } + + class PDAThread { + final int fID; + + /** The push down automata data stack (the data stack). */ + final Stack fStack = new Stack(); + + /** + * PDAThread copy of the code. It can differ from the program if + * performing an evaluation. + */ + String[] fThreadCode; + + /** PDAThread copy of the labels. */ Map<String, Integer> fThreadLabels; - /** The stack of stack frames (the control stack) */ + /** The stack of stack frames (the control stack) */ final List<Frame> fFrames = new LinkedList<>(); - /** Current stack frame (not includced in fFrames) */ - Frame fCurrentFrame; + /** Current stack frame (not includced in fFrames) */ + Frame fCurrentFrame; - /** - * The run flag is true if the thread is running. If the run flag is - * false, the thread exits the next time the main instruction loop runs. - */ - boolean fRun = true; + /** + * The run flag is true if the thread is running. If the run flag is + * false, the thread exits the next time the main instruction loop runs. + */ + boolean fRun = true; - String fSuspend = null; + String fSuspend = null; - boolean fStep = false; + boolean fStep = false; - boolean fStepReturn = false; + boolean fStepReturn = false; - int fSavedPC; + int fSavedPC; - boolean fPerformingEval = false; + boolean fPerformingEval = false; - PDAThread(int id, String function, int pc) { - fID = id; - fCurrentFrame = new Frame(function, pc); - fThreadCode = fCode; - fThreadLabels = fLabels; - } - } + PDAThread(int id, String function, int pc) { + fID = id; + fCurrentFrame = new Frame(function, pc); + fThreadCode = fCode; + fThreadLabels = fLabels; + } + } final Map<Integer, PDAThread> fThreads = new LinkedHashMap<>(); - int fNextThreadId = 1; + int fNextThreadId = 1; - boolean fStarted = true; - /** - * The code is stored as an array of strings, each line of the source file - * being one entry in the array. - */ - final String[] fCode; + boolean fStarted = true; + /** + * The code is stored as an array of strings, each line of the source file + * being one entry in the array. + */ + final String[] fCode; - /** A mapping of labels to indicies in the code array */ + /** A mapping of labels to indicies in the code array */ final Map<String, Integer> fLabels; - /** Each stack frame is a mapping of variable names to values. */ - class Frame { + /** Each stack frame is a mapping of variable names to values. */ + class Frame { final Map<String, Object> fLocalVariables = new LinkedHashMap<>(); - /** - * The name of the function in this frame - */ - final String fFunction; - - /** - * The current program counter in the frame the pc points to the next - * instruction to be executed - */ - int fPC; - - Frame(String function, int pc) { - fFunction = function; - fPC = pc; - } - - void set(String name, Object value) { - if (name.startsWith("$")) { //$NON-NLS-1$ - setRegisterValue(name, value); - } else { - fLocalVariables.put(name, value); - } - } - - Object get(String name) { - if (name.startsWith("$")) { //$NON-NLS-1$ - return getRegisterValue(name); - } else { - return fLocalVariables.get(name); - } - } - } - - void setRegisterValue(String name, Object value) { - Register reg = fRegisters.get(getRegisterPartOfName(name)); - if (reg == null) { + /** + * The name of the function in this frame + */ + final String fFunction; + + /** + * The current program counter in the frame the pc points to the next + * instruction to be executed + */ + int fPC; + + Frame(String function, int pc) { + fFunction = function; + fPC = pc; + } + + void set(String name, Object value) { + if (name.startsWith("$")) { //$NON-NLS-1$ + setRegisterValue(name, value); + } else { + fLocalVariables.put(name, value); + } + } + + Object get(String name) { + if (name.startsWith("$")) { //$NON-NLS-1$ + return getRegisterValue(name); + } else { + return fLocalVariables.get(name); + } + } + } + + void setRegisterValue(String name, Object value) { + Register reg = fRegisters.get(getRegisterPartOfName(name)); + if (reg == null) { return; } - String bitFieldName = getBitFieldPartOfName(name); - if (bitFieldName != null) { - BitField bitField = reg.fBitFields.get(bitFieldName); - if (bitField == null) { + String bitFieldName = getBitFieldPartOfName(name); + if (bitFieldName != null) { + BitField bitField = reg.fBitFields.get(bitFieldName); + if (bitField == null) { return; } - Integer intValue = null; - if (value instanceof Integer) { - intValue = (Integer)value; - } else if (value instanceof String) { - intValue = bitField.fMnemonics.get(value); - } - if (intValue != null) { - int bitFieldMask = 2^(bitField.fBitCount - 1); - int registerMask = ~(bitFieldMask << bitField.fBitOffset); - int bitFieldValue = intValue.intValue() & bitFieldMask; - reg.fValue = (reg.fValue & registerMask) | (bitFieldValue << bitField.fBitOffset); - } - } else if (value instanceof Integer) { - reg.fValue = ((Integer)value).intValue(); - } - } - - Object getRegisterValue(String name) { - Register reg = fRegisters.get(getRegisterPartOfName(name)); - if (reg == null) { + Integer intValue = null; + if (value instanceof Integer) { + intValue = (Integer)value; + } else if (value instanceof String) { + intValue = bitField.fMnemonics.get(value); + } + if (intValue != null) { + int bitFieldMask = 2^(bitField.fBitCount - 1); + int registerMask = ~(bitFieldMask << bitField.fBitOffset); + int bitFieldValue = intValue.intValue() & bitFieldMask; + reg.fValue = (reg.fValue & registerMask) | (bitFieldValue << bitField.fBitOffset); + } + } else if (value instanceof Integer) { + reg.fValue = ((Integer)value).intValue(); + } + } + + Object getRegisterValue(String name) { + Register reg = fRegisters.get(getRegisterPartOfName(name)); + if (reg == null) { return null; } - String bitFieldName = getBitFieldPartOfName(name); - if (bitFieldName != null) { - BitField bitField = reg.fBitFields.get(bitFieldName); - if (bitField == null) { + String bitFieldName = getBitFieldPartOfName(name); + if (bitFieldName != null) { + BitField bitField = reg.fBitFields.get(bitFieldName); + if (bitField == null) { return null; } - int bitFieldMask = 2^(bitField.fBitCount - 1); - int registerMask = bitFieldMask << bitField.fBitOffset; - return Integer.valueOf( (reg.fValue & registerMask) >> bitField.fBitOffset ); - } else { - return Integer.valueOf(reg.fValue); - } - } - - /** - * Breakpoints are stored per each each line of code. The boolean indicates - * whether the whole VM should suspend or just the triggering thread. - */ + int bitFieldMask = 2^(bitField.fBitCount - 1); + int registerMask = bitFieldMask << bitField.fBitOffset; + return Integer.valueOf( (reg.fValue & registerMask) >> bitField.fBitOffset ); + } else { + return Integer.valueOf(reg.fValue); + } + } + + /** + * Breakpoints are stored per each each line of code. The boolean indicates + * whether the whole VM should suspend or just the triggering thread. + */ final Map<Integer, Boolean> fBreakpoints = new HashMap<>(); - /** - * The suspend flag is true if the VM should suspend running the program and - * just listen for debug commands. - */ - String fSuspendVM; + /** + * The suspend flag is true if the VM should suspend running the program and + * just listen for debug commands. + */ + String fSuspendVM; - /** Flag indicating whether the debugger is performing a step. */ - boolean fStepVM = false; + /** Flag indicating whether the debugger is performing a step. */ + boolean fStepVM = false; - /** Flag indicating whether the debugger is performing a step return */ - boolean fStepReturnVM = false; + /** Flag indicating whether the debugger is performing a step return */ + boolean fStepReturnVM = false; - int fSteppingThread = 0; + int fSteppingThread = 0; - /** Name of the pda program being debugged */ - final String fFilename; + /** Name of the pda program being debugged */ + final String fFilename; - /** The command line argument to start a debug session. */ - final boolean fDebug; + /** The command line argument to start a debug session. */ + final boolean fDebug; - /** The port to listen for debug commands on */ - final int fCommandPort; + /** The port to listen for debug commands on */ + final int fCommandPort; - /** - * Command socket for receiving debug commands and sending command responses - */ - Socket fCommandSocket; + /** + * Command socket for receiving debug commands and sending command responses + */ + Socket fCommandSocket; - /** Command socket reader */ - BufferedReader fCommandReceiveStream; + /** Command socket reader */ + BufferedReader fCommandReceiveStream; - /** Command socket write stream. */ - OutputStream fCommandResponseStream; + /** Command socket write stream. */ + OutputStream fCommandResponseStream; - /** The port to send debug events to */ - final int fEventPort; + /** The port to send debug events to */ + final int fEventPort; - /** Event socket */ - Socket fEventSocket; + /** Event socket */ + Socket fEventSocket; - /** Event socket and write stream. */ - OutputStream fEventStream; + /** Event socket and write stream. */ + OutputStream fEventStream; - /** The eventstops table holds which events cause suspends and which do not. */ + /** The eventstops table holds which events cause suspends and which do not. */ final Map<String, Boolean> fEventStops = new HashMap<>(); - { - fEventStops.put("unimpinstr", Boolean.FALSE); //$NON-NLS-1$ - fEventStops.put("nosuchlabel", Boolean.FALSE); //$NON-NLS-1$ - } - - /** - * The watchpoints table holds watchpoint information. - * <p/> - * variablename_stackframedepth => N - * <ul> - * <li>N = 0 is no watch</li> - * <li>N = 1 is read watch</li> - * <li>N = 2 is write watch</li> - * <li>N = 3 is both, etc.</li> - */ + { + fEventStops.put("unimpinstr", Boolean.FALSE); //$NON-NLS-1$ + fEventStops.put("nosuchlabel", Boolean.FALSE); //$NON-NLS-1$ + } + + /** + * The watchpoints table holds watchpoint information. + * <p/> + * variablename_stackframedepth => N + * <ul> + * <li>N = 0 is no watch</li> + * <li>N = 1 is read watch</li> + * <li>N = 2 is write watch</li> + * <li>N = 3 is both, etc.</li> + */ final Map<String, Integer> fWatchpoints = new HashMap<>(); - public static void main(String[] args) { - String programFile = args.length >= 1 ? args[0] : null; - if (programFile == null) { - System.err.println("Error: No program specified"); //$NON-NLS-1$ - return; - } - - String debugFlag = args.length >= 2 ? args[1] : ""; //$NON-NLS-1$ - boolean debug = "-debug".equals(debugFlag); //$NON-NLS-1$ - int commandPort = 0; - int eventPort = 0; - - if (debug) { - String commandPortStr = args.length >= 3 ? args[2] : ""; //$NON-NLS-1$ - try { - commandPort = Integer.parseInt(commandPortStr); - } catch (NumberFormatException e) { - System.err.println("Error: Invalid command port"); //$NON-NLS-1$ - return; - } - - String eventPortStr = args.length >= 4 ? args[3] : ""; //$NON-NLS-1$ - try { - eventPort = Integer.parseInt(eventPortStr); - } catch (NumberFormatException e) { - System.err.println("Error: Invalid event port"); //$NON-NLS-1$ - return; - } - } - - PDAVirtualMachine pdaVM = null; - try { - pdaVM = new PDAVirtualMachine(programFile, debug, commandPort, eventPort); - pdaVM.startDebugger(); - } catch (IOException e) { - System.err.println("Error: " + e.toString()); //$NON-NLS-1$ - return; - } - pdaVM.run(); - } - - PDAVirtualMachine(String inputFile, boolean debug, int commandPort, int eventPort) throws IOException { - fFilename = inputFile; - - // Load all the code into memory - StringWriter stringWriter = new StringWriter(); + public static void main(String[] args) { + String programFile = args.length >= 1 ? args[0] : null; + if (programFile == null) { + System.err.println("Error: No program specified"); //$NON-NLS-1$ + return; + } + + String debugFlag = args.length >= 2 ? args[1] : ""; //$NON-NLS-1$ + boolean debug = "-debug".equals(debugFlag); //$NON-NLS-1$ + int commandPort = 0; + int eventPort = 0; + + if (debug) { + String commandPortStr = args.length >= 3 ? args[2] : ""; //$NON-NLS-1$ + try { + commandPort = Integer.parseInt(commandPortStr); + } catch (NumberFormatException e) { + System.err.println("Error: Invalid command port"); //$NON-NLS-1$ + return; + } + + String eventPortStr = args.length >= 4 ? args[3] : ""; //$NON-NLS-1$ + try { + eventPort = Integer.parseInt(eventPortStr); + } catch (NumberFormatException e) { + System.err.println("Error: Invalid event port"); //$NON-NLS-1$ + return; + } + } + + PDAVirtualMachine pdaVM = null; + try { + pdaVM = new PDAVirtualMachine(programFile, debug, commandPort, eventPort); + pdaVM.startDebugger(); + } catch (IOException e) { + System.err.println("Error: " + e.toString()); //$NON-NLS-1$ + return; + } + pdaVM.run(); + } + + PDAVirtualMachine(String inputFile, boolean debug, int commandPort, int eventPort) throws IOException { + fFilename = inputFile; + + // Load all the code into memory + StringWriter stringWriter = new StringWriter(); List<String> code = new LinkedList<>(); try (FileReader fileReader = new FileReader(inputFile)) { - int c = fileReader.read(); - while (c != -1) { - if (c == '\n') { - code.add(stringWriter.toString().trim()); - stringWriter = new StringWriter(); - } else { - stringWriter.write(c); - } - c = fileReader.read(); - } - } - - code.add(stringWriter.toString().trim()); - fCode = code.toArray(new String[code.size()]); - - fLabels = mapLabels(fCode); - - fDebug = debug; - fCommandPort = commandPort; - fEventPort = eventPort; - } - - /** - * Initializes the labels map - */ + int c = fileReader.read(); + while (c != -1) { + if (c == '\n') { + code.add(stringWriter.toString().trim()); + stringWriter = new StringWriter(); + } else { + stringWriter.write(c); + } + c = fileReader.read(); + } + } + + code.add(stringWriter.toString().trim()); + fCode = code.toArray(new String[code.size()]); + + fLabels = mapLabels(fCode); + + fDebug = debug; + fCommandPort = commandPort; + fEventPort = eventPort; + } + + /** + * Initializes the labels map + */ Map<String, Integer> mapLabels(String[] code) { Map<String, Integer> labels = new HashMap<>(); - for (int i = 0; i < code.length; i++) { - if (code[i].length() != 0 && code[i].charAt(0) == ':') { - labels.put(code[i].substring(1), Integer.valueOf(i)); - } - } - return labels; - } - - void sendCommandResponse(String response) { - try { - fCommandResponseStream.write(response.getBytes()); - fCommandResponseStream.flush(); - } catch (IOException e) { - } - } - - void sendDebugEvent(String event, boolean error) { - if (fDebug) { - try { - fEventStream.write(event.getBytes()); - fEventStream.write('\n'); - fEventStream.flush(); - } catch (IOException e) { - System.err.println("Error: " + e); //$NON-NLS-1$ - System.exit(1); - } - } else if (error) { - System.err.println("Error: " + event); //$NON-NLS-1$ - } - } - - void startDebugger() throws IOException { - if (fDebug) { - System.out.println("-debug " + fCommandPort + " " + fEventPort); //$NON-NLS-1$ //$NON-NLS-2$ - } + for (int i = 0; i < code.length; i++) { + if (code[i].length() != 0 && code[i].charAt(0) == ':') { + labels.put(code[i].substring(1), Integer.valueOf(i)); + } + } + return labels; + } + + void sendCommandResponse(String response) { + try { + fCommandResponseStream.write(response.getBytes()); + fCommandResponseStream.flush(); + } catch (IOException e) { + } + } + + void sendDebugEvent(String event, boolean error) { + if (fDebug) { + try { + fEventStream.write(event.getBytes()); + fEventStream.write('\n'); + fEventStream.flush(); + } catch (IOException e) { + System.err.println("Error: " + e); //$NON-NLS-1$ + System.exit(1); + } + } else if (error) { + System.err.println("Error: " + event); //$NON-NLS-1$ + } + } + + void startDebugger() throws IOException { + if (fDebug) { + System.out.println("-debug " + fCommandPort + " " + fEventPort); //$NON-NLS-1$ //$NON-NLS-2$ + } try (ServerSocket commandServerSocket = new ServerSocket(fCommandPort)) { fCommandSocket = commandServerSocket.accept(); @@ -463,104 +463,104 @@ public class PDAVirtualMachine { } try (ServerSocket eventServerSocket = new ServerSocket(fEventPort)) { - fEventSocket = eventServerSocket.accept(); - fEventStream = new PrintStream(fEventSocket.getOutputStream()); - } - - System.out.println("debug connection accepted"); //$NON-NLS-1$ - - fSuspendVM = "client"; //$NON-NLS-1$ - } - - void run() { - int id = fNextThreadId++; - sendDebugEvent("vmstarted", false); //$NON-NLS-1$ - fThreads.put(Integer.valueOf(id), new PDAThread(id, "main", 0)); //$NON-NLS-1$ - if (fDebug) { - sendDebugEvent("started " + id, false); //$NON-NLS-1$ - } - - boolean allThreadsSuspended = false; - while (!fThreads.isEmpty()) { - checkForBreakpoint(); - - if (fSuspendVM != null) { - debugUI(); - } else { - yieldToDebug(allThreadsSuspended); - if (fSuspendVM != null) { - // Received a command to suspend VM, skip executing threads. - continue; - } - } - - PDAThread[] threadsCopy = fThreads.values().toArray(new PDAThread[fThreads.size()]); - allThreadsSuspended = true; - for (int i = 0; i < threadsCopy.length; i++) { - PDAThread thread = threadsCopy[i]; - if (thread.fSuspend == null) { - allThreadsSuspended = false; - - String instruction = thread.fThreadCode[thread.fCurrentFrame.fPC]; - thread.fCurrentFrame.fPC++; - doOneInstruction(thread, instruction); - if (thread.fCurrentFrame.fPC >= thread.fThreadCode.length) { - // Thread reached end of code, exit from the thread. - thread.fRun = false; - } else if (thread.fStepReturn) { - // If this thread is in a step-return operation, check - // if we've returned from a call. - instruction = thread.fThreadCode[thread.fCurrentFrame.fPC]; - if ("return".equals(instruction)) { //$NON-NLS-1$ - // Note: this will only be triggered if the current - // thread also has the fStepReturn flag set. - if (fStepReturnVM) { - fSuspendVM = thread.fID + " step"; //$NON-NLS-1$ - } else { - thread.fSuspend = "step"; //$NON-NLS-1$ - } - } - } - if (!thread.fRun) { - sendDebugEvent("exited " + thread.fID, false); //$NON-NLS-1$ - fThreads.remove(Integer.valueOf(thread.fID)); - } else if (thread.fSuspend != null) { - sendDebugEvent("suspended " + thread.fID + " " + thread.fSuspend, false); //$NON-NLS-1$ //$NON-NLS-2$ - thread.fStep = thread.fStepReturn = thread.fPerformingEval = false; - } - } - } - - // Force thread context switch to avoid starving out other - // processes in the system. - Thread.yield(); - } - - sendDebugEvent("vmterminated", false); //$NON-NLS-1$ - if (fDebug) { - try { - fCommandReceiveStream.close(); - fCommandResponseStream.close(); - fCommandSocket.close(); - fEventStream.close(); - fEventSocket.close(); - } catch (IOException e) { - System.out.println("Error: " + e); //$NON-NLS-1$ - } - } - - } - - void doOneInstruction(PDAThread thread, String instr) { - StringTokenizer tokenizer = new StringTokenizer(instr); - String op = tokenizer.nextToken(); + fEventSocket = eventServerSocket.accept(); + fEventStream = new PrintStream(fEventSocket.getOutputStream()); + } + + System.out.println("debug connection accepted"); //$NON-NLS-1$ + + fSuspendVM = "client"; //$NON-NLS-1$ + } + + void run() { + int id = fNextThreadId++; + sendDebugEvent("vmstarted", false); //$NON-NLS-1$ + fThreads.put(Integer.valueOf(id), new PDAThread(id, "main", 0)); //$NON-NLS-1$ + if (fDebug) { + sendDebugEvent("started " + id, false); //$NON-NLS-1$ + } + + boolean allThreadsSuspended = false; + while (!fThreads.isEmpty()) { + checkForBreakpoint(); + + if (fSuspendVM != null) { + debugUI(); + } else { + yieldToDebug(allThreadsSuspended); + if (fSuspendVM != null) { + // Received a command to suspend VM, skip executing threads. + continue; + } + } + + PDAThread[] threadsCopy = fThreads.values().toArray(new PDAThread[fThreads.size()]); + allThreadsSuspended = true; + for (int i = 0; i < threadsCopy.length; i++) { + PDAThread thread = threadsCopy[i]; + if (thread.fSuspend == null) { + allThreadsSuspended = false; + + String instruction = thread.fThreadCode[thread.fCurrentFrame.fPC]; + thread.fCurrentFrame.fPC++; + doOneInstruction(thread, instruction); + if (thread.fCurrentFrame.fPC >= thread.fThreadCode.length) { + // Thread reached end of code, exit from the thread. + thread.fRun = false; + } else if (thread.fStepReturn) { + // If this thread is in a step-return operation, check + // if we've returned from a call. + instruction = thread.fThreadCode[thread.fCurrentFrame.fPC]; + if ("return".equals(instruction)) { //$NON-NLS-1$ + // Note: this will only be triggered if the current + // thread also has the fStepReturn flag set. + if (fStepReturnVM) { + fSuspendVM = thread.fID + " step"; //$NON-NLS-1$ + } else { + thread.fSuspend = "step"; //$NON-NLS-1$ + } + } + } + if (!thread.fRun) { + sendDebugEvent("exited " + thread.fID, false); //$NON-NLS-1$ + fThreads.remove(Integer.valueOf(thread.fID)); + } else if (thread.fSuspend != null) { + sendDebugEvent("suspended " + thread.fID + " " + thread.fSuspend, false); //$NON-NLS-1$ //$NON-NLS-2$ + thread.fStep = thread.fStepReturn = thread.fPerformingEval = false; + } + } + } + + // Force thread context switch to avoid starving out other + // processes in the system. + Thread.yield(); + } + + sendDebugEvent("vmterminated", false); //$NON-NLS-1$ + if (fDebug) { + try { + fCommandReceiveStream.close(); + fCommandResponseStream.close(); + fCommandSocket.close(); + fEventStream.close(); + fEventSocket.close(); + } catch (IOException e) { + System.out.println("Error: " + e); //$NON-NLS-1$ + } + } + + } + + void doOneInstruction(PDAThread thread, String instr) { + StringTokenizer tokenizer = new StringTokenizer(instr); + String op = tokenizer.nextToken(); List<String> tokens = new LinkedList<>(); - while (tokenizer.hasMoreTokens()) { - tokens.add(tokenizer.nextToken()); - } - Args args = new Args( tokens.toArray(new String[tokens.size()]) ); + while (tokenizer.hasMoreTokens()) { + tokens.add(tokenizer.nextToken()); + } + Args args = new Args( tokens.toArray(new String[tokens.size()]) ); - boolean opValid = true; + boolean opValid = true; if (op.equals("add")) { //$NON-NLS-1$ iAdd(thread, args); } else if (op.equals("branch_not_zero")) { //$NON-NLS-1$ @@ -590,122 +590,122 @@ public class PDAVirtualMachine { } else if (op.equals("xyzzy")) { //$NON-NLS-1$ iInternalEndEval(thread, args); } else if (op.startsWith(":")) {} // label //$NON-NLS-1$ - else if (op.startsWith("#")) {} // comment //$NON-NLS-1$ - else { - opValid = false; - } - - if (!opValid) { - sendDebugEvent("unimplemented instruction " + op, true); //$NON-NLS-1$ - if ( fEventStops.get("unimpinstr").booleanValue() ) { //$NON-NLS-1$ - fSuspendVM = thread.fID + " event unimpinstr"; //$NON-NLS-1$ - thread.fCurrentFrame.fPC--; - } - } else if (thread.fStep) { - if (fStepVM) { - fSuspendVM = thread.fID + " step"; //$NON-NLS-1$ - fStepVM = false; - } else { - thread.fSuspend = "step"; //$NON-NLS-1$ - } - thread.fStep = false; - } - } - - void checkForBreakpoint() { - if (fDebug) { + else if (op.startsWith("#")) {} // comment //$NON-NLS-1$ + else { + opValid = false; + } + + if (!opValid) { + sendDebugEvent("unimplemented instruction " + op, true); //$NON-NLS-1$ + if ( fEventStops.get("unimpinstr").booleanValue() ) { //$NON-NLS-1$ + fSuspendVM = thread.fID + " event unimpinstr"; //$NON-NLS-1$ + thread.fCurrentFrame.fPC--; + } + } else if (thread.fStep) { + if (fStepVM) { + fSuspendVM = thread.fID + " step"; //$NON-NLS-1$ + fStepVM = false; + } else { + thread.fSuspend = "step"; //$NON-NLS-1$ + } + thread.fStep = false; + } + } + + void checkForBreakpoint() { + if (fDebug) { for (Iterator<PDAThread> itr = fThreads.values().iterator(); itr.hasNext();) { - PDAThread thread = itr.next(); - Integer pc = Integer.valueOf(thread.fCurrentFrame.fPC); - // Suspend for breakpoint if: - // - the VM is not yet set to suspend, for e.g. as a result of step end, - // - the thread is not yet suspended and is not performing an evaluation - // - the breakpoints table contains a breakpoint for the given line. - if (fSuspendVM == null && - thread.fSuspend == null && !thread.fPerformingEval && - fBreakpoints.containsKey(pc)) - { - if ( fBreakpoints.get(pc).booleanValue() ) { - fSuspendVM = thread.fID + " breakpoint " + pc; //$NON-NLS-1$ - } else { - thread.fSuspend = "breakpoint " + pc; //$NON-NLS-1$ - thread.fStep = thread.fStepReturn = false; - sendDebugEvent("suspended " + thread.fID + " " + thread.fSuspend, false); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - } - } - - /** - * After each instruction, we check the debug command channel for control input. If - * there are commands, process them. - */ - void yieldToDebug(boolean allThreadsSuspended) { - if (fDebug) { - String line = ""; //$NON-NLS-1$ - try { - if (allThreadsSuspended || fCommandReceiveStream.ready()) { - line = fCommandReceiveStream.readLine(); - processDebugCommand(line); - } - } catch (IOException e) { - System.err.println("Error: " + e); //$NON-NLS-1$ - System.exit(1); - } - } - } - - /** - * Service the debugger commands while the VM is suspended - */ - void debugUI() { - if (!fStarted) { - sendDebugEvent("vmsuspended " + fSuspendVM, false); //$NON-NLS-1$ - } else { - fStarted = false; - } - - // Clear all stepping flags. In case the VM suspended while - // a step operation was being performed for the VM or some thread. - fStepVM = fStepReturnVM = false; + PDAThread thread = itr.next(); + Integer pc = Integer.valueOf(thread.fCurrentFrame.fPC); + // Suspend for breakpoint if: + // - the VM is not yet set to suspend, for e.g. as a result of step end, + // - the thread is not yet suspended and is not performing an evaluation + // - the breakpoints table contains a breakpoint for the given line. + if (fSuspendVM == null && + thread.fSuspend == null && !thread.fPerformingEval && + fBreakpoints.containsKey(pc)) + { + if ( fBreakpoints.get(pc).booleanValue() ) { + fSuspendVM = thread.fID + " breakpoint " + pc; //$NON-NLS-1$ + } else { + thread.fSuspend = "breakpoint " + pc; //$NON-NLS-1$ + thread.fStep = thread.fStepReturn = false; + sendDebugEvent("suspended " + thread.fID + " " + thread.fSuspend, false); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + } + } + } + + /** + * After each instruction, we check the debug command channel for control input. If + * there are commands, process them. + */ + void yieldToDebug(boolean allThreadsSuspended) { + if (fDebug) { + String line = ""; //$NON-NLS-1$ + try { + if (allThreadsSuspended || fCommandReceiveStream.ready()) { + line = fCommandReceiveStream.readLine(); + processDebugCommand(line); + } + } catch (IOException e) { + System.err.println("Error: " + e); //$NON-NLS-1$ + System.exit(1); + } + } + } + + /** + * Service the debugger commands while the VM is suspended + */ + void debugUI() { + if (!fStarted) { + sendDebugEvent("vmsuspended " + fSuspendVM, false); //$NON-NLS-1$ + } else { + fStarted = false; + } + + // Clear all stepping flags. In case the VM suspended while + // a step operation was being performed for the VM or some thread. + fStepVM = fStepReturnVM = false; for (Iterator<PDAThread> itr = fThreads.values().iterator(); itr.hasNext();) { - PDAThread thread = itr.next(); - thread.fSuspend = null; - thread.fStep = thread.fStepReturn = thread.fPerformingEval = false; - } - - while (fSuspendVM != null) { - String line = ""; //$NON-NLS-1$ - try { - line = fCommandReceiveStream.readLine(); - } catch (IOException e) { - System.err.println("Error: " + e); //$NON-NLS-1$ - System.exit(1); - return; - } - processDebugCommand(line); - } - - if (fStepVM || fStepReturnVM) { - sendDebugEvent("vmresumed step", false); //$NON-NLS-1$ - } else { - sendDebugEvent("vmresumed client", false); //$NON-NLS-1$ - } - } - - void processDebugCommand(String line) { - StringTokenizer tokenizer = new StringTokenizer(line.trim()); - if (line.length() == 0) { - return; - } - - String command = tokenizer.nextToken(); + PDAThread thread = itr.next(); + thread.fSuspend = null; + thread.fStep = thread.fStepReturn = thread.fPerformingEval = false; + } + + while (fSuspendVM != null) { + String line = ""; //$NON-NLS-1$ + try { + line = fCommandReceiveStream.readLine(); + } catch (IOException e) { + System.err.println("Error: " + e); //$NON-NLS-1$ + System.exit(1); + return; + } + processDebugCommand(line); + } + + if (fStepVM || fStepReturnVM) { + sendDebugEvent("vmresumed step", false); //$NON-NLS-1$ + } else { + sendDebugEvent("vmresumed client", false); //$NON-NLS-1$ + } + } + + void processDebugCommand(String line) { + StringTokenizer tokenizer = new StringTokenizer(line.trim()); + if (line.length() == 0) { + return; + } + + String command = tokenizer.nextToken(); List<String> tokens = new LinkedList<>(); - while (tokenizer.hasMoreTokens()) { - tokens.add(tokenizer.nextToken()); - } - Args args = new Args( tokens.toArray(new String[tokens.size()])); + while (tokenizer.hasMoreTokens()) { + tokens.add(tokenizer.nextToken()); + } + Args args = new Args( tokens.toArray(new String[tokens.size()])); if ("children".equals(command)) { //$NON-NLS-1$ debugChildren(args); @@ -764,770 +764,770 @@ public class PDAVirtualMachine { } else if ("watch".equals(command)) { //$NON-NLS-1$ debugWatch(args); } else { - sendCommandResponse("error: invalid command\n"); //$NON-NLS-1$ - } - } + sendCommandResponse("error: invalid command\n"); //$NON-NLS-1$ + } + } - void debugChildren(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } + void debugChildren(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } - int sfnumber = args.getNextIntArg(); - String var = args.getNextStringArg(); + int sfnumber = args.getNextIntArg(); + String var = args.getNextStringArg(); - Frame frame = sfnumber >= thread.fFrames.size() - ? thread.fCurrentFrame : (Frame)thread.fFrames.get(sfnumber); + Frame frame = sfnumber >= thread.fFrames.size() + ? thread.fCurrentFrame : (Frame)thread.fFrames.get(sfnumber); - String varDot = var + "."; //$NON-NLS-1$ + String varDot = var + "."; //$NON-NLS-1$ List<String> children = new ArrayList<>(); for (Iterator<String> itr = frame.fLocalVariables.keySet().iterator(); itr.hasNext();) { - String localVar = itr.next(); - if (localVar.startsWith(varDot) && localVar.indexOf('.', varDot.length() + 1) == -1) { - children.add(localVar); - } - } + String localVar = itr.next(); + if (localVar.startsWith(varDot) && localVar.indexOf('.', varDot.length() + 1) == -1) { + children.add(localVar); + } + } - StringBuilder result = new StringBuilder(); + StringBuilder result = new StringBuilder(); for (Iterator<String> itr = children.iterator(); itr.hasNext();) { - result.append(itr.next()); - result.append('|'); - } - result.append('\n'); + result.append(itr.next()); + result.append('|'); + } + result.append('\n'); - sendCommandResponse(result.toString()); - } + sendCommandResponse(result.toString()); + } - void debugClearBreakpoint(Args args) { - int line = args.getNextIntArg(); + void debugClearBreakpoint(Args args) { + int line = args.getNextIntArg(); - fBreakpoints.remove( Integer.valueOf(line) ); - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } + fBreakpoints.remove( Integer.valueOf(line) ); + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } - private static Pattern fPackPattern = Pattern.compile("%([a-fA-F0-9][a-fA-F0-9])"); //$NON-NLS-1$ + private static Pattern fPackPattern = Pattern.compile("%([a-fA-F0-9][a-fA-F0-9])"); //$NON-NLS-1$ - void debugData(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } + void debugData(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } - StringBuilder result = new StringBuilder(); + StringBuilder result = new StringBuilder(); for (Iterator<?> itr = thread.fStack.iterator(); itr.hasNext();) { - result.append(itr.next()); - result.append('|'); - } - result.append('\n'); - sendCommandResponse(result.toString()); - } - - void debugDropFrame(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } - - if (!thread.fFrames.isEmpty()) { - thread.fCurrentFrame = thread.fFrames.remove(thread.fFrames.size() - 1); - } - thread.fCurrentFrame.fPC--; - sendCommandResponse("ok\n"); //$NON-NLS-1$ - if (fSuspendVM != null) { - sendDebugEvent("vmresumed drop", false); //$NON-NLS-1$ - sendDebugEvent("vmsuspended " + thread.fID + " drop", false); //$NON-NLS-1$ //$NON-NLS-2$ - } else { - sendDebugEvent("resumed " + thread.fID + " drop", false); //$NON-NLS-1$ //$NON-NLS-2$ - sendDebugEvent("suspended " + thread.fID + " drop", false); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - void debugEval(Args args) { - if (fSuspendVM != null) { - sendCommandResponse("error: cannot evaluate while vm is suspended\n"); //$NON-NLS-1$ - return; - } - - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } - - if (thread.fSuspend == null) { - sendCommandResponse("error: thread running\n"); //$NON-NLS-1$ - return; - } - - StringTokenizer tokenizer = new StringTokenizer(args.getNextStringArg(), "|"); //$NON-NLS-1$ - tokenizer.countTokens(); - - int numEvalLines = tokenizer.countTokens(); - thread.fThreadCode = new String[fCode.length + numEvalLines + 1]; - System.arraycopy(fCode, 0, thread.fThreadCode, 0, fCode.length); - for (int i = 0; i < numEvalLines; i++) { - String line = tokenizer.nextToken(); - StringBuilder lineBuf = new StringBuilder(line.length()); - Matcher matcher = fPackPattern.matcher(line); - int lastMatchEnd = 0; - while (matcher.find()) { - lineBuf.append(line.substring(lastMatchEnd, matcher.start())); - String charCode = line.substring(matcher.start() + 1, matcher.start() + 3); - try { - lineBuf.append((char) Integer.parseInt(charCode, 16)); - } catch (NumberFormatException e) { - } - lastMatchEnd = matcher.end(); - } - if (lastMatchEnd < line.length()) { - lineBuf.append(line.substring(lastMatchEnd)); - } - thread.fThreadCode[fCode.length + i] = lineBuf.toString(); - } - thread.fThreadCode[fCode.length + numEvalLines] = "xyzzy"; //$NON-NLS-1$ - thread.fThreadLabels = mapLabels(fCode); - - thread.fSavedPC = thread.fCurrentFrame.fPC; - thread.fCurrentFrame.fPC = fCode.length; - thread.fPerformingEval = true; - - thread.fSuspend = null; - - sendCommandResponse("ok\n"); //$NON-NLS-1$ - - sendDebugEvent("resumed " + thread.fID + " eval", false); //$NON-NLS-1$ //$NON-NLS-2$ - } - - void debugEventStop(Args args) { - String event = args.getNextStringArg(); - int stop = args.getNextIntArg(); - fEventStops.put(event, Boolean.valueOf(stop > 0)); - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } - - void debugTerminate() { - sendCommandResponse("ok\n"); //$NON-NLS-1$ - sendDebugEvent("vmterminated", false); //$NON-NLS-1$ - System.exit(0); - } - - void debugFrame(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } - - int sfnumber = args.getNextIntArg(); - Frame frame = null; - if (sfnumber >= thread.fFrames.size()) { - frame = thread.fCurrentFrame; - } else { - frame = thread.fFrames.get(sfnumber); - } - sendCommandResponse(printFrame(frame) + "\n"); //$NON-NLS-1$ - } - - /** - * @param args - */ - void debugGroups(Args args) { + result.append(itr.next()); + result.append('|'); + } + result.append('\n'); + sendCommandResponse(result.toString()); + } + + void debugDropFrame(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } + + if (!thread.fFrames.isEmpty()) { + thread.fCurrentFrame = thread.fFrames.remove(thread.fFrames.size() - 1); + } + thread.fCurrentFrame.fPC--; + sendCommandResponse("ok\n"); //$NON-NLS-1$ + if (fSuspendVM != null) { + sendDebugEvent("vmresumed drop", false); //$NON-NLS-1$ + sendDebugEvent("vmsuspended " + thread.fID + " drop", false); //$NON-NLS-1$ //$NON-NLS-2$ + } else { + sendDebugEvent("resumed " + thread.fID + " drop", false); //$NON-NLS-1$ //$NON-NLS-2$ + sendDebugEvent("suspended " + thread.fID + " drop", false); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + void debugEval(Args args) { + if (fSuspendVM != null) { + sendCommandResponse("error: cannot evaluate while vm is suspended\n"); //$NON-NLS-1$ + return; + } + + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } + + if (thread.fSuspend == null) { + sendCommandResponse("error: thread running\n"); //$NON-NLS-1$ + return; + } + + StringTokenizer tokenizer = new StringTokenizer(args.getNextStringArg(), "|"); //$NON-NLS-1$ + tokenizer.countTokens(); + + int numEvalLines = tokenizer.countTokens(); + thread.fThreadCode = new String[fCode.length + numEvalLines + 1]; + System.arraycopy(fCode, 0, thread.fThreadCode, 0, fCode.length); + for (int i = 0; i < numEvalLines; i++) { + String line = tokenizer.nextToken(); + StringBuilder lineBuf = new StringBuilder(line.length()); + Matcher matcher = fPackPattern.matcher(line); + int lastMatchEnd = 0; + while (matcher.find()) { + lineBuf.append(line.substring(lastMatchEnd, matcher.start())); + String charCode = line.substring(matcher.start() + 1, matcher.start() + 3); + try { + lineBuf.append((char) Integer.parseInt(charCode, 16)); + } catch (NumberFormatException e) { + } + lastMatchEnd = matcher.end(); + } + if (lastMatchEnd < line.length()) { + lineBuf.append(line.substring(lastMatchEnd)); + } + thread.fThreadCode[fCode.length + i] = lineBuf.toString(); + } + thread.fThreadCode[fCode.length + numEvalLines] = "xyzzy"; //$NON-NLS-1$ + thread.fThreadLabels = mapLabels(fCode); + + thread.fSavedPC = thread.fCurrentFrame.fPC; + thread.fCurrentFrame.fPC = fCode.length; + thread.fPerformingEval = true; + + thread.fSuspend = null; + + sendCommandResponse("ok\n"); //$NON-NLS-1$ + + sendDebugEvent("resumed " + thread.fID + " eval", false); //$NON-NLS-1$ //$NON-NLS-2$ + } + + void debugEventStop(Args args) { + String event = args.getNextStringArg(); + int stop = args.getNextIntArg(); + fEventStops.put(event, Boolean.valueOf(stop > 0)); + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } + + void debugTerminate() { + sendCommandResponse("ok\n"); //$NON-NLS-1$ + sendDebugEvent("vmterminated", false); //$NON-NLS-1$ + System.exit(0); + } + + void debugFrame(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } + + int sfnumber = args.getNextIntArg(); + Frame frame = null; + if (sfnumber >= thread.fFrames.size()) { + frame = thread.fCurrentFrame; + } else { + frame = thread.fFrames.get(sfnumber); + } + sendCommandResponse(printFrame(frame) + "\n"); //$NON-NLS-1$ + } + + /** + * @param args + */ + void debugGroups(Args args) { TreeSet<String> groups = new TreeSet<>(); for (Iterator<Register> itr = fRegisters.values().iterator(); itr.hasNext();) { - Register reg = itr.next(); - groups.add(reg.fGroup); - } - StringBuilder response = new StringBuilder(); + Register reg = itr.next(); + groups.add(reg.fGroup); + } + StringBuilder response = new StringBuilder(); for (Iterator<String> itr = groups.iterator(); itr.hasNext();) { - response.append(itr.next()); - response.append('|'); - } - response.append('\n'); - sendCommandResponse(response.toString()); - } - - void debugPopData(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } - - thread.fStack.pop(); - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } - - void debugPushData(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } - - Object val = args.getNextIntOrStringArg(); - thread.fStack.push(val); - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } - - void debugRegisters(Args args) { - String group = args.getNextStringArg(); - - StringBuilder response = new StringBuilder(); + response.append(itr.next()); + response.append('|'); + } + response.append('\n'); + sendCommandResponse(response.toString()); + } + + void debugPopData(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } + + thread.fStack.pop(); + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } + + void debugPushData(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } + + Object val = args.getNextIntOrStringArg(); + thread.fStack.push(val); + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } + + void debugRegisters(Args args) { + String group = args.getNextStringArg(); + + StringBuilder response = new StringBuilder(); for (Iterator<Register> itr = fRegisters.values().iterator(); itr.hasNext();) { - Register reg = itr.next(); - if (group.equals(reg.fGroup)) { - response.append(reg.fName); - response.append(' '); - response.append(reg.fIsWriteable); + Register reg = itr.next(); + if (group.equals(reg.fGroup)) { + response.append(reg.fName); + response.append(' '); + response.append(reg.fIsWriteable); for (Iterator<BitField> itr2 = reg.fBitFields.values().iterator(); itr2.hasNext();) { - BitField bitField = itr2.next(); - response.append('|'); - response.append(bitField.fName); - response.append(' '); - response.append(bitField.fBitOffset); - response.append(' '); - response.append(bitField.fBitCount); - response.append(' '); + BitField bitField = itr2.next(); + response.append('|'); + response.append(bitField.fName); + response.append(' '); + response.append(bitField.fBitOffset); + response.append(' '); + response.append(bitField.fBitCount); + response.append(' '); for (Iterator<Entry<String, Integer>> itr3 = bitField.fMnemonics.entrySet().iterator(); itr3.hasNext();) { Entry<String, Integer> mnemonicEntry = itr3.next(); - response.append(mnemonicEntry.getKey()); - response.append(' '); - response.append(mnemonicEntry.getValue()); - response.append(' '); - } - } - - response.append('#'); - } - } - response.append('\n'); - sendCommandResponse(response.toString()); - } - - /** - * @param args - */ - void debugRestart(Args args) { - fSuspendVM = "restart"; //$NON-NLS-1$ + response.append(mnemonicEntry.getKey()); + response.append(' '); + response.append(mnemonicEntry.getValue()); + response.append(' '); + } + } + + response.append('#'); + } + } + response.append('\n'); + sendCommandResponse(response.toString()); + } + + /** + * @param args + */ + void debugRestart(Args args) { + fSuspendVM = "restart"; //$NON-NLS-1$ for (Iterator<Integer> itr = fThreads.keySet().iterator(); itr.hasNext();) { - Integer id = itr.next(); - sendDebugEvent("exited " + id, false); //$NON-NLS-1$ - } - fThreads.clear(); - - int id = fNextThreadId++; - fThreads.put(Integer.valueOf(id), new PDAThread(id, "main", 0)); //$NON-NLS-1$ - sendDebugEvent("started " + id, false); //$NON-NLS-1$ - - fRegisters.clear(); - - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } - - void debugResume(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } - if (fSuspendVM != null) { - sendCommandResponse("error: cannot resume thread when vm is suspended\n"); //$NON-NLS-1$ - return; - } - if (thread.fSuspend == null) { - sendCommandResponse("error: thread already running\n"); //$NON-NLS-1$ - return; - } - - thread.fSuspend = null; - sendDebugEvent("resumed " + thread.fID + " client", false); //$NON-NLS-1$ //$NON-NLS-2$ - - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } - - void debugSetBreakpoint(Args args) { - int line = args.getNextIntArg(); - int stopVM = args.getNextIntArg(); - - fBreakpoints.put(Integer.valueOf(line), Boolean.valueOf(stopVM != 0)); - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } - - void debugSetData(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } - - int offset = args.getNextIntArg(); - Object val = args.getNextIntOrStringArg(); - - if (offset < thread.fStack.size()) { - thread.fStack.set(offset, val); - } else { - thread.fStack.add(0, val); - } - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } - - void debugSetVariable(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } - - int sfnumber = args.getNextIntArg(); - String var = args.getNextStringArg(); - Object val = args.getNextIntOrStringArg(); - while (args.hasNextArg()) { - val = val.toString() + " " + args.getNextStringArg(); //$NON-NLS-1$ - } - - if (sfnumber >= thread.fFrames.size()) { - thread.fCurrentFrame.set(var, val); - } else { - thread.fFrames.get(sfnumber).set(var, val); - } - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } - - void debugStack(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } - - StringBuilder result = new StringBuilder(); + Integer id = itr.next(); + sendDebugEvent("exited " + id, false); //$NON-NLS-1$ + } + fThreads.clear(); + + int id = fNextThreadId++; + fThreads.put(Integer.valueOf(id), new PDAThread(id, "main", 0)); //$NON-NLS-1$ + sendDebugEvent("started " + id, false); //$NON-NLS-1$ + + fRegisters.clear(); + + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } + + void debugResume(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } + if (fSuspendVM != null) { + sendCommandResponse("error: cannot resume thread when vm is suspended\n"); //$NON-NLS-1$ + return; + } + if (thread.fSuspend == null) { + sendCommandResponse("error: thread already running\n"); //$NON-NLS-1$ + return; + } + + thread.fSuspend = null; + sendDebugEvent("resumed " + thread.fID + " client", false); //$NON-NLS-1$ //$NON-NLS-2$ + + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } + + void debugSetBreakpoint(Args args) { + int line = args.getNextIntArg(); + int stopVM = args.getNextIntArg(); + + fBreakpoints.put(Integer.valueOf(line), Boolean.valueOf(stopVM != 0)); + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } + + void debugSetData(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } + + int offset = args.getNextIntArg(); + Object val = args.getNextIntOrStringArg(); + + if (offset < thread.fStack.size()) { + thread.fStack.set(offset, val); + } else { + thread.fStack.add(0, val); + } + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } + + void debugSetVariable(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } + + int sfnumber = args.getNextIntArg(); + String var = args.getNextStringArg(); + Object val = args.getNextIntOrStringArg(); + while (args.hasNextArg()) { + val = val.toString() + " " + args.getNextStringArg(); //$NON-NLS-1$ + } + + if (sfnumber >= thread.fFrames.size()) { + thread.fCurrentFrame.set(var, val); + } else { + thread.fFrames.get(sfnumber).set(var, val); + } + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } + + void debugStack(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } + + StringBuilder result = new StringBuilder(); for (Iterator<Frame> itr = thread.fFrames.iterator(); itr.hasNext();) { - Frame frame = itr.next(); - result.append(printFrame(frame)); - result.append('#'); - } - result.append(printFrame(thread.fCurrentFrame)); - result.append('\n'); - sendCommandResponse(result.toString()); - } - - void debugStackDepth(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } - sendCommandResponse( Integer.toString(thread.fFrames.size() + 1) + "\n" ); //$NON-NLS-1$ - } - - - /** - * The stack frame output is: frame # frame # frame ... where each frame is: - * filename | line number | function name | var | var | var | var ... - */ - private String printFrame(Frame frame) { - StringBuilder buf = new StringBuilder(); - buf.append(fFilename); - buf.append('|'); - buf.append(frame.fPC); - buf.append('|'); - buf.append(frame.fFunction); + Frame frame = itr.next(); + result.append(printFrame(frame)); + result.append('#'); + } + result.append(printFrame(thread.fCurrentFrame)); + result.append('\n'); + sendCommandResponse(result.toString()); + } + + void debugStackDepth(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } + sendCommandResponse( Integer.toString(thread.fFrames.size() + 1) + "\n" ); //$NON-NLS-1$ + } + + + /** + * The stack frame output is: frame # frame # frame ... where each frame is: + * filename | line number | function name | var | var | var | var ... + */ + private String printFrame(Frame frame) { + StringBuilder buf = new StringBuilder(); + buf.append(fFilename); + buf.append('|'); + buf.append(frame.fPC); + buf.append('|'); + buf.append(frame.fFunction); for (Iterator<String> itr = frame.fLocalVariables.keySet().iterator(); itr.hasNext();) { - String var = itr.next(); - if (var.indexOf('.') == -1) { - buf.append('|'); - buf.append(var); - } - } - return buf.toString(); - } - - void debugState(Args args) { - PDAThread thread = args.getThreadArg(); - String response = null; - if (thread == null) { - response = fSuspendVM == null ? "running" : fSuspendVM; //$NON-NLS-1$ - } else if (fSuspendVM != null) { - response = "vm"; //$NON-NLS-1$ - } else { - response = thread.fSuspend == null ? "running" : thread.fSuspend; //$NON-NLS-1$ - } - sendCommandResponse(response + "\n"); //$NON-NLS-1$ - } - - void debugStep(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } - - // Set suspend to null to allow the debug loop to exit back to the - // instruction loop and thus run an instruction. However, we want to - // come back to the debug loop right away, so the step flag is set to - // true which will cause the suspend flag to get set to true when we - // get to the next instruction. - if (fSuspendVM != null) { - // All threads are suspended, so suspend all threads again when - // step completes. - fSuspendVM = null; - fStepVM = true; - // Also mark the thread that initiated the step to mark it as - // the triggering thread when suspending. - thread.fStep = true; - } else { - if (thread.fSuspend == null) { - sendCommandResponse("error: thread already running\n"); //$NON-NLS-1$ - return; - } - thread.fSuspend = null; - thread.fStep = true; - sendDebugEvent("resumed " + thread.fID + " step", false); //$NON-NLS-1$ //$NON-NLS-2$ - } - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } - - void debugStepReturn(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } - - if (fSuspendVM != null) { - fSuspendVM = null; - fStepReturnVM = true; - thread.fStepReturn = true; - } else { - if (thread.fSuspend == null) { - sendCommandResponse("error: thread running\n"); //$NON-NLS-1$ - return; - } - thread.fSuspend = null; - thread.fStepReturn = true; - sendDebugEvent("resumed " + thread.fID + " step", false); //$NON-NLS-1$ //$NON-NLS-2$ - } - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } - - void debugSuspend(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } - if (fSuspendVM != null) { - sendCommandResponse("error: vm already suspended\n"); //$NON-NLS-1$ - return; - } - if (thread.fSuspend != null) { - sendCommandResponse("error: thread already suspended\n"); //$NON-NLS-1$ - return; - } - - thread.fSuspend = "client"; //$NON-NLS-1$ - sendDebugEvent("suspended " + thread.fID + " client", false); //$NON-NLS-1$ //$NON-NLS-2$ - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } - - void debugThreads() { - StringBuilder response = new StringBuilder(); + String var = itr.next(); + if (var.indexOf('.') == -1) { + buf.append('|'); + buf.append(var); + } + } + return buf.toString(); + } + + void debugState(Args args) { + PDAThread thread = args.getThreadArg(); + String response = null; + if (thread == null) { + response = fSuspendVM == null ? "running" : fSuspendVM; //$NON-NLS-1$ + } else if (fSuspendVM != null) { + response = "vm"; //$NON-NLS-1$ + } else { + response = thread.fSuspend == null ? "running" : thread.fSuspend; //$NON-NLS-1$ + } + sendCommandResponse(response + "\n"); //$NON-NLS-1$ + } + + void debugStep(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } + + // Set suspend to null to allow the debug loop to exit back to the + // instruction loop and thus run an instruction. However, we want to + // come back to the debug loop right away, so the step flag is set to + // true which will cause the suspend flag to get set to true when we + // get to the next instruction. + if (fSuspendVM != null) { + // All threads are suspended, so suspend all threads again when + // step completes. + fSuspendVM = null; + fStepVM = true; + // Also mark the thread that initiated the step to mark it as + // the triggering thread when suspending. + thread.fStep = true; + } else { + if (thread.fSuspend == null) { + sendCommandResponse("error: thread already running\n"); //$NON-NLS-1$ + return; + } + thread.fSuspend = null; + thread.fStep = true; + sendDebugEvent("resumed " + thread.fID + " step", false); //$NON-NLS-1$ //$NON-NLS-2$ + } + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } + + void debugStepReturn(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } + + if (fSuspendVM != null) { + fSuspendVM = null; + fStepReturnVM = true; + thread.fStepReturn = true; + } else { + if (thread.fSuspend == null) { + sendCommandResponse("error: thread running\n"); //$NON-NLS-1$ + return; + } + thread.fSuspend = null; + thread.fStepReturn = true; + sendDebugEvent("resumed " + thread.fID + " step", false); //$NON-NLS-1$ //$NON-NLS-2$ + } + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } + + void debugSuspend(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } + if (fSuspendVM != null) { + sendCommandResponse("error: vm already suspended\n"); //$NON-NLS-1$ + return; + } + if (thread.fSuspend != null) { + sendCommandResponse("error: thread already suspended\n"); //$NON-NLS-1$ + return; + } + + thread.fSuspend = "client"; //$NON-NLS-1$ + sendDebugEvent("suspended " + thread.fID + " client", false); //$NON-NLS-1$ //$NON-NLS-2$ + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } + + void debugThreads() { + StringBuilder response = new StringBuilder(); for (Iterator<Integer> itr = fThreads.keySet().iterator(); itr.hasNext();) { - response.append(itr.next()); - response.append(' '); - } - sendCommandResponse(response.toString().trim() + "\n"); //$NON-NLS-1$ - } - - void debugVar(Args args) { - PDAThread thread = args.getThreadArg(); - if (thread == null) { - sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ - return; - } - - int sfnumber = args.getNextIntArg(); - String var = args.getNextStringArg(); - - Frame frame = sfnumber >= thread.fFrames.size() - ? thread.fCurrentFrame : (Frame)thread.fFrames.get(sfnumber); - - Object val = frame.get(var); - if (val == null) { - sendCommandResponse("error: variable undefined\n"); //$NON-NLS-1$ - } else { - sendCommandResponse(val.toString() + "\n"); //$NON-NLS-1$ - } - } - - void debugVMResume() { - if (fSuspendVM == null) { - sendCommandResponse("error: vm already running\n"); //$NON-NLS-1$ - return; - } - - fSuspendVM = null; - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } - - void debugVMSuspend() { - if (fSuspendVM != null) { - sendCommandResponse("error: vm already suspended\n"); //$NON-NLS-1$ - return; - } - - fSuspendVM = "client"; //$NON-NLS-1$ - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } - - void debugWatch(Args args) { - String funcAndVar = args.getNextStringArg(); - int flags = args.getNextIntArg(); - fWatchpoints.put(funcAndVar, Integer.valueOf(flags)); - sendCommandResponse("ok\n"); //$NON-NLS-1$ - } - - /** - * @param thread - * @param args - */ - void iAdd(PDAThread thread, Args args) { - Object val1 = thread.fStack.pop(); - Object val2 = thread.fStack.pop(); - if (val1 instanceof Integer && val2 instanceof Integer) { - int intVal1 = ((Integer) val1).intValue(); - int intVal2 = ((Integer) val2).intValue(); - thread.fStack.push( Integer.valueOf(intVal1 + intVal2) ); - } else { - thread.fStack.push( Integer.valueOf(-1) ); - } - } - - void iBranchNotZero(PDAThread thread, Args args) { - Object val = thread.fStack.pop(); - if (val instanceof Integer && ((Integer) val).intValue() != 0) { - String label = args.getNextStringArg(); - if (thread.fThreadLabels.containsKey(label)) { - thread.fCurrentFrame.fPC = thread.fThreadLabels.get(label).intValue(); - } else { - sendDebugEvent("no such label " + label, true); //$NON-NLS-1$ - if ( fEventStops.get("nosuchlabel").booleanValue() ) { //$NON-NLS-1$ - fSuspendVM = thread.fID + " event nosuchlabel"; //$NON-NLS-1$ - thread.fStack.push(val); - thread.fCurrentFrame.fPC--; - } - } - } - } - - void iCall(PDAThread thread, Args args) { - String label = args.getNextStringArg(); - if (thread.fThreadLabels.containsKey(label)) { - thread.fFrames.add(thread.fCurrentFrame); - thread.fCurrentFrame = new Frame(label, thread.fThreadLabels.get(label).intValue()); - } else { - sendDebugEvent("no such label " + label, true); //$NON-NLS-1$ - if ( fEventStops.get("nosuchlabel").booleanValue() ) { //$NON-NLS-1$ - fSuspendVM = thread.fID + " event nosuchlabel"; //$NON-NLS-1$ - thread.fCurrentFrame.fPC--; - } - } - } - - /** - * @param thread - * @param args - */ - void iDec(PDAThread thread, Args args) { - Object val = thread.fStack.pop(); - if (val instanceof Integer) { - val = Integer.valueOf(((Integer) val).intValue() - 1); - } - thread.fStack.push(val); - } - - /** - * @param thread - * @param args - */ - void iDef(PDAThread thread, Args args) { - String type = args.getNextStringArg(); - - String name = args.getNextStringArg(); - String regName = getRegisterPartOfName(name); - String bitFieldName = getBitFieldPartOfName(name); - - if ("register".equals(type)) { //$NON-NLS-1$ - Register reg = new Register(regName); - reg.fGroup = args.getNextStringArg(); - fRegisters.put(regName, reg); - reg.fIsWriteable = args.getNextBooleanArg(); - } else if ("bitfield".equals(type)) { //$NON-NLS-1$ - Register reg = fRegisters.get(regName); - if (reg == null) { + response.append(itr.next()); + response.append(' '); + } + sendCommandResponse(response.toString().trim() + "\n"); //$NON-NLS-1$ + } + + void debugVar(Args args) { + PDAThread thread = args.getThreadArg(); + if (thread == null) { + sendCommandResponse("error: invalid thread\n"); //$NON-NLS-1$ + return; + } + + int sfnumber = args.getNextIntArg(); + String var = args.getNextStringArg(); + + Frame frame = sfnumber >= thread.fFrames.size() + ? thread.fCurrentFrame : (Frame)thread.fFrames.get(sfnumber); + + Object val = frame.get(var); + if (val == null) { + sendCommandResponse("error: variable undefined\n"); //$NON-NLS-1$ + } else { + sendCommandResponse(val.toString() + "\n"); //$NON-NLS-1$ + } + } + + void debugVMResume() { + if (fSuspendVM == null) { + sendCommandResponse("error: vm already running\n"); //$NON-NLS-1$ + return; + } + + fSuspendVM = null; + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } + + void debugVMSuspend() { + if (fSuspendVM != null) { + sendCommandResponse("error: vm already suspended\n"); //$NON-NLS-1$ + return; + } + + fSuspendVM = "client"; //$NON-NLS-1$ + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } + + void debugWatch(Args args) { + String funcAndVar = args.getNextStringArg(); + int flags = args.getNextIntArg(); + fWatchpoints.put(funcAndVar, Integer.valueOf(flags)); + sendCommandResponse("ok\n"); //$NON-NLS-1$ + } + + /** + * @param thread + * @param args + */ + void iAdd(PDAThread thread, Args args) { + Object val1 = thread.fStack.pop(); + Object val2 = thread.fStack.pop(); + if (val1 instanceof Integer && val2 instanceof Integer) { + int intVal1 = ((Integer) val1).intValue(); + int intVal2 = ((Integer) val2).intValue(); + thread.fStack.push( Integer.valueOf(intVal1 + intVal2) ); + } else { + thread.fStack.push( Integer.valueOf(-1) ); + } + } + + void iBranchNotZero(PDAThread thread, Args args) { + Object val = thread.fStack.pop(); + if (val instanceof Integer && ((Integer) val).intValue() != 0) { + String label = args.getNextStringArg(); + if (thread.fThreadLabels.containsKey(label)) { + thread.fCurrentFrame.fPC = thread.fThreadLabels.get(label).intValue(); + } else { + sendDebugEvent("no such label " + label, true); //$NON-NLS-1$ + if ( fEventStops.get("nosuchlabel").booleanValue() ) { //$NON-NLS-1$ + fSuspendVM = thread.fID + " event nosuchlabel"; //$NON-NLS-1$ + thread.fStack.push(val); + thread.fCurrentFrame.fPC--; + } + } + } + } + + void iCall(PDAThread thread, Args args) { + String label = args.getNextStringArg(); + if (thread.fThreadLabels.containsKey(label)) { + thread.fFrames.add(thread.fCurrentFrame); + thread.fCurrentFrame = new Frame(label, thread.fThreadLabels.get(label).intValue()); + } else { + sendDebugEvent("no such label " + label, true); //$NON-NLS-1$ + if ( fEventStops.get("nosuchlabel").booleanValue() ) { //$NON-NLS-1$ + fSuspendVM = thread.fID + " event nosuchlabel"; //$NON-NLS-1$ + thread.fCurrentFrame.fPC--; + } + } + } + + /** + * @param thread + * @param args + */ + void iDec(PDAThread thread, Args args) { + Object val = thread.fStack.pop(); + if (val instanceof Integer) { + val = Integer.valueOf(((Integer) val).intValue() - 1); + } + thread.fStack.push(val); + } + + /** + * @param thread + * @param args + */ + void iDef(PDAThread thread, Args args) { + String type = args.getNextStringArg(); + + String name = args.getNextStringArg(); + String regName = getRegisterPartOfName(name); + String bitFieldName = getBitFieldPartOfName(name); + + if ("register".equals(type)) { //$NON-NLS-1$ + Register reg = new Register(regName); + reg.fGroup = args.getNextStringArg(); + fRegisters.put(regName, reg); + reg.fIsWriteable = args.getNextBooleanArg(); + } else if ("bitfield".equals(type)) { //$NON-NLS-1$ + Register reg = fRegisters.get(regName); + if (reg == null) { return; } - BitField bitField = new BitField(bitFieldName); - bitField.fBitOffset = args.getNextIntArg(); - bitField.fBitCount = args.getNextIntArg(); - reg.fBitFields.put(bitFieldName, bitField); - } else if ("mnemonic".equals(type)) { //$NON-NLS-1$ - Register reg = fRegisters.get(regName); - if (reg == null) { + BitField bitField = new BitField(bitFieldName); + bitField.fBitOffset = args.getNextIntArg(); + bitField.fBitCount = args.getNextIntArg(); + reg.fBitFields.put(bitFieldName, bitField); + } else if ("mnemonic".equals(type)) { //$NON-NLS-1$ + Register reg = fRegisters.get(regName); + if (reg == null) { return; } - BitField bitField = reg.fBitFields.get(bitFieldName); - if (bitField == null) { + BitField bitField = reg.fBitFields.get(bitFieldName); + if (bitField == null) { return; } - bitField.fMnemonics.put(args.getNextStringArg(), Integer.valueOf(args.getNextIntArg())); - } - sendDebugEvent("registers", false); //$NON-NLS-1$ - } - - private String getRegisterPartOfName(String name) { - if (name.startsWith("$")) { //$NON-NLS-1$ - int end = name.indexOf('.'); - end = end != -1 ? end : name.length(); - return name.substring(1, end); - } - return null; - } - - private String getBitFieldPartOfName(String name) { - int start = name.indexOf('.'); - if (name.startsWith("$") && start != -1) { //$NON-NLS-1$ - return name.substring(start + 1, name.length()); - } - return null; - } - - /** - * @param thread - * @param args - */ - void iDup(PDAThread thread, Args args) { - Object val = thread.fStack.pop(); - thread.fStack.push(val); - thread.fStack.push(val); - } - - void iExec(PDAThread thread, Args args) { - String label = args.getNextStringArg(); - if (fLabels.containsKey(label)) { - int id = fNextThreadId++; - fThreads.put( Integer.valueOf(id), new PDAThread(id, label, fLabels.get(label).intValue()) ); - sendDebugEvent("started " + id, false); //$NON-NLS-1$ - } else { - sendDebugEvent("no such label " + label, true); //$NON-NLS-1$ - if ( fEventStops.get("nosuchlabel").booleanValue() ) { //$NON-NLS-1$ - thread.fSuspend = "event nosuchlabel"; //$NON-NLS-1$ - thread.fCurrentFrame.fPC--; - } - } - } - - /** - * @param thread - * @param args - */ - void iHalt(PDAThread thread, Args args) { - thread.fRun = false; - } - - /** - * @param thread - * @param args - */ - void iOutput(PDAThread thread, Args args) { - System.out.println(thread.fStack.pop()); - } - - void iPop(PDAThread thread, Args args) { - String arg = args.getNextStringArg(); - if (arg.startsWith("$")) { //$NON-NLS-1$ - String var = arg.substring(1); - thread.fCurrentFrame.set(var, thread.fStack.pop()); - String key = thread.fCurrentFrame.fFunction + "::" + var; //$NON-NLS-1$ - if ( fWatchpoints.containsKey(key) && (fWatchpoints.get(key).intValue() & 2) != 0 ) { - fSuspendVM = thread.fID + " watch write " + key; //$NON-NLS-1$ - } - } else { - thread.fStack.pop(); - } - } - - void iPush(PDAThread thread, Args args) { - String arg = args.getNextStringArg(); - while (arg.length() != 0) { - if (arg.startsWith("$")) { //$NON-NLS-1$ - String var = arg.substring(1); - Object val = thread.fCurrentFrame.get(var); - if (val == null) + bitField.fMnemonics.put(args.getNextStringArg(), Integer.valueOf(args.getNextIntArg())); + } + sendDebugEvent("registers", false); //$NON-NLS-1$ + } + + private String getRegisterPartOfName(String name) { + if (name.startsWith("$")) { //$NON-NLS-1$ + int end = name.indexOf('.'); + end = end != -1 ? end : name.length(); + return name.substring(1, end); + } + return null; + } + + private String getBitFieldPartOfName(String name) { + int start = name.indexOf('.'); + if (name.startsWith("$") && start != -1) { //$NON-NLS-1$ + return name.substring(start + 1, name.length()); + } + return null; + } + + /** + * @param thread + * @param args + */ + void iDup(PDAThread thread, Args args) { + Object val = thread.fStack.pop(); + thread.fStack.push(val); + thread.fStack.push(val); + } + + void iExec(PDAThread thread, Args args) { + String label = args.getNextStringArg(); + if (fLabels.containsKey(label)) { + int id = fNextThreadId++; + fThreads.put( Integer.valueOf(id), new PDAThread(id, label, fLabels.get(label).intValue()) ); + sendDebugEvent("started " + id, false); //$NON-NLS-1$ + } else { + sendDebugEvent("no such label " + label, true); //$NON-NLS-1$ + if ( fEventStops.get("nosuchlabel").booleanValue() ) { //$NON-NLS-1$ + thread.fSuspend = "event nosuchlabel"; //$NON-NLS-1$ + thread.fCurrentFrame.fPC--; + } + } + } + + /** + * @param thread + * @param args + */ + void iHalt(PDAThread thread, Args args) { + thread.fRun = false; + } + + /** + * @param thread + * @param args + */ + void iOutput(PDAThread thread, Args args) { + System.out.println(thread.fStack.pop()); + } + + void iPop(PDAThread thread, Args args) { + String arg = args.getNextStringArg(); + if (arg.startsWith("$")) { //$NON-NLS-1$ + String var = arg.substring(1); + thread.fCurrentFrame.set(var, thread.fStack.pop()); + String key = thread.fCurrentFrame.fFunction + "::" + var; //$NON-NLS-1$ + if ( fWatchpoints.containsKey(key) && (fWatchpoints.get(key).intValue() & 2) != 0 ) { + fSuspendVM = thread.fID + " watch write " + key; //$NON-NLS-1$ + } + } else { + thread.fStack.pop(); + } + } + + void iPush(PDAThread thread, Args args) { + String arg = args.getNextStringArg(); + while (arg.length() != 0) { + if (arg.startsWith("$")) { //$NON-NLS-1$ + String var = arg.substring(1); + Object val = thread.fCurrentFrame.get(var); + if (val == null) { val = "<undefined>"; //$NON-NLS-1$ } - thread.fStack.push(val); - String key = thread.fCurrentFrame.fFunction + "::" + var; //$NON-NLS-1$ - if (fWatchpoints.containsKey(key) && (fWatchpoints.get(key).intValue() & 1) != 0) { - fSuspendVM = thread.fID + " watch read " + key; //$NON-NLS-1$ - } - } else { - Object val = arg; - if (args.hasNextArg()) { - while (args.hasNextArg()) { - val = val.toString() + " " + args.getNextStringArg(); //$NON-NLS-1$ - } - } else { - try { - val = Integer.valueOf(arg); - } catch (NumberFormatException e) { - } - } - thread.fStack.push(val); - } - - arg = args.getNextStringArg(); - } - } - - /** - * @param thread - * @param args - */ - void iReturn(PDAThread thread, Args args) { - if (!thread.fFrames.isEmpty()) { - thread.fCurrentFrame = thread.fFrames.remove(thread.fFrames.size() - 1); - } else { - // Execution returned from the top frame, which means this thread - // should exit. - thread.fRun = false; - } - } - - void iVar(PDAThread thread, Args args) { - String var = args.getNextStringArg(); - thread.fCurrentFrame.set(var, Integer.valueOf(0)); - } - - /** - * @param thread - * @param args - */ - void iInternalEndEval(PDAThread thread, Args args) { - Object result = thread.fStack.pop(); - thread.fThreadCode = fCode; - thread.fThreadLabels = fLabels; - thread.fCurrentFrame.fPC = thread.fSavedPC; - sendDebugEvent("evalresult " + result, false); //$NON-NLS-1$ - thread.fSuspend = "eval"; //$NON-NLS-1$ - thread.fPerformingEval = false; - } + thread.fStack.push(val); + String key = thread.fCurrentFrame.fFunction + "::" + var; //$NON-NLS-1$ + if (fWatchpoints.containsKey(key) && (fWatchpoints.get(key).intValue() & 1) != 0) { + fSuspendVM = thread.fID + " watch read " + key; //$NON-NLS-1$ + } + } else { + Object val = arg; + if (args.hasNextArg()) { + while (args.hasNextArg()) { + val = val.toString() + " " + args.getNextStringArg(); //$NON-NLS-1$ + } + } else { + try { + val = Integer.valueOf(arg); + } catch (NumberFormatException e) { + } + } + thread.fStack.push(val); + } + + arg = args.getNextStringArg(); + } + } + + /** + * @param thread + * @param args + */ + void iReturn(PDAThread thread, Args args) { + if (!thread.fFrames.isEmpty()) { + thread.fCurrentFrame = thread.fFrames.remove(thread.fFrames.size() - 1); + } else { + // Execution returned from the top frame, which means this thread + // should exit. + thread.fRun = false; + } + } + + void iVar(PDAThread thread, Args args) { + String var = args.getNextStringArg(); + thread.fCurrentFrame.set(var, Integer.valueOf(0)); + } + + /** + * @param thread + * @param args + */ + void iInternalEndEval(PDAThread thread, Args args) { + Object result = thread.fStack.pop(); + thread.fThreadCode = fCode; + thread.fThreadLabels = fLabels; + thread.fCurrentFrame.fPC = thread.fSavedPC; + sendDebugEvent("evalresult " + result, false); //$NON-NLS-1$ + thread.fSuspend = "eval"; //$NON-NLS-1$ + thread.fPerformingEval = false; + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/breakpoints/PDALineBreakpoint.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/breakpoints/PDALineBreakpoint.java index 2469f6fdb..c1a21a99b 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/breakpoints/PDALineBreakpoint.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/breakpoints/PDALineBreakpoint.java @@ -90,85 +90,85 @@ public class PDALineBreakpoint extends LineBreakpoint implements IPDAEventListen return false; } - /** - * Installs this breakpoint in the given interprettor. - * Registeres this breakpoint as an event listener in the - * given target and creates the breakpoint specific request. - * - * @param target PDA interprettor - * @throws CoreException if installation fails - */ - public void install(PDADebugTarget target) throws CoreException { - fTarget = target; - target.addEventListener(this); - createRequest(target); - } - - /** - * Create the breakpoint specific request in the target. Subclasses - * should override. - * - * @param target PDA interprettor - * @throws CoreException if request creation fails - */ - protected void createRequest(PDADebugTarget target) throws CoreException { + /** + * Installs this breakpoint in the given interprettor. + * Registeres this breakpoint as an event listener in the + * given target and creates the breakpoint specific request. + * + * @param target PDA interprettor + * @throws CoreException if installation fails + */ + public void install(PDADebugTarget target) throws CoreException { + fTarget = target; + target.addEventListener(this); + createRequest(target); + } + + /** + * Create the breakpoint specific request in the target. Subclasses + * should override. + * + * @param target PDA interprettor + * @throws CoreException if request creation fails + */ + protected void createRequest(PDADebugTarget target) throws CoreException { //#ifdef ex3 //# // TODO: Exercise 3 - create breakpoint request in interpreter //#else - target.sendCommand(new PDASetBreakpointCommand((getLineNumber() - 1), false)); + target.sendCommand(new PDASetBreakpointCommand((getLineNumber() - 1), false)); //#endif - } - - /** - * Removes this breakpoint's event request from the target. Subclasses - * should override. - * - * @param target PDA interprettor - * @throws CoreException if clearing the request fails - */ - protected void clearRequest(PDADebugTarget target) throws CoreException { + } + + /** + * Removes this breakpoint's event request from the target. Subclasses + * should override. + * + * @param target PDA interprettor + * @throws CoreException if clearing the request fails + */ + protected void clearRequest(PDADebugTarget target) throws CoreException { //#ifdef ex3 //# // TODO: Exercise 3 - clear breakpoint request in interpreter //#else - target.sendCommand(new PDAClearBreakpointCommand((getLineNumber() - 1))); + target.sendCommand(new PDAClearBreakpointCommand((getLineNumber() - 1))); //#endif - } - - /** - * Removes this breakpoint from the given interprettor. - * Removes this breakpoint as an event listener and clears - * the request for the interprettor. - * - * @param target PDA interprettor - * @throws CoreException if removal fails - */ - public void remove(PDADebugTarget target) throws CoreException { - target.removeEventListener(this); - clearRequest(target); - fTarget = null; - - } - - /** - * Returns the target this breakpoint is installed in or <code>null</code>. - * - * @return the target this breakpoint is installed in or <code>null</code> - */ - protected PDADebugTarget getDebugTarget() { - return fTarget; - } - - /** - * Notify's the PDA interprettor that this breakpoint has been hit. - */ - protected void notifyThread(int threadId) { - if (fTarget != null) { + } + + /** + * Removes this breakpoint from the given interprettor. + * Removes this breakpoint as an event listener and clears + * the request for the interprettor. + * + * @param target PDA interprettor + * @throws CoreException if removal fails + */ + public void remove(PDADebugTarget target) throws CoreException { + target.removeEventListener(this); + clearRequest(target); + fTarget = null; + + } + + /** + * Returns the target this breakpoint is installed in or <code>null</code>. + * + * @return the target this breakpoint is installed in or <code>null</code> + */ + protected PDADebugTarget getDebugTarget() { + return fTarget; + } + + /** + * Notify's the PDA interprettor that this breakpoint has been hit. + */ + protected void notifyThread(int threadId) { + if (fTarget != null) { PDAThread thread = fTarget.getThread(threadId); if (thread != null) { - thread.suspendedBy(this); - } - } - } + thread.suspendedBy(this); + } + } + } /* * Subclasses should override to handle their breakpoint specific event. @@ -176,31 +176,31 @@ public class PDALineBreakpoint extends LineBreakpoint implements IPDAEventListen @Override public void handleEvent(PDAEvent event) { if (event instanceof PDASuspendedEvent || event instanceof PDAVMSuspendedEvent) { - PDARunControlEvent rcEvent = (PDARunControlEvent)event; - if (rcEvent.fReason.equals("breakpoint")) { //$NON-NLS-1$ - handleHit(rcEvent); - } + PDARunControlEvent rcEvent = (PDARunControlEvent)event; + if (rcEvent.fReason.equals("breakpoint")) { //$NON-NLS-1$ + handleHit(rcEvent); + } } } /** - * Determines if this breakpoint was hit and notifies the thread. - * - * @param event breakpoint event - */ - private void handleHit(PDARunControlEvent event) { - int lastSpace = event.fMessage.lastIndexOf(' '); - if (lastSpace > 0) { - String line = event.fMessage.substring(lastSpace + 1); - int lineNumber = Integer.parseInt(line); - // breakpoints event line numbers are 0 based, model objects are 1 based - lineNumber++; - try { + * Determines if this breakpoint was hit and notifies the thread. + * + * @param event breakpoint event + */ + private void handleHit(PDARunControlEvent event) { + int lastSpace = event.fMessage.lastIndexOf(' '); + if (lastSpace > 0) { + String line = event.fMessage.substring(lastSpace + 1); + int lineNumber = Integer.parseInt(line); + // breakpoints event line numbers are 0 based, model objects are 1 based + lineNumber++; + try { if (getLineNumber() == lineNumber) { notifyThread(event.fThreadId); } - } catch (CoreException e) { - } - } - } + } catch (CoreException e) { + } + } + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/breakpoints/PDAWatchpoint.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/breakpoints/PDAWatchpoint.java index 41b0ae901..b126728b0 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/breakpoints/PDAWatchpoint.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/breakpoints/PDAWatchpoint.java @@ -34,14 +34,14 @@ import org.eclipse.debug.examples.core.pda.protocol.PDAWatchCommand; */ public class PDAWatchpoint extends PDALineBreakpoint implements IWatchpoint { - // 'read' or 'write' depending on what caused the last suspend for this watchpoint - private String fLastSuspendType; + // 'read' or 'write' depending on what caused the last suspend for this watchpoint + private String fLastSuspendType; - // marker attributes - public static final String ACCESS = "ACCESS"; //$NON-NLS-1$ - public static final String MODIFICATION = "MODIFICATION"; //$NON-NLS-1$ - public static final String FUNCTION_NAME = "FUNCTION_NAME"; //$NON-NLS-1$ - public static final String VAR_NAME = "VAR_NAME"; //$NON-NLS-1$ + // marker attributes + public static final String ACCESS = "ACCESS"; //$NON-NLS-1$ + public static final String MODIFICATION = "MODIFICATION"; //$NON-NLS-1$ + public static final String FUNCTION_NAME = "FUNCTION_NAME"; //$NON-NLS-1$ + public static final String VAR_NAME = "VAR_NAME"; //$NON-NLS-1$ /** * Default constructor is required for the breakpoint manager @@ -49,7 +49,7 @@ public class PDAWatchpoint extends PDALineBreakpoint implements IWatchpoint { * the <code>setMarker(...)</code> method is called to restore * this breakpoint's attributes. */ - public PDAWatchpoint() { + public PDAWatchpoint() { } /** * Constructs a line breakpoint on the given resource at the given @@ -80,134 +80,134 @@ public class PDAWatchpoint extends PDALineBreakpoint implements IWatchpoint { run(getMarkerRule(resource), runnable); } - @Override + @Override public boolean isAccess() throws CoreException { - return getMarker().getAttribute(ACCESS, true); - } + return getMarker().getAttribute(ACCESS, true); + } - @Override + @Override public void setAccess(boolean access) throws CoreException { - setAttribute(ACCESS, access); - } + setAttribute(ACCESS, access); + } - @Override + @Override public boolean isModification() throws CoreException { - return getMarker().getAttribute(MODIFICATION, true); - } + return getMarker().getAttribute(MODIFICATION, true); + } - @Override + @Override public void setModification(boolean modification) throws CoreException { - setAttribute(MODIFICATION, modification); - } + setAttribute(MODIFICATION, modification); + } - @Override + @Override public boolean supportsAccess() { - return true; - } + return true; + } - @Override + @Override public boolean supportsModification() { - return true; - } - - /** - * Sets the variable and function names the watchpoint is set on. - * - * @param functionName function name - * @param variableName variable name - * @throws CoreException if an exception occurrs setting marker attribtues - */ - protected void setVariable(String functionName, String variableName) throws CoreException { - setAttribute(VAR_NAME, variableName); - setAttribute(FUNCTION_NAME, functionName); - } - - /** - * Returns the name of the variable this watchpoint is set on. - * - * @return the name of the variable this watchpoint is set on - * @throws CoreException if unable to access the attribute - */ - public String getVariableName() throws CoreException { - return getMarker().getAttribute(VAR_NAME, (String)null); - } - - /** - * Returns the name of the function the variable associted with this watchpoint is defined in. - * - * @return the name of the function the variable associted with this watchpoint is defined in - * @throws CoreException if unable to access the attribute - */ - public String getFunctionName() throws CoreException { - return getMarker().getAttribute(FUNCTION_NAME, (String)null); - } - - /** - * Sets the type of event that causes the last suspend event. - * - * @param description one of 'read' or 'write' - */ - public void setSuspendType(String description) { - fLastSuspendType = description; - } - - /** - * Returns the type of event that caused the last suspend. - * - * @return 'read', 'write', or <code>null</code> if undefined - */ - public String getSuspendType() { - return fLastSuspendType; - } + return true; + } + + /** + * Sets the variable and function names the watchpoint is set on. + * + * @param functionName function name + * @param variableName variable name + * @throws CoreException if an exception occurrs setting marker attribtues + */ + protected void setVariable(String functionName, String variableName) throws CoreException { + setAttribute(VAR_NAME, variableName); + setAttribute(FUNCTION_NAME, functionName); + } + + /** + * Returns the name of the variable this watchpoint is set on. + * + * @return the name of the variable this watchpoint is set on + * @throws CoreException if unable to access the attribute + */ + public String getVariableName() throws CoreException { + return getMarker().getAttribute(VAR_NAME, (String)null); + } + + /** + * Returns the name of the function the variable associted with this watchpoint is defined in. + * + * @return the name of the function the variable associted with this watchpoint is defined in + * @throws CoreException if unable to access the attribute + */ + public String getFunctionName() throws CoreException { + return getMarker().getAttribute(FUNCTION_NAME, (String)null); + } + + /** + * Sets the type of event that causes the last suspend event. + * + * @param description one of 'read' or 'write' + */ + public void setSuspendType(String description) { + fLastSuspendType = description; + } + + /** + * Returns the type of event that caused the last suspend. + * + * @return 'read', 'write', or <code>null</code> if undefined + */ + public String getSuspendType() { + return fLastSuspendType; + } @Override protected void createRequest(PDADebugTarget target) throws CoreException { - int flag = 0; - if (isAccess()) { - flag = flag | 1; - } - if (isModification()) { - flag = flag | 2; - } + int flag = 0; + if (isAccess()) { + flag = flag | 1; + } + if (isModification()) { + flag = flag | 2; + } target.sendCommand(new PDAWatchCommand(getFunctionName(), getVariableName(), flag)); } @Override protected void clearRequest(PDADebugTarget target) throws CoreException { - target.sendCommand(new PDAWatchCommand(getFunctionName(), getVariableName(), 0)); + target.sendCommand(new PDAWatchCommand(getFunctionName(), getVariableName(), 0)); } @Override public void handleEvent(PDAEvent event) { - if (event instanceof PDASuspendedEvent || event instanceof PDAVMSuspendedEvent) { - PDARunControlEvent rcEvent = (PDARunControlEvent)event; - if (rcEvent.fReason.equals("watch")) { //$NON-NLS-1$ - handleHit(rcEvent); - } - } + if (event instanceof PDASuspendedEvent || event instanceof PDAVMSuspendedEvent) { + PDARunControlEvent rcEvent = (PDARunControlEvent)event; + if (rcEvent.fReason.equals("watch")) { //$NON-NLS-1$ + handleHit(rcEvent); + } + } } /** - * Determines if this breakpoint was hit and notifies the thread. - * - * @param event breakpoint event - */ - private void handleHit(PDARunControlEvent event) { - String[] strings = event.fMessage.split(" "); //$NON-NLS-1$ - if (strings.length == 4) { - String fv = strings[3]; - int j = fv.indexOf("::"); //$NON-NLS-1$ - if (j > 0) { - String fcn = fv.substring(0, j); - String var = fv.substring(j + 2); + * Determines if this breakpoint was hit and notifies the thread. + * + * @param event breakpoint event + */ + private void handleHit(PDARunControlEvent event) { + String[] strings = event.fMessage.split(" "); //$NON-NLS-1$ + if (strings.length == 4) { + String fv = strings[3]; + int j = fv.indexOf("::"); //$NON-NLS-1$ + if (j > 0) { + String fcn = fv.substring(0, j); + String var = fv.substring(j + 2); try { if (getVariableName().equals(var) && getFunctionName().equals(fcn)) { setSuspendType(strings[2]); - notifyThread(event.fThreadId); + notifyThread(event.fThreadId); } } catch (CoreException e) { } - } - } - } + } + } + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/launcher/PDALaunchDelegate.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/launcher/PDALaunchDelegate.java index 7a37de287..cb5a4223d 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/launcher/PDALaunchDelegate.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/launcher/PDALaunchDelegate.java @@ -55,22 +55,22 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate { List<String> commandList = new ArrayList<>(); - // Get Java VM path - String javaVMHome = System.getProperty("java.home"); //$NON-NLS-1$ - String javaVMExec = javaVMHome + File.separatorChar + "bin" + File.separatorChar + "java"; //$NON-NLS-1$ //$NON-NLS-2$ - if (File.separatorChar == '\\') { - javaVMExec += ".exe"; //$NON-NLS-1$ - } - File exe = new File(javaVMExec); - if (!exe.exists()) { - abort(MessageFormat.format("Specified java VM executable {0} does not exist.", new Object[]{javaVMExec}), null); //$NON-NLS-1$ - } - commandList.add(javaVMExec); - - commandList.add("-cp"); //$NON-NLS-1$ - commandList.add(File.pathSeparator + DebugCorePlugin.getFileInPlugin(new Path("bin"))); //$NON-NLS-1$ - - commandList.add("org.eclipse.debug.examples.pdavm.PDAVirtualMachine"); //$NON-NLS-1$ + // Get Java VM path + String javaVMHome = System.getProperty("java.home"); //$NON-NLS-1$ + String javaVMExec = javaVMHome + File.separatorChar + "bin" + File.separatorChar + "java"; //$NON-NLS-1$ //$NON-NLS-2$ + if (File.separatorChar == '\\') { + javaVMExec += ".exe"; //$NON-NLS-1$ + } + File exe = new File(javaVMExec); + if (!exe.exists()) { + abort(MessageFormat.format("Specified java VM executable {0} does not exist.", new Object[]{javaVMExec}), null); //$NON-NLS-1$ + } + commandList.add(javaVMExec); + + commandList.add("-cp"); //$NON-NLS-1$ + commandList.add(File.pathSeparator + DebugCorePlugin.getFileInPlugin(new Path("bin"))); //$NON-NLS-1$ + + commandList.add("org.eclipse.debug.examples.pdavm.PDAVirtualMachine"); //$NON-NLS-1$ // program name String program = configuration.getAttribute(DebugCorePlugin.ATTR_PDA_PROGRAM, (String)null); diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDADebugElement.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDADebugElement.java index 37fbc949d..338de32e8 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDADebugElement.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDADebugElement.java @@ -45,50 +45,50 @@ public class PDADebugElement extends DebugElement { } /** - * Sends a request to the PDA interpreter, waits for and returns the reply. - * - * @param request command - * @return reply - * @throws DebugException if the request fails - * - * @see org.eclipse.debug.examples.core.pda.protocol.PDATerminateCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDAVMSuspendCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDAVMResumeCommand - * - * @see org.eclipse.debug.examples.core.pda.protocol.PDASuspendCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDAResumeCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDAStepCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDADropFrameCommand - * - * @see org.eclipse.debug.examples.core.pda.protocol.PDASetBreakpointCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDAClearBreakpointCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDAWatchCommand - * - * @see org.eclipse.debug.examples.core.pda.protocol.PDADataCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDASetDataCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDAPopDataCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDAPushDataCommand - * - * @see org.eclipse.debug.examples.core.pda.protocol.PDAEvalCommand - * - * @see org.eclipse.debug.examples.core.pda.protocol.PDAEventStopCommand - * - * @see org.eclipse.debug.examples.core.pda.protocol.PDAStackCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDAStackDepthCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDAFrameCommand - * - * @see org.eclipse.debug.examples.core.pda.protocol.PDASetVarCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDAVarCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDAChildrenCommand - * - * @see org.eclipse.debug.examples.core.pda.protocol.PDAGroupsCommand - * @see org.eclipse.debug.examples.core.pda.protocol.PDARegistersCommand - * - * @since 3.5 - */ + * Sends a request to the PDA interpreter, waits for and returns the reply. + * + * @param request command + * @return reply + * @throws DebugException if the request fails + * + * @see org.eclipse.debug.examples.core.pda.protocol.PDATerminateCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDAVMSuspendCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDAVMResumeCommand + * + * @see org.eclipse.debug.examples.core.pda.protocol.PDASuspendCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDAResumeCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDAStepCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDADropFrameCommand + * + * @see org.eclipse.debug.examples.core.pda.protocol.PDASetBreakpointCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDAClearBreakpointCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDAWatchCommand + * + * @see org.eclipse.debug.examples.core.pda.protocol.PDADataCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDASetDataCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDAPopDataCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDAPushDataCommand + * + * @see org.eclipse.debug.examples.core.pda.protocol.PDAEvalCommand + * + * @see org.eclipse.debug.examples.core.pda.protocol.PDAEventStopCommand + * + * @see org.eclipse.debug.examples.core.pda.protocol.PDAStackCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDAStackDepthCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDAFrameCommand + * + * @see org.eclipse.debug.examples.core.pda.protocol.PDASetVarCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDAVarCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDAChildrenCommand + * + * @see org.eclipse.debug.examples.core.pda.protocol.PDAGroupsCommand + * @see org.eclipse.debug.examples.core.pda.protocol.PDARegistersCommand + * + * @since 3.5 + */ public PDACommandResult sendCommand(PDACommand command) throws DebugException { - return getPDADebugTarget().sendCommand(command); - } + return getPDADebugTarget().sendCommand(command); + } /** * Returns the debug target as a PDA target. @@ -96,15 +96,15 @@ public class PDADebugElement extends DebugElement { * @return PDA debug target */ protected PDADebugTarget getPDADebugTarget() { - return (PDADebugTarget) getDebugTarget(); + return (PDADebugTarget) getDebugTarget(); } /** * Returns the breakpoint manager * - * @return the breakpoint manager - */ - protected IBreakpointManager getBreakpointManager() { - return DebugPlugin.getDefault().getBreakpointManager(); - } + * @return the breakpoint manager + */ + protected IBreakpointManager getBreakpointManager() { + return DebugPlugin.getDefault().getBreakpointManager(); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDADebugTarget.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDADebugTarget.java index daf2a0709..9685b6f6e 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDADebugTarget.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDADebugTarget.java @@ -117,15 +117,15 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr try { message = fEventReader.readLine(); if (message != null) { - PDAEvent event = null; - try { - event = PDAEvent.parseEvent(message); - } - catch (IllegalArgumentException e) { - DebugCorePlugin.getDefault().getLog().log( - new Status (IStatus.ERROR, "org.eclipse.debug.examples.core", "Error parsing PDA event", e)); //$NON-NLS-1$ //$NON-NLS-2$ - continue; - } + PDAEvent event = null; + try { + event = PDAEvent.parseEvent(message); + } + catch (IllegalArgumentException e) { + DebugCorePlugin.getDefault().getLog().log( + new Status (IStatus.ERROR, "org.eclipse.debug.examples.core", "Error parsing PDA event", e)); //$NON-NLS-1$ //$NON-NLS-2$ + continue; + } Object[] listeners = fEventListeners.toArray(); for (int i = 0; i < listeners.length; i++) { ((IPDAEventListener)listeners[i]).handleEvent(event); @@ -148,11 +148,11 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr * @param listener event listener */ public void addEventListener(IPDAEventListener listener) { - synchronized(fEventListeners) { - if (!fEventListeners.contains(listener)) { - fEventListeners.add(listener); - } - } + synchronized(fEventListeners) { + if (!fEventListeners.contains(listener)) { + fEventListeners.add(listener); + } + } } /** @@ -204,12 +204,12 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr fEventDispatch = new EventDispatchJob(); fEventDispatch.schedule(); IBreakpointManager breakpointManager = getBreakpointManager(); - breakpointManager.addBreakpointListener(this); + breakpointManager.addBreakpointListener(this); breakpointManager.addBreakpointManagerListener(this); // initialize error hanlding to suspend on 'unimplemented instructions' // and 'no such label' errors sendCommand(new PDAEventStopCommand(PDAEventStopCommand.UNIMPINSTR, true)); - sendCommand(new PDAEventStopCommand(PDAEventStopCommand.NOSUCHLABEL, true)); + sendCommand(new PDAEventStopCommand(PDAEventStopCommand.NOSUCHLABEL, true)); } @Override @@ -218,9 +218,9 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr } @Override public IThread[] getThreads() throws DebugException { - synchronized (fThreads) { - return fThreads.values().toArray(new IThread[fThreads.size()]); - } + synchronized (fThreads) { + return fThreads.values().toArray(new IThread[fThreads.size()]); + } } @Override public boolean hasThreads() throws DebugException { @@ -282,7 +282,7 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr //#ifdef ex2 //# // TODO: Exercise 2 - send termination request to interpreter //#else - sendCommand(new PDATerminateCommand()); + sendCommand(new PDATerminateCommand()); //#endif } @@ -303,12 +303,12 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr @Override public void resume() throws DebugException { - sendCommand(new PDAVMResumeCommand()); + sendCommand(new PDAVMResumeCommand()); } @Override public void suspend() throws DebugException { - sendCommand(new PDAVMSuspendCommand()); + sendCommand(new PDAVMSuspendCommand()); } @Override @@ -317,7 +317,7 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr try { if ((breakpoint.isEnabled() && getBreakpointManager().isEnabled()) || !breakpoint.isRegistered()) { PDALineBreakpoint pdaBreakpoint = (PDALineBreakpoint)breakpoint; - pdaBreakpoint.install(this); + pdaBreakpoint.install(this); } } catch (CoreException e) { } @@ -328,7 +328,7 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) { if (supportsBreakpoint(breakpoint)) { try { - PDALineBreakpoint pdaBreakpoint = (PDALineBreakpoint)breakpoint; + PDALineBreakpoint pdaBreakpoint = (PDALineBreakpoint)breakpoint; pdaBreakpoint.remove(this); } catch (CoreException e) { } @@ -405,58 +405,58 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr setTerminated(true); fThreads.clear(); IBreakpointManager breakpointManager = getBreakpointManager(); - breakpointManager.removeBreakpointListener(this); + breakpointManager.removeBreakpointListener(this); breakpointManager.removeBreakpointManagerListener(this); fireTerminateEvent(); removeEventListener(this); } private void vmResumed(PDAVMResumedEvent event) { - setVMSuspended(false); - fireResumeEvent(calcDetail(event.fReason)); + setVMSuspended(false); + fireResumeEvent(calcDetail(event.fReason)); } private void vmSuspended(PDAVMSuspendedEvent event) { - setVMSuspended(true); - fireSuspendEvent(calcDetail(event.fReason)); + setVMSuspended(true); + fireSuspendEvent(calcDetail(event.fReason)); } private int calcDetail(String reason) { - if (reason.equals("breakpoint") || reason.equals("watch")) { //$NON-NLS-1$ //$NON-NLS-2$ - return DebugEvent.BREAKPOINT; - } else if (reason.equals("step")) { //$NON-NLS-1$ - return DebugEvent.STEP_OVER; - } else if (reason.equals("drop")) { //$NON-NLS-1$ - return DebugEvent.STEP_RETURN; - } else if (reason.equals("client")) { //$NON-NLS-1$ - return DebugEvent.CLIENT_REQUEST; - } else if (reason.equals("event")) { //$NON-NLS-1$ - return DebugEvent.BREAKPOINT; - } else { - return DebugEvent.UNSPECIFIED; - } + if (reason.equals("breakpoint") || reason.equals("watch")) { //$NON-NLS-1$ //$NON-NLS-2$ + return DebugEvent.BREAKPOINT; + } else if (reason.equals("step")) { //$NON-NLS-1$ + return DebugEvent.STEP_OVER; + } else if (reason.equals("drop")) { //$NON-NLS-1$ + return DebugEvent.STEP_RETURN; + } else if (reason.equals("client")) { //$NON-NLS-1$ + return DebugEvent.CLIENT_REQUEST; + } else if (reason.equals("event")) { //$NON-NLS-1$ + return DebugEvent.BREAKPOINT; + } else { + return DebugEvent.UNSPECIFIED; + } } private void started(PDAStartedEvent event) { - PDAThread newThread = new PDAThread(this, event.fThreadId); - fThreads.put(Integer.valueOf(event.fThreadId), newThread); - newThread.start(); + PDAThread newThread = new PDAThread(this, event.fThreadId); + fThreads.put(Integer.valueOf(event.fThreadId), newThread); + newThread.start(); } private void exited(PDAExitedEvent event) { - PDAThread thread = fThreads.remove(Integer.valueOf(event.fThreadId)); - if (thread != null) { - thread.exit(); - } + PDAThread thread = fThreads.remove(Integer.valueOf(event.fThreadId)); + if (thread != null) { + thread.exit(); + } } private synchronized void setVMSuspended(boolean suspended) { - fVMSuspended = suspended; + fVMSuspended = suspended; } - private synchronized void setTerminated(boolean terminated) { - fTerminated = terminated; - } + private synchronized void setTerminated(boolean terminated) { + fTerminated = terminated; + } private String sendRequest(String request) throws DebugException { synchronized (fRequestSocket) { @@ -466,7 +466,7 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr // wait for reply String retVal = fRequestReader.readLine(); if (retVal == null) { - requestFailed("Request failed: " + request + ". Debugger connection closed.", null); //$NON-NLS-1$ //$NON-NLS-2$ + requestFailed("Request failed: " + request + ". Debugger connection closed.", null); //$NON-NLS-1$ //$NON-NLS-2$ } return retVal; } catch (IOException e) { @@ -479,8 +479,8 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr @Override public PDACommandResult sendCommand(PDACommand command) throws DebugException { - String response = sendRequest(command.getRequest()); - return command.createResult(response); + String response = sendRequest(command.getRequest()); + return command.createResult(response); } /** @@ -496,7 +496,7 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr } else { breakpointRemoved(breakpoints[i], null); } - } + } } @Override @@ -505,15 +505,15 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr started((PDAStartedEvent)event); } else if (event instanceof PDAExitedEvent) { exited((PDAExitedEvent)event); - } else if (event instanceof PDAVMStartedEvent) { - vmStarted((PDAVMStartedEvent)event); + } else if (event instanceof PDAVMStartedEvent) { + vmStarted((PDAVMStartedEvent)event); } else if (event instanceof PDAVMTerminatedEvent) { - vmTerminated(); - } else if (event instanceof PDAVMSuspendedEvent) { - vmSuspended((PDAVMSuspendedEvent)event); - } else if (event instanceof PDAVMResumedEvent) { - vmResumed((PDAVMResumedEvent)event); - } + vmTerminated(); + } else if (event instanceof PDAVMSuspendedEvent) { + vmSuspended((PDAVMSuspendedEvent)event); + } else if (event instanceof PDAVMResumedEvent) { + vmResumed((PDAVMResumedEvent)event); + } } /** @@ -526,15 +526,15 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr * if terminated */ public PDAThread getThread(int threadId) { - if (threadId > 0) { - return fThreads.get(Integer.valueOf(threadId)); - } else { - synchronized(fThreads) { - if (fThreads.size() > 0) { - return fThreads.values().iterator().next(); - } - } - } + if (threadId > 0) { + return fThreads.get(Integer.valueOf(threadId)); + } else { + synchronized(fThreads) { + if (fThreads.size() > 0) { + return fThreads.values().iterator().next(); + } + } + } return null; } @@ -544,7 +544,7 @@ public class PDADebugTarget extends PDADebugElement implements IDebugTarget, IBr * @throws DebugException */ public void restart() throws DebugException { - sendCommand(new PDARestartCommand()); - } + sendCommand(new PDARestartCommand()); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAStackFrame.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAStackFrame.java index fdd7cde92..761ea8211 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAStackFrame.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAStackFrame.java @@ -221,15 +221,15 @@ public class PDAStackFrame extends PDADebugElement implements IStackFrame { return fId; } - /** - * Returns the stack frame's thread's unique identifier - * - * @return this stack frame's thread's unique identifier - * - * @since 3.5 - */ + /** + * Returns the stack frame's thread's unique identifier + * + * @return this stack frame's thread's unique identifier + * + * @since 3.5 + */ protected int getThreadIdentifier() { - return fThread.getIdentifier(); + return fThread.getIdentifier(); } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAStackValue.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAStackValue.java index 6eda5867b..007c5c25b 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAStackValue.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAStackValue.java @@ -24,17 +24,17 @@ import org.eclipse.debug.core.model.IVariable; */ public class PDAStackValue extends PDADebugElement implements IValue { - final private PDAThread fThread; - final private String fValue; - final private int fIndex; + final private PDAThread fThread; + final private String fValue; + final private int fIndex; - /** - * Constructs a value that appears on the data stack - * - * @param target debug target - * @param value value on the stack - * @param index index on the stack - */ + /** + * Constructs a value that appears on the data stack + * + * @param target debug target + * @param value value on the stack + * @param index index on the stack + */ public PDAStackValue(PDAThread thread, String value, int index) { super(thread.getDebugTarget()); fThread = thread; @@ -43,43 +43,43 @@ public class PDAStackValue extends PDADebugElement implements IValue { } public PDAThread getThread() { - return fThread; + return fThread; } - @Override + @Override public String getValueString() throws DebugException { - return fValue; - } + return fValue; + } - @Override + @Override public boolean isAllocated() throws DebugException { - return true; - } + return true; + } - @Override + @Override public IVariable[] getVariables() throws DebugException { - return new IVariable[0]; - } + return new IVariable[0]; + } - @Override + @Override public boolean hasVariables() throws DebugException { - return false; - } + return false; + } - @Override + @Override public String getReferenceTypeName() throws DebugException { - return null; - } + return null; + } - @Override + @Override public boolean equals(Object obj) { - return obj instanceof PDAStackValue && - ((PDAStackValue)obj).fValue.equals(fValue) && - ((PDAStackValue)obj).fIndex == fIndex; - } + return obj instanceof PDAStackValue && + ((PDAStackValue)obj).fValue.equals(fValue) && + ((PDAStackValue)obj).fIndex == fIndex; + } - @Override + @Override public int hashCode() { - return super.hashCode() + fIndex; - } + return super.hashCode() + fIndex; + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAThread.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAThread.java index 19913ecf7..b72fa1b18 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAThread.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAThread.java @@ -50,10 +50,10 @@ import org.eclipse.debug.examples.core.pda.protocol.PDAVMSuspendedEvent; */ public class PDAThread extends PDADebugElement implements IThread, IPDAEventListener { - /** - * ID of this thread as reported by PDA. - */ - private final int fThreadId; + /** + * ID of this thread as reported by PDA. + */ + private final int fThreadId; /** * Breakpoint this thread is suspended at or <code>null</code> @@ -97,29 +97,29 @@ public class PDAThread extends PDADebugElement implements IThread, IPDAEventList * @since 3.5 */ void start() { - fireCreationEvent(); - getPDADebugTarget().addEventListener(this); + fireCreationEvent(); + getPDADebugTarget().addEventListener(this); } - /** - * Called by the debug target before the thread is removed. - * - * @since 3.5 - */ + /** + * Called by the debug target before the thread is removed. + * + * @since 3.5 + */ void exit() { - getPDADebugTarget().removeEventListener(this); - fireTerminateEvent(); + getPDADebugTarget().removeEventListener(this); + fireTerminateEvent(); } @Override public IStackFrame[] getStackFrames() throws DebugException { if (isSuspended()) { - PDAStackCommandResult result = (PDAStackCommandResult)sendCommand(new PDAStackCommand(fThreadId)); - IStackFrame[] frames = new IStackFrame[result.fFrames.length]; - for (int i = 0; i < result.fFrames.length; i++) { - frames[frames.length - i - 1] = new PDAStackFrame(this, result.fFrames[i], i); + PDAStackCommandResult result = (PDAStackCommandResult)sendCommand(new PDAStackCommand(fThreadId)); + IStackFrame[] frames = new IStackFrame[result.fFrames.length]; + for (int i = 0; i < result.fFrames.length; i++) { + frames[frames.length - i - 1] = new PDAStackFrame(this, result.fFrames[i], i); } - return frames; + return frames; } return new IStackFrame[0]; } @@ -178,15 +178,15 @@ public class PDAThread extends PDADebugElement implements IThread, IPDAEventList @Override public boolean isSuspended() { - if (getDebugTarget().isTerminated()) { - return false; - } - if (getDebugTarget().isSuspended()) { - return true; - } - synchronized (this) { - return fSuspended; - } + if (getDebugTarget().isTerminated()) { + return false; + } + if (getDebugTarget().isSuspended()) { + return true; + } + synchronized (this) { + return fSuspended; + } } @Override @@ -203,7 +203,7 @@ public class PDAThread extends PDADebugElement implements IThread, IPDAEventList //#ifdef ex2 //# // TODO: Exercise 2 - send suspend request to interpreter //#else - sendCommand(new PDASuspendCommand(fThreadId)); + sendCommand(new PDASuspendCommand(fThreadId)); //#endif } @@ -252,7 +252,7 @@ public class PDAThread extends PDADebugElement implements IThread, IPDAEventList @Override public void terminate() throws DebugException { - getDebugTarget().terminate(); + getDebugTarget().terminate(); } /** @@ -296,64 +296,64 @@ public class PDAThread extends PDADebugElement implements IThread, IPDAEventList @Override public void handleEvent(PDAEvent _event) { - if (_event instanceof PDARunControlEvent && fThreadId == ((PDARunControlEvent)_event).fThreadId) { - PDARunControlEvent event = (PDARunControlEvent)_event; - // clear previous state - fBreakpoint = null; - setStepping(false); - - // handle events - if (event instanceof PDAResumedEvent || event instanceof PDAVMResumedEvent) { - setSuspended(false); - if ("step".equals(event.fReason)) { //$NON-NLS-1$ - setStepping(true); - resumed(DebugEvent.STEP_OVER); - //#ifdef ex2 - //# } - //# // TODO: Exercise 2 - handle/fire "client" resume event - //#else - } else if ("client".equals(event.fReason)) { //$NON-NLS-1$ - resumed(DebugEvent.CLIENT_REQUEST); - } - //#endif - //#ifdef ex5 - //# // TODO: Exercise 5 - handle start of drop event - //#else - else if ("drop".equals(event.fReason)) { //$NON-NLS-1$ - resumed(DebugEvent.STEP_RETURN); - } - //#endif - } else if (event instanceof PDASuspendedEvent || event instanceof PDAVMSuspendedEvent) { - setSuspended(true); - //#ifdef ex2 - //# // TODO: Exercise 2 - handle/fire "client" suspend event - //# if (event.endsWith("step")) { - //# suspended(DebugEvent.STEP_END); - //# } else if (event.startsWith("suspended event") && getError() != null) { - //# exceptionHit(); - //# } - //#else - if ("client".equals(event.fReason)) { //$NON-NLS-1$ - suspended(DebugEvent.CLIENT_REQUEST); - } else if ("step".equals(event.fReason)) { //$NON-NLS-1$ - suspended(DebugEvent.STEP_END); - } else if ("event".equals(event.fReason) && getError() != null) { //$NON-NLS-1$ - exceptionHit(); - } - //#endif - //#ifdef ex5 - //# // TODO: Exercise 5 - handle end of drop event - //#else - else if ("drop".equals(event.fReason)) { //$NON-NLS-1$ - suspended(DebugEvent.STEP_END); - } - //#endif - } else if (_event instanceof PDANoSuchLabelEvent || - _event instanceof PDAUnimplementedInstructionEvent) - { - setError(event.fMessage); - } - } + if (_event instanceof PDARunControlEvent && fThreadId == ((PDARunControlEvent)_event).fThreadId) { + PDARunControlEvent event = (PDARunControlEvent)_event; + // clear previous state + fBreakpoint = null; + setStepping(false); + + // handle events + if (event instanceof PDAResumedEvent || event instanceof PDAVMResumedEvent) { + setSuspended(false); + if ("step".equals(event.fReason)) { //$NON-NLS-1$ + setStepping(true); + resumed(DebugEvent.STEP_OVER); + //#ifdef ex2 + //# } + //# // TODO: Exercise 2 - handle/fire "client" resume event + //#else + } else if ("client".equals(event.fReason)) { //$NON-NLS-1$ + resumed(DebugEvent.CLIENT_REQUEST); + } + //#endif + //#ifdef ex5 + //# // TODO: Exercise 5 - handle start of drop event + //#else + else if ("drop".equals(event.fReason)) { //$NON-NLS-1$ + resumed(DebugEvent.STEP_RETURN); + } + //#endif + } else if (event instanceof PDASuspendedEvent || event instanceof PDAVMSuspendedEvent) { + setSuspended(true); + //#ifdef ex2 + //# // TODO: Exercise 2 - handle/fire "client" suspend event + //# if (event.endsWith("step")) { + //# suspended(DebugEvent.STEP_END); + //# } else if (event.startsWith("suspended event") && getError() != null) { + //# exceptionHit(); + //# } + //#else + if ("client".equals(event.fReason)) { //$NON-NLS-1$ + suspended(DebugEvent.CLIENT_REQUEST); + } else if ("step".equals(event.fReason)) { //$NON-NLS-1$ + suspended(DebugEvent.STEP_END); + } else if ("event".equals(event.fReason) && getError() != null) { //$NON-NLS-1$ + exceptionHit(); + } + //#endif + //#ifdef ex5 + //# // TODO: Exercise 5 - handle end of drop event + //#else + else if ("drop".equals(event.fReason)) { //$NON-NLS-1$ + suspended(DebugEvent.STEP_END); + } + //#endif + } else if (_event instanceof PDANoSuchLabelEvent || + _event instanceof PDAUnimplementedInstructionEvent) + { + setError(event.fMessage); + } + } } /** @@ -380,12 +380,12 @@ public class PDAThread extends PDADebugElement implements IThread, IPDAEventList } /** - * Notification an error was encountered. Fires a breakpoint - * suspend event. - */ - private void exceptionHit() { - suspended(DebugEvent.BREAKPOINT); - } + * Notification an error was encountered. Fires a breakpoint + * suspend event. + */ + private void exceptionHit() { + suspended(DebugEvent.BREAKPOINT); + } /** * Sets the current variables for the given stack frame. Called @@ -421,8 +421,8 @@ public class PDAThread extends PDADebugElement implements IThread, IPDAEventList * Pops the top frame off the callstack. * * @throws DebugException - * - * @since 3.5 + * + * @since 3.5 */ public void popFrame() throws DebugException { //#ifdef ex5 @@ -451,89 +451,89 @@ public class PDAThread extends PDADebugElement implements IThread, IPDAEventList return false; } - /** - * Returns the values on the data stack (top down) - * - * @return the values on the data stack (top down) - * - * @since 3.5 - */ - public IValue[] getDataStack() throws DebugException { - PDAListResult result = (PDAListResult)sendCommand(new PDADataCommand(fThreadId)); - if (result.fValues.length > 0) { - IValue[] values = new IValue[result.fValues.length]; - for (int i = 0; i < result.fValues.length; i++) { - values[values.length - i - 1] = new PDAStackValue(this, result.fValues[i], i); - } - return values; - } - return new IValue[0]; - } - - /** - * Returns whether popping the data stack is currently permitted - * - * @return whether popping the data stack is currently permitted - * - * @since 3.5 - */ - public boolean canPopData() { - try { - return !isTerminated() && isSuspended() && getDataStack().length > 0; - } catch (DebugException e) { - } - return false; - } - - /** - * Pops and returns the top of the data stack - * - * @return the top value on the stack - * @throws DebugException if the stack is empty or the request fails - * - * @since 3.5 - */ - public IValue popData() throws DebugException { - IValue[] dataStack = getDataStack(); - if (dataStack.length > 0) { - sendCommand(new PDAPopDataCommand(fThreadId)); - return dataStack[0]; - } - requestFailed("Empty stack", null); //$NON-NLS-1$ - return null; - } - - /** - * Returns whether pushing a value is currently supported. - * - * @return whether pushing a value is currently supported - * - * @since 3.5 - */ - public boolean canPushData() { - return !isTerminated() && isSuspended(); - } - - /** - * Pushes a value onto the stack. - * - * @param value value to push - * @throws DebugException on failure - * - * @since 3.5 - */ - public void pushData(String value) throws DebugException { - sendCommand(new PDAPushDataCommand(fThreadId, value)); - } - - /** - * Returns this thread's unique identifier - * - * @return this thread's unique identifier - * - * @since 3.5 - */ + /** + * Returns the values on the data stack (top down) + * + * @return the values on the data stack (top down) + * + * @since 3.5 + */ + public IValue[] getDataStack() throws DebugException { + PDAListResult result = (PDAListResult)sendCommand(new PDADataCommand(fThreadId)); + if (result.fValues.length > 0) { + IValue[] values = new IValue[result.fValues.length]; + for (int i = 0; i < result.fValues.length; i++) { + values[values.length - i - 1] = new PDAStackValue(this, result.fValues[i], i); + } + return values; + } + return new IValue[0]; + } + + /** + * Returns whether popping the data stack is currently permitted + * + * @return whether popping the data stack is currently permitted + * + * @since 3.5 + */ + public boolean canPopData() { + try { + return !isTerminated() && isSuspended() && getDataStack().length > 0; + } catch (DebugException e) { + } + return false; + } + + /** + * Pops and returns the top of the data stack + * + * @return the top value on the stack + * @throws DebugException if the stack is empty or the request fails + * + * @since 3.5 + */ + public IValue popData() throws DebugException { + IValue[] dataStack = getDataStack(); + if (dataStack.length > 0) { + sendCommand(new PDAPopDataCommand(fThreadId)); + return dataStack[0]; + } + requestFailed("Empty stack", null); //$NON-NLS-1$ + return null; + } + + /** + * Returns whether pushing a value is currently supported. + * + * @return whether pushing a value is currently supported + * + * @since 3.5 + */ + public boolean canPushData() { + return !isTerminated() && isSuspended(); + } + + /** + * Pushes a value onto the stack. + * + * @param value value to push + * @throws DebugException on failure + * + * @since 3.5 + */ + public void pushData(String value) throws DebugException { + sendCommand(new PDAPushDataCommand(fThreadId, value)); + } + + /** + * Returns this thread's unique identifier + * + * @return this thread's unique identifier + * + * @since 3.5 + */ public int getIdentifier() { - return fThreadId; + return fThreadId; } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAValue.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAValue.java index 24a8ef402..fe1452c4c 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAValue.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAValue.java @@ -26,7 +26,7 @@ import org.eclipse.debug.examples.core.pda.protocol.PDAListResult; */ public class PDAValue extends PDADebugElement implements IValue { - final private PDAVariable fVariable; + final private PDAVariable fVariable; final private String fValue; public PDAValue(PDAVariable variable, String value) { @@ -57,46 +57,46 @@ public class PDAValue extends PDADebugElement implements IValue { @Override public IVariable[] getVariables() throws DebugException { - PDAStackFrame frame = fVariable.getStackFrame(); - PDAListResult result = (PDAListResult) sendCommand( - new PDAChildrenCommand(frame.getThreadIdentifier(), frame.getIdentifier(), fVariable.getName()) ); + PDAStackFrame frame = fVariable.getStackFrame(); + PDAListResult result = (PDAListResult) sendCommand( + new PDAChildrenCommand(frame.getThreadIdentifier(), frame.getIdentifier(), fVariable.getName()) ); - IVariable[] children = new IVariable[result.fValues.length]; - for(int i = 0; i < result.fValues.length; i++) { - children[i] = new PDAVariable(frame, result.fValues[i]); - } + IVariable[] children = new IVariable[result.fValues.length]; + for(int i = 0; i < result.fValues.length; i++) { + children[i] = new PDAVariable(frame, result.fValues[i]); + } return children; } @Override public boolean hasVariables() throws DebugException { - if (getVariables().length != 0) { - return true; - } - // Value with multiple words can be show as an array using logical - // structures. If the value has multiple words, it needs to indicate - // that it has children even if logical structures are not turned on. + if (getVariables().length != 0) { + return true; + } + // Value with multiple words can be show as an array using logical + // structures. If the value has multiple words, it needs to indicate + // that it has children even if logical structures are not turned on. return fValue.split("\\W+").length > 1; //$NON-NLS-1$ } - @Override + @Override public boolean equals(Object obj) { - return obj instanceof PDAValue && ((PDAValue)obj).fValue.equals(fValue); - } + return obj instanceof PDAValue && ((PDAValue)obj).fValue.equals(fValue); + } - @Override + @Override public int hashCode() { - return fValue.hashCode(); - } + return fValue.hashCode(); + } - /** - * Returns the variable that this value was created for. - * - * @return The variable that this value was created for. - * - * @since 3.5 - */ - public PDAVariable getVariable() { - return fVariable; - } + /** + * Returns the variable that this value was created for. + * + * @return The variable that this value was created for. + * + * @since 3.5 + */ + public PDAVariable getVariable() { + return fVariable; + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAVariable.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAVariable.java index afe1d7f9c..4db49c209 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAVariable.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/model/PDAVariable.java @@ -49,7 +49,7 @@ public class PDAVariable extends PDADebugElement implements IVariable { @Override public IValue getValue() throws DebugException { PDACommandResult result = sendCommand(new PDAVarCommand( - fFrame.getThreadIdentifier(), getStackFrame().getIdentifier(), getName())); + fFrame.getThreadIdentifier(), getStackFrame().getIdentifier(), getName())); return new PDAValue(this, result.fResponseText); } @@ -70,8 +70,8 @@ public class PDAVariable extends PDADebugElement implements IVariable { @Override public void setValue(String expression) throws DebugException { - sendCommand(new PDASetVarCommand( - fFrame.getThreadIdentifier(), getStackFrame().getIdentifier(), getName(), expression)); + sendCommand(new PDASetVarCommand( + fFrame.getThreadIdentifier(), getStackFrame().getIdentifier(), getName(), expression)); fireChangeEvent(DebugEvent.CONTENT); } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDABitFieldData.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDABitFieldData.java index 7f407eed0..6188ccddf 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDABitFieldData.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDABitFieldData.java @@ -25,21 +25,21 @@ import java.util.StringTokenizer; */ public class PDABitFieldData { - final public String fName; - final public int fOffset; - final public int fCount; + final public String fName; + final public int fOffset; + final public int fCount; final public Map<String, String> fMnemonics; - PDABitFieldData(String bitFieldString) { - StringTokenizer st = new StringTokenizer(bitFieldString, " "); //$NON-NLS-1$ + PDABitFieldData(String bitFieldString) { + StringTokenizer st = new StringTokenizer(bitFieldString, " "); //$NON-NLS-1$ - fName = st.nextToken(); - fOffset = Integer.parseInt(st.nextToken()); - fCount = Integer.parseInt(st.nextToken()); + fName = st.nextToken(); + fOffset = Integer.parseInt(st.nextToken()); + fCount = Integer.parseInt(st.nextToken()); fMnemonics = new LinkedHashMap<>(0); - while (st.hasMoreTokens()) { - fMnemonics.put(st.nextToken(), st.nextToken()); - } - } + while (st.hasMoreTokens()) { + fMnemonics.put(st.nextToken(), st.nextToken()); + } + } }
\ No newline at end of file diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAChildrenCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAChildrenCommand.java index 4ae78a10b..f85431b7c 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAChildrenCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAChildrenCommand.java @@ -28,12 +28,12 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAChildrenCommand extends PDACommand { - public PDAChildrenCommand(int threadId, int frameId, String name ) { - super("children " + threadId + " " + frameId + " " + name); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } + public PDAChildrenCommand(int threadId, int frameId, String name ) { + super("children " + threadId + " " + frameId + " " + name); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDAListResult(resultText); - } + return new PDAListResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAClearBreakpointCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAClearBreakpointCommand.java index ceb16884f..45a383b38 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAClearBreakpointCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAClearBreakpointCommand.java @@ -25,12 +25,12 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAClearBreakpointCommand extends PDACommand { - public PDAClearBreakpointCommand(int line) { - super("clear " + line); //$NON-NLS-1$ - } + public PDAClearBreakpointCommand(int line) { + super("clear " + line); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDACommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDACommand.java index cb2ea671c..b04f388a9 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDACommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDACommand.java @@ -20,24 +20,24 @@ package org.eclipse.debug.examples.core.pda.protocol; */ abstract public class PDACommand { - final private String fRequest; + final private String fRequest; - public PDACommand(String request) { - fRequest = request; - } + public PDACommand(String request) { + fRequest = request; + } - /** - * Returns the request to be sent to PDA. - */ - public String getRequest() { - return fRequest; - } + /** + * Returns the request to be sent to PDA. + */ + public String getRequest() { + return fRequest; + } - /** - * Returns the command result based on the given PDA response. This command - * uses the class type parameter as the return type to allow the compiler to - * enforce the correct command result. This class must be implemented by - * each command to create the concrete result type. - */ - abstract public PDACommandResult createResult(String resultText); + /** + * Returns the command result based on the given PDA response. This command + * uses the class type parameter as the return type to allow the compiler to + * enforce the correct command result. This class must be implemented by + * each command to create the concrete result type. + */ + abstract public PDACommandResult createResult(String resultText); } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDACommandResult.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDACommandResult.java index 6b0ff76d4..9e8977111 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDACommandResult.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDACommandResult.java @@ -22,9 +22,9 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDACommandResult { - final public String fResponseText; + final public String fResponseText; - public PDACommandResult(String response) { - fResponseText = response; - } + public PDACommandResult(String response) { + fResponseText = response; + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDADataCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDADataCommand.java index 5742e4bdd..326eed9cc 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDADataCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDADataCommand.java @@ -29,12 +29,12 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDADataCommand extends PDACommand { - public PDADataCommand(int threadId) { - super("data " + threadId); //$NON-NLS-1$ - } + public PDADataCommand(int threadId) { + super("data " + threadId); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDAListResult(resultText); - } + return new PDAListResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDADropFrameCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDADropFrameCommand.java index 2ff3fc140..e768055cb 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDADropFrameCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDADropFrameCommand.java @@ -38,12 +38,12 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDADropFrameCommand extends PDACommand { - public PDADropFrameCommand(int threadId) { - super("drop " + threadId); //$NON-NLS-1$ - } + public PDADropFrameCommand(int threadId) { + super("drop " + threadId); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEvalCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEvalCommand.java index b0d019574..7307b709c 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEvalCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEvalCommand.java @@ -37,12 +37,12 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAEvalCommand extends PDACommand { - public PDAEvalCommand(int threadId, String operation) { - super("eval " + threadId + " " + operation); //$NON-NLS-1$ //$NON-NLS-2$ - } + public PDAEvalCommand(int threadId, String operation) { + super("eval " + threadId + " " + operation); //$NON-NLS-1$ //$NON-NLS-2$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEvalResultEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEvalResultEvent.java index c3d27287b..b5ffe03fa 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEvalResultEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEvalResultEvent.java @@ -23,14 +23,14 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAEvalResultEvent extends PDAEvent { - public final String fResult; + public final String fResult; - public PDAEvalResultEvent(String message) { - super(message); - fResult = message.substring(getName(message).length() + 1); - } + public PDAEvalResultEvent(String message) { + super(message); + fResult = message.substring(getName(message).length() + 1); + } - public static boolean isEventMessage(String message) { - return message.startsWith("evalresult"); //$NON-NLS-1$ - } + public static boolean isEventMessage(String message) { + return message.startsWith("evalresult"); //$NON-NLS-1$ + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEvent.java index c65642e2c..484339209 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEvent.java @@ -17,62 +17,62 @@ package org.eclipse.debug.examples.core.pda.protocol; * Base class for PDA events. */ public class PDAEvent { - public final String fMessage; - public final String fName; + public final String fMessage; + public final String fName; - public PDAEvent(String message) { - fMessage = message; - fName = getName(message); - } + public PDAEvent(String message) { + fMessage = message; + fName = getName(message); + } - protected String getName(String message) { - int nameEnd = message.indexOf(' '); - nameEnd = nameEnd == -1 ? message.length() : nameEnd; - return message.substring(0, nameEnd); - } + protected String getName(String message) { + int nameEnd = message.indexOf(' '); + nameEnd = nameEnd == -1 ? message.length() : nameEnd; + return message.substring(0, nameEnd); + } - public static PDAEvent parseEvent(String message) { - if (PDAEvalResultEvent.isEventMessage(message)) { - return new PDAEvalResultEvent(message); - } - else if (PDAExitedEvent.isEventMessage(message)) { - return new PDAExitedEvent(message); - } - else if (PDANoSuchLabelEvent.isEventMessage(message)) { - return new PDANoSuchLabelEvent(message); - } - else if (PDARegistersEvent.isEventMessage(message)) { - return new PDARegistersEvent(message); - } - else if (PDAResumedEvent.isEventMessage(message)) { - return new PDAResumedEvent(message); - } - else if (PDAStartedEvent.isEventMessage(message)) { - return new PDAStartedEvent(message); - } - else if (PDASuspendedEvent.isEventMessage(message)) { - return new PDASuspendedEvent(message); - } - else if (PDATerminatedEvent.isEventMessage(message)) { - return new PDATerminatedEvent(message); - } - else if (PDAUnimplementedInstructionEvent.isEventMessage(message)) { - return new PDAUnimplementedInstructionEvent(message); - } - else if (PDAVMResumedEvent.isEventMessage(message)) { - return new PDAVMResumedEvent(message); - } - else if (PDAVMStartedEvent.isEventMessage(message)) { - return new PDAVMStartedEvent(message); - } - else if (PDAVMSuspendedEvent.isEventMessage(message)) { - return new PDAVMSuspendedEvent(message); - } - else if (PDAExitedEvent.isEventMessage(message)) { - return new PDAExitedEvent(message); - } - else { - return new PDAEvent(message); - } - } + public static PDAEvent parseEvent(String message) { + if (PDAEvalResultEvent.isEventMessage(message)) { + return new PDAEvalResultEvent(message); + } + else if (PDAExitedEvent.isEventMessage(message)) { + return new PDAExitedEvent(message); + } + else if (PDANoSuchLabelEvent.isEventMessage(message)) { + return new PDANoSuchLabelEvent(message); + } + else if (PDARegistersEvent.isEventMessage(message)) { + return new PDARegistersEvent(message); + } + else if (PDAResumedEvent.isEventMessage(message)) { + return new PDAResumedEvent(message); + } + else if (PDAStartedEvent.isEventMessage(message)) { + return new PDAStartedEvent(message); + } + else if (PDASuspendedEvent.isEventMessage(message)) { + return new PDASuspendedEvent(message); + } + else if (PDATerminatedEvent.isEventMessage(message)) { + return new PDATerminatedEvent(message); + } + else if (PDAUnimplementedInstructionEvent.isEventMessage(message)) { + return new PDAUnimplementedInstructionEvent(message); + } + else if (PDAVMResumedEvent.isEventMessage(message)) { + return new PDAVMResumedEvent(message); + } + else if (PDAVMStartedEvent.isEventMessage(message)) { + return new PDAVMStartedEvent(message); + } + else if (PDAVMSuspendedEvent.isEventMessage(message)) { + return new PDAVMSuspendedEvent(message); + } + else if (PDAExitedEvent.isEventMessage(message)) { + return new PDAExitedEvent(message); + } + else { + return new PDAEvent(message); + } + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEventStopCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEventStopCommand.java index c89eedd5a..f040a0869 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEventStopCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAEventStopCommand.java @@ -36,18 +36,18 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDAEventStopCommand extends PDACommand { - public static final int UNIMPINSTR = 0; - public static final int NOSUCHLABEL = 1; + public static final int UNIMPINSTR = 0; + public static final int NOSUCHLABEL = 1; - public PDAEventStopCommand(int event, boolean enable) { - super("eventstop " + //$NON-NLS-1$ - (event == UNIMPINSTR ? "unimpinstr " : "nosuchlabel ") + //$NON-NLS-1$ //$NON-NLS-2$ - (enable ? "1" : "0")); //$NON-NLS-1$ //$NON-NLS-2$ - } + public PDAEventStopCommand(int event, boolean enable) { + super("eventstop " + //$NON-NLS-1$ + (event == UNIMPINSTR ? "unimpinstr " : "nosuchlabel ") + //$NON-NLS-1$ //$NON-NLS-2$ + (enable ? "1" : "0")); //$NON-NLS-1$ //$NON-NLS-2$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAExitedEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAExitedEvent.java index 66ed1e333..eb3c9c696 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAExitedEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAExitedEvent.java @@ -23,11 +23,11 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAExitedEvent extends PDARunControlEvent { - public PDAExitedEvent(String message) { - super(message); - } + public PDAExitedEvent(String message) { + super(message); + } - public static boolean isEventMessage(String message) { - return message.startsWith("exited"); //$NON-NLS-1$ - } + public static boolean isEventMessage(String message) { + return message.startsWith("exited"); //$NON-NLS-1$ + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAFrameCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAFrameCommand.java index dc72143ba..22b8e9bee 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAFrameCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAFrameCommand.java @@ -29,13 +29,13 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAFrameCommand extends PDACommand { - public PDAFrameCommand(int threadId, int frameNum) { - super("frame " + threadId + " " + frameNum); //$NON-NLS-1$ //$NON-NLS-2$ - } + public PDAFrameCommand(int threadId, int frameNum) { + super("frame " + threadId + " " + frameNum); //$NON-NLS-1$ //$NON-NLS-2$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDAFrameCommandResult(resultText); - } + return new PDAFrameCommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAFrameCommandResult.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAFrameCommandResult.java index 4db761741..48fe4aed2 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAFrameCommandResult.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAFrameCommandResult.java @@ -21,13 +21,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDAFrameCommandResult extends PDACommandResult { - /** - * Frame data return by the frame command. - */ - final public PDAFrameData fFrame; + /** + * Frame data return by the frame command. + */ + final public PDAFrameData fFrame; - PDAFrameCommandResult(String response) { - super(response); - fFrame = new PDAFrameData(response); - } + PDAFrameCommandResult(String response) { + super(response); + fFrame = new PDAFrameData(response); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAFrameData.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAFrameData.java index 4aa13dbdc..4ae645796 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAFrameData.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAFrameData.java @@ -29,22 +29,22 @@ import org.eclipse.core.runtime.Path; public class PDAFrameData { - final public IPath fFilePath; - final public int fPC; - final public String fFunction; - final public String[] fVariables; + final public IPath fFilePath; + final public int fPC; + final public String fFunction; + final public String[] fVariables; - PDAFrameData(String frameString) { - StringTokenizer st = new StringTokenizer(frameString, "|"); //$NON-NLS-1$ + PDAFrameData(String frameString) { + StringTokenizer st = new StringTokenizer(frameString, "|"); //$NON-NLS-1$ - fFilePath = new Path(st.nextToken()); - fPC = Integer.parseInt(st.nextToken()); - fFunction = st.nextToken(); + fFilePath = new Path(st.nextToken()); + fPC = Integer.parseInt(st.nextToken()); + fFunction = st.nextToken(); List<String> variablesList = new ArrayList<>(); - while (st.hasMoreTokens()) { - variablesList.add(st.nextToken()); - } - fVariables = variablesList.toArray(new String[variablesList.size()]); - } + while (st.hasMoreTokens()) { + variablesList.add(st.nextToken()); + } + fVariables = variablesList.toArray(new String[variablesList.size()]); + } }
\ No newline at end of file diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAGroupsCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAGroupsCommand.java index 9ff5b3425..f5a3b606c 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAGroupsCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAGroupsCommand.java @@ -26,13 +26,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDAGroupsCommand extends PDACommand { - public PDAGroupsCommand() { - super("groups"); //$NON-NLS-1$ - } + public PDAGroupsCommand() { + super("groups"); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDAListResult(resultText); - } + return new PDAListResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAListResult.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAListResult.java index 67d3ab73c..11c5092be 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAListResult.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAListResult.java @@ -25,23 +25,23 @@ import java.util.StringTokenizer; public class PDAListResult extends PDACommandResult { - final public String[] fValues; + final public String[] fValues; - PDAListResult(String response) { - super(response); - StringTokenizer st = new StringTokenizer(response, "|"); //$NON-NLS-1$ + PDAListResult(String response) { + super(response); + StringTokenizer st = new StringTokenizer(response, "|"); //$NON-NLS-1$ List<String> valuesList = new ArrayList<>(); - while (st.hasMoreTokens()) { - String token = st.nextToken(); - if (token.length() != 0) { - valuesList.add(token); - } - } - - fValues = new String[valuesList.size()]; - for (int i = 0; i < valuesList.size(); i++) { - fValues[i] = valuesList.get(i); - } - } + while (st.hasMoreTokens()) { + String token = st.nextToken(); + if (token.length() != 0) { + valuesList.add(token); + } + } + + fValues = new String[valuesList.size()]; + for (int i = 0; i < valuesList.size(); i++) { + fValues[i] = valuesList.get(i); + } + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDANoSuchLabelEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDANoSuchLabelEvent.java index 5d14047e6..48748cd3c 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDANoSuchLabelEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDANoSuchLabelEvent.java @@ -24,22 +24,22 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDANoSuchLabelEvent extends PDAEvent { - public final String fLabel; + public final String fLabel; - public PDANoSuchLabelEvent(String message) { - super(message); - fLabel = message.substring(getName(message).length() + 1); - } + public PDANoSuchLabelEvent(String message) { + super(message); + fLabel = message.substring(getName(message).length() + 1); + } - public static boolean isEventMessage(String message) { - return message.startsWith("no such label"); //$NON-NLS-1$ - } + public static boolean isEventMessage(String message) { + return message.startsWith("no such label"); //$NON-NLS-1$ + } - @Override + @Override protected String getName(String message) { - if (isEventMessage(message)) { - return "no such label"; //$NON-NLS-1$ - } - throw new IllegalArgumentException("Invalid event: " + message); //$NON-NLS-1$ - } + if (isEventMessage(message)) { + return "no such label"; //$NON-NLS-1$ + } + throw new IllegalArgumentException("Invalid event: " + message); //$NON-NLS-1$ + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAPopDataCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAPopDataCommand.java index 56f7c78fd..e719a19cd 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAPopDataCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAPopDataCommand.java @@ -28,12 +28,12 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAPopDataCommand extends PDACommand { - public PDAPopDataCommand(int threadId) { - super("popdata " + threadId); //$NON-NLS-1$ - } + public PDAPopDataCommand(int threadId) { + super("popdata " + threadId); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAPushDataCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAPushDataCommand.java index 8c54a975d..6045881e4 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAPushDataCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAPushDataCommand.java @@ -29,13 +29,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDAPushDataCommand extends PDACommand { - public PDAPushDataCommand(int threadId, String value) { - super("pushdata " + threadId + " " + value); //$NON-NLS-1$ //$NON-NLS-2$ - } + public PDAPushDataCommand(int threadId, String value) { + super("pushdata " + threadId + " " + value); //$NON-NLS-1$ //$NON-NLS-2$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegisterData.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegisterData.java index c8fa66162..e071d4768 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegisterData.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegisterData.java @@ -26,22 +26,22 @@ import java.util.StringTokenizer; public class PDARegisterData { - final public String fName; - final public boolean fWritable; - final public PDABitFieldData[] fBitFields; + final public String fName; + final public boolean fWritable; + final public PDABitFieldData[] fBitFields; - PDARegisterData(String regString) { - StringTokenizer st = new StringTokenizer(regString, "|"); //$NON-NLS-1$ + PDARegisterData(String regString) { + StringTokenizer st = new StringTokenizer(regString, "|"); //$NON-NLS-1$ - String regInfo = st.nextToken(); - StringTokenizer regSt = new StringTokenizer(regInfo, " "); //$NON-NLS-1$ - fName = regSt.nextToken(); - fWritable = Boolean.getBoolean(regSt.nextToken()); + String regInfo = st.nextToken(); + StringTokenizer regSt = new StringTokenizer(regInfo, " "); //$NON-NLS-1$ + fName = regSt.nextToken(); + fWritable = Boolean.getBoolean(regSt.nextToken()); List<PDABitFieldData> bitFieldsList = new ArrayList<>(); - while (st.hasMoreTokens()) { - bitFieldsList.add(new PDABitFieldData(st.nextToken())); - } - fBitFields = bitFieldsList.toArray(new PDABitFieldData[bitFieldsList.size()]); - } + while (st.hasMoreTokens()) { + bitFieldsList.add(new PDABitFieldData(st.nextToken())); + } + fBitFields = bitFieldsList.toArray(new PDABitFieldData[bitFieldsList.size()]); + } }
\ No newline at end of file diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegistersCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegistersCommand.java index 19ff4a04b..94a094305 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegistersCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegistersCommand.java @@ -26,13 +26,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDARegistersCommand extends PDACommand { - public PDARegistersCommand(String group) { - super("registers " + group); //$NON-NLS-1$ - } + public PDARegistersCommand(String group) { + super("registers " + group); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDARegistersCommandResult(resultText); - } + return new PDARegistersCommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegistersCommandResult.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegistersCommandResult.java index e0b5bbbbb..ff092ecc7 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegistersCommandResult.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegistersCommandResult.java @@ -25,19 +25,19 @@ import java.util.StringTokenizer; public class PDARegistersCommandResult extends PDACommandResult { - /** - * Array of registers returned by the registers commands. - */ - final public PDARegisterData[] fRegisters; + /** + * Array of registers returned by the registers commands. + */ + final public PDARegisterData[] fRegisters; - PDARegistersCommandResult(String response) { - super(response); - StringTokenizer st = new StringTokenizer(response, "#"); //$NON-NLS-1$ + PDARegistersCommandResult(String response) { + super(response); + StringTokenizer st = new StringTokenizer(response, "#"); //$NON-NLS-1$ List<PDARegisterData> regList = new ArrayList<>(); - while (st.hasMoreTokens()) { - regList.add(new PDARegisterData(st.nextToken())); - } - fRegisters = regList.toArray(new PDARegisterData[regList.size()]); - } + while (st.hasMoreTokens()) { + regList.add(new PDARegisterData(st.nextToken())); + } + fRegisters = regList.toArray(new PDARegisterData[regList.size()]); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegistersEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegistersEvent.java index 9be258251..a0a4a7486 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegistersEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARegistersEvent.java @@ -24,11 +24,11 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDARegistersEvent extends PDAEvent { - public PDARegistersEvent(String message) { - super(message); - } + public PDARegistersEvent(String message) { + super(message); + } - public static boolean isEventMessage(String message) { - return message.startsWith("registers"); //$NON-NLS-1$ - } + public static boolean isEventMessage(String message) { + return message.startsWith("registers"); //$NON-NLS-1$ + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARestartCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARestartCommand.java index 448aa89db..75c766345 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARestartCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARestartCommand.java @@ -28,13 +28,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDARestartCommand extends PDACommand { - public PDARestartCommand() { - super("restart"); //$NON-NLS-1$ - } + public PDARestartCommand() { + super("restart"); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAResumeCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAResumeCommand.java index be6b1660f..d0be2eb9f 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAResumeCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAResumeCommand.java @@ -33,13 +33,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDAResumeCommand extends PDACommand { - public PDAResumeCommand(int threadId) { - super("resume " + threadId); //$NON-NLS-1$ - } + public PDAResumeCommand(int threadId) { + super("resume " + threadId); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAResumedEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAResumedEvent.java index bea022c9d..29b95ed53 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAResumedEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAResumedEvent.java @@ -23,11 +23,11 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAResumedEvent extends PDARunControlEvent { - public PDAResumedEvent(String message) { - super(message); - } + public PDAResumedEvent(String message) { + super(message); + } - public static boolean isEventMessage(String message) { - return message.startsWith("resumed"); //$NON-NLS-1$ - } + public static boolean isEventMessage(String message) { + return message.startsWith("resumed"); //$NON-NLS-1$ + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARunControlEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARunControlEvent.java index dc99a8fee..c98e75257 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARunControlEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDARunControlEvent.java @@ -20,55 +20,55 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDARunControlEvent extends PDAEvent { - public final int fThreadId; - public final String fReason; + public final int fThreadId; + public final String fReason; - public PDARunControlEvent(String message) { - super(message); - fThreadId = getThreadId(message); - fReason = getStateChangeReason(message); - } + public PDARunControlEvent(String message) { + super(message); + fThreadId = getThreadId(message); + fReason = getStateChangeReason(message); + } - protected int getThreadId(String message) { - int nameEnd = getName(message).length(); - if ( Character.isDigit(message.charAt(nameEnd + 1)) ) { - int threadIdEnd = message.indexOf(' ', nameEnd + 1); - threadIdEnd = threadIdEnd == -1 ? message.length() : threadIdEnd; - try { - return Integer.parseInt(message.substring(nameEnd + 1, threadIdEnd)); - } catch (NumberFormatException e) { - throw new IllegalArgumentException("Invalid event: " + message); //$NON-NLS-1$ - } - } else { - return -1; - } - } + protected int getThreadId(String message) { + int nameEnd = getName(message).length(); + if ( Character.isDigit(message.charAt(nameEnd + 1)) ) { + int threadIdEnd = message.indexOf(' ', nameEnd + 1); + threadIdEnd = threadIdEnd == -1 ? message.length() : threadIdEnd; + try { + return Integer.parseInt(message.substring(nameEnd + 1, threadIdEnd)); + } catch (NumberFormatException e) { + throw new IllegalArgumentException("Invalid event: " + message); //$NON-NLS-1$ + } + } else { + return -1; + } + } - protected String getStateChangeReason(String message) { - int idx = getName(message).length(); - if ( Character.isDigit(message.charAt(idx + 1)) ) { - idx = message.indexOf(' ', idx + 1); - idx = idx == -1 ? message.length() : idx + 1; - } else { - idx++; - } - if (idx >= message.length()) { - return ""; //$NON-NLS-1$ - } + protected String getStateChangeReason(String message) { + int idx = getName(message).length(); + if ( Character.isDigit(message.charAt(idx + 1)) ) { + idx = message.indexOf(' ', idx + 1); + idx = idx == -1 ? message.length() : idx + 1; + } else { + idx++; + } + if (idx >= message.length()) { + return ""; //$NON-NLS-1$ + } - int endIdx = message.indexOf(' ', idx); - endIdx = endIdx == -1 ? message.length() : endIdx; - return message.substring(idx, endIdx); - } + int endIdx = message.indexOf(' ', idx); + endIdx = endIdx == -1 ? message.length() : endIdx; + return message.substring(idx, endIdx); + } - @Override + @Override protected String getName(String message) { - int nameEnd = message.indexOf(' '); - nameEnd = nameEnd == -1 ? message.length() : nameEnd; - return message.substring(0, nameEnd); - } + int nameEnd = message.indexOf(' '); + nameEnd = nameEnd == -1 ? message.length() : nameEnd; + return message.substring(0, nameEnd); + } - public static boolean isEventMessage(String message) { - return message.startsWith("started"); //$NON-NLS-1$ - } + public static boolean isEventMessage(String message) { + return message.startsWith("started"); //$NON-NLS-1$ + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASetBreakpointCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASetBreakpointCommand.java index df8e6e44f..54706916b 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASetBreakpointCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASetBreakpointCommand.java @@ -37,15 +37,15 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDASetBreakpointCommand extends PDACommand { - public PDASetBreakpointCommand(int line, boolean stopVM) { - super("set " + //$NON-NLS-1$ - line + " " + //$NON-NLS-1$ - (stopVM ? "1" : "0")); //$NON-NLS-1$ //$NON-NLS-2$ - } + public PDASetBreakpointCommand(int line, boolean stopVM) { + super("set " + //$NON-NLS-1$ + line + " " + //$NON-NLS-1$ + (stopVM ? "1" : "0")); //$NON-NLS-1$ //$NON-NLS-2$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASetDataCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASetDataCommand.java index 2273a4456..2a30eb7b2 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASetDataCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASetDataCommand.java @@ -29,13 +29,13 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDASetDataCommand extends PDACommand { - public PDASetDataCommand(int threadId, int index, String value) { - super("setdata " + threadId + " " + index + " " + value); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } + public PDASetDataCommand(int threadId, int index, String value) { + super("setdata " + threadId + " " + index + " " + value); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASetVarCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASetVarCommand.java index 504fbda4b..a813906cb 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASetVarCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASetVarCommand.java @@ -31,13 +31,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDASetVarCommand extends PDACommand { - public PDASetVarCommand(int threadId, int frame, String variable, String value) { - super("setvar " + threadId + " " + frame + " " + variable + " " + value); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } + public PDASetVarCommand(int threadId, int frame, String variable, String value) { + super("setvar " + threadId + " " + frame + " " + variable + " " + value); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackCommand.java index 2a3300a6f..6c4206551 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackCommand.java @@ -32,13 +32,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDAStackCommand extends PDACommand { - public PDAStackCommand(int threadId) { - super("stack " + threadId); //$NON-NLS-1$ - } + public PDAStackCommand(int threadId) { + super("stack " + threadId); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDAStackCommandResult(resultText); - } + return new PDAStackCommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackCommandResult.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackCommandResult.java index be6db7343..9a1774603 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackCommandResult.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackCommandResult.java @@ -25,20 +25,20 @@ import java.util.StringTokenizer; public class PDAStackCommandResult extends PDACommandResult { - /** - * Array of frames return by the stack commands. The frames are ordered - * with the highest-level frame first. - */ - final public PDAFrameData[] fFrames; + /** + * Array of frames return by the stack commands. The frames are ordered + * with the highest-level frame first. + */ + final public PDAFrameData[] fFrames; - PDAStackCommandResult(String response) { - super(response); - StringTokenizer st = new StringTokenizer(response, "#"); //$NON-NLS-1$ + PDAStackCommandResult(String response) { + super(response); + StringTokenizer st = new StringTokenizer(response, "#"); //$NON-NLS-1$ List<PDAFrameData> framesList = new ArrayList<>(); - while (st.hasMoreTokens()) { - framesList.add(new PDAFrameData(st.nextToken())); - } - fFrames = framesList.toArray(new PDAFrameData[framesList.size()]); - } + while (st.hasMoreTokens()) { + framesList.add(new PDAFrameData(st.nextToken())); + } + fFrames = framesList.toArray(new PDAFrameData[framesList.size()]); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackDepthCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackDepthCommand.java index 2a6f777e5..53a00a699 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackDepthCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackDepthCommand.java @@ -29,13 +29,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDAStackDepthCommand extends PDACommand { - public PDAStackDepthCommand(int threadId) { - super("stackdepth " + threadId); //$NON-NLS-1$ - } + public PDAStackDepthCommand(int threadId) { + super("stackdepth " + threadId); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDAStackDepthCommandResult(resultText); - } + return new PDAStackDepthCommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackDepthCommandResult.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackDepthCommandResult.java index 9688c76a7..267d7d466 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackDepthCommandResult.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStackDepthCommandResult.java @@ -21,14 +21,14 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDAStackDepthCommandResult extends PDACommandResult { - final public int fDepth; + final public int fDepth; - PDAStackDepthCommandResult(String response) { - super(response); - int depth = 1; // default to something that won't cause NPEs - try { - depth = Integer.parseInt(response); - } catch (NumberFormatException e) {} - fDepth = depth; - } + PDAStackDepthCommandResult(String response) { + super(response); + int depth = 1; // default to something that won't cause NPEs + try { + depth = Integer.parseInt(response); + } catch (NumberFormatException e) {} + fDepth = depth; + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStartedEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStartedEvent.java index 993785c76..1fa2402df 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStartedEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStartedEvent.java @@ -24,11 +24,11 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAStartedEvent extends PDARunControlEvent { - public PDAStartedEvent(String message) { - super(message); - } + public PDAStartedEvent(String message) { + super(message); + } - public static boolean isEventMessage(String message) { - return message.startsWith("started"); //$NON-NLS-1$ - } + public static boolean isEventMessage(String message) { + return message.startsWith("started"); //$NON-NLS-1$ + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStepCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStepCommand.java index 071128324..947cbe899 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStepCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStepCommand.java @@ -38,13 +38,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDAStepCommand extends PDACommand { - public PDAStepCommand(int threadId) { - super("step " + threadId); //$NON-NLS-1$ - } + public PDAStepCommand(int threadId) { + super("step " + threadId); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStepReturnCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStepReturnCommand.java index 3b4f5c775..a927178b4 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStepReturnCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAStepReturnCommand.java @@ -39,13 +39,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDAStepReturnCommand extends PDACommand { - public PDAStepReturnCommand(int threadId) { - super("stepreturn " + threadId); //$NON-NLS-1$ - } + public PDAStepReturnCommand(int threadId) { + super("stepreturn " + threadId); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASuspendCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASuspendCommand.java index 85502dac8..1059e7240 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASuspendCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASuspendCommand.java @@ -33,13 +33,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDASuspendCommand extends PDACommand { - public PDASuspendCommand(int threadId) { - super("suspend " + threadId); //$NON-NLS-1$ - } + public PDASuspendCommand(int threadId) { + super("suspend " + threadId); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASuspendedEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASuspendedEvent.java index 18c99af38..575515132 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASuspendedEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDASuspendedEvent.java @@ -37,11 +37,11 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDASuspendedEvent extends PDARunControlEvent { - public PDASuspendedEvent(String message) { - super(message); - } + public PDASuspendedEvent(String message) { + super(message); + } - public static boolean isEventMessage(String message) { - return message.startsWith("suspended"); //$NON-NLS-1$ - } + public static boolean isEventMessage(String message) { + return message.startsWith("suspended"); //$NON-NLS-1$ + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDATerminateCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDATerminateCommand.java index 542e86512..7e18f5e7c 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDATerminateCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDATerminateCommand.java @@ -27,13 +27,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDATerminateCommand extends PDACommand { - public PDATerminateCommand() { - super("terminate"); //$NON-NLS-1$ - } + public PDATerminateCommand() { + super("terminate"); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDATerminatedEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDATerminatedEvent.java index 52d92a569..d9b5831f1 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDATerminatedEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDATerminatedEvent.java @@ -23,11 +23,11 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDATerminatedEvent extends PDAEvent { - public PDATerminatedEvent(String message) { - super(message); - } + public PDATerminatedEvent(String message) { + super(message); + } - public static boolean isEventMessage(String message) { - return message.startsWith("terminated"); //$NON-NLS-1$ - } + public static boolean isEventMessage(String message) { + return message.startsWith("terminated"); //$NON-NLS-1$ + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAUnimplementedInstructionEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAUnimplementedInstructionEvent.java index 645348415..16ec91c05 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAUnimplementedInstructionEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAUnimplementedInstructionEvent.java @@ -25,22 +25,22 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAUnimplementedInstructionEvent extends PDAEvent { - public final String fOperation; + public final String fOperation; - public PDAUnimplementedInstructionEvent(String message) { - super(message); - fOperation = message.substring(getName(message).length() + 1); - } + public PDAUnimplementedInstructionEvent(String message) { + super(message); + fOperation = message.substring(getName(message).length() + 1); + } - public static boolean isEventMessage(String message) { - return message.startsWith("unimplemented instruction"); //$NON-NLS-1$ - } + public static boolean isEventMessage(String message) { + return message.startsWith("unimplemented instruction"); //$NON-NLS-1$ + } - @Override + @Override protected String getName(String message) { - if (isEventMessage(message)) { - return "unimplemented instruction"; //$NON-NLS-1$ - } - throw new IllegalArgumentException("Invalid event: " + message); //$NON-NLS-1$ - } + if (isEventMessage(message)) { + return "unimplemented instruction"; //$NON-NLS-1$ + } + throw new IllegalArgumentException("Invalid event: " + message); //$NON-NLS-1$ + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMResumeCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMResumeCommand.java index cfd3d5b9d..13e8b182f 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMResumeCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMResumeCommand.java @@ -30,13 +30,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDAVMResumeCommand extends PDACommand { - public PDAVMResumeCommand() { - super("vmresume"); //$NON-NLS-1$ - } + public PDAVMResumeCommand() { + super("vmresume"); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMResumedEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMResumedEvent.java index 752254edd..ae927989e 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMResumedEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMResumedEvent.java @@ -30,11 +30,11 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAVMResumedEvent extends PDARunControlEvent { - public PDAVMResumedEvent(String message) { - super(message); - } + public PDAVMResumedEvent(String message) { + super(message); + } - public static boolean isEventMessage(String message) { - return message.startsWith("vmresumed"); //$NON-NLS-1$ - } + public static boolean isEventMessage(String message) { + return message.startsWith("vmresumed"); //$NON-NLS-1$ + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMStartedEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMStartedEvent.java index b784bff87..dd9747aa6 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMStartedEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMStartedEvent.java @@ -24,11 +24,11 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAVMStartedEvent extends PDAEvent { - public PDAVMStartedEvent(String message) { - super(message); - } + public PDAVMStartedEvent(String message) { + super(message); + } - public static boolean isEventMessage(String message) { - return message.startsWith("vmstarted"); //$NON-NLS-1$ - } + public static boolean isEventMessage(String message) { + return message.startsWith("vmstarted"); //$NON-NLS-1$ + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMSuspendCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMSuspendCommand.java index bfbc90863..75304a55b 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMSuspendCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMSuspendCommand.java @@ -30,13 +30,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDAVMSuspendCommand extends PDACommand { - public PDAVMSuspendCommand() { - super("vmsuspend"); //$NON-NLS-1$ - } + public PDAVMSuspendCommand() { + super("vmsuspend"); //$NON-NLS-1$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMSuspendedEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMSuspendedEvent.java index 96ca3ec5d..df7860fb6 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMSuspendedEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMSuspendedEvent.java @@ -38,11 +38,11 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAVMSuspendedEvent extends PDARunControlEvent { - public PDAVMSuspendedEvent(String message) { - super(message); - } + public PDAVMSuspendedEvent(String message) { + super(message); + } - public static boolean isEventMessage(String message) { - return message.startsWith("vmsuspended"); //$NON-NLS-1$ - } + public static boolean isEventMessage(String message) { + return message.startsWith("vmsuspended"); //$NON-NLS-1$ + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMTerminatedEvent.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMTerminatedEvent.java index fcbe52580..63ade7796 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMTerminatedEvent.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVMTerminatedEvent.java @@ -22,11 +22,11 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAVMTerminatedEvent extends PDAEvent { - public PDAVMTerminatedEvent(String message) { - super(message); - } + public PDAVMTerminatedEvent(String message) { + super(message); + } - public static boolean isEventMessage(String message) { - return message.startsWith("vmterminated"); //$NON-NLS-1$ - } + public static boolean isEventMessage(String message) { + return message.startsWith("vmterminated"); //$NON-NLS-1$ + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVarCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVarCommand.java index f39347a33..91e07a0ec 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVarCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAVarCommand.java @@ -32,13 +32,13 @@ package org.eclipse.debug.examples.core.pda.protocol; public class PDAVarCommand extends PDACommand { - public PDAVarCommand(int threadId, int frameId, String name) { - super("var " + threadId + " " + frameId + " " + name); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } + public PDAVarCommand(int threadId, int frameId, String name) { + super("var " + threadId + " " + frameId + " " + name); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAWatchCommand.java b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAWatchCommand.java index a681e873e..64ebbb300 100644 --- a/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAWatchCommand.java +++ b/org.eclipse.debug.examples.core/src/org/eclipse/debug/examples/core/pda/protocol/PDAWatchCommand.java @@ -31,18 +31,18 @@ package org.eclipse.debug.examples.core.pda.protocol; */ public class PDAWatchCommand extends PDACommand { - public static final int READ = 1; - public static final int WRITE = 2; - public static final int BOTH = READ | WRITE; - public static final int NONE = 0; + public static final int READ = 1; + public static final int WRITE = 2; + public static final int BOTH = READ | WRITE; + public static final int NONE = 0; - public PDAWatchCommand(String function, String variable, int operation) { - super("watch " + function+ "::" + variable + " " + operation); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } + public PDAWatchCommand(String function, String variable, int operation) { + super("watch " + function+ "::" + variable + " " + operation); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } - @Override + @Override public PDACommandResult createResult(String resultText) { - return new PDACommandResult(resultText); - } + return new PDACommandResult(resultText); + } } diff --git a/org.eclipse.debug.examples.core/src_ant/org/eclipse/debug/examples/ant/tasks/PreProcessor.java b/org.eclipse.debug.examples.core/src_ant/org/eclipse/debug/examples/ant/tasks/PreProcessor.java index 2bb17d2af..1a600ca28 100644 --- a/org.eclipse.debug.examples.core/src_ant/org/eclipse/debug/examples/ant/tasks/PreProcessor.java +++ b/org.eclipse.debug.examples.core/src_ant/org/eclipse/debug/examples/ant/tasks/PreProcessor.java @@ -73,25 +73,25 @@ public class PreProcessor extends Task { public PreProcessor() { } - /** - * Adds a set of files to process. - * - * @param set a set of files to process - */ - public void addFileset(FileSet set) { - fFileSets.addElement(set); - } + /** + * Adds a set of files to process. + * + * @param set a set of files to process + */ + public void addFileset(FileSet set) { + fFileSets.addElement(set); + } - /** - * Sets the destination directory for processed files. - * - * @param destDir destination directory for processed files - */ - public void setDestdir(File destDir) { - fDestDir = destDir; - } + /** + * Sets the destination directory for processed files. + * + * @param destDir destination directory for processed files + */ + public void setDestdir(File destDir) { + fDestDir = destDir; + } - /** + /** * Sets the symbols that are "on" for the preprocessing. * * @param symbols symbols that are "on" for the preprocessing @@ -283,7 +283,7 @@ public class PreProcessor extends Task { } } - public static void main(String[] args) { + public static void main(String[] args) { PreProcessor processor = new PreProcessor(); processor.setSymbols("ex2"); //$NON-NLS-1$ String string = processor.preProcessFile(new File("c:\\eclipse3.1\\dev\\example.debug.core\\src\\example\\debug\\core\\launcher\\PDALaunchDelegate.java"), "//#"); //$NON-NLS-1$ //$NON-NLS-2$ |