Search in sources :

Example 6 with DataUnavailableException

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);
    }
}
Also used : DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) IOSStackFrame(com.ibm.j9ddr.corereaders.osthread.IOSStackFrame) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) IOSThread(com.ibm.j9ddr.corereaders.osthread.IOSThread)

Example 7 with DataUnavailableException

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();
}
Also used : IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) ImageSymbol(com.ibm.dtfj.image.ImageSymbol) ISymbol(com.ibm.j9ddr.corereaders.memory.ISymbol) ArrayList(java.util.ArrayList) Collection(java.util.Collection)

Example 8 with DataUnavailableException

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());
    }
}
Also used : DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) DTFJCorruptDataException(com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) DTFJCorruptDataException(com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) Properties(java.util.Properties)

Aggregations

DataUnavailableException (com.ibm.j9ddr.DataUnavailableException)8 CorruptDataException (com.ibm.j9ddr.CorruptDataException)3 ISymbol (com.ibm.j9ddr.corereaders.memory.ISymbol)3 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)2 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)2 DTFJCorruptDataException (com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException)2 Properties (java.util.Properties)2 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)1 ImageSymbol (com.ibm.dtfj.image.ImageSymbol)1 CorruptCoreException (com.ibm.j9ddr.corereaders.CorruptCoreException)1 InvalidDumpFormatException (com.ibm.j9ddr.corereaders.InvalidDumpFormatException)1 IMemory (com.ibm.j9ddr.corereaders.memory.IMemory)1 IMemoryRange (com.ibm.j9ddr.corereaders.memory.IMemoryRange)1 IModule (com.ibm.j9ddr.corereaders.memory.IModule)1 IOSStackFrame (com.ibm.j9ddr.corereaders.osthread.IOSStackFrame)1 IOSThread (com.ibm.j9ddr.corereaders.osthread.IOSThread)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1