[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1024218: Acknowledgement (apitrace: FTBFS with libproc2)



tags 1024218

Hi,
  Attached is a patch for API trace. I couldn't actually get apitrace to build on my system (even without the patch) so it's hard to test it.

 - Craig

Description: Build for libproc2
 Replace libprocps with libproc2
Author: Craig Small <csmall@debian.org>
Reviewed-by: Craig Small <csmall@debian.org>
Last-Update: 2022-11-16
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/lib/os/os_memory.hpp
+++ b/lib/os/os_memory.hpp
@@ -30,13 +30,46 @@
 
 #pragma once
 
-#ifdef HAVE_READPROC_H
+#ifdef LIBPROC2_FOUND
+#include <libproc2/pids.h>
+#elif defined(HAVE_READPROC_H)
 #include <proc/readproc.h>
 #endif
 
 namespace os {
 
-#if defined(HAVE_READPROC_H)
+#ifdef LIBPROC2_FOUND
+    inline long long
+    getVsize(void) {
+        enum pids_item Item[] = {PIDS_VSIZE_PGS};
+        struct pids_info *info = NULL;
+        struct pids_stack *stack;
+        unsigned long value=0
+        if (
+            (procps_pids_new(&info, Item, 1) == 0) &&
+            ((stack = fatal_proc_unmounted(info, 1)) == NULL)) {
+            value = PIDS_VAL(0, ul_int, stack, info);
+        }
+        procps_pids_unref(&info);
+        return value;
+    }
+
+    inline long long
+    getRss(void) {
+        enum pids_item Item[] = {PIDS_RSS};
+        struct pids_info *info = NULL;
+        struct pids_stack *stack;
+        unsigned long value=0
+        if (
+            (procps_pids_new(&info, Item, 1) == 0) &&
+            ((stack = fatal_proc_unmounted(info, 1)) == NULL)) {
+            value = PIDS_VAL(0, ul_int, stack, info);
+        }
+        procps_pids_unref(&info);
+        return value;
+    }
+
+#elif defined(HAVE_READPROC_H)
 
     inline long long
     getVsize(void) {
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -490,6 +490,7 @@
     if (PKG_CONFIG_FOUND)
         pkg_check_modules (BROTLIDEC IMPORTED_TARGET libbrotlidec>=1.0.7)
         pkg_check_modules (BROTLIENC IMPORTED_TARGET libbrotlienc>=1.0.7)
+        pkg_check_modules (LIBPROC2 IMPORTED_TARGET libproc2)
     endif ()
 
     find_package (GTest)
--- a/lib/os/CMakeLists.txt
+++ b/lib/os/CMakeLists.txt
@@ -38,3 +38,8 @@
     add_gtest (os_thread_test os_thread_test.cpp)
     target_link_libraries (os_thread_test os)
 endif ()
+
+if (LIBPROC2_FOUND)
+    target_link_libraries(os PUBLIC PkgConfig::LIBPROC2)
+endif ()
+

Reply to: