$OpenBSD: patch-services_resource_coordinator_public_cpp_memory_instrumentation_os_metrics_linux_cc,v 1.4 2018/08/10 14:57:53 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
@@ -16,8 +16,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 {
 
@@ -28,6 +30,7 @@ using mojom::VmRegionPtr;
 
 const uint32_t kMaxLineSize = 4096;
 
+#if !defined(OS_BSD)
 base::ScopedFD OpenStatm(base::ProcessId pid) {
   std::string name =
       "/proc/" +
@@ -58,6 +61,7 @@ std::unique_ptr<base::ProcessMetrics> CreateProcessMet
   }
   return base::ProcessMetrics::CreateProcessMetrics(pid);
 }
+#endif
 
 bool ParseSmapsHeader(const char* header_line, VmRegion* region) {
   // e.g., "00400000-00421000 r-xp 00000000 fc:01 1234  /foo.so\n"
@@ -101,7 +105,7 @@ bool ParseSmapsHeader(const char* header_line, VmRegio
   // Build ID is needed to symbolize heap profiles, and is generated only on
   // official builds. Build ID is only added for the current library (chrome)
   // since it is racy to read other libraries which can be unmapped any time.
-#if defined(OFFICIAL_BUILD)
+#if defined(OFFICIAL_BUILD) && !defined(OS_BSD)
   uintptr_t addr = reinterpret_cast<uintptr_t>(&ParseSmapsHeader);
   if (addr >= region->start_address && addr < end_addr) {
     base::Optional<std::string> buildid =
@@ -196,6 +200,9 @@ void OSMetrics::SetProcSmapsForTesting(FILE* f) {
 // static
 bool OSMetrics::FillOSMemoryDump(base::ProcessId pid,
                                  mojom::RawOSMemDump* dump) {
+#if defined(OS_BSD)
+  return false;
+#else
   base::ScopedFD autoclose = OpenStatm(pid);
   int statm_fd = autoclose.get();
 
@@ -221,6 +228,7 @@ bool OSMetrics::FillOSMemoryDump(base::ProcessId pid,
   dump->resident_set_kb = process_metrics->GetResidentSetSize() / 1024;
 
   return true;
+#endif
 }
 
 // static
