4646import java .util .Set ;
4747import java .util .function .Predicate ;
4848
49+ import com .oracle .svm .core .image .ImageHeapLayoutInfo ;
4950import com .oracle .svm .core .option .HostedOptionValues ;
5051import org .graalvm .nativeimage .ImageSingletons ;
5152import org .graalvm .nativeimage .c .function .RelocatedPointer ;
@@ -801,7 +802,7 @@ public ObjectInfo addLateToImageHeap(Object object, Object reason) {
801802 /**
802803 * Dumps metadata for every object in the image heap.
803804 */
804- public void dumpMetadata () {
805+ public void dumpMetadata (ImageHeapLayoutInfo heapLayout ) {
805806 String metadataFileName = SubstrateOptions .ImageHeapMetadataDumpFileName .getValue ();
806807 if (metadataFileName == null || metadataFileName .isEmpty ()) {
807808 // Do not dump metadata if the file name isn't set
@@ -815,11 +816,13 @@ public void dumpMetadata() {
815816 throw VMError .shouldNotReachHere ("Image heap metadata directory does not exist: " + metadataDir );
816817 }
817818
819+ long heapLayoutStartOffset = heapLayout .getStartOffset ();
820+
818821 try (FileWriter metadataOut = new FileWriter (metadataFile );
819822 BufferedWriter metadataBw = new BufferedWriter (metadataOut )) {
820823 metadataBw .write ("class-name,partition,offset-in-heap,size\n " );
821824 for (ObjectInfo info : getObjects ()) {
822- String csvLine = info .getClazz ().getName () + "," + info .getPartition ().getName () + "," + info .getOffset () + "," + info .getSize () + System .lineSeparator ();
825+ String csvLine = info .getClazz ().getName () + "," + info .getPartition ().getName () + "," + ( info .getOffset () - heapLayoutStartOffset ) + "," + info .getSize () + System .lineSeparator ();
823826 metadataBw .write (csvLine );
824827 }
825828 } catch (IOException ex ) {
0 commit comments