perf symbols: Encapsulate dsos list head into struct dsos

This is a precursor patch to enable long name searching of DSOs using
a rbtree.

In this patch, a new dsos structure is created which contains only a
list head structure for the moment.

The new dsos structure is used, in turn, in the machine structure for
the user_dsos and kernel_dsos fields.

Only the following 3 dsos functions are modified to accept the new dsos
structure parameter instead of list_head:

 - dsos__add()
 - dsos__find()
 - __dsos__findnew()

Signed-off-by: Waiman Long <Waiman.Long@hp.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Douglas Hatch <doug.hatch@hp.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Scott J Norton <scott.norton@hp.com>
Link: http://lkml.kernel.org/r/1412021249-19201-2-git-send-email-Waiman.Long@hp.com
[ Move struct dsos to dso.h to reduce the dso methods depends on machine.h ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Waiman Long
2014-09-29 16:07:28 -04:00
committed by Arnaldo Carvalho de Melo
parent e19685ed24
commit 8fa7d87f91
7 changed files with 60 additions and 41 deletions

View File

@@ -851,35 +851,36 @@ bool __dsos__read_build_ids(struct list_head *head, bool with_hits)
return have_build_id;
}
void dsos__add(struct list_head *head, struct dso *dso)
void dsos__add(struct dsos *dsos, struct dso *dso)
{
list_add_tail(&dso->node, head);
list_add_tail(&dso->node, &dsos->head);
}
struct dso *dsos__find(const struct list_head *head, const char *name, bool cmp_short)
struct dso *dsos__find(const struct dsos *dsos, const char *name,
bool cmp_short)
{
struct dso *pos;
if (cmp_short) {
list_for_each_entry(pos, head, node)
list_for_each_entry(pos, &dsos->head, node)
if (strcmp(pos->short_name, name) == 0)
return pos;
return NULL;
}
list_for_each_entry(pos, head, node)
list_for_each_entry(pos, &dsos->head, node)
if (strcmp(pos->long_name, name) == 0)
return pos;
return NULL;
}
struct dso *__dsos__findnew(struct list_head *head, const char *name)
struct dso *__dsos__findnew(struct dsos *dsos, const char *name)
{
struct dso *dso = dsos__find(head, name, false);
struct dso *dso = dsos__find(dsos, name, false);
if (!dso) {
dso = dso__new(name);
if (dso != NULL) {
dsos__add(head, dso);
dsos__add(dsos, dso);
dso__set_basename(dso);
}
}