use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class J9RegCommand method run.
/**
* Run method for !j9reg extension.
*
* @param command !j9reg
* @param args args passed by !j9reg extension.
* @param context Context of current core file.
* @param out PrintStream to print the output to the console.
* @throws DDRInteractiveCommandException
*/
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
int level = 0;
if (0 == args.length) {
level = 1;
} else if (1 == args.length) {
try {
level = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
out.println(args[0] + " is not a valid integer. Please try again.");
return;
}
} else {
printUsage(out);
}
J9JavaVMPointer vm;
try {
vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
VMRegMapHelper.printRegisters(vm, level, out);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException("Failed to get vm address from RAS");
} catch (UnknownArchitectureException uae) {
throw new DDRInteractiveCommandException(uae.getMessage(), uae);
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class J9MemTagCommands method runFindHeader.
private void runFindHeader(String command, String[] args, Context context) throws DDRInteractiveCommandException {
long address = 0;
J9MemTagPointer header = null;
if (args.length != 1) {
out.println("Usage: ");
out.println(" !findheader <address> (e.g. !findheader 0xa2b4c6d8)");
return;
}
address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
out.println(String.format("Searching memory allocation header for %s", U8Pointer.cast(address).getHexAddress()));
/*
* Search for an eyecatcher on or before the specified address. Start
* the search on the specified address since an eyecatcher may start on
* the address. Ensure that the eyecatcher that is found is on or before
* the address. If this condition is not satisfied, start searching for
* an eyecatcher 1K before the previous start address. Continue until an
* eyecatcher is found, or the start address of 0 is reached.
*/
long searchBase = address - SEARCH_SLAB_SIZE;
SEARCH_LOOP: do {
/* Add 3 (length of eyecatcher - 1) to the top address, to catch eyecatchers written between search slabs */
J9MemTagIterator it = J9MemTagIterator.iterateAllocatedHeaders(searchBase, searchBase + SEARCH_SLAB_SIZE + 3);
while (it.hasNext()) {
J9MemTagPointer potential = it.next();
if (Addresses.greaterThan(potential.getAddress(), address)) {
/* Walked past address */
break;
}
VoidPointer start = J9MemTagHelper.j9mem_get_memory_base(potential);
VoidPointer end;
try {
end = start.addOffset(potential.allocSize().longValue());
} catch (CorruptDataException e) {
continue;
}
if (Addresses.greaterThanOrEqual(address, start.getAddress()) && Addresses.lessThan(address, end.getAddress())) {
/* Match */
header = potential;
break SEARCH_LOOP;
}
}
if (Addresses.lessThan(searchBase, SEARCH_SLAB_SIZE)) {
searchBase = 0;
} else {
searchBase = searchBase - SEARCH_SLAB_SIZE;
}
} while (searchBase != 0);
if (header == null) {
out.println("No memory allocation header found");
} else {
String callsite;
try {
callsite = header.callSite().getCStringAtOffset(0);
} catch (CorruptDataException ex) {
callsite = "<FAULT> reading callsite string: " + ex.getMessage();
}
String categoryName;
try {
categoryName = header.category().name().getCStringAtOffset(0);
} catch (CorruptDataException ex) {
categoryName = "<FAULT> reading category name string: " + ex.getMessage();
}
try {
out.println(String.format("Found memory allocation header, !j9x %s,0x%#x", J9MemTagHelper.j9mem_get_memory_base(header).getHexAddress(), header.allocSize().longValue()));
out.println(String.format("J9MemTag at %s {", header.getHexAddress()));
out.println(String.format(" U_32 eyeCatcher = 0x%x;", header.eyeCatcher().longValue()));
out.println(String.format(" U_32 sumCheck = 0x%x;", header.sumCheck().longValue()));
out.println(String.format(" UDATA allocSize = 0x%x;", header.allocSize().longValue()));
out.println(String.format(" char* callSite = %s;", callsite));
out.println(String.format(" struct OMRMemCategory* category = !omrmemcategory 0x%x (%s);", header.category().longValue(), categoryName));
out.println("}");
} catch (CorruptDataException ex) {
out.println("CDE formatting J9MemTag at " + header.getHexAddress());
}
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class MarkMapCommand method isMarked.
protected void isMarked(String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
J9ObjectPointer object = J9ObjectPointer.cast(address);
MarkedObject result = markMap.queryObject(object);
if (result != null) {
if (result.wasRelocated()) {
out.format("Object %s is marked and relocated to %s\n", result.object.getHexAddress(), result.relocatedObject.getHexAddress());
} else {
out.format("Object %s is marked\n", result.object.getHexAddress());
}
} else {
out.format("Object %s is not marked\n", object.getHexAddress());
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class ObjectSizeInfo method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
this.out = out;
fieldStats = new TreeMap<String, ClassFieldInfo>();
Table summary = new Table("Object field size summary");
summary.row(ClassFieldInfo.getTitleRow());
HeapFieldInfo hfi = new HeapFieldInfo();
if (args != null) {
if (!parseArgs(out, args)) {
return;
}
}
try {
scanHeap();
for (FieldInfo cfi : fieldStats.values()) {
summary.row(cfi.getResults());
hfi.addClass(cfi);
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
summary.row(FieldInfo.getTitleRow());
try {
summary.row(hfi.getResults());
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
summary.render(out);
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class ObjectSizeInfo method scanHeap.
private void scanHeap() {
try {
GCHeapRegionIterator regions = GCHeapRegionIterator.from();
while (regions.hasNext()) {
GCHeapRegionDescriptor region = regions.next();
scanObjects(region);
}
} catch (CorruptDataException e) {
e.printStackTrace();
}
}
Aggregations