Search in sources :

Example 1 with IOSStackFrame

use of com.ibm.j9ddr.corereaders.osthread.IOSStackFrame in project openj9 by eclipse.

the class BaseAIXOSThread method walkStack.

private void walkStack() {
    frames = new LinkedList<IOSStackFrame>();
    long stackPointer = getStackPointer();
    long instructionPointer = getInstructionPointer();
    if (0 == instructionPointer || !isValidAddress(instructionPointer)) {
        instructionPointer = getBasePointer();
    }
    try {
        if (0 != instructionPointer && 0 != stackPointer && isValidAddress(instructionPointer) && isValidAddress(stackPointer)) {
            frames.add(new OSStackFrame(stackPointer, instructionPointer));
            long previousStackPointer = -1;
            final long stepping = process.bytesPerPointer();
            int loops = 0;
            // maximum 256 frames, for protection against excessive or infinite loops in corrupt dumps
            while (previousStackPointer != stackPointer && loops++ < 256) {
                previousStackPointer = stackPointer;
                stackPointer = process.getPointerAt(stackPointer);
                long addressToRead = stackPointer + stepping;
                // readAddress(); // Ignore conditionRegister
                addressToRead += stepping;
                instructionPointer = process.getPointerAt(addressToRead);
                frames.add(new OSStackFrame(stackPointer, instructionPointer));
            }
        } else {
            // This is a temporary hack until we can understand signal handler stacks
            // better
            logger.logp(Level.WARNING, "com.ibm.j9ddr.corereaders.aix.BaseAIXOSThread", "walkStack", "MISSED");
        // TODO handle this case sensibly
        }
    } catch (CorruptDataException e) {
    // TODO handle
    }
}
Also used : IOSStackFrame(com.ibm.j9ddr.corereaders.osthread.IOSStackFrame) OSStackFrame(com.ibm.j9ddr.corereaders.osthread.OSStackFrame) IOSStackFrame(com.ibm.j9ddr.corereaders.osthread.IOSStackFrame) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 2 with IOSStackFrame

use of com.ibm.j9ddr.corereaders.osthread.IOSStackFrame in project openj9 by eclipse.

the class NativeStacksCommand method run.

public void run(String cmd, String[] args, Context ctx, PrintStream out) throws DDRInteractiveCommandException {
    Set<Long> threadIds = null;
    for (String arg : args) {
        if (threadIds == null) {
            threadIds = new HashSet<Long>();
        }
        Long tid = CommandUtils.parseNumber(arg).longValue();
        threadIds.add(tid);
    }
    try {
        Collection<? extends IOSThread> threads = ctx.process.getThreads();
        for (IOSThread t : threads) {
            if (threadIds == null || threadIds.contains(t.getThreadId())) {
                try {
                    out.printf("Thread id: %d (0x%X)\n", t.getThreadId(), t.getThreadId());
                    int frameId = 0;
                    if (threadIds != null) {
                        threadIds.remove(t.getThreadId());
                    }
                    for (IOSStackFrame f : t.getStackFrames()) {
                        String symbol = ctx.process.getProcedureNameForAddress(f.getInstructionPointer());
                        if (ctx.process.bytesPerPointer() == 8) {
                            out.printf("#%d bp:0x%016X ip:0x%016X %s\n", frameId++, f.getBasePointer(), f.getInstructionPointer(), symbol);
                        } else {
                            out.printf("#%d bp:0x%08X ip:0x%08X %s\n", frameId++, f.getBasePointer(), f.getInstructionPointer(), symbol);
                        }
                    }
                } catch (DataUnavailableException e) {
                    out.printf("DataUnavailableException reading stack for thread %d\n", t.getThreadId());
                } catch (CorruptDataException e) {
                    out.printf("CorruptDataException reading stack for thread %d\n", t.getThreadId());
                }
                out.println("----------");
            }
        }
        if (threadIds != null && !threadIds.isEmpty()) {
            out.print("Unable to find native thread for id(s): ");
            for (long tid : threadIds) {
                out.print(tid);
            }
            out.println();
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) IOSStackFrame(com.ibm.j9ddr.corereaders.osthread.IOSStackFrame) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) IOSThread(com.ibm.j9ddr.corereaders.osthread.IOSThread)

Example 3 with IOSStackFrame

use of com.ibm.j9ddr.corereaders.osthread.IOSStackFrame in project openj9 by eclipse.

the class J9DDRImageThread method getStackFrames.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.image.ImageThread#getStackFrames()
	 */
public Iterator<?> getStackFrames() throws DataUnavailable {
    List<? extends IOSStackFrame> frames = thread.getStackFrames();
    List<ImageStackFrame> dtfjFrames = new ArrayList<ImageStackFrame>(frames.size());
    for (IOSStackFrame thisFrame : frames) {
        dtfjFrames.add(new J9DDRImageStackFrame(process, thisFrame, this));
    }
    return dtfjFrames.iterator();
}
Also used : IOSStackFrame(com.ibm.j9ddr.corereaders.osthread.IOSStackFrame) ArrayList(java.util.ArrayList) ImageStackFrame(com.ibm.dtfj.image.ImageStackFrame)

Aggregations

IOSStackFrame (com.ibm.j9ddr.corereaders.osthread.IOSStackFrame)3 CorruptDataException (com.ibm.j9ddr.CorruptDataException)2 ImageStackFrame (com.ibm.dtfj.image.ImageStackFrame)1 DataUnavailableException (com.ibm.j9ddr.DataUnavailableException)1 IOSThread (com.ibm.j9ddr.corereaders.osthread.IOSThread)1 OSStackFrame (com.ibm.j9ddr.corereaders.osthread.OSStackFrame)1 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1 ArrayList (java.util.ArrayList)1