libsysprof: rename follow_fork() to follow_process()

This is more of what we want to be doing anyway, we don't care about all
the forks in existence.

Additionally, include the comm[] with the pid so that instruments can take
action based on it.
This commit is contained in:
Christian Hergert
2023-08-28 17:24:27 -07:00
parent 8aa55a7b2d
commit 31547de795
6 changed files with 30 additions and 20 deletions

View File

@ -48,7 +48,8 @@ struct _SysprofInstrumentClass
SysprofRecording *recording); SysprofRecording *recording);
DexFuture *(*process_started) (SysprofInstrument *self, DexFuture *(*process_started) (SysprofInstrument *self,
SysprofRecording *recording, SysprofRecording *recording,
int pid); int pid,
const char *comm);
}; };
DexFuture *_sysprof_instruments_acquire_policy (GPtrArray *instruments, DexFuture *_sysprof_instruments_acquire_policy (GPtrArray *instruments,
@ -62,6 +63,7 @@ DexFuture *_sysprof_instruments_augment (GPtrArray *instruments,
SysprofRecording *recording); SysprofRecording *recording);
DexFuture *_sysprof_instruments_process_started (GPtrArray *instruments, DexFuture *_sysprof_instruments_process_started (GPtrArray *instruments,
SysprofRecording *recording, SysprofRecording *recording,
int pid); int pid,
const char *comm);
G_END_DECLS G_END_DECLS

View File

@ -126,13 +126,14 @@ _sysprof_instrument_augment (SysprofInstrument *self,
static DexFuture * static DexFuture *
_sysprof_instrument_process_started (SysprofInstrument *self, _sysprof_instrument_process_started (SysprofInstrument *self,
SysprofRecording *recording, SysprofRecording *recording,
int pid) int pid,
const char *comm)
{ {
g_assert (SYSPROF_IS_INSTRUMENT (self)); g_assert (SYSPROF_IS_INSTRUMENT (self));
g_assert (SYSPROF_IS_RECORDING (recording)); g_assert (SYSPROF_IS_RECORDING (recording));
if (SYSPROF_INSTRUMENT_GET_CLASS (self)->process_started) if (SYSPROF_INSTRUMENT_GET_CLASS (self)->process_started)
return SYSPROF_INSTRUMENT_GET_CLASS (self)->process_started (self, recording, pid); return SYSPROF_INSTRUMENT_GET_CLASS (self)->process_started (self, recording, pid, comm);
return dex_future_new_for_boolean (TRUE); return dex_future_new_for_boolean (TRUE);
} }
@ -288,7 +289,8 @@ _sysprof_instruments_augment (GPtrArray *instruments,
DexFuture * DexFuture *
_sysprof_instruments_process_started (GPtrArray *instruments, _sysprof_instruments_process_started (GPtrArray *instruments,
SysprofRecording *recording, SysprofRecording *recording,
int pid) int pid,
const char *comm)
{ {
g_autoptr(GPtrArray) futures = NULL; g_autoptr(GPtrArray) futures = NULL;
@ -301,7 +303,7 @@ _sysprof_instruments_process_started (GPtrArray *instruments,
{ {
SysprofInstrument *instrument = g_ptr_array_index (instruments, i); SysprofInstrument *instrument = g_ptr_array_index (instruments, i);
g_ptr_array_add (futures, _sysprof_instrument_process_started (instrument, recording, pid)); g_ptr_array_add (futures, _sysprof_instrument_process_started (instrument, recording, pid, comm));
} }
if (futures->len == 0) if (futures->len == 0)

View File

@ -294,7 +294,8 @@ sysprof_linux_instrument_prepare (SysprofInstrument *instrument,
static DexFuture * static DexFuture *
sysprof_linux_instrument_process_started (SysprofInstrument *instrument, sysprof_linux_instrument_process_started (SysprofInstrument *instrument,
SysprofRecording *recording, SysprofRecording *recording,
int pid) int pid,
const char *comm)
{ {
g_assert (SYSPROF_IS_INSTRUMENT (instrument)); g_assert (SYSPROF_IS_INSTRUMENT (instrument));
g_assert (SYSPROF_IS_RECORDING (recording)); g_assert (SYSPROF_IS_RECORDING (recording));

View File

@ -95,8 +95,9 @@ void _sysprof_recording_add_file_data (SysprofRecording *s
const char *contents, const char *contents,
gssize length, gssize length,
gboolean compress); gboolean compress);
void _sysprof_recording_follow_fork (SysprofRecording *self, void _sysprof_recording_follow_process(SysprofRecording *self,
int pid); int pid,
const char *comm);
void _sysprof_recording_diagnostic (SysprofRecording *self, void _sysprof_recording_diagnostic (SysprofRecording *self,
const char *domain, const char *domain,
const char *format, const char *format,

View File

@ -904,11 +904,12 @@ sysprof_recording_get_subprocess (SysprofRecording *self)
} }
void void
_sysprof_recording_follow_fork (SysprofRecording *self, _sysprof_recording_follow_process (SysprofRecording *self,
int pid) int pid,
const char *comm)
{ {
g_return_if_fail (SYSPROF_IS_RECORDING (self)); g_return_if_fail (SYSPROF_IS_RECORDING (self));
g_return_if_fail (pid > 0); g_return_if_fail (pid > 0);
dex_future_disown (_sysprof_instruments_process_started (self->instruments, self, pid)); dex_future_disown (_sysprof_instruments_process_started (self->instruments, self, pid, comm));
} }

View File

@ -122,11 +122,17 @@ sysprof_sampler_perf_event_stream_cb (const SysprofPerfEvent *event,
memcpy (&time, event->comm.comm + offset, sizeof time); memcpy (&time, event->comm.comm + offset, sizeof time);
if (event->comm.pid == event->comm.tid) if (event->comm.pid == event->comm.tid)
sysprof_capture_writer_add_process (writer, {
time, sysprof_capture_writer_add_process (writer,
cpu, time,
event->comm.pid, cpu,
event->comm.comm); event->comm.pid,
event->comm.comm);
_sysprof_recording_follow_process (recording,
event->comm.pid,
event->comm.comm);
}
break; break;
@ -148,9 +154,6 @@ sysprof_sampler_perf_event_stream_cb (const SysprofPerfEvent *event,
cpu, cpu,
event->fork.ptid, event->fork.ptid,
event->fork.tid); event->fork.tid);
_sysprof_recording_follow_fork (recording, event->fork.tid);
break; break;
case PERF_RECORD_LOST: case PERF_RECORD_LOST: