No public description

PiperOrigin-RevId: 640895934
Change-Id: Ic009ccd707e7796b763c907aae38ae0b5e2d2fae
diff --git a/cheriot/cheriot_renode.cc b/cheriot/cheriot_renode.cc
index ad96a65..321cadb 100644
--- a/cheriot/cheriot_renode.cc
+++ b/cheriot/cheriot_renode.cc
@@ -183,6 +183,18 @@
     }
     inst_profile_file.close();
   }
+  if (mem_profiler_ != nullptr) {
+    std::string mem_profile_file_name =
+        absl::StrCat("./mpact_cheriot_", name_, "_mem_profile.csv");
+    std::fstream mem_profile_file(mem_profile_file_name.c_str(),
+                                  std::ios_base::out);
+    if (!mem_profile_file.good()) {
+      LOG(ERROR) << "Failed to write profile to file";
+    } else {
+      mem_profiler_->WriteProfile(mem_profile_file);
+    }
+    mem_profile_file.close();
+  }
   // Export counters.
   auto component_proto = std::make_unique<ComponentData>();
   CHECK_OK(cheriot_top_->Export(component_proto.get()))
diff --git a/cheriot/memory_use_profiler.h b/cheriot/memory_use_profiler.h
index c7ebf83..68e8fd4 100644
--- a/cheriot/memory_use_profiler.h
+++ b/cheriot/memory_use_profiler.h
@@ -89,6 +89,7 @@
 
   // Accessor.
   void set_is_enabled(bool is_enabled) { is_enabled_ = is_enabled; }
+  bool is_enabled() const { return is_enabled_; }
 
  private:
   bool is_enabled_ = false;