mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 23:46:15 +01:00
bef9efd0a9
This adds static markers for dtrace, which are also usable by systemtap. Additionally it adds a tapset for systemtap that makes it easier to use the static markers. These are enabled by default. This initial set of probes is rather limited: * allocation and free using g_malloc & co * allocation and free using g_slice * gquark name tracking (useful for converting quarks to strings in probes) Notes on naming: Its traditional with dtrace to use probe names with dashes as delimiter (slice-alloc). Since dashes are not usable in identifiers the C code uses double underscores (slice__alloc) which is converted to dashes in the UI. We follow this for the shared lowlevel probe names. Additionally dtrace supports putting a "provider" part in the probe names which is essentially a namespacing thing. On systemtap this field is currently ignored (but may be implemented in the future), but this is not really a problem since in systemtap the probes are specified by combining the solib file and the marker name, so there can't really be name conflicts. For the systemtap tapset highlevel probes we instead use names that are systemtapish with single dashes as separators. https://bugzilla.gnome.org/show_bug.cgi?id=606044
85 lines
2.8 KiB
Plaintext
85 lines
2.8 KiB
Plaintext
global gquarks
|
|
|
|
/* This is needed to keep track of gquark for use in other probes.*/
|
|
probe process("@ABS_GLIB_RUNTIME_LIBDIR@/libglib-2.0.so.0.@LT_CURRENT@.@LT_REVISION@").mark("quark__new")
|
|
{
|
|
gquarks[pid(), $arg2] = user_string($arg1)
|
|
}
|
|
|
|
/**
|
|
* probe glib.quark_new - Called when a #GQuark is initially created
|
|
* @quark: integer value for the quark
|
|
* @str: string form of the quark
|
|
*/
|
|
probe glib.quark_new = process("@ABS_GLIB_RUNTIME_LIBDIR@/libglib-2.0.so.0.@LT_CURRENT@.@LT_REVISION@").mark("quark__new")
|
|
{
|
|
str = user_string ($arg1);
|
|
quark = $arg2;
|
|
probestr = sprintf("glib.quark_new(%s) -> %d", str, quark);
|
|
}
|
|
|
|
/**
|
|
* probe glib.mem_alloc - Called when a malloc block is initially requested
|
|
* @mem: Raw memory pointer returned
|
|
* @n_bytes: number of bytes
|
|
* @zeroed: Boolean value, %TRUE if this block was filled with NUL bytes
|
|
* @failable: Boolean value, %TRUE if program execution can continue on allocation failure
|
|
*/
|
|
probe glib.mem_alloc = process("@ABS_GLIB_RUNTIME_LIBDIR@/libglib-2.0.so.0.@LT_CURRENT@.@LT_REVISION@").mark("mem__alloc")
|
|
{
|
|
mem = $arg1;
|
|
n_bytes = $arg2;
|
|
zeroed = $arg3;
|
|
failable = $arg4;
|
|
probestr = sprintf("glib.mem_alloc(n_bytes=%d) -> %p", n_bytes, mem);
|
|
}
|
|
|
|
/**
|
|
* probe glib.mem_free - Called when a malloc block freed
|
|
*/
|
|
probe glib.mem_free = process("@ABS_GLIB_RUNTIME_LIBDIR@/libglib-2.0.so.0.@LT_CURRENT@.@LT_REVISION@").mark("mem__free")
|
|
{
|
|
mem = $arg1; /* ARG: @mem: Raw memory pointer */
|
|
probestr = sprintf("glib.mem_free(mem=%p)", mem);
|
|
}
|
|
|
|
/**
|
|
* probe glib.mem_realloc - Called when a malloc block is resized
|
|
* @mem: Raw memory pointer returned
|
|
* @old_mem: Original memory pointer
|
|
* @n_bytes: number of bytes
|
|
* @failable: Boolean value, %TRUE if program execution can continue on allocation failure
|
|
*/
|
|
probe glib.mem_realloc = process("@ABS_GLIB_RUNTIME_LIBDIR@/libglib-2.0.so.0.@LT_CURRENT@.@LT_REVISION@").mark("mem__realloc")
|
|
{
|
|
mem = $arg1;
|
|
old_mem = $arg2;
|
|
n_bytes = $arg3;
|
|
failable = $arg4;
|
|
probestr = sprintf("glib.mem_realloc(old_mem=%p, n_bytes=%d) -> %p", old_mem, n_bytes, mem);
|
|
}
|
|
|
|
/**
|
|
* probe glib.slice_alloc - Called when g_slice_alloc() is used
|
|
* @mem: Raw memory pointer returned
|
|
* @n_bytes: number of bytes
|
|
*/
|
|
probe glib.slice_alloc = process("@ABS_GLIB_RUNTIME_LIBDIR@/libglib-2.0.so.0.@LT_CURRENT@.@LT_REVISION@").mark("slice__alloc")
|
|
{
|
|
mem = $arg1;
|
|
n_bytes = $arg2;
|
|
probestr = sprintf("glib.slice_alloc(n_bytes=%d) -> %p", n_bytes, mem);
|
|
}
|
|
|
|
/**
|
|
* probe glib.slice_free - Called when memory slice is freed
|
|
* @mem: Raw memory pointer returned
|
|
* @n_bytes: Number of bytes
|
|
*/
|
|
probe glib.slice_free = process("@ABS_GLIB_RUNTIME_LIBDIR@/libglib-2.0.so.0.@LT_CURRENT@.@LT_REVISION@").mark("slice__free")
|
|
{
|
|
mem = $arg1;
|
|
n_bytes = $arg2;
|
|
probestr = sprintf("glib.slice_free(n_bytes=%d) -> %p", n_bytes, mem);
|
|
}
|