Search in sources :

Example 6 with BreakPointInstruction

use of org.apache.sysml.runtime.instructions.cp.BreakPointInstruction in project systemml by apache.

the class DMLDebuggerFunctions method listBreakpoints.

// ///////////////////////////////////////////
// public interface for debugger functions //
// ///////////////////////////////////////////
/**
 * Print all breakpoints along with current status (i.e. enabled or disabled)
 * @param breakpoints Contains all existing breakpoints
 */
public void listBreakpoints(TreeMap<Integer, BreakPointInstruction> breakpoints) {
    // Display all breakpoints
    if (breakpoints == null) {
        System.out.println("No breakpoints are set for this program.");
        return;
    }
    // active breakpoint ids
    int currBreakpoint = 1;
    int numVisibleBreakpoints = 0;
    for (Entry<Integer, BreakPointInstruction> e : breakpoints.entrySet()) {
        Integer lineNumber = e.getKey();
        BreakPointInstruction inst = e.getValue();
        if (inst.getBPInstructionStatus() == BPINSTRUCTION_STATUS.ENABLED) {
            System.out.format("Breakpoint %2d, at line %4d (%s)\n", currBreakpoint++, lineNumber, "enabled");
            numVisibleBreakpoints++;
        } else if (inst.getBPInstructionStatus() == BPINSTRUCTION_STATUS.DISABLED) {
            System.out.format("Breakpoint %2d, at line %4d (%s)\n", currBreakpoint++, lineNumber, "disabled");
            numVisibleBreakpoints++;
        }
    }
    if (numVisibleBreakpoints == 0) {
        System.out.println("No breakpoints are set for this program.");
    }
}
Also used : BreakPointInstruction(org.apache.sysml.runtime.instructions.cp.BreakPointInstruction)

Example 7 with BreakPointInstruction

use of org.apache.sysml.runtime.instructions.cp.BreakPointInstruction in project systemml by apache.

the class DMLDebuggerFunctions method printInstructions.

/**
 * Print range of DML program lines interspersed with corresponding runtime instructions
 * @param lines DML script lines of code
 * @param DMLInstMap Mapping between source code line number and corresponding runtime instruction(s)
 * @param range Range of lines of DML code to be displayed
 * @param debug Flag for displaying instructions in debugger test integration
 */
public void printInstructions(String[] lines, TreeMap<Integer, ArrayList<Instruction>> DMLInstMap, IntRange range, boolean debug) {
    // Display instructions with corresponding DML line numbers
    for (int lineNumber = range.getMinimumInteger(); lineNumber <= range.getMaximumInteger(); lineNumber++) {
        System.out.format("line %4d: %s\n", lineNumber, lines[lineNumber - 1]);
        if (DMLInstMap.get(lineNumber) != null) {
            for (Instruction currInst : DMLInstMap.get(lineNumber)) {
                if (currInst instanceof CPInstruction) {
                    if (!debug)
                        System.out.format("\t\t id %4d: %s\n", currInst.getInstID(), prepareInstruction(currInst.toString()));
                    else {
                        String[] instStr = prepareInstruction(currInst.toString()).split(" ");
                        System.out.format("\t\t id %4d: %s %s\n", currInst.getInstID(), instStr[0], instStr[1]);
                    }
                } else if (currInst instanceof MRJobInstruction) {
                    MRJobInstruction currMRInst = (MRJobInstruction) currInst;
                    System.out.format("\t\t id %4d: %s\n", currInst.getInstID(), prepareInstruction(currMRInst.getMRString(debug)));
                } else if (currInst instanceof BreakPointInstruction) {
                    BreakPointInstruction currBPInst = (BreakPointInstruction) currInst;
                    System.out.format("\t\t id %4d: %s\n", currInst.getInstID(), currBPInst.toString());
                }
            }
        }
    }
}
Also used : CPInstruction(org.apache.sysml.runtime.instructions.cp.CPInstruction) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) BreakPointInstruction(org.apache.sysml.runtime.instructions.cp.BreakPointInstruction) BreakPointInstruction(org.apache.sysml.runtime.instructions.cp.BreakPointInstruction) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) CPInstruction(org.apache.sysml.runtime.instructions.cp.CPInstruction) Instruction(org.apache.sysml.runtime.instructions.Instruction)

