diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-11-17 12:40:53 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-19 00:03:34 -0500 |
commit | cfc10d3bcc50d70f72c0f43d03eee965c726ccc0 (patch) | |
tree | 1316349f72bca0c8ec3afd284f4151af5a29c32a /tools/perf/util/symbol.c | |
parent | 11ada26c78febe4662a8e848f3bff74e3200c920 (diff) |
perf symbols: Add a long_name_len member to struct dso
Using a two bytes hole we already had and since we also need to
calculate this strlen for fetching the buildids. We'll use it in
'perf top' to auto-adjust the output based on the terminal
width.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1258479655-28662-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r-- | tools/perf/util/symbol.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 1b77e81b38de..5cc96c86861b 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -109,13 +109,24 @@ static size_t symbol__fprintf(struct symbol *self, FILE *fp) | |||
109 | self->start, self->end, self->name); | 109 | self->start, self->end, self->name); |
110 | } | 110 | } |
111 | 111 | ||
112 | static void dso__set_long_name(struct dso *self, char *name) | ||
113 | { | ||
114 | self->long_name = name; | ||
115 | self->long_name_len = strlen(name); | ||
116 | } | ||
117 | |||
118 | static void dso__set_basename(struct dso *self) | ||
119 | { | ||
120 | self->short_name = basename(self->long_name); | ||
121 | } | ||
122 | |||
112 | struct dso *dso__new(const char *name) | 123 | struct dso *dso__new(const char *name) |
113 | { | 124 | { |
114 | struct dso *self = malloc(sizeof(*self) + strlen(name) + 1); | 125 | struct dso *self = malloc(sizeof(*self) + strlen(name) + 1); |
115 | 126 | ||
116 | if (self != NULL) { | 127 | if (self != NULL) { |
117 | strcpy(self->name, name); | 128 | strcpy(self->name, name); |
118 | self->long_name = self->name; | 129 | dso__set_long_name(self, self->name); |
119 | self->short_name = self->name; | 130 | self->short_name = self->name; |
120 | self->syms = RB_ROOT; | 131 | self->syms = RB_ROOT; |
121 | self->find_symbol = dso__find_symbol; | 132 | self->find_symbol = dso__find_symbol; |
@@ -888,7 +899,7 @@ bool fetch_build_id_table(struct list_head *head) | |||
888 | continue; | 899 | continue; |
889 | have_buildid = true; | 900 | have_buildid = true; |
890 | memset(&b.header, 0, sizeof(b.header)); | 901 | memset(&b.header, 0, sizeof(b.header)); |
891 | len = strlen(pos->long_name) + 1; | 902 | len = pos->long_name_len + 1; |
892 | len = ALIGN(len, 64); | 903 | len = ALIGN(len, 64); |
893 | b.header.size = sizeof(b) + len; | 904 | b.header.size = sizeof(b) + len; |
894 | 905 | ||
@@ -1165,6 +1176,7 @@ static int dsos__load_modules_sym_dir(char *dirname, symbol_filter_t filter) | |||
1165 | dso_name[PATH_MAX]; | 1176 | dso_name[PATH_MAX]; |
1166 | struct map *map; | 1177 | struct map *map; |
1167 | struct rb_node *last; | 1178 | struct rb_node *last; |
1179 | char *long_name; | ||
1168 | 1180 | ||
1169 | if (dot == NULL || strcmp(dot, ".ko")) | 1181 | if (dot == NULL || strcmp(dot, ".ko")) |
1170 | continue; | 1182 | continue; |
@@ -1179,9 +1191,11 @@ static int dsos__load_modules_sym_dir(char *dirname, symbol_filter_t filter) | |||
1179 | snprintf(path, sizeof(path), "%s/%s", | 1191 | snprintf(path, sizeof(path), "%s/%s", |
1180 | dirname, dent->d_name); | 1192 | dirname, dent->d_name); |
1181 | 1193 | ||
1182 | map->dso->long_name = strdup(path); | 1194 | long_name = strdup(path); |
1183 | if (map->dso->long_name == NULL) | 1195 | if (long_name == NULL) |
1184 | goto failure; | 1196 | goto failure; |
1197 | dso__set_long_name(map->dso, long_name); | ||
1198 | dso__set_basename(map->dso); | ||
1185 | 1199 | ||
1186 | err = dso__load_module_sym(map->dso, map, filter); | 1200 | err = dso__load_module_sym(map->dso, map, filter); |
1187 | if (err < 0) | 1201 | if (err < 0) |
@@ -1420,8 +1434,10 @@ struct dso *dsos__findnew(const char *name) | |||
1420 | 1434 | ||
1421 | if (!dso) { | 1435 | if (!dso) { |
1422 | dso = dso__new(name); | 1436 | dso = dso__new(name); |
1423 | if (dso != NULL) | 1437 | if (dso != NULL) { |
1424 | dsos__add(dso); | 1438 | dsos__add(dso); |
1439 | dso__set_basename(dso); | ||
1440 | } | ||
1425 | } | 1441 | } |
1426 | 1442 | ||
1427 | return dso; | 1443 | return dso; |