use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class DumpRomMethodCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
Iterable<J9ROMClassAndMethod> methodIterator = null;
if (args.length < 1) {
printUsage(out);
return;
}
String selector = args[0];
if (selector.equals("-a")) {
if (args.length != 2) {
printUsage(out);
return;
}
/* decimal or hexadecimal */
long methodAddress = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
J9MethodPointer ramMethod = J9MethodPointer.cast(methodAddress);
if (ramMethod.isNull()) {
CommandUtils.dbgPrint(out, "bad ram method addr\n");
return;
}
methodIterator = romMethodIteratorFromRamMethod(ramMethod);
} else if (selector.equals("-o")) {
if (args.length != 2) {
printUsage(out);
return;
}
long methodAddress = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
J9ROMMethodPointer romMethod = J9ROMMethodPointer.cast(methodAddress);
if (romMethod.isNull()) {
CommandUtils.dbgPrint(out, "bad rom method addr\n");
return;
}
J9ROMMethodPointer bytecodesStart = romMethod.add(1);
/* bytecodes immediately follow the J9ROMMethod struct */
U8Pointer pc = U8Pointer.cast(bytecodesStart.getAddress());
J9MethodPointer ramMethod = J9JavaVMHelper.getMethodFromPC(J9RASHelper.getVM(DataType.getJ9RASPointer()), pc);
methodIterator = romMethodIteratorFromRamMethod(ramMethod);
} else {
try {
methodIterator = new FilteredROMMethodsIterator(out, context, selector);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
for (J9ROMClassAndMethod mi : methodIterator) {
out.println(String.format("Class: %s", J9UTF8Helper.stringValue(mi.romClass.className())));
J9BCUtil.j9bcutil_dumpRomMethod(out, mi.romMethod, mi.romClass, dumpFlags, J9BCUtil.BCUtil_DumpAnnotations);
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
} catch (NullPointerException e) {
e.printStackTrace();
throw e;
}
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class FindPatternCommand method run.
/**
* Run method for !findpattern extension.
*
* @param command !findpattern
* @param args args passed by !findpattern extension.
* @param context Context
* @param out PrintStream
* @throws DDRInteractiveCommandException
*/
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
byte[] pattern = null;
BigInteger bytesToSearch = CommandUtils.longToBigInteger(UDATA.MAX.longValue());
int length = 0;
if (args.length != 1) {
printUsage(out);
return;
}
String[] realArgs = args[0].split(",");
if (realArgs.length == 1) {
CommandUtils.dbgError(out, "Error: must specify alignment\n");
printUsage(out);
return;
}
String hexstring = realArgs[0];
int patternAlignment = Integer.parseInt(realArgs[1]);
long startSearchFrom = 0;
if (realArgs.length == 3) {
startSearchFrom = CommandUtils.parsePointer(realArgs[2], J9BuildFlags.env_data64);
bytesToSearch = bytesToSearch.subtract(CommandUtils.longToBigInteger(startSearchFrom));
} else if (realArgs.length == 4) {
startSearchFrom = CommandUtils.parsePointer(realArgs[2], J9BuildFlags.env_data64);
bytesToSearch = CommandUtils.parseNumber(realArgs[3]);
if (bytesToSearch.add(CommandUtils.longToBigInteger(startSearchFrom)).toString(CommandUtils.RADIX_HEXADECIMAL).length() > UDATA.SIZEOF) {
out.println("Warning: bytesToSearch value (" + realArgs[3] + ") is larger than the max available memory after the search start address (" + realArgs[2] + ").\n Pattern will be searched in all the remaining memory after the search start address");
bytesToSearch = CommandUtils.longToBigInteger(UDATA.MAX.longValue()).subtract(CommandUtils.longToBigInteger(startSearchFrom));
}
} else if (realArgs.length > 4) {
CommandUtils.dbgError(out, "Error: too many arguments\n");
}
length = hexstring.length() / 2;
if (length > PATTERN_LENGHT) {
CommandUtils.dbgPrint(out, String.format("Pattern is too long. Truncating to %d bytes\n", PATTERN_LENGHT));
length = PATTERN_LENGHT;
}
pattern = new byte[length];
for (int i = 0; i < length; i++) {
int hex1 = hexValue(hexstring.charAt(i * 2));
int hex2 = hexValue(hexstring.charAt(i * 2 + 1));
if ((hex1 < 0) || (hex2 < 0)) {
CommandUtils.dbgError(out, "Error: non-hex value found in hex string\n");
return;
}
pattern[i] = (byte) ((hex1 << 4) + hex2);
}
/* ensure that alignment is > 0 */
if (patternAlignment == 0) {
patternAlignment = 1;
}
CommandUtils.dbgPrint(out, String.format("Searching for %d bytes. Alignment = %d, start = %s, bytesToSearch = %s ...\n", length, patternAlignment, U8Pointer.cast(startSearchFrom).getHexAddress(), bytesToSearch.toString()));
long result = dbgFindPatternInRange(context, pattern, patternAlignment, startSearchFrom, bytesToSearch);
if (0 != result) {
CommandUtils.dbgPrint(out, String.format("Result = %s\n", U8Pointer.cast(result).getHexAddress()));
} else {
CommandUtils.dbgPrint(out, String.format("Result = No Match Found.\n"));
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class FindOverlappingSegmentsCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
int segmentType = MemorySegmentIterator.MEMORY_ALL_TYPES & ~((int) J9MemorySegment.MEMORY_TYPE_SHARED_META);
if (args.length == 0) {
/* use default */
} else {
String argument = args[0];
if (argument.equalsIgnoreCase("help")) {
printHelp(out);
return;
} else if (argument.equalsIgnoreCase("all")) {
segmentType = MemorySegmentIterator.MEMORY_ALL_TYPES;
} else if (argument.equalsIgnoreCase("virtual")) {
segmentType = (int) J9MemorySegment.MEMORY_TYPE_VIRTUAL;
}
}
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
SegmentsUtil.checkSegmentsForOverlap(out, vm, segmentType);
out.append(nl);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class FindVMCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
J9RASHelper.setCachedVM(null);
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
CommandUtils.dbgPrint(out, "!j9javavm %s\n", vm.getHexAddress());
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class GCCheckCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
GCCheckRunner.run(vm, args, out);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations