Skip to content

Commit

Permalink
use filename returned from profile frames for prefix path checks
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Jun 7, 2024
1 parent 0da2baa commit 44e32d4
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions ext/datadog_cov/datadog_cov.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,6 @@ static void dd_cov_update_coverage(rb_event_flag_t event, VALUE data, VALUE self
}
dd_cov_data->last_filename_ptr = current_filename_ptr;

// if the current filename is not located under the root, we skip it
if (strncmp(dd_cov_data->root, c_filename, dd_cov_data->root_len) != 0)
{
return;
}

// if ignored_path is provided and the current filename is located under the ignored_path, we skip it too
// this is useful for ignoring bundled gems location
if (dd_cov_data->ignored_path_len != 0 && strncmp(dd_cov_data->ignored_path, c_filename, dd_cov_data->ignored_path_len) == 0)
{
return;
}

int captured_frames = rb_profile_frames(
0 /* stack starting depth */,
PROFILE_FRAMES_BUFFER_SIZE,
Expand All @@ -148,6 +135,20 @@ static void dd_cov_update_coverage(rb_event_flag_t event, VALUE data, VALUE self
return;
}

char *filename_ptr = StringValuePtr(filename);
// if the current filename is not located under the root, we skip it
if (strncmp(dd_cov_data->root, filename_ptr, dd_cov_data->root_len) != 0)
{
return;
}

// if ignored_path is provided and the current filename is located under the ignored_path, we skip it too
// this is useful for ignoring bundled gems location
if (dd_cov_data->ignored_path_len != 0 && strncmp(dd_cov_data->ignored_path, filename_ptr, dd_cov_data->ignored_path_len) == 0)
{
return;
}

rb_hash_aset(dd_cov_data->coverage, filename, Qtrue);
}

Expand Down

0 comments on commit 44e32d4

Please sign in to comment.