Search in sources :

Example 16 with J9ClassPointer

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

the class ClassloadersSummaryCommand method getStat.

public Collection<ClassloadersSummaryNode> getStat() throws CorruptDataException {
    Map<J9ClassLoaderPointer, Counter> classloadersCount = new HashMap<J9ClassLoaderPointer, Counter>();
    J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
    GCClassLoaderIterator iterator = GCClassLoaderIterator.from();
    while (iterator.hasNext()) {
        J9ClassLoaderPointer classLoader = iterator.next();
        classloadersCount.put(classLoader, new Counter(0));
    }
    /* Iterate through all classes and count how many were loaded by each classLoader */
    ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
    while (classSegmentIterator.hasNext()) {
        J9ClassPointer classPointer = (J9ClassPointer) classSegmentIterator.next();
        Counter counter = classloadersCount.get(classPointer.classLoader());
        if (counter != null) {
            counter.addOne();
        } else {
            classloadersCount.put(classPointer.classLoader(), new Counter(1));
        }
    }
    J9ObjectPointer sys = vm.systemClassLoader().classLoaderObject();
    final UDATA valueROM = new UDATA(J9MemorySegment.MEMORY_TYPE_ROM_CLASS);
    final UDATA valueRAM = new UDATA(J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
    Map<String, ClassloadersSummaryNode> classloaders = new LinkedHashMap<String, ClassloadersSummaryNode>();
    for (Map.Entry<J9ClassLoaderPointer, Counter> entry : classloadersCount.entrySet()) {
        J9ObjectPointer classLoaderObject = entry.getKey().classLoaderObject();
        boolean isSystem = classLoaderObject.equals(sys);
        String loader = isSystem ? "*System*" : J9ObjectHelper.getClassName(classLoaderObject);
        /*	For each classloader, iterate through each associated memory segment and identify whether it is  
			 * 	a ROM or a RAM type memory segment  */
        long romSegmentCount = 0;
        long ramSegmentCount = 0;
        long romSegmentAllocatedMem = 0;
        long ramSegmentAllocatedMem = 0;
        J9MemorySegmentPointer segment = entry.getKey().classSegments();
        while (segment.notNull()) {
            if ((segment.type().bitAnd(valueROM)).equals(valueROM)) {
                romSegmentCount += 1;
                romSegmentAllocatedMem += segment.size().longValue();
            } else if ((segment.type().bitAnd(valueRAM)).equals(valueRAM)) {
                ramSegmentCount += 1;
                ramSegmentAllocatedMem += segment.size().longValue();
            }
            segment = segment.nextSegmentInClassLoader();
        }
        ClassloadersSummaryNode cpentry = classloaders.get(loader);
        if (cpentry == null) {
            // If the classLoader is not in the list, add it with "# Classloaders = 1" and "# Loaded Classes = classesLoaded"
            classloaders.put(loader, new ClassloadersSummaryNode(loader, 1L, entry.getValue().getCount(), ramSegmentCount, romSegmentCount, romSegmentAllocatedMem, ramSegmentAllocatedMem));
        } else {
            // If the classLoader is in the list, increment "# Classloaders" by 1 and increment "# Loaded Classes" by classesLoaded
            cpentry.numClassloaders += 1;
            cpentry.numLoadedClasses += entry.getValue().getCount();
            cpentry.ramSegmentCounter += ramSegmentCount;
            cpentry.romSegmentCounter += romSegmentCount;
            cpentry.totalROMSegmentAllocatedMemory += romSegmentAllocatedMem;
            cpentry.totalRAMSegmentAllocatedMemory += ramSegmentAllocatedMem;
        }
    }
    return classloaders.values();
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ClassLoaderPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer) GCClassLoaderIterator(com.ibm.j9ddr.vm29.j9.gc.GCClassLoaderIterator) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) LinkedHashMap(java.util.LinkedHashMap) ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) J9MemorySegmentPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 17 with J9ClassPointer

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

the class BytecodesCommand method run.

// dbgext_bytecodes
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
        J9MethodPointer ramMethod = J9MethodPointer.cast(address);
        long maps = 0;
        if (ramMethod.isNull()) {
            CommandUtils.dbgPrint(out, "bad or missing ram method addr\n");
            return;
        }
        J9ClassPointer ramClass = ConstantPoolHelpers.J9_CLASS_FROM_METHOD(ramMethod);
        if (args.length == 2 && args[1].equals("maps")) {
            maps |= BCT_DumpMaps;
        }
        if (J9BuildFlags.env_littleEndian) {
            maps |= BCT_LittleEndianOutput;
        } else {
            maps |= BCT_BigEndianOutput;
        }
        J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(ramMethod);
        J9ROMClassPointer romClass = ramClass.romClass();
        J9BCUtil.j9bcutil_dumpRomMethod(out, romMethod, romClass, maps, 0);
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 18 with J9ClassPointer

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

