use of com.ibm.j9ddr.DataUnavailableException in project openj9 by eclipse.
the class MiniDumpReader method getCommandLine.
String getCommandLine() throws CorruptDataException, DataUnavailableException {
// For dumps from Windows Vista, Server 2008 and later, we have no way to find the command line
if (_windowsMajorVersion >= 6) {
throw new DataUnavailableException("Command line not available from Windows core dump");
}
// For dumps from older Windows versions, we can get the command line from the known PEB location
String commandLine = null;
try {
IMemory memory = getMemory();
short length;
long commandAddress;
if (is64Bit()) {
length = memory.getShortAt(COMMAND_LINE_LENGTH_ADDRESS_64);
commandAddress = memory.getLongAt(COMMAND_LINE_ADDRESS_ADDRESS_64);
} else {
length = memory.getShortAt(COMMAND_LINE_LENGTH_ADDRESS_32);
commandAddress = 0xFFFFFFFF & memory.getIntAt(COMMAND_LINE_ADDRESS_ADDRESS_32);
}
if (commandAddress == 0) {
throw new DataUnavailableException("Command line not in core file");
}
byte[] buf = new byte[length];
memory.getBytesAt(commandAddress, buf);
// FIXME: Should UTF-16LE be hard coded here? Is the encoding platform
// specific?
commandLine = new String(buf, "UTF-16LE");
return commandLine;
} catch (Exception e) {
// throw a corrupt data exception as we expect the command line to be present so DataUnavailable is not appropriate
throw new CorruptDataException("Failed to read command line from core file", e);
}
}
use of com.ibm.j9ddr.DataUnavailableException in project openj9 by eclipse.
the class J9DDRImageProcess method getCommandLine.
/**
* This method tries to get command line of the program that generated core file.
*
* We can't get the command line from the core dump on zOS, or on recent Windows versions. On Linux
* it may be truncated. The java launcher stores the command line in an environment variable, so for
* all platforms we now try that first, with the core reader as a fallback.
*
* @return String instance of the commandline
* @throws DataUnavailable
* @throws {@link CorruptDataException}
*/
public String getCommandLine() throws DataUnavailable, CorruptDataException {
try {
Properties environment = getEnvironment();
String javaCommandLine = environment.getProperty(JAVA_COMMAND_LINE_ENVIRONMENT_VARIABLE);
if (javaCommandLine != null) {
return javaCommandLine;
}
return process.getCommandLine();
} catch (com.ibm.j9ddr.CorruptDataException e) {
throw new DTFJCorruptDataException(process, e);
} catch (DataUnavailableException e) {
throw new DataUnavailable(e.getMessage());
}
}
use of com.ibm.j9ddr.DataUnavailableException in project openj9 by eclipse.
the class WindowsProcessAddressSpace method getEnvironmentSymbols.
/**
* This method returns a list of symbols with the name "_environ"
*
* @return LinkedList instance of symbols with the name "_environ"
* @throws CorruptDataException
*/
private LinkedList<ISymbol> getEnvironmentSymbols() throws CorruptDataException {
List<IModule> modules = getModules();
LinkedList<ISymbol> symbols = new LinkedList<ISymbol>();
for (IModule thisModule : modules) {
try {
for (ISymbol thisSymbol : thisModule.getSymbols()) {
if (thisSymbol.getName().equals("_environ")) {
symbols.add(thisSymbol);
}
}
} catch (DataUnavailableException e) {
continue;
}
}
return symbols;
}
use of com.ibm.j9ddr.DataUnavailableException in project openj9 by eclipse.
the class WindowsProcessAddressSpace method getEnvironmentVariables.
/**
* This method tries to get environment variables by iterating through modules.
* It returns the one with environment var "IBM_JAVA_COMMAND_LINE"
* If there is no module with IBM_JAVA_COMMAND_LINE, then it returns the last one.
*
* @return Properties instance of environment variables.
* @throws DataUnavailableException
* @throws CorruptDataException
*/
public Properties getEnvironmentVariables() throws DataUnavailableException, CorruptDataException {
if (null == environment) {
LinkedList<ISymbol> environSymbols = getEnvironmentSymbols();
ISymbol environ = null;
if (0 == environSymbols.size()) {
throw new DataUnavailableException("Couldn't find environment symbol");
}
/* There might be more than one module with environment variables. Use the one that has IBM_JAVA_COMMAND_LINE */
for (int i = 0; i < environSymbols.size(); i++) {
environ = environSymbols.get(i);
long environPointer = getPointerAt(environ.getAddress());
environment = EnvironmentUtils.readEnvironment(this, environPointer);
if (environment.containsKey("IBM_JAVA_COMMAND_LINE")) {
break;
}
}
}
return environment;
}
use of com.ibm.j9ddr.DataUnavailableException in project openj9 by eclipse.
the class LookupSymbolCommand method run.
public void run(String cmd, String[] args, Context ctx, PrintStream out) throws DDRInteractiveCommandException {
if (args.length != 1) {
out.println("Please supply a function pointer to lookup.");
return;
}
boolean is64BitPlatform = (ctx.process.bytesPerPointer() == 8) ? true : false;
long address = CommandUtils.parsePointer(args[0], is64BitPlatform);
try {
String symbol = ctx.process.getProcedureNameForAddress(address);
out.println("Closest match:");
out.println(symbol);
} catch (DataUnavailableException e) {
throw new DDRInteractiveCommandException(e);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations