Search in sources :

Example 1 with StructureDescriptor

use of com.ibm.j9ddr.StructureReader.StructureDescriptor in project openj9 by eclipse.

the class CommandUtils method followPointerFromStructure.

public static long followPointerFromStructure(Context context, String structureName, long structureAddress, String fieldName) throws MemoryFault, DDRInteractiveCommandException {
    if (structureAddress == 0) {
        throw new DDRInteractiveCommandException(new NullPointerException("Null " + structureName + " found."));
    }
    StructureDescriptor desc = StructureCommandUtil.getStructureDescriptor(structureName, context);
    for (FieldDescriptor f : desc.getFields()) {
        if (f.getDeclaredName().equals(fieldName)) {
            long offset = f.getOffset();
            long pointerAddress = structureAddress + offset;
            long pointer = context.process.getPointerAt(pointerAddress);
            return pointer;
        }
    }
    return 0;
}
Also used : StructureDescriptor(com.ibm.j9ddr.StructureReader.StructureDescriptor) FieldDescriptor(com.ibm.j9ddr.StructureReader.FieldDescriptor)

Example 2 with StructureDescriptor

use of com.ibm.j9ddr.StructureReader.StructureDescriptor in project openj9 by eclipse.

the class StructureCommandUtil method loadStructureMap.

private static void loadStructureMap() {
    structureMap = new HashMap<String, StructureDescriptor>();
    for (StructureDescriptor descriptor : cachedContext.vmData.getStructures()) {
        structureMap.put(descriptor.getName().toLowerCase(), descriptor);
    }
    typeManager = new StructureTypeManager(cachedContext.vmData.getStructures());
    StringBuilder b = new StringBuilder();
    b.append("0x%0");
    b.append(2 * cachedContext.process.bytesPerPointer());
    b.append("X");
    pointerFormatString = b.toString();
}
Also used : StructureTypeManager(com.ibm.j9ddr.StructureTypeManager) StructureDescriptor(com.ibm.j9ddr.StructureReader.StructureDescriptor)

Example 3 with StructureDescriptor

use of com.ibm.j9ddr.StructureReader.StructureDescriptor in project openj9 by eclipse.

the class EnumFormatter method format.

@Override
public FormatWalkResult format(String name, String type, String declaredType, int typeCode, long address, PrintStream out, Context context, IStructureFormatter structureFormatter) throws CorruptDataException {
    if (typeCode != TYPE_ENUM) {
        return FormatWalkResult.KEEP_WALKING;
    }
    // Get a handle on the descriptor for the enum - to find out how big it is
    type = type.replace("enum", "");
    type = type.trim();
    StructureDescriptor desc = StructureCommandUtil.getStructureDescriptor(type, context);
    if (null == desc) {
        out.print("<<Missing description of " + type + ">>");
        return FormatWalkResult.STOP_WALKING;
    }
    long value;
    switch(desc.getSizeOf()) {
        case 1:
            value = U8Pointer.cast(address).at(0).longValue();
            break;
        case 2:
            value = U16Pointer.cast(address).at(0).longValue();
            break;
        case 4:
            value = U32Pointer.cast(address).at(0).longValue();
            break;
        case 8:
            value = U64Pointer.cast(address).at(0).longValue();
            break;
        default:
            out.print("<<Unhandled enum size: " + desc.getSizeOf() + ">>");
            return FormatWalkResult.STOP_WALKING;
    }
    out.print("0x" + Long.toHexString(value));
    out.print(" (");
    out.print(value);
    out.print(")");
    boolean mnemonicWritten = false;
    for (ConstantDescriptor constant : desc.getConstants()) {
        if (constant.getValue() == value) {
            out.print(" //");
            out.print(constant.getName());
            mnemonicWritten = true;
            break;
        }
    }
    if (!mnemonicWritten) {
        out.print(" <<Not matched to enum constant>>");
    }
    return FormatWalkResult.STOP_WALKING;
}
Also used : ConstantDescriptor(com.ibm.j9ddr.StructureReader.ConstantDescriptor) StructureDescriptor(com.ibm.j9ddr.StructureReader.StructureDescriptor)

Example 4 with StructureDescriptor

use of com.ibm.j9ddr.StructureReader.StructureDescriptor in project openj9 by eclipse.

the class PointerGenerator method generateClasses.

