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