Commit 834a8eae authored by Alastair Robertson's avatar Alastair Robertson

Convert BPFtrace::start() to BPFtrace::run() and properly detach BEGIN and END probes

parent 02b11f46
...@@ -131,7 +131,7 @@ std::unique_ptr<AttachedProbe> BPFtrace::attach_probe(Probe &probe) ...@@ -131,7 +131,7 @@ std::unique_ptr<AttachedProbe> BPFtrace::attach_probe(Probe &probe)
return nullptr; return nullptr;
} }
int BPFtrace::start() int BPFtrace::run()
{ {
for (Probe &probe : special_probes_) for (Probe &probe : special_probes_)
{ {
...@@ -156,10 +156,11 @@ int BPFtrace::start() ...@@ -156,10 +156,11 @@ int BPFtrace::start()
} }
poll_perf_events(epollfd); poll_perf_events(epollfd);
attached_probes_.clear(); attached_probes_.clear();
END_trigger(); END_trigger();
poll_perf_events(epollfd, 100); poll_perf_events(epollfd, 100);
special_attached_probes_.clear();
return 0; return 0;
} }
...@@ -220,11 +221,6 @@ void BPFtrace::poll_perf_events(int epollfd, int timeout) ...@@ -220,11 +221,6 @@ void BPFtrace::poll_perf_events(int epollfd, int timeout)
return; return;
} }
void BPFtrace::stop()
{
attached_probes_.clear();
}
int BPFtrace::print_maps() const int BPFtrace::print_maps() const
{ {
for(auto &mapmap : maps_) for(auto &mapmap : maps_)
......
...@@ -17,8 +17,7 @@ public: ...@@ -17,8 +17,7 @@ public:
explicit BPFtrace(const std::string &path) : bpftrace_path_(path) { } explicit BPFtrace(const std::string &path) : bpftrace_path_(path) { }
virtual ~BPFtrace() { } virtual ~BPFtrace() { }
virtual int add_probe(ast::Probe &p); virtual int add_probe(ast::Probe &p);
int start(); int run();
void stop();
int print_maps() const; int print_maps() const;
std::string get_stack(uint32_t stackid, bool ustack, int indent=0) const; std::string get_stack(uint32_t stackid, bool ustack, int indent=0) const;
......
...@@ -97,12 +97,10 @@ int main(int argc, char *argv[]) ...@@ -97,12 +97,10 @@ int main(int argc, char *argv[])
std::cout << "Running... press Ctrl-C to stop" << std::endl; std::cout << "Running... press Ctrl-C to stop" << std::endl;
err = bpftrace.start(); err = bpftrace.run();
if (err) if (err)
return err; return err;
bpftrace.stop();
std::cout << "\n\n"; std::cout << "\n\n";
err = bpftrace.print_maps(); err = bpftrace.print_maps();
......
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