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;
}
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();
}
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;
}
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);
}
}
}
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);
}
}
}
Aggregations