forked from bpftrace/bpftrace
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprobe_types.cpp
More file actions
76 lines (63 loc) · 2.42 KB
/
Copy pathprobe_types.cpp
File metadata and controls
76 lines (63 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <algorithm>
#include <cassert>
#include <iostream>
#include "probe_types.h"
#include "util/strings.h"
namespace bpftrace {
std::ostream &operator<<(std::ostream &os, ProbeType type)
{
os << probetypeName(type);
return os;
}
ProbeType probetype(const std::string &probeName)
{
ProbeType retType = ProbeType::invalid;
const std::string lowerProbeName = util::to_lower(probeName);
auto v = std::ranges::find_if(PROBE_LIST,
[&lowerProbeName](const ProbeItem &p) {
return (p.name == lowerProbeName ||
p.aliases.contains(lowerProbeName));
});
if (v != PROBE_LIST.end())
retType = v->type;
return retType;
}
std::string expand_probe_name(const std::string &orig_name)
{
std::string expanded_name = util::to_lower(orig_name);
auto v = std::ranges::find_if(PROBE_LIST, [&orig_name](const ProbeItem &p) {
return (p.name == orig_name || p.aliases.contains(orig_name));
});
if (v != PROBE_LIST.end())
expanded_name = v->name;
return expanded_name;
}
std::string probetypeName(ProbeType t)
{
// clang-format off
switch (t)
{
case ProbeType::invalid: return "invalid"; break;
case ProbeType::special: return "special"; break;
case ProbeType::test: return "test"; break;
case ProbeType::benchmark: return "benchmark"; break;
case ProbeType::kprobe: return "kprobe"; break;
case ProbeType::kretprobe: return "kretprobe"; break;
case ProbeType::uprobe: return "uprobe"; break;
case ProbeType::uretprobe: return "uretprobe"; break;
case ProbeType::usdt: return "usdt"; break;
case ProbeType::tracepoint: return "tracepoint"; break;
case ProbeType::profile: return "profile"; break;
case ProbeType::interval: return "interval"; break;
case ProbeType::software: return "software"; break;
case ProbeType::hardware: return "hardware"; break;
case ProbeType::watchpoint: return "watchpoint"; break;
case ProbeType::fentry: return "fentry"; break;
case ProbeType::fexit: return "fexit"; break;
case ProbeType::iter: return "iter"; break;
case ProbeType::rawtracepoint: return "rawtracepoint"; break;
}
// clang-format on
return {}; // unreached
}
} // namespace bpftrace