the class DumpRomClassCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        long maps = 0;
        if (args.length != 1 && args.length != 2) {
            printUsage(out);
            return;
        }
        if (args.length == 2 && args[1].equals("maps")) {
            maps |= J9BCTranslationData.BCT_DumpMaps;
        }
        if (J9BuildFlags.env_littleEndian) {
            maps |= J9BCTranslationData.BCT_LittleEndianOutput;
        } else {
            maps |= J9BCTranslationData.BCT_BigEndianOutput;
        }
        /* check for name:<name> */
        if (args[0].startsWith("name:")) {
            long hitCount = 0;
            String searchClassName = args[0].substring(args[0].indexOf(':') + 1);
            PatternString pattern = new PatternString(searchClassName);
            J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
            ClassSegmentIterator iterator = new ClassSegmentIterator(vm.classMemorySegments());
            while (iterator.hasNext()) {
                J9ClassPointer classPointer = (J9ClassPointer) iterator.next();
                String javaName = J9ClassHelper.getJavaName(classPointer);
                if (pattern.isMatch(javaName)) {
                    hitCount++;
                    J9ROMClassPointer clazz = classPointer.romClass();
                    String hexString = clazz.getHexAddress();
                    out.println(String.format("ROMClass %1$s named %2$s\n", hexString, javaName));
                    J9BCUtil.j9bcutil_dumpRomClass(out, clazz, maps);
                }
            }
            out.println(String.format("Found %1$d class(es) with name %2$s\n", hitCount, searchClassName));
        } else {
            /* treat argument as address */
            long addr = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
            J9ROMClassPointer clazz = J9ROMClassPointer.cast(addr);
            J9BCUtil.j9bcutil_dumpRomClass(out, clazz, maps);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) PatternString(com.ibm.j9ddr.util.PatternString) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) PatternString(com.ibm.j9ddr.util.PatternString) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 19 with J9ClassPointer

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

the class DumpRomMethodCommand method romMethodIteratorFromRamMethod.

private Iterable<J9ROMClassAndMethod> romMethodIteratorFromRamMethod(J9MethodPointer ramMethod) throws CorruptDataException {
    Iterable<J9ROMClassAndMethod> methodIterator;
    J9ClassPointer ramClass = ConstantPoolHelpers.J9_CLASS_FROM_METHOD(ramMethod);
    J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(ramMethod);
    J9ROMClassPointer romClass = ramClass.romClass();
    Vector<J9ROMClassAndMethod> methodInfoVector = new Vector<J9ROMClassAndMethod>(1);
    methodInfoVector.add(new J9ROMClassAndMethod(romMethod, romClass));
    methodIterator = methodInfoVector;
    return methodIterator;
}
Also used : J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) Vector(java.util.Vector) J9ROMClassAndMethod(com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod)

Example 20 with J9ClassPointer

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

the class ITableSizeCommand method iTableExtendedSize.

public long iTableExtendedSize(J9ITablePointer startTable, J9ITablePointer superTable) throws CorruptDataException {
    long size = 0;
    J9ITablePointer iTable = startTable;
    while (!iTable.eq(superTable)) {
        size += J9ITable.SIZEOF;
        J9ClassPointer interfaceClass = iTable.interfaceClass();
        J9ROMClassPointer romClass = interfaceClass.romClass();
        J9ITablePointer allInterfaces = J9ITablePointer.cast(interfaceClass.iTable());
        do {
            size += (UDATA.SIZEOF * allInterfaces.interfaceClass().romClass().romMethodCount().intValue());
            allInterfaces = allInterfaces.next();
        } while (!allInterfaces.eq(J9ITablePointer.NULL));
        iTable = iTable.next();
    }
    return size;
}
Also used : J9ITablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ITablePointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)

Aggregations

J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)67 CorruptDataException (com.ibm.j9ddr.CorruptDataException)34 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)16 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)13 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)13 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)12 UDATA (com.ibm.j9ddr.vm29.types.UDATA)12 U32 (com.ibm.j9ddr.vm29.types.U32)11 J9MemorySegmentPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer)9 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)9 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)8 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)8 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)7 NoSuchElementException (java.util.NoSuchElementException)7 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)6 J9ClassLoaderPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer)6 GCClassHeapIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassHeapIterator)5 GCSegmentIterator (com.ibm.j9ddr.vm29.j9.gc.GCSegmentIterator)5 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)5 J9ITablePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ITablePointer)5