This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [PATCH v3 3/5] perf/sdt: Show SDT cache contents
- From: Namhyung Kim <namhyung at kernel dot org>
- To: Hemant Kumar <hemant at linux dot vnet dot ibm dot com>
- Cc: linux-kernel at vger dot kernel dot org, srikar at linux dot vnet dot ibm dot com, peterz at infradead dot org, oleg at redhat dot com, hegdevasant at linux dot vnet dot ibm dot com, mingo at redhat dot com, anton at redhat dot com, systemtap at sourceware dot org, masami dot hiramatsu dot pt at hitachi dot com, aravinda at linux dot vnet dot ibm dot com, penberg at iki dot fi
- Date: Wed, 22 Oct 2014 13:48:35 +0900
- Subject: Re: [PATCH v3 3/5] perf/sdt: Show SDT cache contents
- Authentication-results: sourceware.org; auth=none
- References: <20141010104402 dot 15506 dot 73285 dot stgit at hemant-fedora> <20141010105830 dot 15506 dot 69597 dot stgit at hemant-fedora>
On Fri, 10 Oct 2014 16:28:43 +0530, Hemant Kumar wrote:
> This patch adds support to dump the SDT cache onto sdtout.
> The cache data is read into a hash_list and then, it iterates through
> the hash_list to dump the data onto stdout.
>
> # ./perf sdt-cache --dump
>
> /usr/lib64/libc-2.16.so :
> %libc:lll_futex_wake
> %libc:longjmp_target
> %libc:longjmp
> %libc:lll_lock_wait_private
> %libc:lll_futex_wake
> %libc:longjmp_target
> %libc:longjmp
> %libc:setjmp
Hmm.. it seems the output is prefixed with '\t' in the code..
[SNIP]
> @@ -35,10 +45,14 @@ int cmd_sdt_cache(int argc, const char **argv, const char *prefix __maybe_unused
> OPT_CALLBACK('a', "add", NULL, "filename",
> "add SDT events from a file.",
> opt_add_sdt_events),
> + OPT_CALLBACK_NOOPT('D', "dump", NULL, "show SDT events",
> + "Read SDT events from cache and display.",
> + opt_show_sdt_events),
> OPT_END()
> };
> const char * const sdt_cache_usage[] = {
> "perf sdt-cache --add filename",
> + "perf sd-cache --dump",
s/sd-cache/sdt-cache/
> NULL
> };
[SNIP]
> +static void file_hash_list__display(struct hash_table *file_hash)
> +{
> + struct file_sdt_ent *file_pos;
> + struct list_head *sdt_head;
> + struct hlist_head *ent_head;
> + struct sdt_note *sdt_ptr;
> + int i;
> +
> + /* Go through all entries */
> + for (i = 0; i < SDT_HASH_SIZE; i++) {
> + /* Obtain the list head */
> + ent_head = &file_hash->ent[i];
> +
> + /* ':' are used here as delimiters */
> + hlist_for_each_entry(file_pos, ent_head, file_list) {
> + fprintf(stdout, "%s:\n", file_pos->name);
> + sdt_head = &file_pos->sdt_list;
> + list_for_each_entry(sdt_ptr, sdt_head, note_list) {
> + fprintf(stdout, "\t%%%s:%s\n",
> + sdt_ptr->provider, sdt_ptr->name);
.. Here you printed it with \t.
Other than that, looks good to me.
Thanks,
Namhyung
> + }
> + printf("\n");
> + }
> + }
> +}
> +
> +/**
> + * dump_sdt_events: Dump the SDT events on stdout
> + */
> +int dump_sdt_events(void)
> +{
> + struct hash_table file_hash;
> + int ret;
> +
> + ret = file_hash_list__init(&file_hash);
> + if (!ret)
> + file_hash_list__display(&file_hash);
> + file_hash_list__cleanup(&file_hash);
> + return ret;
> +}