tools: use sysprof_tracefd_consumer_new

This just allows us to avoid some duplicated code.
This commit is contained in:
Christian Hergert
2023-07-27 15:49:34 -07:00
parent 048e366ea9
commit 3a74254f73
2 changed files with 22 additions and 26 deletions

View File

@ -599,6 +599,9 @@ main (int argc,
}
}
sysprof_profiler_add_instrument (profiler, sysprof_tracefd_consumer_new (g_steal_fd (&gjs_trace_fd)));
sysprof_profiler_add_instrument (profiler, sysprof_tracefd_consumer_new (g_steal_fd (&trace_fd)));
/* Now open the writer for our session */
if (!(writer = sysprof_capture_writer_new (capture_filename, BUFFER_SIZE)))
{
@ -625,28 +628,6 @@ main (int argc,
g_main_loop_run (main_loop);
if (gjs_trace_fd != -1)
{
SysprofCaptureReader *reader = NULL;
if ((reader = sysprof_capture_reader_new_from_fd (g_steal_fd (&gjs_trace_fd))))
{
sysprof_capture_writer_cat (writer, reader);
sysprof_capture_reader_unref (reader);
}
}
if (trace_fd != -1)
{
SysprofCaptureReader *reader = NULL;
if ((reader = sysprof_capture_reader_new_from_fd (g_steal_fd (&trace_fd))))
{
sysprof_capture_writer_cat (writer, reader);
sysprof_capture_reader_unref (reader);
}
}
sysprof_capture_writer_flush (writer);
sysprof_capture_writer_unref (writer);