4646import java .util .Set ;
4747import java .util .function .Predicate ;
4848
49+ import com .oracle .svm .core .image .ImageHeapLayoutInfo ;
4950import org .graalvm .nativeimage .ImageSingletons ;
5051import org .graalvm .nativeimage .c .function .RelocatedPointer ;
5152import org .graalvm .word .UnsignedWord ;
@@ -812,7 +813,7 @@ public ObjectInfo addLateToImageHeap(Object object, Object reason) {
812813 /**
813814 * Dumps metadata for every object in the image heap.
814815 */
815- public void dumpMetadata () {
816+ public void dumpMetadata (ImageHeapLayoutInfo heapLayout ) {
816817 String metadataFileName = SubstrateOptions .ImageHeapMetadataDumpFileName .getValue ();
817818 if (metadataFileName == null || metadataFileName .isEmpty ()) {
818819 // Do not dump metadata if the file name isn't set
@@ -826,11 +827,13 @@ public void dumpMetadata() {
826827 throw VMError .shouldNotReachHere ("Image heap metadata directory does not exist: " + metadataDir );
827828 }
828829
830+ long heapLayoutStartOffset = heapLayout .getStartOffset ();
831+
829832 try (FileWriter metadataOut = new FileWriter (metadataFile );
830833 BufferedWriter metadataBw = new BufferedWriter (metadataOut )) {
831834 metadataBw .write ("class-name,partition,offset-in-heap,size\n " );
832835 for (ObjectInfo info : getObjects ()) {
833- String csvLine = info .getClazz ().getName () + "," + info .getPartition ().getName () + "," + info .getOffset () + "," + info .getSize () + System .lineSeparator ();
836+ String csvLine = info .getClazz ().getName () + "," + info .getPartition ().getName () + "," + ( info .getOffset () - heapLayoutStartOffset ) + "," + info .getSize () + System .lineSeparator ();
834837 metadataBw .write (csvLine );
835838 }
836839 } catch (IOException ex ) {
0 commit comments