Skip to content

Commit

Permalink
Relocate Go uprobe opt out filtering out of ConvertPIDsListToMap
Browse files Browse the repository at this point in the history
Signed-off-by: Dom Del Nano <[email protected]>
  • Loading branch information
ddelnano committed Jul 28, 2024
1 parent 92f79ba commit d895cad
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/stirling/source_connectors/socket_tracer/uprobe_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,7 @@ namespace {

// Convert PID list from list of UPIDs to a map with key=binary name, value=PIDs
std::map<std::string, std::vector<int32_t>> ConvertPIDsListToMap(
const absl::flat_hash_set<md::UPID>& upids,
const absl::flat_hash_set<std::string>& opt_out_filter) {
const absl::flat_hash_set<md::UPID>& upids) {
const system::ProcParser proc_parser;

// Convert to a map of binaries, with the upids that are instances of that binary.
Expand All @@ -582,11 +581,6 @@ std::map<std::string, std::vector<int32_t>> ConvertPIDsListToMap(
if (!fs::Exists(host_exe_path)) {
continue;
}
// Add filter here if the executable should be omitted
if (opt_out_filter.contains(host_exe_path.filename().string())) {
VLOG(1) << absl::Substitute(kUprobeSkippedMessage, host_exe_path.string());
continue;
}
pids[host_exe_path.string()].push_back(upid.pid());
}

Expand Down Expand Up @@ -845,7 +839,13 @@ int UProbeManager::DeployGoUProbes(const absl::flat_hash_set<md::UPID>& pids) {

static int32_t kPID = getpid();

for (const auto& [binary, pid_vec] : ConvertPIDsListToMap(pids, uprobe_opt_out_)) {
for (const auto& [binary, pid_vec] : ConvertPIDsListToMap(pids)) {
std::filesystem::path binary_path(binary);
auto binary_filepath = binary_path.filename().string();
if (uprobe_opt_out_.contains(binary_filepath)) {
VLOG(1) << absl::Substitute(kUprobeSkippedMessage, binary_filepath);
continue;
}
// Don't bother rescanning binaries that have been scanned before to avoid unnecessary work.
if (!scanned_binaries_.insert(binary).second) {
continue;
Expand Down

0 comments on commit d895cad

Please sign in to comment.