Example 8 with BreakPointInstruction

use of org.apache.sysml.runtime.instructions.cp.BreakPointInstruction in project systemml by apache.

the class DMLDebuggerProgramInfo method accesBreakpointInstruction.

/**
 * Access breakpoint instruction at specified line number in set of instructions (if valid)
 * @param instructions Instructions for current program block
 * @param lineNumber Location for inserting breakpoint
 * @param op Breakpoint operation
 * @param status Current breakpoint status
 */
private void accesBreakpointInstruction(ArrayList<Instruction> instructions, int lineNumber, int op, BPINSTRUCTION_STATUS status) {
    for (int i = 0; i < instructions.size(); i++) {
        Instruction currInst = instructions.get(i);
        if (op == 0) {
            if (currInst instanceof MRJobInstruction) {
                MRJobInstruction currMRInst = (MRJobInstruction) currInst;
                // Check if current instruction line number correspond to breakpoint line number
                if (currMRInst.findMRInstructions(lineNumber)) {
                    BreakPointInstruction breakpoint = new BreakPointInstruction();
                    breakpoint.setLocation(currInst);
                    breakpoint.setInstID(instID++);
                    breakpoint.setBPInstructionLocation(location);
                    instructions.add(i, breakpoint);
                    DMLBreakpointManager.insertBreakpoint(breakpoint, lineNumber);
                    return;
                }
            } else if (currInst instanceof CPInstruction || currInst instanceof SPInstruction) {
                // Check if current instruction line number correspond to breakpoint line number
                if (currInst.getLineNum() == lineNumber) {
                    BreakPointInstruction breakpoint = new BreakPointInstruction();
                    breakpoint.setLocation(currInst);
                    breakpoint.setInstID(instID++);
                    breakpoint.setBPInstructionLocation(location);
                    instructions.add(i, breakpoint);
                    DMLBreakpointManager.insertBreakpoint(breakpoint, lineNumber);
                    return;
                }
            } else if (currInst instanceof BreakPointInstruction && currInst.getLineNum() == lineNumber) {
                BreakPointInstruction breakpoint = (BreakPointInstruction) currInst;
                breakpoint.setBPInstructionStatus(BPINSTRUCTION_STATUS.ENABLED);
                breakpoint.setBPInstructionLocation(location);
                instructions.set(i, breakpoint);
                DMLBreakpointManager.updateBreakpoint(lineNumber, status);
                return;
            }
        } else {
            // Check if current instruction line number correspond to breakpoint line number
            if (currInst instanceof BreakPointInstruction && currInst.getLineNum() == lineNumber) {
                if (op == 1) {
                    BreakPointInstruction breakpoint = (BreakPointInstruction) currInst;
                    breakpoint.setLocation(currInst);
                    breakpoint.setInstID(currInst.getInstID());
                    breakpoint.setBPInstructionStatus(status);
                    breakpoint.setBPInstructionLocation(location);
                    instructions.set(i, breakpoint);
                    DMLBreakpointManager.updateBreakpoint(lineNumber, status);
                } else {
                    instructions.remove(i);
                    DMLBreakpointManager.removeBreakpoint(lineNumber, status);
                }
                return;
            }
        }
    }
}
Also used : SPInstruction(org.apache.sysml.runtime.instructions.spark.SPInstruction) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) CPInstruction(org.apache.sysml.runtime.instructions.cp.CPInstruction) BreakPointInstruction(org.apache.sysml.runtime.instructions.cp.BreakPointInstruction) SPInstruction(org.apache.sysml.runtime.instructions.spark.SPInstruction) BreakPointInstruction(org.apache.sysml.runtime.instructions.cp.BreakPointInstruction) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) CPInstruction(org.apache.sysml.runtime.instructions.cp.CPInstruction) Instruction(org.apache.sysml.runtime.instructions.Instruction)

