use of com.ibm.j9ddr.corereaders.memory.IAddressSpace in project openj9 by eclipse.
the class JniReader method getAddressSpaces.
/**
* This method creates JNI address space and puts it into collection instance.
*
* @return Collection of address spaces
*/
public Collection<? extends IAddressSpace> getAddressSpaces() {
if (null == addressSpaces) {
addressSpaces = new ArrayList<IAddressSpace>(1);
JniAddressSpace addressSpace = new JniAddressSpace(0, this);
Iterator<? extends IProcess> ite = addressSpace.getProcesses().iterator();
if (ite.hasNext()) {
IProcess process = ite.next();
/* This is sanity check. It should always be the JniProcess instance */
if (process instanceof JniProcess) {
JniProcess jniProcess = (JniProcess) process;
/* Set ICore.PROCESSOR_TYPE_PROPERTY in the properties by checking the target architecture */
int targetArchitecture = jniProcess.getTargetArchitecture();
switch(targetArchitecture) {
case JniProcess.TARGET_TYPE_X86_32:
properties.setProperty(ICore.PROCESSOR_TYPE_PROPERTY, "x86");
break;
case JniProcess.TARGET_TYPE_X86_64:
properties.put(ICore.PROCESSOR_TYPE_PROPERTY, "amd64");
break;
case JniProcess.TARGET_TYPE_S390_31:
case JniProcess.TARGET_TYPE_S390_64:
properties.put(ICore.PROCESSOR_TYPE_PROPERTY, "s390");
break;
case JniProcess.TARGET_TYPE_PPC_32:
case JniProcess.TARGET_TYPE_PPC_64:
properties.put(ICore.PROCESSOR_TYPE_PROPERTY, "ppc");
break;
default:
}
}
}
addressSpaces.add(addressSpace);
}
return addressSpaces;
}
use of com.ibm.j9ddr.corereaders.memory.IAddressSpace in project openj9 by eclipse.
the class DDRInteractive method locateRuntimes.
private void locateRuntimes(ICore reader) {
currentCore = reader;
Collection<? extends IAddressSpace> spaces = reader.getAddressSpaces();
for (IAddressSpace thisSpace : spaces) {
// indicates if a context has been allocated for the address space
boolean hasCtxBeenAddedForAS = false;
Collection<? extends IProcess> processes = thisSpace.getProcesses();
for (IProcess thisProcess : processes) {
hasCtxBeenAddedForAS = true;
try {
IVMData vmData = VMDataFactory.getVMData(thisProcess);
if (vmData != null) {
contexts.add(new Context(thisProcess, vmData, nonVMCommands));
} else {
addMissingJVMToContexts(thisProcess);
}
} catch (JVMNotDDREnabledException e) {
addMissingJVMToContexts(thisProcess);
} catch (JVMNotFoundException e) {
addMissingJVMToContexts(thisProcess);
} catch (MissingDDRStructuresException e) {
addMissingJVMToContexts(thisProcess);
} catch (IOException e) {
System.err.println("Problem searching for VMData in process " + thisProcess);
e.printStackTrace();
// put the stack trace to the log
Logger logger = Logger.getLogger(LoggerNames.LOGGER_INTERACTIVE_CONTEXT);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
logger.logp(FINE, null, null, sw.toString());
}
}
if (!hasCtxBeenAddedForAS) {
ASNoProcess as = new ASNoProcess(thisSpace);
addMissingJVMToContexts(as);
}
}
if (contexts.size() == 0) {
throw new RuntimeException("Couldn't find any address spaces in this dump");
} else {
// default to the first address space
currentContext = contexts.get(0);
for (Context ctx : contexts) {
// but if there is one with a JVM in it, set it to that
if (!(ctx.vmData instanceof MissingVMData)) {
currentContext = ctx;
break;
}
}
}
}
use of com.ibm.j9ddr.corereaders.memory.IAddressSpace in project openj9 by eclipse.
the class DDRInteractive method addDDRContextFromDTFJ.
private void addDDRContextFromDTFJ(Object dtfjctx) throws Exception {
Method getAddressSpace = findMethod(dtfjctx.getClass(), "getAddressSpace", (Class<?>[]) null);
Method getProcess = findMethod(dtfjctx.getClass(), "getProcess", (Class<?>[]) null);
Method getRuntime = findMethod(dtfjctx.getClass(), "getRuntime", (Class<?>[]) null);
Object addressSpace = getAddressSpace.invoke(dtfjctx, (Object[]) null);
Object process = getProcess.invoke(dtfjctx, (Object[]) null);
Object runtime = getRuntime.invoke(dtfjctx, (Object[]) null);
if (addressSpace == null) {
throw new IOException("Cannot create a context without an associated address space");
}
if (!(addressSpace instanceof J9DDRImageAddressSpace)) {
throw new UnsupportedOperationException("The supplied DTFJ context is not backed by a DDR implementation");
}
IAddressSpace space = ((J9DDRImageAddressSpace) addressSpace).getIAddressSpace();
IProcess proc = null;
if (process != null) {
proc = ((J9DDRImageProcess) process).getIProcess();
}
if (proc == null) {
ASNoProcess as = new ASNoProcess(space);
addMissingJVMToContexts(as);
return;
}
if (runtime == null) {
addMissingJVMToContexts(proc);
return;
}
// DDR will cache the VM data, so if the DTFJ context has already found it then this should be in the cache
IVMData vmData = VMDataFactory.getVMData(proc);
if (vmData != null) {
contexts.add(new Context(proc, vmData, nonVMCommands));
} else {
addMissingJVMToContexts(proc);
}
}
use of com.ibm.j9ddr.corereaders.memory.IAddressSpace in project openj9 by eclipse.
the class BootstrapJUnitTest method beforeClass.
@BeforeClass
public static void beforeClass() {
try {
String coreFileName = System.getProperty("ddr.core.file.name");
if (coreFileName == null) {
fail("Did not specify core file name with -Dddr.core.file.name");
}
ICore core = CoreReader.readCoreFile(coreFileName);
List<IAddressSpace> addressSpaces = new ArrayList<IAddressSpace>(core.getAddressSpaces());
for (IAddressSpace thisAS : addressSpaces) {
for (IProcess thisProc : thisAS.getProcesses()) {
try {
vmData = VMDataFactory.getVMData(thisProc);
return;
} catch (IOException ex) {
// This happens if we can't find a JVM or a blob. Keep looking
}
}
}
fail("Couldn't initialize VMData");
} catch (FileNotFoundException e) {
fail("Could not initialize VMData: " + e.getMessage());
} catch (IOException e) {
fail("Could not initialize VMData: " + e.getMessage());
}
}
use of com.ibm.j9ddr.corereaders.memory.IAddressSpace in project openj9 by eclipse.
the class DumpSegments method main.
/**
* @param args
*/
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println("Expected 1 argument, got " + args.length);
}
String filename = args[0];
ICore core = CoreReader.readCoreFile(filename);
Collection<? extends IAddressSpace> addressSpaces = core.getAddressSpaces();
for (IAddressSpace as : addressSpaces) {
System.err.println("Address space: " + as.getAddressSpaceId());
List<? extends IMemoryRange> ranges = new ArrayList<IMemoryRange>(as.getMemoryRanges());
Collections.sort(ranges);
// System.err.println("Raw mappings");
// for(IMemoryRange thisRange : ranges) {
// System.err.println("Base: " +
// Long.toHexString(thisRange.getBaseAddress()) + " - size: " +
// Long.toHexString(thisRange.getSize()));
// if (thisRange.getBaseAddress() == 0xf95f000) {
// System.err.println("Found!");
// }
// }
List<Range> localRanges = new LinkedList<Range>();
for (IMemoryRange range : ranges) {
Range newRange = new Range();
newRange.base = range.getBaseAddress();
newRange.size = range.getSize();
localRanges.add(newRange);
}
localRanges = mergeRanges(localRanges);
for (Range range : localRanges) {
System.err.println("Base: " + Long.toHexString(range.base) + " - size: " + Long.toHexString(range.size));
try {
if (range.size > 7) {
/*
* Pick three addresses and read integers from them -
* proves that endian conversion is working
*/
long address1 = range.base;
long address2 = range.base + range.size - 5;
long address3 = (address1 + address2) / 2;
System.err.print(Long.toHexString(address1) + " - ");
System.err.println(Integer.toHexString(as.getIntAt(address1)));
System.err.print(Long.toHexString(address2) + " - ");
System.err.println(Integer.toHexString(as.getIntAt(address2)));
System.err.print(Long.toHexString(address3) + " - ");
if (0xf971ffd == address3) {
System.err.println("Found!");
}
System.err.println(Integer.toHexString(as.getIntAt(address3)));
}
} catch (MemoryFault ex) {
ex.printStackTrace();
}
}
}
}
Aggregations