mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
memprof: add memory profiling using LD_PRELOAD
This brings over some of the techniques from the old memprof design. Sysprof and memprof shared a lot of code, so it is pretty natural to bring back the same callgraph view based on memory allocations. This reuses the StackStash just like it did in memprof. While it would be nice to reuse some existing tools out there, the fit of memprof with sysprof is so naturally aligned, it's not really a big deal to bring back the LD_PRELOAD. The value really comes from seeing all this stuff together instead of multiple apps. There are plenty of things we can implement on top of this that we are not doing yet such as temporary allocations, cross-thread frees, graphing the heap, and graphing differences between the heap at to points in time. I'd like all of these things, given enough time to make them useful. This is still a bit slow though due to the global lock we take to access the writer. To improve the speed here we need to get rid of that lock and head towards a design that allows a thread to request a new writer from Sysprof and save it in TLS (to be destroyed when the thread exits).
This commit is contained in:
@ -207,6 +207,10 @@ sysprof_capture_cursor_foreach (SysprofCaptureCursor *self,
|
||||
delegate = READ_DELEGATE (sysprof_capture_reader_read_file);
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_ALLOCATION:
|
||||
delegate = READ_DELEGATE (sysprof_capture_reader_read_allocation);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!sysprof_capture_reader_skip (self->reader))
|
||||
return;
|
||||
|
||||
@ -1352,3 +1352,52 @@ sysprof_capture_reader_find_file (SysprofCaptureReader *self,
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const SysprofCaptureAllocation *
|
||||
sysprof_capture_reader_read_allocation (SysprofCaptureReader *self)
|
||||
{
|
||||
SysprofCaptureAllocation *ma;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0);
|
||||
g_assert (self->pos <= self->bufsz);
|
||||
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, sizeof *ma))
|
||||
return NULL;
|
||||
|
||||
ma = (SysprofCaptureAllocation *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
sysprof_capture_reader_bswap_frame (self, &ma->frame);
|
||||
|
||||
if (ma->frame.type != SYSPROF_CAPTURE_FRAME_ALLOCATION)
|
||||
return NULL;
|
||||
|
||||
if (ma->frame.len < sizeof *ma)
|
||||
return NULL;
|
||||
|
||||
if (self->endian != G_BYTE_ORDER)
|
||||
{
|
||||
ma->n_addrs = GUINT16_SWAP_LE_BE (ma->n_addrs);
|
||||
ma->alloc_size = GUINT64_SWAP_LE_BE (ma->alloc_size);
|
||||
ma->alloc_addr = GUINT64_SWAP_LE_BE (ma->alloc_addr);
|
||||
ma->tid = GUINT32_SWAP_LE_BE (ma->tid);
|
||||
}
|
||||
|
||||
if (ma->frame.len < (sizeof *ma + (sizeof(SysprofCaptureAddress) * ma->n_addrs)))
|
||||
return NULL;
|
||||
|
||||
if (!sysprof_capture_reader_ensure_space_for (self, ma->frame.len))
|
||||
return NULL;
|
||||
|
||||
ma = (SysprofCaptureAllocation *)(gpointer)&self->buf[self->pos];
|
||||
|
||||
if (G_UNLIKELY (self->endian != G_BYTE_ORDER))
|
||||
{
|
||||
for (guint i = 0; i < ma->n_addrs; i++)
|
||||
ma->addrs[i] = GUINT64_SWAP_LE_BE (ma->addrs[i]);
|
||||
}
|
||||
|
||||
self->pos += ma->frame.len;
|
||||
|
||||
return ma;
|
||||
}
|
||||
|
||||
@ -64,86 +64,88 @@ G_BEGIN_DECLS
|
||||
typedef struct _SysprofCaptureReader SysprofCaptureReader;
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCaptureReader *sysprof_capture_reader_new (const gchar *filename,
|
||||
GError **error);
|
||||
SysprofCaptureReader *sysprof_capture_reader_new (const gchar *filename,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCaptureReader *sysprof_capture_reader_new_from_fd (int fd,
|
||||
GError **error);
|
||||
SysprofCaptureReader *sysprof_capture_reader_new_from_fd (int fd,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCaptureReader *sysprof_capture_reader_copy (SysprofCaptureReader *self);
|
||||
SysprofCaptureReader *sysprof_capture_reader_copy (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCaptureReader *sysprof_capture_reader_ref (SysprofCaptureReader *self);
|
||||
SysprofCaptureReader *sysprof_capture_reader_ref (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_capture_reader_unref (SysprofCaptureReader *self);
|
||||
void sysprof_capture_reader_unref (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gint sysprof_capture_reader_get_byte_order (SysprofCaptureReader *self);
|
||||
gint sysprof_capture_reader_get_byte_order (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const gchar *sysprof_capture_reader_get_filename (SysprofCaptureReader *self);
|
||||
const gchar *sysprof_capture_reader_get_filename (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const gchar *sysprof_capture_reader_get_time (SysprofCaptureReader *self);
|
||||
const gchar *sysprof_capture_reader_get_time (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gint64 sysprof_capture_reader_get_start_time (SysprofCaptureReader *self);
|
||||
gint64 sysprof_capture_reader_get_start_time (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gint64 sysprof_capture_reader_get_end_time (SysprofCaptureReader *self);
|
||||
gint64 sysprof_capture_reader_get_end_time (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_reader_skip (SysprofCaptureReader *self);
|
||||
gboolean sysprof_capture_reader_skip (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_reader_peek_type (SysprofCaptureReader *self,
|
||||
SysprofCaptureFrameType *type);
|
||||
gboolean sysprof_capture_reader_peek_type (SysprofCaptureReader *self,
|
||||
SysprofCaptureFrameType *type);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_reader_peek_frame (SysprofCaptureReader *self,
|
||||
SysprofCaptureFrame *frame);
|
||||
gboolean sysprof_capture_reader_peek_frame (SysprofCaptureReader *self,
|
||||
SysprofCaptureFrame *frame);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureLog *sysprof_capture_reader_read_log (SysprofCaptureReader *self);
|
||||
const SysprofCaptureLog *sysprof_capture_reader_read_log (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureMap *sysprof_capture_reader_read_map (SysprofCaptureReader *self);
|
||||
const SysprofCaptureMap *sysprof_capture_reader_read_map (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureMark *sysprof_capture_reader_read_mark (SysprofCaptureReader *self);
|
||||
const SysprofCaptureMark *sysprof_capture_reader_read_mark (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureMetadata *sysprof_capture_reader_read_metadata (SysprofCaptureReader *self);
|
||||
const SysprofCaptureMetadata *sysprof_capture_reader_read_metadata (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureExit *sysprof_capture_reader_read_exit (SysprofCaptureReader *self);
|
||||
const SysprofCaptureExit *sysprof_capture_reader_read_exit (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureFork *sysprof_capture_reader_read_fork (SysprofCaptureReader *self);
|
||||
const SysprofCaptureFork *sysprof_capture_reader_read_fork (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureTimestamp *sysprof_capture_reader_read_timestamp (SysprofCaptureReader *self);
|
||||
const SysprofCaptureTimestamp *sysprof_capture_reader_read_timestamp (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureProcess *sysprof_capture_reader_read_process (SysprofCaptureReader *self);
|
||||
const SysprofCaptureProcess *sysprof_capture_reader_read_process (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureSample *sysprof_capture_reader_read_sample (SysprofCaptureReader *self);
|
||||
const SysprofCaptureSample *sysprof_capture_reader_read_sample (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GHashTable *sysprof_capture_reader_read_jitmap (SysprofCaptureReader *self);
|
||||
GHashTable *sysprof_capture_reader_read_jitmap (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureCounterDefine *sysprof_capture_reader_read_counter_define (SysprofCaptureReader *self);
|
||||
const SysprofCaptureCounterDefine *sysprof_capture_reader_read_counter_define (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureCounterSet *sysprof_capture_reader_read_counter_set (SysprofCaptureReader *self);
|
||||
const SysprofCaptureCounterSet *sysprof_capture_reader_read_counter_set (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureFileChunk *sysprof_capture_reader_read_file (SysprofCaptureReader *self);
|
||||
const SysprofCaptureFileChunk *sysprof_capture_reader_read_file (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_3_36
|
||||
const SysprofCaptureAllocation *sysprof_capture_reader_read_allocation (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_reader_reset (SysprofCaptureReader *self);
|
||||
gboolean sysprof_capture_reader_reset (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_reader_splice (SysprofCaptureReader *self,
|
||||
SysprofCaptureWriter *dest,
|
||||
GError **error);
|
||||
gboolean sysprof_capture_reader_splice (SysprofCaptureReader *self,
|
||||
SysprofCaptureWriter *dest,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_reader_save_as (SysprofCaptureReader *self,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
gboolean sysprof_capture_reader_save_as (SysprofCaptureReader *self,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_reader_get_stat (SysprofCaptureReader *self,
|
||||
SysprofCaptureStat *st_buf);
|
||||
gboolean sysprof_capture_reader_get_stat (SysprofCaptureReader *self,
|
||||
SysprofCaptureStat *st_buf);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_capture_reader_set_stat (SysprofCaptureReader *self,
|
||||
const SysprofCaptureStat *st_buf);
|
||||
void sysprof_capture_reader_set_stat (SysprofCaptureReader *self,
|
||||
const SysprofCaptureStat *st_buf);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofCaptureFileChunk *sysprof_capture_reader_find_file (SysprofCaptureReader *self,
|
||||
const gchar *path);
|
||||
const SysprofCaptureFileChunk *sysprof_capture_reader_find_file (SysprofCaptureReader *self,
|
||||
const gchar *path);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gchar **sysprof_capture_reader_list_files (SysprofCaptureReader *self);
|
||||
gchar **sysprof_capture_reader_list_files (SysprofCaptureReader *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_reader_read_file_fd (SysprofCaptureReader *self,
|
||||
const gchar *path,
|
||||
gint fd);
|
||||
gboolean sysprof_capture_reader_read_file_fd (SysprofCaptureReader *self,
|
||||
const gchar *path,
|
||||
gint fd);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofCaptureReader, sysprof_capture_reader_unref)
|
||||
|
||||
|
||||
@ -115,19 +115,20 @@ typedef union
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SYSPROF_CAPTURE_FRAME_TIMESTAMP = 1,
|
||||
SYSPROF_CAPTURE_FRAME_SAMPLE = 2,
|
||||
SYSPROF_CAPTURE_FRAME_MAP = 3,
|
||||
SYSPROF_CAPTURE_FRAME_PROCESS = 4,
|
||||
SYSPROF_CAPTURE_FRAME_FORK = 5,
|
||||
SYSPROF_CAPTURE_FRAME_EXIT = 6,
|
||||
SYSPROF_CAPTURE_FRAME_JITMAP = 7,
|
||||
SYSPROF_CAPTURE_FRAME_CTRDEF = 8,
|
||||
SYSPROF_CAPTURE_FRAME_CTRSET = 9,
|
||||
SYSPROF_CAPTURE_FRAME_MARK = 10,
|
||||
SYSPROF_CAPTURE_FRAME_METADATA = 11,
|
||||
SYSPROF_CAPTURE_FRAME_LOG = 12,
|
||||
SYSPROF_CAPTURE_FRAME_FILE_CHUNK = 13,
|
||||
SYSPROF_CAPTURE_FRAME_TIMESTAMP = 1,
|
||||
SYSPROF_CAPTURE_FRAME_SAMPLE = 2,
|
||||
SYSPROF_CAPTURE_FRAME_MAP = 3,
|
||||
SYSPROF_CAPTURE_FRAME_PROCESS = 4,
|
||||
SYSPROF_CAPTURE_FRAME_FORK = 5,
|
||||
SYSPROF_CAPTURE_FRAME_EXIT = 6,
|
||||
SYSPROF_CAPTURE_FRAME_JITMAP = 7,
|
||||
SYSPROF_CAPTURE_FRAME_CTRDEF = 8,
|
||||
SYSPROF_CAPTURE_FRAME_CTRSET = 9,
|
||||
SYSPROF_CAPTURE_FRAME_MARK = 10,
|
||||
SYSPROF_CAPTURE_FRAME_METADATA = 11,
|
||||
SYSPROF_CAPTURE_FRAME_LOG = 12,
|
||||
SYSPROF_CAPTURE_FRAME_FILE_CHUNK = 13,
|
||||
SYSPROF_CAPTURE_FRAME_ALLOCATION = 14,
|
||||
} SysprofCaptureFrameType;
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
@ -311,6 +312,19 @@ typedef struct
|
||||
} SysprofCaptureFileChunk
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
SYSPROF_ALIGNED_BEGIN(1)
|
||||
typedef struct
|
||||
{
|
||||
SysprofCaptureFrame frame;
|
||||
SysprofCaptureAddress alloc_addr;
|
||||
gint64 alloc_size;
|
||||
gint32 tid;
|
||||
guint32 n_addrs : 16;
|
||||
guint32 padding1 : 16;
|
||||
SysprofCaptureAddress addrs[0];
|
||||
} SysprofCaptureAllocation
|
||||
SYSPROF_ALIGNED_END(1);
|
||||
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureFileHeader) == 256);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureFrame) == 24);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureMap) == 56);
|
||||
@ -328,6 +342,8 @@ G_STATIC_ASSERT (sizeof (SysprofCaptureMark) == 96);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureMetadata) == 64);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureLog) == 64);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureFileChunk) == 284);
|
||||
G_STATIC_ASSERT (sizeof (SysprofCaptureAllocation) == 48);
|
||||
G_STATIC_ASSERT ((G_STRUCT_OFFSET (SysprofCaptureAllocation, addrs) % 8) == 0);
|
||||
|
||||
static inline gint
|
||||
sysprof_capture_address_compare (SysprofCaptureAddress a,
|
||||
|
||||
@ -477,6 +477,24 @@ sysprof_capture_writer_cat (SysprofCaptureWriter *self,
|
||||
goto panic;
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_ALLOCATION: {
|
||||
const SysprofCaptureAllocation *frame;
|
||||
|
||||
if (!(frame = sysprof_capture_reader_read_allocation (reader)))
|
||||
goto panic;
|
||||
|
||||
sysprof_capture_writer_add_allocation_copy (self,
|
||||
frame->frame.time,
|
||||
frame->frame.cpu,
|
||||
frame->frame.pid,
|
||||
frame->tid,
|
||||
frame->alloc_addr,
|
||||
frame->alloc_size,
|
||||
frame->addrs,
|
||||
frame->n_addrs);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
/* Silently drop, which is better than looping. We could potentially
|
||||
* copy this over using the raw bytes at some point.
|
||||
|
||||
@ -78,6 +78,7 @@
|
||||
#define DEFAULT_BUFFER_SIZE (_sysprof_getpagesize() * 64L)
|
||||
#define INVALID_ADDRESS (G_GUINT64_CONSTANT(0))
|
||||
#define MAX_COUNTERS ((1 << 24) - 1)
|
||||
#define MAX_UNWIND_DEPTH 128
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -1510,3 +1511,101 @@ sysprof_capture_writer_set_flush_delay (SysprofCaptureWriter *self,
|
||||
|
||||
g_source_attach (self->periodic_flush, main_context);
|
||||
}
|
||||
|
||||
gboolean
|
||||
sysprof_capture_writer_add_allocation (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
gint32 tid,
|
||||
SysprofCaptureAddress alloc_addr,
|
||||
gint64 alloc_size,
|
||||
SysprofBacktraceFunc backtrace_func,
|
||||
gpointer backtrace_data)
|
||||
{
|
||||
SysprofCaptureAllocation *ev;
|
||||
gsize len;
|
||||
guint n_addrs;
|
||||
|
||||
g_assert (self != NULL);
|
||||
g_assert (backtrace_func != NULL);
|
||||
|
||||
len = sizeof *ev + (MAX_UNWIND_DEPTH * sizeof (SysprofCaptureAddress));
|
||||
ev = (SysprofCaptureAllocation *)sysprof_capture_writer_allocate (self, &len);
|
||||
if (!ev)
|
||||
return FALSE;
|
||||
|
||||
sysprof_capture_writer_frame_init (&ev->frame,
|
||||
len,
|
||||
cpu,
|
||||
pid,
|
||||
time,
|
||||
SYSPROF_CAPTURE_FRAME_ALLOCATION);
|
||||
|
||||
ev->alloc_size = alloc_size;
|
||||
ev->alloc_addr = alloc_addr;
|
||||
ev->padding1 = 0;
|
||||
ev->tid = tid;
|
||||
ev->n_addrs = 0;
|
||||
|
||||
n_addrs = backtrace_func (ev->addrs, MAX_UNWIND_DEPTH, backtrace_data);
|
||||
|
||||
if (n_addrs <= MAX_UNWIND_DEPTH)
|
||||
ev->n_addrs = n_addrs;
|
||||
|
||||
if (ev->n_addrs < MAX_UNWIND_DEPTH)
|
||||
{
|
||||
gsize diff = (sizeof (SysprofCaptureAddress) * (MAX_UNWIND_DEPTH - ev->n_addrs));
|
||||
|
||||
ev->frame.len -= diff;
|
||||
self->pos -= diff;
|
||||
}
|
||||
|
||||
self->stat.frame_count[SYSPROF_CAPTURE_FRAME_ALLOCATION]++;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
sysprof_capture_writer_add_allocation_copy (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
gint32 tid,
|
||||
SysprofCaptureAddress alloc_addr,
|
||||
gint64 alloc_size,
|
||||
const SysprofCaptureAddress *addrs,
|
||||
guint n_addrs)
|
||||
{
|
||||
SysprofCaptureAllocation *ev;
|
||||
gsize len;
|
||||
|
||||
g_assert (self != NULL);
|
||||
|
||||
if (n_addrs > 0xFFF)
|
||||
n_addrs = 0xFFF;
|
||||
|
||||
len = sizeof *ev + (n_addrs * sizeof (SysprofCaptureAddress));
|
||||
ev = (SysprofCaptureAllocation *)sysprof_capture_writer_allocate (self, &len);
|
||||
if (!ev)
|
||||
return FALSE;
|
||||
|
||||
sysprof_capture_writer_frame_init (&ev->frame,
|
||||
len,
|
||||
cpu,
|
||||
pid,
|
||||
time,
|
||||
SYSPROF_CAPTURE_FRAME_ALLOCATION);
|
||||
|
||||
ev->alloc_size = alloc_size;
|
||||
ev->alloc_addr = alloc_addr;
|
||||
ev->padding1 = 0;
|
||||
ev->tid = tid;
|
||||
ev->n_addrs = n_addrs;
|
||||
|
||||
memcpy (ev->addrs, addrs, sizeof (SysprofCaptureAddress) * n_addrs);
|
||||
|
||||
self->stat.frame_count[SYSPROF_CAPTURE_FRAME_ALLOCATION]++;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -63,154 +63,188 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct _SysprofCaptureWriter SysprofCaptureWriter;
|
||||
|
||||
/**
|
||||
* SysprofBacktraceFunc:
|
||||
* @addrs: (inout) (array length=n_addrs): an array to place addresses
|
||||
* into the capture frame
|
||||
* @n_addrs: the length of @addrs
|
||||
* @user_data: (scope call): closure data for the callback
|
||||
*
|
||||
* Returns: the number of addresses filled in @addrs
|
||||
*/
|
||||
typedef guint (*SysprofBacktraceFunc) (SysprofCaptureAddress *addrs,
|
||||
guint n_addrs,
|
||||
gpointer user_data);
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCaptureWriter *sysprof_capture_writer_new_from_env (gsize buffer_size);
|
||||
SysprofCaptureWriter *sysprof_capture_writer_new_from_env (gsize buffer_size);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCaptureWriter *sysprof_capture_writer_new (const gchar *filename,
|
||||
gsize buffer_size);
|
||||
SysprofCaptureWriter *sysprof_capture_writer_new (const gchar *filename,
|
||||
gsize buffer_size);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCaptureWriter *sysprof_capture_writer_new_from_fd (int fd,
|
||||
gsize buffer_size);
|
||||
SysprofCaptureWriter *sysprof_capture_writer_new_from_fd (int fd,
|
||||
gsize buffer_size);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gsize sysprof_capture_writer_get_buffer_size (SysprofCaptureWriter *self);
|
||||
gsize sysprof_capture_writer_get_buffer_size (SysprofCaptureWriter *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCaptureWriter *sysprof_capture_writer_ref (SysprofCaptureWriter *self);
|
||||
SysprofCaptureWriter *sysprof_capture_writer_ref (SysprofCaptureWriter *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_capture_writer_unref (SysprofCaptureWriter *self);
|
||||
void sysprof_capture_writer_unref (SysprofCaptureWriter *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_capture_writer_stat (SysprofCaptureWriter *self,
|
||||
SysprofCaptureStat *stat);
|
||||
void sysprof_capture_writer_stat (SysprofCaptureWriter *self,
|
||||
SysprofCaptureStat *stat);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_capture_writer_set_flush_delay (SysprofCaptureWriter *self,
|
||||
GMainContext *main_context,
|
||||
guint timeout_seconds);
|
||||
void sysprof_capture_writer_set_flush_delay (SysprofCaptureWriter *self,
|
||||
GMainContext *main_context,
|
||||
guint timeout_seconds);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_add_file (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const gchar *path,
|
||||
gboolean is_last,
|
||||
const guint8 *data,
|
||||
gsize data_len);
|
||||
gboolean sysprof_capture_writer_add_file (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const gchar *path,
|
||||
gboolean is_last,
|
||||
const guint8 *data,
|
||||
gsize data_len);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_add_file_fd (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const gchar *path,
|
||||
gint fd);
|
||||
gboolean sysprof_capture_writer_add_file_fd (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const gchar *path,
|
||||
gint fd);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_add_map (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
guint64 start,
|
||||
guint64 end,
|
||||
guint64 offset,
|
||||
guint64 inode,
|
||||
const gchar *filename);
|
||||
gboolean sysprof_capture_writer_add_map (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
guint64 start,
|
||||
guint64 end,
|
||||
guint64 offset,
|
||||
guint64 inode,
|
||||
const gchar *filename);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_add_mark (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
guint64 duration,
|
||||
const gchar *group,
|
||||
const gchar *name,
|
||||
const gchar *message);
|
||||
gboolean sysprof_capture_writer_add_mark (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
guint64 duration,
|
||||
const gchar *group,
|
||||
const gchar *name,
|
||||
const gchar *message);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_add_metadata (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const gchar *id,
|
||||
const gchar *metadata,
|
||||
gssize metadata_len);
|
||||
gboolean sysprof_capture_writer_add_metadata (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const gchar *id,
|
||||
const gchar *metadata,
|
||||
gssize metadata_len);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
guint64 sysprof_capture_writer_add_jitmap (SysprofCaptureWriter *self,
|
||||
const gchar *name);
|
||||
guint64 sysprof_capture_writer_add_jitmap (SysprofCaptureWriter *self,
|
||||
const gchar *name);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_add_process (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const gchar *cmdline);
|
||||
gboolean sysprof_capture_writer_add_process (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const gchar *cmdline);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_add_sample (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
gint32 tid,
|
||||
const SysprofCaptureAddress *addrs,
|
||||
guint n_addrs);
|
||||
gboolean sysprof_capture_writer_add_sample (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
gint32 tid,
|
||||
const SysprofCaptureAddress *addrs,
|
||||
guint n_addrs);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_add_fork (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
gint32 child_pid);
|
||||
gboolean sysprof_capture_writer_add_fork (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
gint32 child_pid);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_add_exit (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid);
|
||||
gboolean sysprof_capture_writer_add_exit (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_add_timestamp (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid);
|
||||
gboolean sysprof_capture_writer_add_timestamp (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_define_counters (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const SysprofCaptureCounter *counters,
|
||||
guint n_counters);
|
||||
gboolean sysprof_capture_writer_define_counters (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const SysprofCaptureCounter *counters,
|
||||
guint n_counters);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_set_counters (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const guint *counters_ids,
|
||||
const SysprofCaptureCounterValue *values,
|
||||
guint n_counters);
|
||||
gboolean sysprof_capture_writer_set_counters (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
const guint *counters_ids,
|
||||
const SysprofCaptureCounterValue *values,
|
||||
guint n_counters);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_add_log (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
GLogLevelFlags severity,
|
||||
const gchar *domain,
|
||||
const gchar *message);
|
||||
gboolean sysprof_capture_writer_add_log (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
GLogLevelFlags severity,
|
||||
const gchar *domain,
|
||||
const gchar *message);
|
||||
SYSPROF_AVAILABLE_IN_3_36
|
||||
gboolean sysprof_capture_writer_add_allocation (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
gint32 tid,
|
||||
SysprofCaptureAddress alloc_addr,
|
||||
gint64 alloc_size,
|
||||
SysprofBacktraceFunc backtrace_func,
|
||||
gpointer backtrace_data);
|
||||
SYSPROF_AVAILABLE_IN_3_36
|
||||
gboolean sysprof_capture_writer_add_allocation_copy (SysprofCaptureWriter *self,
|
||||
gint64 time,
|
||||
gint cpu,
|
||||
gint32 pid,
|
||||
gint32 tid,
|
||||
SysprofCaptureAddress alloc_addr,
|
||||
gint64 alloc_size,
|
||||
const SysprofCaptureAddress *addrs,
|
||||
guint n_addrs);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_flush (SysprofCaptureWriter *self);
|
||||
gboolean sysprof_capture_writer_flush (SysprofCaptureWriter *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_save_as (SysprofCaptureWriter *self,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
gboolean sysprof_capture_writer_save_as (SysprofCaptureWriter *self,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
guint sysprof_capture_writer_request_counter (SysprofCaptureWriter *self,
|
||||
guint n_counters);
|
||||
guint sysprof_capture_writer_request_counter (SysprofCaptureWriter *self,
|
||||
guint n_counters);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofCaptureReader *sysprof_capture_writer_create_reader (SysprofCaptureWriter *self,
|
||||
GError **error);
|
||||
SysprofCaptureReader *sysprof_capture_writer_create_reader (SysprofCaptureWriter *self,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_splice (SysprofCaptureWriter *self,
|
||||
SysprofCaptureWriter *dest,
|
||||
GError **error);
|
||||
gboolean sysprof_capture_writer_splice (SysprofCaptureWriter *self,
|
||||
SysprofCaptureWriter *dest,
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_writer_cat (SysprofCaptureWriter *self,
|
||||
SysprofCaptureReader *reader,
|
||||
GError **error);
|
||||
gboolean sysprof_capture_writer_cat (SysprofCaptureWriter *self,
|
||||
SysprofCaptureReader *reader,
|
||||
GError **error);
|
||||
G_GNUC_INTERNAL
|
||||
gboolean _sysprof_capture_writer_splice_from_fd (SysprofCaptureWriter *self,
|
||||
int fd,
|
||||
GError **error) G_GNUC_INTERNAL;
|
||||
gboolean _sysprof_capture_writer_splice_from_fd (SysprofCaptureWriter *self,
|
||||
int fd,
|
||||
GError **error) G_GNUC_INTERNAL;
|
||||
G_GNUC_INTERNAL
|
||||
gboolean _sysprof_capture_writer_set_time_range (SysprofCaptureWriter *self,
|
||||
gint64 start_time,
|
||||
gint64 end_time) G_GNUC_INTERNAL;
|
||||
gboolean _sysprof_capture_writer_set_time_range (SysprofCaptureWriter *self,
|
||||
gint64 start_time,
|
||||
gint64 end_time) G_GNUC_INTERNAL;
|
||||
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofCaptureWriter, sysprof_capture_writer_unref)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user