Commit 438fdf5b authored by Brendan Gregg's avatar Brendan Gregg Committed by GitHub

Merge pull request #368 from iovisor/bugs

fix tracepoint wildcards
parents 33c9c2ef 946c7859
...@@ -87,10 +87,7 @@ int BPFtrace::add_probe(ast::Probe &p) ...@@ -87,10 +87,7 @@ int BPFtrace::add_probe(ast::Probe &p)
} }
std::vector<std::string> attach_funcs; std::vector<std::string> attach_funcs;
if (attach_point->need_expansion && ( if (attach_point->need_expansion && has_wildcard(attach_point->func))
attach_point->func.find("*") != std::string::npos ||
attach_point->func.find("[") != std::string::npos &&
attach_point->func.find("]") != std::string::npos))
{ {
std::set<std::string> matches; std::set<std::string> matches;
switch (probetype(attach_point->provider)) switch (probetype(attach_point->provider))
......
...@@ -29,20 +29,24 @@ bool TracepointFormatParser::parse(ast::Program *program) ...@@ -29,20 +29,24 @@ bool TracepointFormatParser::parse(ast::Program *program)
{ {
std::string &category = ap->target; std::string &category = ap->target;
std::string &event_name = ap->func; 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::string format_file_path = "/sys/kernel/debug/tracing/events/" + category + "/" + event_name + "/format";
std::ifstream format_file(format_file_path.c_str()); std::ifstream format_file(format_file_path.c_str());
if (format_file.fail()) 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: // helper message:
if (ap->target == "syscall") if (category == "syscall")
std::cerr << "Did you mean syscalls:" << ap->func << "?" << std::endl; std::cerr << "Did you mean syscalls:" << event_name << "?" << std::endl;
if (bt_verbose) { if (bt_verbose) {
if (format_file_path.find('*') == std::string::npos)
std::cerr << strerror(errno) << ": " << format_file_path << std::endl; std::cerr << strerror(errno) << ": " << format_file_path << std::endl;
} }
return false; return false;
} }
......
...@@ -31,6 +31,16 @@ std::vector<int> read_cpu_range(std::string path) ...@@ -31,6 +31,16 @@ std::vector<int> read_cpu_range(std::string path)
namespace bpftrace { 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() std::vector<int> get_online_cpus()
{ {
return read_cpu_range("/sys/devices/system/cpu/online"); return read_cpu_range("/sys/devices/system/cpu/online");
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
namespace bpftrace { namespace bpftrace {
inline std::string GetProviderFromPath(std::string path); inline std::string GetProviderFromPath(std::string path);
bool has_wildcard(const std::string &str);
std::vector<int> get_online_cpus(); std::vector<int> get_online_cpus();
std::vector<int> get_possible_cpus(); std::vector<int> get_possible_cpus();
std::vector<std::string> get_kernel_cflags( 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