metrics: install memfd panic handler for better crash reports

The memfd panic handler exposes the panic message and source code
location to the crash collector so that crashes have a meaningful
signature.

BUG=b:234093439
TEST=emerge-brya memd

Cq-Depend: chromium:3900447
Change-Id: Ie32f5ace1b9f377f6a3520cac1b2f476b1e3eb14
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/3901491
Commit-Queue: Paramjit Oberoi <psoberoi@google.com>
Reviewed-by: Vovo Yang <vovoy@chromium.org>
Tested-by: Paramjit Oberoi <psoberoi@google.com>
diff --git a/metrics/memd/Cargo.toml b/metrics/memd/Cargo.toml
index 5df25bd..d9b64c9 100644
--- a/metrics/memd/Cargo.toml
+++ b/metrics/memd/Cargo.toml
@@ -10,6 +10,7 @@
 dbus = "0.6.1"
 env_logger = { version = "0.9", default-features = false }
 libc = "0.2.40"
+libchromeos = "0.1.0"
 log = "0.4.1"
 protobuf = "2.3"
 syslog = "6.0.1"
@@ -25,3 +26,7 @@
 protoc-rust = "2.3"
 
 [workspace]
+
+[patch.crates-io] # ignored by ebuild
+crosvm-base = { path = "../../../../chroot/usr/lib/cros_rust_registry/registry/crosvm-base-0.1.0/" } # ignored by ebuild
+libchromeos = { path = "../../../../chroot/usr/lib/cros_rust_registry/registry/libchromeos-0.1.0/" } # ignored by ebuild
diff --git a/metrics/memd/src/main.rs b/metrics/memd/src/main.rs
index bc6da7d..6c3dd7e 100644
--- a/metrics/memd/src/main.rs
+++ b/metrics/memd/src/main.rs
@@ -1410,6 +1410,7 @@
     let mut always_poll_fast = false;
     let mut debug_log = false;
 
+    libchromeos::panic_handler::install_memfd_handler();
     let args: Vec<String> = std::env::args().collect();
     for arg in &args[1..] {
         match arg.as_ref() {