316 } else {
317 nextLine();
318 }
319 }
320 return mapFile;
321 } catch (Throwable t) {
322 System.out.println("Error parsing line " + lineCount + ": " + line);
323 throw new RuntimeException(t);
324 } finally {
325 System.out.println("Parsed " + lineCount + " lines in " + fileName);
326 System.out.println("Found " + mapFile.heapObjectCount() + " heap objects ("
327 + mapFile.stringCount + " strings)");
328 mapFile = null;
329 reader = null;
330 line = null;
331 lineCount = 0;
332 }
333 }
334
335 private static void mustContain(HashMap<Long, HeapObject> allObjects, Field field, long pointer, boolean isNarrow) {
336 if (allObjects.get(pointer) == null) {
337 throw new RuntimeException((isNarrow ? "narrowOop" : "oop") + " pointer 0x" + Long.toHexString(pointer) +
338 " on line " + field.lineCount + " doesn't point to a valid heap object");
339 }
340 }
341
342 public static void validate(MapFile mapFile, String classLoadLogFile) throws IOException {
343 validateOops(mapFile);
344 if (classLoadLogFile != null) {
345 validateClasses(mapFile, classLoadLogFile);
346 }
347 }
348
349 // Check that each oop fields in the HeapObjects must point to a valid HeapObject.
350 static void validateOops(MapFile mapFile) {
351 int count1 = 0;
352 int count2 = 0;
353 for (HeapObject heapObject : mapFile.heapObjects) {
354 if (heapObject.fields != null) {
355 for (Field field : heapObject.fields) {
356 HeapAddress referentAddress = field.referentAddress;
|
316 } else {
317 nextLine();
318 }
319 }
320 return mapFile;
321 } catch (Throwable t) {
322 System.out.println("Error parsing line " + lineCount + ": " + line);
323 throw new RuntimeException(t);
324 } finally {
325 System.out.println("Parsed " + lineCount + " lines in " + fileName);
326 System.out.println("Found " + mapFile.heapObjectCount() + " heap objects ("
327 + mapFile.stringCount + " strings)");
328 mapFile = null;
329 reader = null;
330 line = null;
331 lineCount = 0;
332 }
333 }
334
335 private static void mustContain(HashMap<Long, HeapObject> allObjects, Field field, long pointer, boolean isNarrow) {
336 if (pointer != 0x0 && allObjects.get(pointer) == null) {
337 throw new RuntimeException((isNarrow ? "narrowOop" : "oop") + " pointer 0x" + Long.toHexString(pointer) +
338 " on line " + field.lineCount + " doesn't point to a valid heap object");
339 }
340 }
341
342 public static void validate(MapFile mapFile, String classLoadLogFile) throws IOException {
343 validateOops(mapFile);
344 if (classLoadLogFile != null) {
345 validateClasses(mapFile, classLoadLogFile);
346 }
347 }
348
349 // Check that each oop fields in the HeapObjects must point to a valid HeapObject.
350 static void validateOops(MapFile mapFile) {
351 int count1 = 0;
352 int count2 = 0;
353 for (HeapObject heapObject : mapFile.heapObjects) {
354 if (heapObject.fields != null) {
355 for (Field field : heapObject.fields) {
356 HeapAddress referentAddress = field.referentAddress;
|