From 9f43bf28130978647e82836f4db568a07071f453 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Tue, 18 Feb 2020 13:45:15 -0800 Subject: [PATCH] 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. --- src/libsysprof/sysprof-memprof-profile.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libsysprof/sysprof-memprof-profile.c b/src/libsysprof/sysprof-memprof-profile.c index 2dfe9620..05133797 100644 --- a/src/libsysprof/sysprof-memprof-profile.c +++ b/src/libsysprof/sysprof-memprof-profile.c @@ -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; }