libintrovirt v0.57.4
IntroVirt introspection library
Loading...
Searching...
No Matches
TaskFilter.hh
Go to the documentation of this file.
1/*
2 * Copyright 2021 Assured Information Security, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
19
20#include <set>
21#include <shared_mutex>
22#include <unordered_set>
23
24namespace introvirt {
25
34class TaskFilter final {
35 public:
41 void add_pid(uint64_t pid);
42
50 bool remove_pid(uint64_t pid);
51
57 void add_tid(uint64_t tid);
58
66 bool remove_tid(uint64_t tid);
67
77 void add_name(const std::string& name);
78
86 bool remove_name(const std::string& name);
87
93 void clear();
94
102 bool matches(const Event& event) const;
103
104 TaskFilter() = default;
105 ~TaskFilter() = default;
106
107 private:
108 mutable std::shared_mutex mtx_;
109 std::unordered_set<uint64_t> tid_filter_;
110 std::unordered_set<uint64_t> pid_filter_;
111 std::set<std::string> proc_name_filter_;
112};
113
114} // namespace introvirt
Interface class for hypervisor events.
Definition Event.hh:43
Filter to remove events based on task.
Definition TaskFilter.hh:34
bool remove_name(const std::string &name)
Remove a process name from the filter.
bool remove_pid(uint64_t pid)
Remove a process ID.
bool remove_tid(uint64_t tid)
Remove a thread ID.
bool matches(const Event &event) const
Check if the event matches our task filter.
void add_name(const std::string &name)
Add a process name to the filter.
void add_pid(uint64_t pid)
Add a process ID.
void add_tid(uint64_t tid)
Add a thread ID.
void clear()
Clear all filters.
Core IntroVirt classes.
Definition Cr0.hh:20