Commit cbcfe37c authored by Alastair Robertson's avatar Alastair Robertson

Fix attaching uprobes - replace bad characters in path with '_'

parent 6408d5a5
#include <iostream>
#include <tuple>
#include <regex>
#include <sys/utsname.h>
#include <tuple>
#include <unistd.h>
#include "attached_probe.h"
......@@ -100,12 +101,17 @@ std::string AttachedProbe::eventname() const
case ProbeType::uprobe:
case ProbeType::uretprobe:
offset_str << std::hex << offset();
return eventprefix() + probe_.path + "_" + offset_str.str();
return eventprefix() + sanitise(probe_.path) + "_" + offset_str.str();
default:
abort();
}
}
std::string AttachedProbe::sanitise(const std::string &str)
{
return std::regex_replace(str, std::regex("[^A-Za-z0-9_]"), "_");
}
uint64_t AttachedProbe::offset() const
{
bcc_symbol sym;
......
......@@ -20,6 +20,7 @@ public:
private:
std::string eventprefix() const;
std::string eventname() const;
static std::string sanitise(const std::string &str);
uint64_t offset() const;
void load_prog();
void attach_kprobe();
......
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