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);
}
