Search in sources :

Example 71 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class J9RegCommand method run.

/**
 * Run method for !j9reg extension.
 *
 * @param command  !j9reg
 * @param args	args passed by !j9reg extension.
 * @param context Context of current core file.
 * @param out PrintStream to print the output to the console.
 * @throws DDRInteractiveCommandException
 */
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    int level = 0;
    if (0 == args.length) {
        level = 1;
    } else if (1 == args.length) {
        try {
            level = Integer.parseInt(args[0]);
        } catch (NumberFormatException e) {
            out.println(args[0] + " is not a valid integer. Please try again.");
            return;
        }
    } else {
        printUsage(out);
    }
    J9JavaVMPointer vm;
    try {
        vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        VMRegMapHelper.printRegisters(vm, level, out);
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException("Failed to get vm address from RAS");
    } catch (UnknownArchitectureException uae) {
        throw new DDRInteractiveCommandException(uae.getMessage(), uae);
    }
}
Also used : UnknownArchitectureException(com.ibm.j9ddr.exceptions.UnknownArchitectureException) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 72 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class J9MemTagCommands method runFindHeader.

private void runFindHeader(String command, String[] args, Context context) throws DDRInteractiveCommandException {
    long address = 0;
    J9MemTagPointer header = null;
    if (args.length != 1) {
        out.println("Usage: ");
        out.println("  !findheader <address> (e.g. !findheader 0xa2b4c6d8)");
        return;
    }
    address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
    out.println(String.format("Searching memory allocation header for %s", U8Pointer.cast(address).getHexAddress()));
    /*
		 * Search for an eyecatcher on or before the specified address. Start
		 * the search on the specified address since an eyecatcher may start on
		 * the address. Ensure that the eyecatcher that is found is on or before
		 * the address. If this condition is not satisfied, start searching for
		 * an eyecatcher 1K before the previous start address. Continue until an
		 * eyecatcher is found, or the start address of 0 is reached.
		 */
    long searchBase = address - SEARCH_SLAB_SIZE;
    SEARCH_LOOP: do {
        /* Add 3 (length of eyecatcher - 1) to the top address, to catch eyecatchers written between search slabs */
        J9MemTagIterator it = J9MemTagIterator.iterateAllocatedHeaders(searchBase, searchBase + SEARCH_SLAB_SIZE + 3);
        while (it.hasNext()) {
            J9MemTagPointer potential = it.next();
            if (Addresses.greaterThan(potential.getAddress(), address)) {
                /* Walked past address */
                break;
            }
            VoidPointer start = J9MemTagHelper.j9mem_get_memory_base(potential);
            VoidPointer end;
            try {
                end = start.addOffset(potential.allocSize().longValue());
            } catch (CorruptDataException e) {
                continue;
            }
            if (Addresses.greaterThanOrEqual(address, start.getAddress()) && Addresses.lessThan(address, end.getAddress())) {
                /* Match */
                header = potential;
                break SEARCH_LOOP;
            }
        }
        if (Addresses.lessThan(searchBase, SEARCH_SLAB_SIZE)) {
            searchBase = 0;
        } else {
            searchBase = searchBase - SEARCH_SLAB_SIZE;
        }
    } while (searchBase != 0);
    if (header == null) {
        out.println("No memory allocation header found");
    } else {
        String callsite;
        try {
            callsite = header.callSite().getCStringAtOffset(0);
        } catch (CorruptDataException ex) {
            callsite = "<FAULT> reading callsite string: " + ex.getMessage();
        }
        String categoryName;
        try {
            categoryName = header.category().name().getCStringAtOffset(0);
        } catch (CorruptDataException ex) {
            categoryName = "<FAULT> reading category name string: " + ex.getMessage();
        }
        try {
            out.println(String.format("Found memory allocation header, !j9x %s,0x%#x", J9MemTagHelper.j9mem_get_memory_base(header).getHexAddress(), header.allocSize().longValue()));
            out.println(String.format("J9MemTag at %s {", header.getHexAddress()));
            out.println(String.format("    U_32 eyeCatcher = 0x%x;", header.eyeCatcher().longValue()));
            out.println(String.format("    U_32 sumCheck = 0x%x;", header.sumCheck().longValue()));
            out.println(String.format("    UDATA allocSize = 0x%x;", header.allocSize().longValue()));
            out.println(String.format("    char* callSite = %s;", callsite));
            out.println(String.format("    struct OMRMemCategory* category = !omrmemcategory 0x%x (%s);", header.category().longValue(), categoryName));
            out.println("}");
        } catch (CorruptDataException ex) {
            out.println("CDE formatting J9MemTag at " + header.getHexAddress());
        }
    }
}
Also used : VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9MemTagPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemTagPointer) J9MemTagIterator(com.ibm.j9ddr.vm29.j9.walkers.J9MemTagIterator)

Example 73 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class MarkMapCommand method isMarked.

protected void isMarked(String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
        J9ObjectPointer object = J9ObjectPointer.cast(address);
        MarkedObject result = markMap.queryObject(object);
        if (result != null) {
            if (result.wasRelocated()) {
                out.format("Object %s is marked and relocated to %s\n", result.object.getHexAddress(), result.relocatedObject.getHexAddress());
            } else {
                out.format("Object %s is marked\n", result.object.getHexAddress());
            }
        } else {
            out.format("Object %s is not marked\n", object.getHexAddress());
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) MarkedObject(com.ibm.j9ddr.vm29.j9.gc.GCHeapMap.MarkedObject) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 74 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class ObjectSizeInfo method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    this.out = out;
    fieldStats = new TreeMap<String, ClassFieldInfo>();
    Table summary = new Table("Object field size summary");
    summary.row(ClassFieldInfo.getTitleRow());
    HeapFieldInfo hfi = new HeapFieldInfo();
    if (args != null) {
        if (!parseArgs(out, args)) {
            return;
        }
    }
    try {
        scanHeap();
        for (FieldInfo cfi : fieldStats.values()) {
            summary.row(cfi.getResults());
            hfi.addClass(cfi);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
    summary.row(FieldInfo.getTitleRow());
    try {
        summary.row(hfi.getResults());
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
    summary.render(out);
}
Also used : Table(com.ibm.j9ddr.tools.ddrinteractive.Table) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) ObjectFieldInfo(com.ibm.j9ddr.vm29.j9.ObjectFieldInfo)

Example 75 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class ObjectSizeInfo method scanHeap.

private void scanHeap() {
    try {
        GCHeapRegionIterator regions = GCHeapRegionIterator.from();
        while (regions.hasNext()) {
            GCHeapRegionDescriptor region = regions.next();
            scanObjects(region);
        }
    } catch (CorruptDataException e) {
        e.printStackTrace();
    }
}
Also used : GCHeapRegionDescriptor(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor) GCHeapRegionIterator(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)221 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)81 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)46 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)41 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)33 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)30 NoSuchElementException (java.util.NoSuchElementException)28 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)25 UDATA (com.ibm.j9ddr.vm29.types.UDATA)20 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)17 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)15 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)11 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)9 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)9 ClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker)8 LinearDumper (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper)8 PatternString (com.ibm.j9ddr.util.PatternString)7 GCVMThreadListIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator)7 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)7 J9PoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer)7