use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.
the class PHDJavaHeap method getSections.
public Iterator<ImageSection> getSections() {
List<ImageSection> c = new ArrayList<ImageSection>();
// This is the start of the last object
long last = runtime.maxAddress;
if (runtime.minAddress <= runtime.maxAddress) {
ImagePointer objPointer = space.getPointer(last);
JavaObject lastObj = null;
try {
lastObj = getLastObject(objPointer, runtime.maxObjClass, runtime.maxObjLen);
} catch (IOException e1) {
// allow to fall through so that jo is null
}
try {
// Find the end of the last object
if (lastObj != null)
last += lastObj.getSize();
ImageSection s = new PHDImageSection(getName(), space.getPointer(runtime.minAddress), last - runtime.minAddress);
c.add(s);
} catch (CorruptDataException e) {
ImageSection s = new PHDImageSection(getName(), space.getPointer(runtime.minAddress), last - runtime.minAddress);
c.add(s);
// The object will take some space
s = new PHDCorruptImageSection("Corrupt " + getName(), objPointer, 8);
c.add(s);
}
}
if (runtime.minClassAddress <= runtime.maxClassAddress) {
// Space in heap for class objects
long last2 = runtime.maxClassAddress;
ImagePointer objPointer = space.getPointer(last2);
int insert = c.size();
ImageSection s;
try {
JavaClass jc = runtime.findClass(last2);
// Make sure the class takes up some room
long size = 8;
if (jc != null) {
JavaObject lastObj = jc.getObject();
if (lastObj != null && lastObj.getID().equals(jc.getID())) {
size = lastObj.getSize();
}
}
last2 += size;
} catch (CorruptDataException e) {
s = new PHDCorruptImageSection("Corrupt " + getName(), objPointer, 8);
c.add(s);
}
// Do the object and class object sections overlap, if so combine them
if (last2 < runtime.minAddress || last < runtime.minClassAddress) {
s = new PHDImageSection(getName(), space.getPointer(runtime.minClassAddress), last2 - runtime.minClassAddress);
c.add(insert, s);
} else {
long minAddr = Math.min(runtime.minAddress, runtime.minClassAddress);
long maxAddr = Math.max(last, last2);
s = new PHDImageSection(getName(), space.getPointer(minAddr), maxAddr - minAddr);
// Replace with a combined section
c.set(0, s);
}
}
return c.iterator();
}
use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.
the class PHDJavaRuntime method initClassCache.
private void initClassCache() {
for (PHDJavaClassLoader ldr : loaders.values()) {
for (Iterator<JavaClass> it = ldr.getDefinedClasses(); it.hasNext(); ) {
JavaClass cls = it.next();
ImagePointer ip = cls.getID();
if (ip != null) {
classIdCache.put(ip.getAddress(), cls);
} else {
// Some classes have pseudo ids
for (long l = 1; l <= lastDummyClassAddr(); ++l) {
if (cls.equals(ldr.findClass(l))) {
classIdCache.put(l, cls);
}
}
}
}
}
}
use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.
the class FindCommand method scanRegion.
private boolean scanRegion(long start, long end, ImageSection imageSection) {
ImagePointer imagePointer = imageSection.getBaseAddress();
long i;
if (0 != start % findAtt.boundary) {
i = start - start % findAtt.boundary + findAtt.boundary;
} else {
i = start;
}
int patternLength = findAtt.length();
byte[] bytes = findAtt.getBytes();
for (; i <= end; i += findAtt.boundary) {
int j;
for (j = 0; j < patternLength; j++) {
byte oneByte = bytes[j];
try {
if (getByteFromImage(imagePointer, i + j) == oneByte) {
continue;
} else {
break;
}
} catch (MemoryAccessException mae) {
return false;
}
}
if (j >= patternLength) {
matches.add(new Long(i));
if (matches.size() == findAtt.numMatchesToDisplay)
return true;
}
}
return false;
}
use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.
the class XDCommand method doCommand.
public void doCommand(String[] args) {
String param = args[0];
Long address;
address = Utils.longFromStringWithPrefix(param);
if (null == address) {
out.println("invalid hex address specified; address must be specified as " + "\"0x<hex_address>\"");
return;
}
out.print("\n");
boolean found = false;
for (int index = 0; index < argUnitNumber; index++) {
long currAddr = address.longValue() + (index * argUnitSize);
out.print("\t");
out.print(Utils.toHex(currAddr));
out.print(": ");
ImageAddressSpace ias = ctx.getAddressSpace();
ImagePointer ip = ias.getPointer(currAddr);
byte b = 0;
short s = 0;
int i = 0;
long l = 0;
try {
switch(argUnitSize) {
case 1:
b = ip.getByteAt(0);
break;
case 2:
s = ip.getShortAt(0);
break;
case 4:
i = ip.getIntAt(0);
break;
case 8:
l = ip.getLongAt(0);
break;
}
found = true;
} catch (CorruptDataException e) {
found = false;
} catch (MemoryAccessException e) {
found = false;
}
if (found) {
switch(argUnitSize) {
case 1:
out.print(Byte.toString(b));
break;
case 2:
out.print(Short.toString(s));
break;
case 4:
out.print(Integer.toString(i));
break;
case 8:
out.print(Long.toString(l));
break;
}
}
out.print("\n");
}
if (!found) {
out.print("<address not found in any address space>");
}
out.print("\n");
}
use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.
the class XKCommand method doCommand.
public void doCommand(String[] args) {
String param = args[0];
Long address = Utils.longFromStringWithPrefix(param);
if (null == address) {
out.println("invalid hex address specified; address must be specified as " + "\"0x<hex_address>\"");
return;
}
ImageAddressSpace ias = ctx.getAddressSpace();
int pointerSize = getIASPointerSize(ias);
int unitSize;
if (pointerSize > 32)
unitSize = 8;
else
unitSize = 4;
out.print("\n");
for (int index = 0; index < argUnitNumber; index++) {
boolean found = false;
long currAddr = address.longValue() + (index * unitSize);
ImagePointer ip = ias.getPointer(currAddr);
out.print("\t");
out.print(Utils.toHex(currAddr));
out.print(" ");
long l = 0;
try {
l = ip.getPointerAt(0).getAddress();
found = true;
} catch (CorruptDataException e) {
found = false;
} catch (MemoryAccessException e) {
found = false;
}
if (found) {
long pointer = l;
out.print(toAdjustedHex(l, pointerSize));
out.print(" ");
if (31 == pointerSize) {
pointer = (int) (pointer & (((long) 1) << pointerSize) - 1);
}
if (printSymbol(pointer, l - currAddr, pointerSize)) {
} else if (printStackPointer(pointer, l - currAddr, pointerSize, ias)) {
}
out.print("\n");
} else {
out.print("<address not found in any address space or exception occurred>\n");
}
}
out.print("\n");
}
Aggregations