Example 9 with BreakPointInstruction

use of org.apache.sysml.runtime.instructions.cp.BreakPointInstruction in project systemml by apache.

the class DMLDebuggerProgramInfo method setInstMap.

/**
 * For each instruction, generate map with corresponding DML
 * script line number
 * @param instructions Instructions for current program block
 */
private void setInstMap(ArrayList<Instruction> instructions) {
    for (int i = 0; i < instructions.size(); i++) {
        Instruction currInst = instructions.get(i);
        // set instruction unique identifier
        if (currInst.getInstID() == 0) {
            currInst.setInstID(instID++);
        }
        if (currInst instanceof MRJobInstruction) {
            MRJobInstruction currMRInst = (MRJobInstruction) currInst;
            int min = Integer.MAX_VALUE;
            // iterate of MR job instructions to identify minimum line number
            for (Integer lineNumber : currMRInst.getMRJobInstructionsLineNumbers()) {
                if (lineNumber < min)
                    min = lineNumber;
            }
            // set MR job line number
            if (min == 0 || min == Integer.MAX_VALUE)
                // last seen instruction line number
                currMRInst.setLocation(null, prevLineNum, prevLineNum, -1, -1);
            else
                // minimum instruction line number for this MR job
                currMRInst.setLocation(null, min, min, -1, -1);
            // insert current MR instruction into corresponding source code line
            if (!disassembler.containsKey(currMRInst.getLineNum()))
                disassembler.put(currMRInst.getLineNum(), new ArrayList<Instruction>());
            disassembler.get(currMRInst.getLineNum()).add(currMRInst);
        } else if (currInst instanceof CPInstruction || currInst instanceof SPInstruction) {
            // if CP instruction line number is not set, then approximate to last seen line number
            if (currInst.getLineNum() == 0)
                currInst.setLocation(null, prevLineNum, prevLineNum, -1, -1);
            // insert current CP instruction into corresponding source code line
            if (!disassembler.containsKey(currInst.getLineNum()))
                disassembler.put(currInst.getLineNum(), new ArrayList<Instruction>());
            disassembler.get(currInst.getLineNum()).add(currInst);
        } else if (currInst instanceof BreakPointInstruction) {
            BreakPointInstruction currBPInst = (BreakPointInstruction) currInst;
            // insert current BP instruction into corresponding source code line
            if (!disassembler.containsKey(currBPInst.getLineNum()))
                disassembler.put(currBPInst.getLineNum(), new ArrayList<Instruction>());
            disassembler.get(currInst.getLineNum()).add(currBPInst);
        }
        // save instruction's line number as last seen
        if (currInst.getLineNum() != 0)
            prevLineNum = currInst.getLineNum();
    }
}
Also used : SPInstruction(org.apache.sysml.runtime.instructions.spark.SPInstruction) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) CPInstruction(org.apache.sysml.runtime.instructions.cp.CPInstruction) BreakPointInstruction(org.apache.sysml.runtime.instructions.cp.BreakPointInstruction) ArrayList(java.util.ArrayList) SPInstruction(org.apache.sysml.runtime.instructions.spark.SPInstruction) BreakPointInstruction(org.apache.sysml.runtime.instructions.cp.BreakPointInstruction) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) CPInstruction(org.apache.sysml.runtime.instructions.cp.CPInstruction) Instruction(org.apache.sysml.runtime.instructions.Instruction)

Example 10 with BreakPointInstruction

use of org.apache.sysml.runtime.instructions.cp.BreakPointInstruction in project incubator-systemml by apache.

the class DMLDebuggerProgramInfo method accesBreakpointInstruction.

/**
 * Access breakpoint instruction at specified line number in set of instructions (if valid)
 * @param instructions Instructions for current program block
 * @param lineNumber Location for inserting breakpoint
 * @param op Breakpoint operation
 * @param status Current breakpoint status
 */
