[sysprof] libsysprof-capture: add collector interface for samples
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] libsysprof-capture: add collector interface for samples
- Date: Thu, 5 Mar 2020 23:28:10 +0000 (UTC)
commit 43f31fb8b74ed61b83638bc3f8f4eb5152ec0abf
Author: Christian Hergert <chergert redhat com>
Date: Thu Mar 5 15:26:31 2020 -0800
libsysprof-capture: add collector interface for samples
src/libsysprof-capture/sysprof-collector.c | 34 ++++++++++++++++++++++++++++++
src/libsysprof-capture/sysprof-collector.h | 3 +++
2 files changed, 37 insertions(+)
---
diff --git a/src/libsysprof-capture/sysprof-collector.c b/src/libsysprof-capture/sysprof-collector.c
index 5864d76..e10ed66 100644
--- a/src/libsysprof-capture/sysprof-collector.c
+++ b/src/libsysprof-capture/sysprof-collector.c
@@ -364,3 +364,37 @@ sysprof_collector_allocate (SysprofCaptureAddress alloc_addr,
} COLLECTOR_END;
}
+
+void
+sysprof_collector_sample (SysprofBacktraceFunc backtrace_func,
+ gpointer backtrace_data)
+{
+ COLLECTOR_BEGIN {
+ SysprofCaptureSample *ev;
+ gsize len;
+
+ len = sizeof *ev + (sizeof (SysprofCaptureSample) * MAX_UNWIND_DEPTH);
+
+ if ((ev = mapped_ring_buffer_allocate (collector->buffer, len)))
+ {
+ gint n_addrs;
+
+ /* See comment from sysprof_collector_allocate(). */
+ if (backtrace_func)
+ n_addrs = backtrace_func (ev->addrs, MAX_UNWIND_DEPTH, backtrace_data);
+ else
+ n_addrs = 0;
+
+ ev->n_addrs = CLAMP (n_addrs, 0, MAX_UNWIND_DEPTH);
+ ev->frame.len = sizeof *ev + sizeof (SysprofCaptureAddress) * ev->n_addrs;
+ ev->frame.type = SYSPROF_CAPTURE_FRAME_SAMPLE;
+ ev->frame.cpu = _do_getcpu ();
+ ev->frame.pid = collector->pid;
+ ev->frame.time = SYSPROF_CAPTURE_CURRENT_TIME;
+ ev->tid = collector->tid;
+
+ mapped_ring_buffer_advance (collector->buffer, ev->frame.len);
+ }
+
+ } COLLECTOR_END;
+}
diff --git a/src/libsysprof-capture/sysprof-collector.h b/src/libsysprof-capture/sysprof-collector.h
index 24a88bc..140eeb7 100644
--- a/src/libsysprof-capture/sysprof-collector.h
+++ b/src/libsysprof-capture/sysprof-collector.h
@@ -68,5 +68,8 @@ void sysprof_collector_allocate (SysprofCaptureAddress
gint64 alloc_size,
SysprofBacktraceFunc backtrace_func,
gpointer backtrace_data);
+SYSPROF_AVAILABLE_IN_3_36
+void sysprof_collector_sample (SysprofBacktraceFunc backtrace_func,
+ gpointer backtrace_data);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]