use of com.ibm.dtfj.image.ImageSymbol 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.ImageSymbol in project openj9 by eclipse.
the class ImageProcessBuilder method addRoutine.
public ImageSymbol addRoutine(ImageModule library, String name, long address) {
ImagePointer addr = fImageAddressSpace.getPointer(address);
ImageSymbol symbol = new JCImageSymbol(name, addr);
JCImageModule mod = (JCImageModule) library;
mod.addSymbol(symbol);
return symbol;
}
use of com.ibm.dtfj.image.ImageSymbol in project openj9 by eclipse.
the class ImageSymbolTest method loadTestObjects.
protected void loadTestObjects(JavaRuntime ddrRuntime, List<Object> ddrObjects, JavaRuntime jextractRuntime, List<Object> jextractObjects) {
Exception ddrException = null;
Exception jextractException = null;
Iterator<?> ddrLibIt = null;
try {
ddrLibIt = ddrProcess.getLibraries();
} catch (Exception e) {
e.printStackTrace();
ddrException = e;
}
Iterator<?> jextractLibIt = null;
try {
jextractLibIt = jextractProcess.getLibraries();
} catch (Exception e) {
e.printStackTrace();
jextractException = e;
}
if (ddrException != null || jextractException != null) {
if (ddrException != null && jextractException != null) {
assertEquals(jextractException.getClass(), ddrException.getClass());
return;
}
if (ddrException != null) {
fail("DDR threw an exception getting libraries and JExtract didn't");
}
if (jextractException != null) {
fail("JExtract threw an exception getting libraries and DDR didn't");
}
}
slurpSymbolsFromLibraryIterator(ddrLibIt, ddrObjects);
slurpSymbolsFromLibraryIterator(jextractLibIt, jextractObjects);
Comparator<Object> c = new Comparator<Object>() {
public int compare(Object o1, Object o2) {
ImageSymbol sym1 = (ImageSymbol) o1;
ImageSymbol sym2 = (ImageSymbol) o2;
return (int) Long.signum(sym1.getAddress().getAddress() - sym2.getAddress().getAddress());
}
};
Collections.sort(ddrObjects, c);
Collections.sort(jextractObjects, c);
}
use of com.ibm.dtfj.image.ImageSymbol in project openj9 by eclipse.
the class ImageSymbolTest method slurpSymbolsFromLibraryIterator.
private void slurpSymbolsFromLibraryIterator(Iterator<?> it, List<Object> list) {
while (it.hasNext()) {
Object obj = it.next();
if (obj instanceof ImageModule) {
ImageModule mod = (ImageModule) obj;
Iterator<?> symIt = mod.getSymbols();
while (symIt.hasNext()) {
Object symObj = symIt.next();
if (symObj instanceof ImageSymbol) {
list.add(symObj);
} else {
System.err.println("Skipping symbol object: " + symObj + ", type " + symObj.getClass().getName());
}
}
} else {
System.err.println("Skipping module object: " + obj + ", type " + obj.getClass().getName());
}
}
}
use of com.ibm.dtfj.image.ImageSymbol in project openj9 by eclipse.
the class J9DDRImageModule method getSymbols.
/* (non-Javadoc)
* @see com.ibm.dtfj.image.ImageModule#getSymbols()
*/
public Iterator<?> getSymbols() {
Collection<? extends ISymbol> symbols;
try {
symbols = delegate.getSymbols();
} catch (DataUnavailableException e) {
// JEXTRACT slightly arbitrary code here. DTFJ/JExtract uses the base address of the .text section as the
// address of the corrupt data. We do the same for compatibility's sake.
Collection<? extends IMemoryRange> memoryRanges = delegate.getMemoryRanges();
long baseAddress = 0;
for (IMemoryRange range : memoryRanges) {
if (range.getName().contains(".text")) {
baseAddress = range.getBaseAddress();
break;
}
}
return Collections.singletonList(new J9DDRCorruptData(process, e.getMessage(), baseAddress)).iterator();
}
List<ImageSymbol> dtfjSymbols = new ArrayList<ImageSymbol>(symbols.size());
for (ISymbol symbol : symbols) {
dtfjSymbols.add(new J9DDRImageSymbol(symbol.getName(), new J9DDRImagePointer(process, symbol.getAddress())));
}
return dtfjSymbols.iterator();
}
Aggregations