Search in sources :

Example 1 with J9JavaStackPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaStackPointer in project openj9 by eclipse.

the class J9JavaStackIterator method next.

public J9JavaStackPointer next() {
    try {
        if (hasNext()) {
            J9JavaStackPointer next;
            next = currentStack;
            currentStack = currentStack.previous();
            return next;
        } else {
            throw new NoSuchElementException("There are no more items available through this iterator");
        }
    } catch (CorruptDataException cde) {
        // broken link to previous stack section, terminate the walk
        currentStack = J9JavaStackPointer.NULL;
        raiseCorruptDataEvent("Error getting next stack section", cde, false);
        return null;
    }
}
Also used : J9JavaStackPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaStackPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) NoSuchElementException(java.util.NoSuchElementException)

Example 2 with J9JavaStackPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaStackPointer in project openj9 by eclipse.

the class FindStackValueCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (0 == args.length) {
        out.println("Usage error: Missing stackvalue to search for. See usage.");
        printUsage(out);
        return;
    } else if (1 < args.length) {
        out.println("Usage error: Too many stackvalues to search for. See usage.");
        printUsage(out);
        return;
    }
    try {
        long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
        UDATAPointer value = UDATAPointer.cast(address);
        GCVMThreadListIterator gcvmThreadListIterator = GCVMThreadListIterator.from();
        while (gcvmThreadListIterator.hasNext()) {
            J9VMThreadPointer vmThreadPointer = gcvmThreadListIterator.next();
            J9JavaStackPointer javaStackPointer = vmThreadPointer.stackObject();
            J9JavaStackIterator javaStackIterator = J9JavaStackIterator.fromJ9JavaStack(javaStackPointer);
            boolean found = false;
            UDATA relativeSP = new UDATA(javaStackPointer.end().sub(vmThreadPointer.sp()));
            while (javaStackIterator.hasNext()) {
                J9JavaStackPointer stack = javaStackIterator.next();
                UDATAPointer localEnd = stack.end().sub(1).add(1);
                UDATAPointer search = localEnd.sub(relativeSP);
                while (!search.eq(localEnd)) {
                    if (search.at(0).longValue() == value.longValue()) {
                        if (!found) {
                            out.append(String.format("!j9vmthread %s\n", Long.toHexString(vmThreadPointer.getAddress())));
                            found = true;
                        }
                        out.append(String.format("\tFound at %s\n", Long.toHexString(search.getAddress())));
                    }
                    search = search.add(1);
                }
            }
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9JavaStackPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaStackPointer) J9JavaStackIterator(com.ibm.j9ddr.vm29.j9.J9JavaStackIterator) UDATAPointer(com.ibm.j9ddr.vm29.pointer.UDATAPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 3 with J9JavaStackPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaStackPointer in project openj9 by eclipse.

the class DTFJJavaThread method walkSections.

private void walkSections() {
    sections = new ArrayList<Object>();
    J9JavaStackIterator stacks;
    try {
        stacks = J9JavaStackIterator.fromJ9JavaStack(thread.stackObject());
    } catch (Throwable t) {
        CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
        sections.add(cd);
        return;
    }
    // JEXTRACT seems to be hard coded to only return 1 stack section ... walking the stack finds more than one.
    int count = 0;
    while (stacks.hasNext() && count < 1) {
        J9JavaStackPointer stack = stacks.next();
        try {
            long size = stack.size().longValue();
            long baseAddress = stack.end().longValue() - size;
            J9DDRImageSection newSection = DTFJContext.getImageSection(baseAddress, getSectionName());
            newSection.setSize(size);
            sections.add(newSection);
            count++;
        } catch (Throwable t) {
            CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
            sections.add(cd);
        }
    }
}
Also used : J9JavaStackPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaStackPointer) J9JavaStackIterator(com.ibm.j9ddr.vm29.j9.J9JavaStackIterator) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData) J9DDRImageSection(com.ibm.j9ddr.view.dtfj.image.J9DDRImageSection)

Aggregations

J9JavaStackPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaStackPointer)3 CorruptDataException (com.ibm.j9ddr.CorruptDataException)2 J9JavaStackIterator (com.ibm.j9ddr.vm29.j9.J9JavaStackIterator)2 CorruptData (com.ibm.dtfj.image.CorruptData)1 JavaObject (com.ibm.dtfj.java.JavaObject)1 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1 J9DDRCorruptData (com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)1 J9DDRImageSection (com.ibm.j9ddr.view.dtfj.image.J9DDRImageSection)1 GCVMThreadListIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator)1 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)1 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)1 UDATA (com.ibm.j9ddr.vm29.types.UDATA)1 NoSuchElementException (java.util.NoSuchElementException)1