[sysprof] capture: add task-id (thread-id) to samples



commit 6b983ab8c1bee38940253325a45a771cd5b06884
Author: Christian Hergert <chergert redhat com>
Date:   Wed May 8 09:19:29 2019 -0700

    capture: add task-id (thread-id) to samples
    
    This could let us do some amount of filtering by threads going
    forward if we have that data available to us.

 src/libsysprof-capture/sp-capture-types.h  | 2 +-
 src/libsysprof-capture/sp-capture-writer.c | 2 ++
 src/libsysprof-capture/sp-capture-writer.h | 1 +
 src/libsysprof/sp-perf-source.c            | 1 +
 src/tests/test-capture.c                   | 3 ++-
 src/tools/sysprof-cat.c                    | 1 +
 6 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/libsysprof-capture/sp-capture-types.h b/src/libsysprof-capture/sp-capture-types.h
index efff305..65723d5 100644
--- a/src/libsysprof-capture/sp-capture-types.h
+++ b/src/libsysprof-capture/sp-capture-types.h
@@ -141,7 +141,7 @@ typedef struct
   SpCaptureFrame   frame;
   guint32          n_addrs : 16;
   guint32          padding1 : 16;
-  guint32          padding2;
+  gint32           tid;
   SpCaptureAddress addrs[0];
 } SpCaptureSample
 SP_ALIGNED_END(1);
diff --git a/src/libsysprof-capture/sp-capture-writer.c b/src/libsysprof-capture/sp-capture-writer.c
index 85f42f0..a4f7ec3 100644
--- a/src/libsysprof-capture/sp-capture-writer.c
+++ b/src/libsysprof-capture/sp-capture-writer.c
@@ -648,6 +648,7 @@ sp_capture_writer_add_sample (SpCaptureWriter        *self,
                               gint64                  time,
                               gint                    cpu,
                               gint32                  pid,
+                              gint32                  tid,
                               const SpCaptureAddress *addrs,
                               guint                   n_addrs)
 {
@@ -669,6 +670,7 @@ sp_capture_writer_add_sample (SpCaptureWriter        *self,
                                 time,
                                 SP_CAPTURE_FRAME_SAMPLE);
   ev->n_addrs = n_addrs;
+  ev->tid = tid;
 
   memcpy (ev->addrs, addrs, (n_addrs * sizeof (SpCaptureAddress)));
 
diff --git a/src/libsysprof-capture/sp-capture-writer.h b/src/libsysprof-capture/sp-capture-writer.h
index 39f817b..0b9e796 100644
--- a/src/libsysprof-capture/sp-capture-writer.h
+++ b/src/libsysprof-capture/sp-capture-writer.h
@@ -76,6 +76,7 @@ gboolean            sp_capture_writer_add_sample      (SpCaptureWriter         *
                                                        gint64                   time,
                                                        gint                     cpu,
                                                        gint32                   pid,
+                                                       gint32                   tid,
                                                        const SpCaptureAddress  *addrs,
                                                        guint                    n_addrs);
 gboolean            sp_capture_writer_add_fork        (SpCaptureWriter         *self,
diff --git a/src/libsysprof/sp-perf-source.c b/src/libsysprof/sp-perf-source.c
index 05f1432..f231da4 100644
--- a/src/libsysprof/sp-perf-source.c
+++ b/src/libsysprof/sp-perf-source.c
@@ -284,6 +284,7 @@ sp_perf_source_handle_callchain (SpPerfSource                      *self,
                                 sample->time,
                                 cpu,
                                 sample->pid,
+                                sample->tid,
                                 ips,
                                 n_ips);
 }
diff --git a/src/tests/test-capture.c b/src/tests/test-capture.c
index 6a98bcb..543ef5a 100644
--- a/src/tests/test-capture.c
+++ b/src/tests/test-capture.c
@@ -326,7 +326,7 @@ test_reader_basic (void)
       for (j = 0; j < i; j++)
         addrs[j] = i;
 
-      if (!sp_capture_writer_add_sample (writer, t, -1, -1, addrs, i))
+      if (!sp_capture_writer_add_sample (writer, t, -1, -1, -2, addrs, i))
         g_assert_not_reached ();
     }
 
@@ -349,6 +349,7 @@ test_reader_basic (void)
       g_assert_cmpint (sample->frame.time, ==, t);
       g_assert_cmpint (sample->frame.cpu, ==, -1);
       g_assert_cmpint (sample->frame.pid, ==, -1);
+      g_assert_cmpint (sample->tid, ==, -2);
       g_assert_cmpint (sample->n_addrs, ==, i);
 
       for (j = 0; j < i; j++)
diff --git a/src/tools/sysprof-cat.c b/src/tools/sysprof-cat.c
index 323be57..68c1bb5 100644
--- a/src/tools/sysprof-cat.c
+++ b/src/tools/sysprof-cat.c
@@ -317,6 +317,7 @@ main (gint   argc,
                                                 frame->frame.time,
                                                 frame->frame.cpu,
                                                 frame->frame.pid,
+                                                frame->tid,
                                                 addrs,
                                                 frame->n_addrs);
                 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]