Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions probes.d
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ provider ruby {
*/
probe string__create(long length, const char *filename, int lineno);

/*
ruby:::string-capa-resize(from_capa, to_capa, filename, lineno);

This probe is fired when String capacity is changed

* `from_capa` the current capacity of the string (long)
* `to_capa` the new capacity of the string (long)
* `filename` the name of the file where the string is allocated (string)
* `lineno` the line number in the file where the string is allocated (int)
*/
probe string__capa__resize(long from_capa, long to_capa, const char *filename, int lineno);

/*
ruby:::symbol-create(str, filename, lineno);

Expand Down
12 changes: 12 additions & 0 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ VALUE rb_cSymbol;
RESIZE_CAPA_TERM(str,capacity,termlen);\
} while (0)
#define RESIZE_CAPA_TERM(str,capacity,termlen) do {\
if (UNLIKELY(RUBY_DTRACE_STRING_CAPA_RESIZE_ENABLED())) {\
int dtrace_line; \
const char *dtrace_file = rb_source_location_cstr(&dtrace_line); \
long prev_capa;\
if (STR_EMBED_P(str)) {\
prev_capa = RSTRING_EMBED_LEN_MAX + 1 - termlen;\
} else {\
prev_capa = RSTRING(str)->as.heap.aux.capa;\
}\
if (!dtrace_file) dtrace_file = ""; \
RUBY_DTRACE_STRING_CAPA_RESIZE(prev_capa, capacity, dtrace_file, dtrace_line);\
}\
if (STR_EMBED_P(str)) {\
if (!STR_EMBEDDABLE_P(capacity, termlen)) {\
char *const tmp = ALLOC_N(char, (size_t)(capacity) + (termlen));\
Expand Down