Commit 946c7859 authored by Brendan Gregg's avatar Brendan Gregg

fix tracepoint wildcards

parent e73f69c9
......@@ -87,10 +87,7 @@ int BPFtrace::add_probe(ast::Probe &p)
}
std::vector<std::string> attach_funcs;
if (attach_point->need_expansion && (
attach_point->func.find("*") != std::string::npos ||
attach_point->func.find("[") != std::string::npos &&
attach_point->func.find("]") != std::string::npos))
if (attach_point->need_expansion && has_wildcard(attach_point->func))
{
std::set<std::string> matches;
switch (probetype(attach_point->provider))
......
......@@ -29,20 +29,24 @@ bool TracepointFormatParser::parse(ast::Program *program)
{
std::string &category = ap->target;
std::string &event_name = ap->func;
if (has_wildcard(event_name))
{
// args not supported with wildcards yet: #132
return true;
}
std::string format_file_path = "/sys/kernel/debug/tracing/events/" + category + "/" + event_name + "/format";
std::ifstream format_file(format_file_path.c_str());
if (format_file.fail())
{
std::cerr << "ERROR: tracepoint not found: " << ap->target << ":" << ap->func << std::endl;
std::cerr << "ERROR: tracepoint not found: " << category << ":" << event_name << std::endl;
// helper message:
if (ap->target == "syscall")
std::cerr << "Did you mean syscalls:" << ap->func << "?" << std::endl;
if (category == "syscall")
std::cerr << "Did you mean syscalls:" << event_name << "?" << std::endl;
if (bt_verbose) {
if (format_file_path.find('*') == std::string::npos)
std::cerr << strerror(errno) << ": " << format_file_path << std::endl;
}
return false;
}
......
......@@ -31,6 +31,16 @@ std::vector<int> read_cpu_range(std::string path)
namespace bpftrace {
bool has_wildcard(const std::string &str)
{
if (str.find("*") != std::string::npos ||
str.find("[") != std::string::npos &&
str.find("]") != std::string::npos)
return true;
else
return false;
}
std::vector<int> get_online_cpus()
{
return read_cpu_range("/sys/devices/system/cpu/online");
......
......@@ -6,6 +6,7 @@
namespace bpftrace {
inline std::string GetProviderFromPath(std::string path);
bool has_wildcard(const std::string &str);
std::vector<int> get_online_cpus();
std::vector<int> get_possible_cpus();
std::vector<std::string> get_kernel_cflags(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment