use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class DumpAllRegionsCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
boolean statsRequested = false;
boolean skipReport = false;
if (0 != args.length) {
String argument = args[0];
if (argument.equalsIgnoreCase("help")) {
help(out);
return;
}
statsRequested = argument.equalsIgnoreCase("stats");
skipReport = statsRequested;
}
try {
GCHeapRegionIterator gcHeapRegionIterator = GCHeapRegionIterator.from();
int[] stats = new int[regionTypesString.length];
int total = 0;
String header1, header2, header3;
String footer;
String formatString;
String regionType;
initializeStats(stats);
if (J9BuildFlags.env_data64) {
header1 = "+----------------+----------------+----------------+----------------+--------+----------------+----------------------\n";
header2 = "| region | start | end | subspace | flags | size | region type \n";
header3 = "+----------------+----------------+----------------+----------------+--------+----------------+----------------------\n";
formatString = " %016x %016x %016x %016x %08x %16x %s\n";
footer = "+----------------+----------------+----------------+----------------+--------+----------------+----------------------\n";
} else {
header1 = "+--------+--------+--------+--------+--------+--------+----------------------\n";
header2 = "| region | start | end |subspace| flags | size | region type \n";
header3 = "+--------+--------+--------+--------+--------+--------+----------------------\n";
formatString = " %08x %08x %08x %08x %08x %8x %s\n";
footer = "+--------+--------+--------+--------+--------+--------+----------------------\n";
}
if (!skipReport) {
out.append(header1);
out.append(header2);
out.append(header3);
}
while (gcHeapRegionIterator.hasNext()) {
GCHeapRegionDescriptor heapRegionDescriptor = gcHeapRegionIterator.next();
int index = (int) heapRegionDescriptor.getRegionType();
total += 1;
if (index < regionTypesString.length) {
regionType = regionTypesString[index];
stats[index] += 1;
} else {
regionType = "Unknown";
}
if (!skipReport) {
out.append(String.format(formatString, heapRegionDescriptor.getHeapRegionDescriptorPointer().getAddress(), heapRegionDescriptor.getLowAddress().getAddress(), heapRegionDescriptor.getHighAddress().getAddress(), heapRegionDescriptor.getSubSpace().getAddress(), heapRegionDescriptor.getTypeFlags().longValue(), heapRegionDescriptor.getSize().longValue(), regionType));
}
}
if (!skipReport) {
out.append(footer);
}
if (statsRequested) {
String formatStringStats = " \t%s: %d\n";
for (int i = 0; i < regionTypesString.length; i++) {
if (0 != stats[i]) {
out.append(String.format(formatStringStats, regionTypesString[i], stats[i]));
}
}
out.append(String.format(formatStringStats, "++++ TOTAL", total));
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class DumpAllRomClassLinearCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
long nestingThreashold;
if (args.length > 1) {
throw new DDRInteractiveCommandException("This debug extension accepts none or one argument!");
} else if (args.length == 1) {
nestingThreashold = Long.valueOf(args[0]);
} else {
nestingThreashold = 1;
}
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (null != vm) {
out.println();
out.println("!j9javavm " + vm.getHexAddress());
} else {
throw new DDRInteractiveCommandException("Unable to find the VM in core dump!");
}
out.println();
ROMClassesIterator iterator = new ROMClassesIterator(out, vm.classMemorySegments());
while (iterator.hasNext()) {
J9ROMClassPointer classPointer = iterator.next();
out.println("!dumpromclasslinear " + classPointer.getHexAddress());
// ROM Class 'org/apache/tomcat/util/buf/MessageBytes' at 0x0DCF9008:
out.println(String.format("ROM Class '%s' at %s", J9UTF8Helper.stringValue(classPointer.className()), classPointer.getHexAddress()));
out.println();
ClassWalker classWalker = new RomClassWalker(classPointer, context);
new LinearDumper().gatherLayoutInfo(out, classWalker, nestingThreashold);
out.println();
}
} catch (CorruptDataException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
use of com.ibm.j9ddr.CorruptDataException 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.CorruptDataException 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.CorruptDataException 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);
}
}
Aggregations