use of com.ibm.dtfj.image.ImageProcess in project openj9 by eclipse.
the class ImageFactory method hasJavaRuntime.
/**
* Checks to see if the supplied image has an available DTFJ Java Runtime. This is to force the parsing of the jextract XML
* for legacy DTFJ and blob parsing for DDR. It does not make any guarantees about the quality and availability of the
* run time data.
* @return true if a non-corrupt runtime is returned
*/
private static boolean hasJavaRuntime(ImageReference imageReference) {
if (null == imageReference || null == imageReference.image) {
return false;
}
Iterator<?> spaces = imageReference.image.getAddressSpaces();
while ((null != spaces) && spaces.hasNext()) {
// search address spaces
Object obj = spaces.next();
if ((null != obj) && (obj instanceof ImageAddressSpace)) {
ImageAddressSpace space = (ImageAddressSpace) obj;
Iterator<?> procs = space.getProcesses();
while ((null != procs) && procs.hasNext()) {
// search processes
Object procobj = procs.next();
if ((null != procobj) && (procobj instanceof ImageProcess)) {
ImageProcess proc = (ImageProcess) procobj;
Iterator<?> runtimes = proc.getRuntimes();
while ((null != runtimes) && runtimes.hasNext()) {
Object rtobj = runtimes.next();
if ((null != rtobj) && (rtobj instanceof JavaRuntime)) {
// found a non-corrupt java runtime
return true;
}
}
}
}
}
}
return false;
}
use of com.ibm.dtfj.image.ImageProcess in project openj9 by eclipse.
the class ImageStackFrame method getProcedureName.
public String getProcedureName() throws CorruptDataException {
if (null == _procedureName) {
ImageModule bestModule = null;
ImageSymbol bestClosest = null;
long bestDelta = Long.MAX_VALUE;
for (Iterator i = this._space.getProcesses(); i.hasNext(); ) {
Object nexti = i.next();
if (nexti instanceof CorruptData)
continue;
ImageProcess process = (ImageProcess) nexti;
if ((_procedureAddress.getAddress() != ((1L << process.getPointerSize()) - 1))) {
try {
ImageModule module = process.getExecutable();
ImageSymbol closest = getClosestSymbolFrom(module);
long delta = getDelta(module, closest);
if (delta >= 0 && delta < bestDelta) {
bestModule = module;
bestClosest = closest;
bestDelta = delta;
}
} catch (DataUnavailable e) {
} catch (CorruptDataException e) {
}
try {
for (Iterator j = process.getLibraries(); j.hasNext(); ) {
Object next = j.next();
if (next instanceof CorruptData)
continue;
ImageModule module = (ImageModule) next;
ImageSymbol closest = getClosestSymbolFrom(module);
long delta = getDelta(module, closest);
if (delta >= 0 && delta < bestDelta) {
bestModule = module;
bestClosest = closest;
bestDelta = delta;
}
}
} catch (DataUnavailable e) {
} catch (CorruptDataException e) {
}
}
}
ImageSymbol closest = bestClosest;
ImageModule module = bestModule;
long delta = bestDelta;
if (null != module) {
String deltaString = "";
if (delta == Long.MAX_VALUE) {
deltaString = "<offset not available>";
} else {
if (delta >= 0) {
deltaString = "+0x" + Long.toHexString(delta);
} else {
deltaString = "-0x" + Long.toHexString(delta);
}
}
if (null != closest) {
_procedureName = module.getName() + "::" + closest.getName() + deltaString;
} else {
_procedureName = module.getName() + deltaString;
}
}
}
// If we haven't found the symbol, we might as well record that fact.
if (null == _procedureName) {
_procedureName = "<unknown location>";
}
return _procedureName;
}
use of com.ibm.dtfj.image.ImageProcess in project openj9 by eclipse.
the class XKCommand method printSymbol.
private boolean printSymbol(long pointer, long diff, int pointerSize) {
ImageProcess ip = ctx.getProcess();
Iterator itModule;
try {
itModule = ip.getLibraries();
} catch (CorruptDataException e) {
// FIXME
itModule = null;
} catch (DataUnavailable e) {
// FIXME
itModule = null;
}
while (null != itModule && itModule.hasNext()) {
ImageModule im = (ImageModule) itModule.next();
Iterator itImageSection = im.getSections();
while (itImageSection.hasNext()) {
ImageSection is = (ImageSection) itImageSection.next();
long startAddr = is.getBaseAddress().getAddress();
long endAddr = startAddr + is.getSize();
if (pointer >= startAddr && pointer < endAddr) {
/* can we find a matching symbol? */
long maxDifference = pointer - startAddr;
ImageSymbol bestSymbol = null;
for (Iterator iter = im.getSymbols(); iter.hasNext(); ) {
Object next = iter.next();
if (next instanceof CorruptData)
continue;
ImageSymbol symbol = (ImageSymbol) next;
long symbolAddress = symbol.getAddress().getAddress();
if (symbolAddress <= pointer && pointer - symbolAddress < maxDifference) {
maxDifference = pointer - symbolAddress;
bestSymbol = symbol;
}
}
try {
out.print(im.getName());
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
}
out.print("::");
if (bestSymbol == null) {
out.print(is.getName());
} else {
out.print(bestSymbol.getName());
}
out.print("+");
out.print(Long.toString(maxDifference));
// trying to find it elsewhere in the address space
return true;
}
}
}
return false;
}
use of com.ibm.dtfj.image.ImageProcess in project openj9 by eclipse.
the class PHDImageAddressSpace method getImageSections.
public Iterator<ImageSection> getImageSections() {
List<ImageSection> list = new ArrayList<ImageSection>();
for (Iterator<ImageProcess> ip = getProcesses(); ip.hasNext(); ) {
ImageProcess p = ip.next();
if (p instanceof CorruptData)
continue;
for (Iterator<ManagedRuntime> jr = p.getRuntimes(); jr.hasNext(); ) {
ManagedRuntime mr = jr.next();
if (mr instanceof CorruptData)
continue;
if (mr instanceof JavaRuntime) {
for (Iterator<JavaHeap> jh = ((JavaRuntime) mr).getHeaps(); jh.hasNext(); ) {
JavaHeap hp = jh.next();
if (hp instanceof CorruptData)
continue;
for (Iterator<ImageSection> is = hp.getSections(); is.hasNext(); ) {
// Add the corrupt sections too
list.add(is.next());
}
}
}
}
}
if (metaImageAddressSpace != null) {
for (Iterator it = metaImageAddressSpace.getImageSections(); it.hasNext(); ) {
Object next = it.next();
if (next instanceof ImageSection) {
ImageSection section = (ImageSection) next;
ImageSection newSection = new PHDImageSection(section.getName(), getPointer(section.getBaseAddress().getAddress()), section.getSize());
list.add(newSection);
}
}
}
return list.iterator();
}
use of com.ibm.dtfj.image.ImageProcess in project openj9 by eclipse.
the class InfoProcCommand method printAddressSpaceInfo.
private void printAddressSpaceInfo() {
ImageAddressSpace ias = ctx.getAddressSpace();
ImageProcess ip = ias.getCurrentProcess();
if (ip == null) {
out.print("\t(No process in this address space)\n");
} else {
printProcessInfo();
}
out.print("\n");
}
Aggregations