mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
preload: add static assertion with offsetof() check
This commit is contained in:
@ -38,12 +38,14 @@ backtrace_func (SysprofCaptureAddress *addrs,
|
|||||||
G_GNUC_UNUSED gpointer user_data)
|
G_GNUC_UNUSED gpointer user_data)
|
||||||
{
|
{
|
||||||
#if GLIB_SIZEOF_VOID_P == 8
|
#if GLIB_SIZEOF_VOID_P == 8
|
||||||
|
SYSPROF_STATIC_ASSERT (offsetof (SysprofCaptureAllocation, addrs) >= GLIB_SIZEOF_VOID_P * 2,
|
||||||
|
"Require space for 2 discarded instruction pointers");
|
||||||
/* We know that collector will overwrite fields *AFTER* it
|
/* We know that collector will overwrite fields *AFTER* it
|
||||||
* has called the backtrace function allowing us to cheat
|
* has called the backtrace function allowing us to cheat
|
||||||
* and subtract an offset from addrs to avoid having to
|
* and subtract an offset from addrs to avoid having to
|
||||||
* copy frame pointers around.
|
* copy frame pointers around.
|
||||||
*/
|
*/
|
||||||
return unw_backtrace ((void **)addrs - 2, n_addrs) - 2;
|
return unw_backtrace (((void **)addrs) - 2, n_addrs) - 2;
|
||||||
#else
|
#else
|
||||||
static const int skip = 2;
|
static const int skip = 2;
|
||||||
void **stack = alloca (n_addrs * sizeof (gpointer));
|
void **stack = alloca (n_addrs * sizeof (gpointer));
|
||||||
|
|||||||
Reference in New Issue
Block a user