libsysprof: only add process cmdline info once

We might get this information from multiple sources (such as Linux's perf
or the proc data source). So only add this information once to avoid
having additional data we don't care about.

This also helps ensure we get a proper tree for the callgraph without
splitting things between updated cmdline information.
This commit is contained in:
Christian Hergert
2020-02-18 13:45:15 -08:00
parent 93acce520f
commit 9f43bf2813

View File

@ -221,11 +221,14 @@ cursor_foreach_cb (const SysprofCaptureFrame *frame,
if G_UNLIKELY (frame->type == SYSPROF_CAPTURE_FRAME_PROCESS)
{
const SysprofCaptureProcess *pr = (const SysprofCaptureProcess *)frame;
g_autofree gchar *cmdline = g_strdup_printf ("[%s]", pr->cmdline);
g_hash_table_insert (g->cmdlines,
GINT_TO_POINTER (frame->pid),
(gchar *)g_string_chunk_insert_const (g->symbols, cmdline));
if (!g_hash_table_contains (g->cmdlines, GINT_TO_POINTER (frame->pid)))
{
g_autofree gchar *cmdline = g_strdup_printf ("[%s]", pr->cmdline);
g_hash_table_insert (g->cmdlines,
GINT_TO_POINTER (frame->pid),
(gchar *)g_string_chunk_insert_const (g->symbols, cmdline));
}
return TRUE;
}