diff --git a/include/lo2s/monitor/process_monitor.hpp b/include/lo2s/monitor/process_monitor.hpp index ef955987..fc0d16cc 100644 --- a/include/lo2s/monitor/process_monitor.hpp +++ b/include/lo2s/monitor/process_monitor.hpp @@ -22,7 +22,9 @@ #pragma once #include #include +#ifdef HAVE_BPF #include +#endif #include #include @@ -54,7 +56,9 @@ class ProcessMonitor : public AbstractProcessMonitor, public MainMonitor private: std::map threads_; +#ifdef HAVE_BPF std::unique_ptr posix_monitor_; +#endif }; } // namespace monitor } // namespace lo2s diff --git a/src/monitor/process_monitor.cpp b/src/monitor/process_monitor.cpp index 963db60f..98d5fe50 100644 --- a/src/monitor/process_monitor.cpp +++ b/src/monitor/process_monitor.cpp @@ -31,11 +31,13 @@ namespace monitor ProcessMonitor::ProcessMonitor() : MainMonitor() { +#ifdef HAVE_BPF if (config().use_posix_io) { posix_monitor_ = std::make_unique(trace_); posix_monitor_->start(); } +#endif trace_.add_monitoring_thread(gettid(), "ProcessMonitor", "ProcessMonitor"); } @@ -48,10 +50,13 @@ void ProcessMonitor::insert_process(Process parent, Process process, std::string void ProcessMonitor::insert_thread(Process process, Thread thread, std::string name, bool spawn) { + +#ifdef HAVE_BPF if (posix_monitor_) { posix_monitor_->insert_thread(thread); } +#endif trace_.add_thread(thread, name); if (config().sampling) @@ -88,10 +93,12 @@ void ProcessMonitor::update_process_name(Process process, const std::string& nam void ProcessMonitor::exit_thread(Thread thread) { +#ifdef HAVE_BPF if (posix_monitor_) { posix_monitor_->exit_thread(thread); } +#endif if (threads_.count(thread) != 0) { threads_.at(thread).stop(); @@ -105,11 +112,12 @@ ProcessMonitor::~ProcessMonitor() { thread.second.stop(); } - +#ifdef HAVE_BPF if (posix_monitor_) { posix_monitor_->stop(); } +#endif } } // namespace monitor } // namespace lo2s