/** * This function should be called only if user has specified -debug option. In this function, if * the user has issued one of the step instructions or has enabled suspend flag in previous * instruction (through breakpoint), then it will wait until user issues a new debugger command. * * @param currInst current instruction * @throws DMLRuntimeException if DMLRuntimeException occurs */ @SuppressWarnings("deprecation") private void suspendIfAskedInDebugMode(Instruction currInst) throws DMLRuntimeException { if (!DMLScript.ENABLE_DEBUG_MODE) { System.err.println( "ERROR: The function suspendIfAskedInDebugMode should not be called in non-debug mode."); } // check for stepping options if (!_dbState.suspend && _dbState.dbCommand != null) { if (_dbState.dbCommand.equalsIgnoreCase("step_instruction")) { System.out.format("Step instruction reached at %s.\n", _dbState.getPC().toString()); _dbState.suspend = true; } else if (_dbState.dbCommand.equalsIgnoreCase("step_line") && _dbState.prevPC.getLineNumber() != currInst.getLineNum() && _dbState.prevPC.getLineNumber() != 0) { // Don't step into first instruction of first line // System.out.format("Step reached at %s.\n", this._prog.getPC().toString()); System.out.format("Step reached at %s.\n", _dbState.getPC().toStringWithoutInstructionID()); _dbState.suspend = true; } else if (_dbState.dbCommand.equalsIgnoreCase("step return") && currInst instanceof FunctionCallCPInstruction) { FunctionCallCPInstruction funCallInst = (FunctionCallCPInstruction) currInst; if (_dbState.dbCommandArg == null || funCallInst.getFunctionName().equalsIgnoreCase(_dbState.dbCommandArg)) { System.out.format( "Step return reached at %s.\n", _dbState.getPC().toStringWithoutInstructionID()); _dbState.suspend = true; } } } // check if runtime suspend signal is set if (_dbState.suspend) { // flush old commands and arguments _dbState.dbCommand = null; _dbState.dbCommandArg = null; // print current DML script source line if (currInst.getLineNum() != 0) _dbState.printDMLSourceLine(currInst.getLineNum()); // save current symbol table _dbState.setVariables(this.getVariables()); // send next command signal to debugger control module _dbState.nextCommand = true; // suspend runtime execution thread Thread.currentThread().suspend(); // reset next command signal _dbState.nextCommand = false; } // reset runtime suspend signal _dbState.suspend = false; // update previous pc _dbState.prevPC.setFunctionName(_dbState.getPC().getFunctionName()); _dbState.prevPC.setProgramBlockNumber(_dbState.getPC().getProgramBlockNumber()); _dbState.prevPC.setLineNumber(currInst.getLineNum()); }
public void updateDebugState(Instruction currInst) throws DMLRuntimeException { if (DMLScript.ENABLE_DEBUG_MODE) { // New change so that shell doesnot seem like it is hanging while running MR job // Since UI cannot accept instructions when user is submitting the program _dbState.nextCommand = false; // Change to stop before first instruction of a given line // update current instruction ID and line number _dbState.getPC().setInstID(currInst.getInstID()); _dbState.getPC().setLineNumber(currInst.getLineNum()); // Change to stop before first instruction of a given line suspendIfAskedInDebugMode(currInst); } }