perf strlist: Make dupstr be the default and part of an extensible config parm
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 20 Jul 2015 15:13:34 +0000 (12:13 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 20 Jul 2015 15:13:34 +0000 (12:13 -0300)
So that we can pass more info to strlist__new() without having to change
its function signature, just adding entries to the strlist_config struct
with sensible defaults for when those fields are not specified.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-5uaaler4931i0s9sedxjquhq@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-buildid-cache.c
tools/perf/builtin-trace.c
tools/perf/util/build-id.c
tools/perf/util/machine.c
tools/perf/util/probe-event.c
tools/perf/util/probe-finder.c
tools/perf/util/strlist.c
tools/perf/util/strlist.h
tools/perf/util/symbol.c
tools/perf/util/thread_map.c

index d47a0cdc71c92a10040e34832886ba8157147349..ddca990bcc008610c35e7a1116a7f1ef1c3cf53b 100644 (file)
@@ -363,7 +363,7 @@ int cmd_buildid_cache(int argc, const char **argv,
        setup_pager();
 
        if (add_name_list_str) {
-               list = strlist__new(true, add_name_list_str);
+               list = strlist__new(add_name_list_str, NULL);
                if (list) {
                        strlist__for_each(pos, list)
                                if (build_id_cache__add_file(pos->s)) {
@@ -381,7 +381,7 @@ int cmd_buildid_cache(int argc, const char **argv,
        }
 
        if (remove_name_list_str) {
-               list = strlist__new(true, remove_name_list_str);
+               list = strlist__new(remove_name_list_str, NULL);
                if (list) {
                        strlist__for_each(pos, list)
                                if (build_id_cache__remove_file(pos->s)) {
@@ -399,7 +399,7 @@ int cmd_buildid_cache(int argc, const char **argv,
        }
 
        if (purge_name_list_str) {
-               list = strlist__new(true, purge_name_list_str);
+               list = strlist__new(purge_name_list_str, NULL);
                if (list) {
                        strlist__for_each(pos, list)
                                if (build_id_cache__purge_path(pos->s)) {
@@ -420,7 +420,7 @@ int cmd_buildid_cache(int argc, const char **argv,
                ret = build_id_cache__fprintf_missing(session, stdout);
 
        if (update_name_list_str) {
-               list = strlist__new(true, update_name_list_str);
+               list = strlist__new(update_name_list_str, NULL);
                if (list) {
                        strlist__for_each(pos, list)
                                if (build_id_cache__update_file(pos->s)) {
index 0ebf55bf20b356e46b92fb6478a4bac38fad2329..3a3173c186c021b52cc9cfdf5c52781735f98daa 100644 (file)
@@ -2931,7 +2931,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
                trace.not_ev_qualifier = *s == '!';
                if (trace.not_ev_qualifier)
                        ++s;
-               trace.ev_qualifier = strlist__new(true, s);
+               trace.ev_qualifier = strlist__new(s, NULL);
                if (trace.ev_qualifier == NULL) {
                        fputs("Not enough memory to parse event qualifier",
                              trace.output);
index 1f6fc2323ef97d5e9fdea6f70a9028db1d14a37e..f98c2ffafba7aafec60a05d124e6a277b1441bbe 100644 (file)
@@ -291,7 +291,7 @@ int build_id_cache__list_build_ids(const char *pathname,
        struct dirent *d;
        int ret = 0;
 
-       list = strlist__new(true, NULL);
+       list = strlist__new(NULL, NULL);
        dir_name = build_id_cache__dirname_from_path(pathname, false, false);
        if (!list || !dir_name) {
                ret = -ENOMEM;
index 7ff682770fdb16e71b368af16efad0edd9443d87..d0bf1e590479689e6f612ed8ceb1f9b1229064e6 100644 (file)
@@ -250,7 +250,7 @@ struct machine *machines__findnew(struct machines *machines, pid_t pid)
                        static struct strlist *seen;
 
                        if (!seen)
-                               seen = strlist__new(true, NULL);
+                               seen = strlist__new(NULL, NULL);
 
                        if (!strlist__has_entry(seen, path)) {
                                pr_err("Can't access file %s\n", path);
index 381f23a443c7e71a78c008cb2e56a88326830d98..7abaac4ec86639d3b573168a5baa817f64acd8ac 100644 (file)
@@ -2066,7 +2066,7 @@ static struct strlist *get_probe_trace_command_rawlist(int fd)
        char *p;
        struct strlist *sl;
 
-       sl = strlist__new(true, NULL);
+       sl = strlist__new(NULL, NULL);
 
        fp = fdopen(dup(fd), "r");
        while (!feof(fp)) {
@@ -2362,7 +2362,7 @@ static struct strlist *get_probe_trace_event_names(int fd, bool include_group)
        rawlist = get_probe_trace_command_rawlist(fd);
        if (!rawlist)
                return NULL;
-       sl = strlist__new(true, NULL);
+       sl = strlist__new(NULL, NULL);
        strlist__for_each(ent, rawlist) {
                ret = parse_probe_trace_command(ent->s, &tev);
                if (ret < 0)
index 2da65a7108932857bd585681eb0fac195f0c850b..7b80f8cb62b95d6aade0f5a88a73ce31f6a6304c 100644 (file)
@@ -1355,7 +1355,7 @@ static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf)
                 vl->point.offset);
 
        /* Find local variables */
-       vl->vars = strlist__new(true, NULL);
+       vl->vars = strlist__new(NULL, NULL);
        if (vl->vars == NULL)
                return -ENOMEM;
        af->child = true;
index 68ae673f9fb64bcae32dd0f59e4384d8211fb86d..dd403850dfab7d97e4a4106e352e435a54dc839c 100644 (file)
@@ -133,7 +133,7 @@ int strlist__parse_list(struct strlist *slist, const char *s)
        return *s ? strlist__parse_list_entry(slist, s) : 0;
 }
 
-struct strlist *strlist__new(bool dupstr, const char *list)
+struct strlist *strlist__new(const char *list, const struct strlist_config *config)
 {
        struct strlist *slist = malloc(sizeof(*slist));
 
@@ -143,7 +143,7 @@ struct strlist *strlist__new(bool dupstr, const char *list)
                slist->rblist.node_new    = strlist__node_new;
                slist->rblist.node_delete = strlist__node_delete;
 
-               slist->dupstr    = dupstr;
+               slist->dupstr    = config ? !config->dont_dupstr : true;
                if (list && strlist__parse_list(slist, list) != 0)
                        goto out_error;
        }
index 5c7f87069d9cd7bfa5412c186068840e76822b2e..a182785d9428b4efc485d8c9a6e5d5afaddc673f 100644 (file)
@@ -16,7 +16,11 @@ struct strlist {
        bool           dupstr;
 };
 
-struct strlist *strlist__new(bool dupstr, const char *slist);
+struct strlist_config {
+       bool dont_dupstr;
+};
+
+struct strlist *strlist__new(const char *slist, const struct strlist_config *config);
 void strlist__delete(struct strlist *slist);
 
 void strlist__remove(struct strlist *slist, struct str_node *sn);
index 48b588c6951a9476246d6c71a9ee7b8535a8be37..db39388188bfd3f438df71b5e933904d7d33118c 100644 (file)
@@ -1906,7 +1906,7 @@ int setup_list(struct strlist **list, const char *list_str,
        if (list_str == NULL)
                return 0;
 
-       *list = strlist__new(true, list_str);
+       *list = strlist__new(list_str, NULL);
        if (!*list) {
                pr_err("problems parsing %s list\n", list_name);
                return -1;
index da7646d767feba14c4f1ad3ba60f3758d5f89413..d526dea80128d023745405979c84a1377c84f92a 100644 (file)
@@ -196,7 +196,8 @@ static struct thread_map *thread_map__new_by_pid_str(const char *pid_str)
        pid_t pid, prev_pid = INT_MAX;
        char *end_ptr;
        struct str_node *pos;
-       struct strlist *slist = strlist__new(false, pid_str);
+       struct strlist_config slist_config = { .dont_dupstr = true, };
+       struct strlist *slist = strlist__new(pid_str, &slist_config);
 
        if (!slist)
                return NULL;
@@ -266,13 +267,14 @@ static struct thread_map *thread_map__new_by_tid_str(const char *tid_str)
        pid_t tid, prev_tid = INT_MAX;
        char *end_ptr;
        struct str_node *pos;
+       struct strlist_config slist_config = { .dont_dupstr = true, };
        struct strlist *slist;
 
        /* perf-stat expects threads to be generated even if tid not given */
        if (!tid_str)
                return thread_map__new_dummy();
 
-       slist = strlist__new(false, tid_str);
+       slist = strlist__new(tid_str, &slist_config);
        if (!slist)
                return NULL;