private void accesBreakpointInstruction(ArrayList<Instruction> instructions, int lineNumber, int op, BPINSTRUCTION_STATUS status) {
    for (int i = 0; i < instructions.size(); i++) {
        Instruction currInst = instructions.get(i);
        if (op == 0) {
            if (currInst instanceof MRJobInstruction) {
                MRJobInstruction currMRInst = (MRJobInstruction) currInst;
                // Check if current instruction line number correspond to breakpoint line number
                if (currMRInst.findMRInstructions(lineNumber)) {
                    BreakPointInstruction breakpoint = new BreakPointInstruction();
                    breakpoint.setLocation(currInst);
                    breakpoint.setInstID(instID++);
                    breakpoint.setBPInstructionLocation(location);
                    instructions.add(i, breakpoint);
                    DMLBreakpointManager.insertBreakpoint(breakpoint, lineNumber);
                    return;
                }
            } else if (currInst instanceof CPInstruction || currInst instanceof SPInstruction) {
                // Check if current instruction line number correspond to breakpoint line number
                if (currInst.getLineNum() == lineNumber) {
                    BreakPointInstruction breakpoint = new BreakPointInstruction();
                    breakpoint.setLocation(currInst);
                    breakpoint.setInstID(instID++);
                    breakpoint.setBPInstructionLocation(location);
                    instructions.add(i, breakpoint);
                    DMLBreakpointManager.insertBreakpoint(breakpoint, lineNumber);
                    return;
                }
            } else if (currInst instanceof BreakPointInstruction && currInst.getLineNum() == lineNumber) {
                BreakPointInstruction breakpoint = (BreakPointInstruction) currInst;
                breakpoint.setBPInstructionStatus(BPINSTRUCTION_STATUS.ENABLED);
                breakpoint.setBPInstructionLocation(location);
                instructions.set(i, breakpoint);
                DMLBreakpointManager.updateBreakpoint(lineNumber, status);
                return;
            }
        } else {
            // Check if current instruction line number correspond to breakpoint line number
            if (currInst instanceof BreakPointInstruction && currInst.getLineNum() == lineNumber) {
                if (op == 1) {
                    BreakPointInstruction breakpoint = (BreakPointInstruction) currInst;
                    breakpoint.setLocation(currInst);
                    breakpoint.setInstID(currInst.getInstID());
                    breakpoint.setBPInstructionStatus(status);
                    breakpoint.setBPInstructionLocation(location);
                    instructions.set(i, breakpoint);
                    DMLBreakpointManager.updateBreakpoint(lineNumber, status);
                } else {
                    instructions.remove(i);
                    DMLBreakpointManager.removeBreakpoint(lineNumber, status);
                }
                return;
            }
        }
    }
}
Also used : SPInstruction(org.apache.sysml.runtime.instructions.spark.SPInstruction) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) CPInstruction(org.apache.sysml.runtime.instructions.cp.CPInstruction) BreakPointInstruction(org.apache.sysml.runtime.instructions.cp.BreakPointInstruction) SPInstruction(org.apache.sysml.runtime.instructions.spark.SPInstruction) BreakPointInstruction(org.apache.sysml.runtime.instructions.cp.BreakPointInstruction) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) CPInstruction(org.apache.sysml.runtime.instructions.cp.CPInstruction) Instruction(org.apache.sysml.runtime.instructions.Instruction)

Aggregations

BreakPointInstruction (org.apache.sysml.runtime.instructions.cp.BreakPointInstruction)10 Instruction (org.apache.sysml.runtime.instructions.Instruction)8 MRJobInstruction (org.apache.sysml.runtime.instructions.MRJobInstruction)8 CPInstruction (org.apache.sysml.runtime.instructions.cp.CPInstruction)8 SPInstruction (org.apache.sysml.runtime.instructions.spark.SPInstruction)4 ArrayList (java.util.ArrayList)2