use of com.ibm.j9ddr.DataUnavailableException in project openj9 by eclipse.
the class NativeStacksCommand method run.
public void run(String cmd, String[] args, Context ctx, PrintStream out) throws DDRInteractiveCommandException {
Set<Long> threadIds = null;
for (String arg : args) {
if (threadIds == null) {
threadIds = new HashSet<Long>();
}
Long tid = CommandUtils.parseNumber(arg).longValue();
threadIds.add(tid);
}
try {
Collection<? extends IOSThread> threads = ctx.process.getThreads();
for (IOSThread t : threads) {
if (threadIds == null || threadIds.contains(t.getThreadId())) {
try {
out.printf("Thread id: %d (0x%X)\n", t.getThreadId(), t.getThreadId());
int frameId = 0;
if (threadIds != null) {
threadIds.remove(t.getThreadId());
}
for (IOSStackFrame f : t.getStackFrames()) {
String symbol = ctx.process.getProcedureNameForAddress(f.getInstructionPointer());
if (ctx.process.bytesPerPointer() == 8) {
out.printf("#%d bp:0x%016X ip:0x%016X %s\n", frameId++, f.getBasePointer(), f.getInstructionPointer(), symbol);
} else {
out.printf("#%d bp:0x%08X ip:0x%08X %s\n", frameId++, f.getBasePointer(), f.getInstructionPointer(), symbol);
}
}
} catch (DataUnavailableException e) {
out.printf("DataUnavailableException reading stack for thread %d\n", t.getThreadId());
} catch (CorruptDataException e) {
out.printf("CorruptDataException reading stack for thread %d\n", t.getThreadId());
}
out.println("----------");
}
}
if (threadIds != null && !threadIds.isEmpty()) {
out.print("Unable to find native thread for id(s): ");
for (long tid : threadIds) {
out.print(tid);
}
out.println();
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.DataUnavailableException 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();
}
use of com.ibm.j9ddr.DataUnavailableException in project openj9 by eclipse.
the class J9DDRImageProcess method getEnvironment.
/**
* This method gets the environment variables.
* First it tries to extract it from RAS structure.
* If not, it tries to get it from loaded modules.
* @return Properties instance of environment variables.
* @throws DataUnavailable
* @throws CorruptDataException
*/
public Properties getEnvironment() throws DataUnavailable, CorruptDataException {
try {
checkFailureInfo();
if (j9rasProcessData != null) {
try {
Properties properties;
long environ = j9rasProcessData.getEnvironment();
if (process.getPlatform() == Platform.WINDOWS && j9rasProcessData.version() > 4) {
// Get the env vars from an environment strings block instead of the environ global
properties = EnvironmentUtils.readEnvironmentStrings(process, environ);
} else {
long stringPointer = process.getPointerAt(environ);
properties = EnvironmentUtils.readEnvironment(process, stringPointer);
}
if ((null == properties) || (0 == properties.size())) {
/* In the case of env vars is null or empty,
* throw exception so that it tries to get env vars from modules
*/
throw new com.ibm.j9ddr.CorruptDataException("");
}
return properties;
} catch (com.ibm.j9ddr.CorruptDataException e1) {
/* Seems like RAS structure is corrupted. Try to get it from modules. */
return process.getEnvironmentVariables();
}
} else {
/* We don't have a J9RAS structure to work with. Try to get it from modules. */
return process.getEnvironmentVariables();
}
} catch (com.ibm.j9ddr.CorruptDataException e) {
throw new DTFJCorruptDataException(process, e);
} catch (DataUnavailableException e) {
throw new DataUnavailable(e.getMessage());
}
}
Aggregations