$OpenBSD: patch-services_resource_coordinator_public_cpp_memory_instrumentation_os_metrics_linux_cc,v 1.7 2019/08/01 08:32:00 robert Exp $

Index: services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_linux.cc
--- services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_linux.cc.orig
+++ services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics_linux.cc
@@ -22,8 +22,10 @@
 #include "build/build_config.h"
 #include "services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.h"
 
+#if !defined(OS_BSD)
 // Symbol with virtual address of the start of ELF header of the current binary.
 extern char __ehdr_start;
+#endif
 
 namespace memory_instrumentation {
 
@@ -35,6 +37,7 @@ using mojom::VmRegionPtr;
 const char kClearPeakRssCommand[] = "5";
 const uint32_t kMaxLineSize = 4096;
 
+#if !defined(OS_BSD)
 // TODO(chiniforooshan): Many of the utility functions in this anonymous
 // namespace should move to base/process/process_metrics_linux.cc to make the
 // code a lot cleaner.  However, we should do so after we made sure the metrics
@@ -224,6 +227,7 @@ uint32_t ReadLinuxProcSmapsFile(FILE* smaps_file,
   }
   return num_valid_regions;
 }
+#endif
 
 }  // namespace
 
@@ -237,6 +241,9 @@ void OSMetrics::SetProcSmapsForTesting(FILE* f) {
 // static
 bool OSMetrics::FillOSMemoryDump(base::ProcessId pid,
                                  mojom::RawOSMemDump* dump) {
+#if defined(OS_BSD)
+  return false;
+#else
   // TODO(chiniforooshan): There is no need to read both /statm and /status
   // files. Refactor to get everything from /status using ProcessMetric.
   auto statm_file = GetProcPidDir(pid).Append("statm");
@@ -289,10 +296,12 @@ bool OSMetrics::FillOSMemoryDump(base::ProcessId pid,
 #endif  //  defined(OS_ANDROID)
 
   return true;
+#endif
 }
 
 // static
 std::vector<VmRegionPtr> OSMetrics::GetProcessMemoryMaps(base::ProcessId pid) {
+#if !defined(OS_BSD)
   std::vector<VmRegionPtr> maps;
   uint32_t res = 0;
   if (g_proc_smaps_for_testing) {
@@ -310,8 +319,13 @@ std::vector<VmRegionPtr> OSMetrics::GetProcessMemoryMa
     return std::vector<VmRegionPtr>();
 
   return maps;
+#else
+    NOTIMPLEMENTED();
+    return std::vector<VmRegionPtr>();
+#endif
 }
 
+#if !defined(OS_BSD) 
 // static
 OSMetrics::MappedAndResidentPagesDumpState OSMetrics::GetMappedAndResidentPages(
     const size_t start_address,
@@ -393,5 +407,6 @@ size_t OSMetrics::GetPeakResidentSetSize(base::Process
   }
   return 0;
 }
+#endif
 
 }  // namespace memory_instrumentation