private void generateClasses() {
    String fileName = opts.get("-f");
    String supersetFileName = opts.get("-s");
    try {
        J9DDRStructureStore store = new J9DDRStructureStore(fileName, supersetFileName);
        System.out.println("superset directory name : " + fileName);
        System.out.println("superset file name : " + store.getSuperSetFileName());
        InputStream inputStream = store.getSuperset();
        structureReader = new StructureReader(inputStream);
        inputStream.close();
    } catch (IOException e) {
        System.out.println("Problem with file: " + fileName);
        e.printStackTrace();
        return;
    }
    outputDir = getOutputDir("-p");
    if (opts.get("-h") != null) {
        // where to write the helpers to if the option is set
        outputDirHelpers = getOutputDir("-h");
    }
    typeManager = new StructureTypeManager(structureReader.getStructures());
    for (StructureDescriptor structure : structureReader.getStructures()) {
        try {
            if (FlagStructureList.isFlagsStructure(structure.getName())) {
                generateBuildFlags(structure);
            } else {
                generateClass(structure);
            }
        } catch (FileNotFoundException e) {
            String error = String.format("File Not Found processing: %s: %s", structure.getPointerName(), e.getMessage());
            System.out.println(error);
        } catch (IOException e) {
            String error = String.format("IOException processing: %s: %s", structure.getPointerName(), e.getMessage());
            System.out.println(error);
        }
    }
}
Also used : StructureTypeManager(com.ibm.j9ddr.StructureTypeManager) J9DDRStructureStore(com.ibm.j9ddr.tools.store.J9DDRStructureStore) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) StructureReader(com.ibm.j9ddr.StructureReader) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) StructureDescriptor(com.ibm.j9ddr.StructureReader.StructureDescriptor)

Example 5 with StructureDescriptor

use of com.ibm.j9ddr.StructureReader.StructureDescriptor in project openj9 by eclipse.

the class StructureStubGenerator method generateClasses.

private void generateClasses() {
    String supersetDirectoryName = opts.get("-f");
    String supersetFileName = opts.get("-s");
    try {
        J9DDRStructureStore store = new J9DDRStructureStore(supersetDirectoryName, supersetFileName);
        System.out.println("superset directory name : " + supersetDirectoryName);
        System.out.println("superset file name : " + store.getSuperSetFileName());
        InputStream inputStream = store.getSuperset();
        structureReader = new StructureReader(inputStream);
        inputStream.close();
    } catch (IOException e) {
        System.out.println("Could not find file: " + supersetDirectoryName + "/" + supersetFileName);
        return;
    }
    outputDir = getOutputDir();
    for (StructureDescriptor structure : structureReader.getStructures()) {
        try {
            if (FlagStructureList.isFlagsStructure(structure.getName())) {
            // generateBuildFlags(structure);
            } else {
                generateClass(structure);
            }
        } catch (FileNotFoundException e) {
            String error = String.format("File Not Found processing: %s: %s", structure.getName(), e.getMessage());
            System.out.println(error);
        } catch (IOException e) {
            String error = String.format("IOException processing: %s: %s", structure.getName(), e.getMessage());
            System.out.println(error);
        }
    }
}
Also used : J9DDRStructureStore(com.ibm.j9ddr.tools.store.J9DDRStructureStore) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) StructureReader(com.ibm.j9ddr.StructureReader) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) StructureDescriptor(com.ibm.j9ddr.StructureReader.StructureDescriptor)

Aggregations

StructureDescriptor (com.ibm.j9ddr.StructureReader.StructureDescriptor)10 StructureReader (com.ibm.j9ddr.StructureReader)4 FieldDescriptor (com.ibm.j9ddr.StructureReader.FieldDescriptor)4 FileInputStream (java.io.FileInputStream)3 InputStream (java.io.InputStream)3 CorruptDataException (com.ibm.j9ddr.CorruptDataException)2 ConstantDescriptor (com.ibm.j9ddr.StructureReader.ConstantDescriptor)2 StructureTypeManager (com.ibm.j9ddr.StructureTypeManager)2 J9DDRStructureStore (com.ibm.j9ddr.tools.store.J9DDRStructureStore)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 ImageInputStream (javax.imageio.stream.ImageInputStream)2 AbstractPointer (com.ibm.j9ddr.vm29.pointer.AbstractPointer)1 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)1 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)1 SlotType (com.ibm.j9ddr.vm29.tools.ddrinteractive.IClassWalkCallbacks.SlotType)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 DigestInputStream (java.security.DigestInputStream)1 ArrayList (java.util.ArrayList)1