Skip to content

Commit 2ce494a

Browse files
author
Ingo Molnar
committed
Merge branch 'perf/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 into perf/urgent
2 parents 90a8a73 + 3b4694d commit 2ce494a

File tree

8 files changed

+84
-42
lines changed

8 files changed

+84
-42
lines changed

tools/perf/builtin-buildid-list.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ static const struct option options[] = {
3636

3737
static int __cmd_buildid_list(void)
3838
{
39-
int err = -1;
4039
struct perf_session *session;
4140

4241
session = perf_session__new(input_name, O_RDONLY, force, false);
@@ -49,7 +48,7 @@ static int __cmd_buildid_list(void)
4948
perf_session__fprintf_dsos_buildid(session, stdout, with_hits);
5049

5150
perf_session__delete(session);
52-
return err;
51+
return 0;
5352
}
5453

5554
int cmd_buildid_list(int argc, const char **argv, const char *prefix __used)

tools/perf/builtin-probe.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
249249
!params.show_lines))
250250
usage_with_options(probe_usage, options);
251251

252+
/*
253+
* Only consider the user's kernel image path if given.
254+
*/
255+
symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
256+
252257
if (params.list_events) {
253258
if (params.mod_events) {
254259
pr_err(" Error: Don't use --list with --add/--del.\n");

tools/perf/util/header.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,16 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
265265
const char *name, bool is_kallsyms)
266266
{
267267
const size_t size = PATH_MAX;
268-
char *filename = malloc(size),
268+
char *realname = realpath(name, NULL),
269+
*filename = malloc(size),
269270
*linkname = malloc(size), *targetname;
270271
int len, err = -1;
271272

272-
if (filename == NULL || linkname == NULL)
273+
if (realname == NULL || filename == NULL || linkname == NULL)
273274
goto out_free;
274275

275276
len = snprintf(filename, size, "%s%s%s",
276-
debugdir, is_kallsyms ? "/" : "", name);
277+
debugdir, is_kallsyms ? "/" : "", realname);
277278
if (mkdir_p(filename, 0755))
278279
goto out_free;
279280

@@ -283,7 +284,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
283284
if (is_kallsyms) {
284285
if (copyfile("/proc/kallsyms", filename))
285286
goto out_free;
286-
} else if (link(name, filename) && copyfile(name, filename))
287+
} else if (link(realname, filename) && copyfile(name, filename))
287288
goto out_free;
288289
}
289290

@@ -300,6 +301,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
300301
if (symlink(targetname, linkname) == 0)
301302
err = 0;
302303
out_free:
304+
free(realname);
303305
free(filename);
304306
free(linkname);
305307
return err;

tools/perf/util/probe-event.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ static struct symbol *__find_kernel_function_by_name(const char *name,
114114
const char *kernel_get_module_path(const char *module)
115115
{
116116
struct dso *dso;
117+
struct map *map;
118+
const char *vmlinux_name;
117119

118120
if (module) {
119121
list_for_each_entry(dso, &machine.kernel_dsos, node) {
@@ -123,10 +125,17 @@ const char *kernel_get_module_path(const char *module)
123125
}
124126
pr_debug("Failed to find module %s.\n", module);
125127
return NULL;
128+
}
129+
130+
map = machine.vmlinux_maps[MAP__FUNCTION];
131+
dso = map->dso;
132+
133+
vmlinux_name = symbol_conf.vmlinux_name;
134+
if (vmlinux_name) {
135+
if (dso__load_vmlinux(dso, map, vmlinux_name, NULL) <= 0)
136+
return NULL;
126137
} else {
127-
dso = machine.vmlinux_maps[MAP__FUNCTION]->dso;
128-
if (dso__load_vmlinux_path(dso,
129-
machine.vmlinux_maps[MAP__FUNCTION], NULL) < 0) {
138+
if (dso__load_vmlinux_path(dso, map, NULL) <= 0) {
130139
pr_debug("Failed to load kernel map.\n");
131140
return NULL;
132141
}

tools/perf/util/probe-finder.c

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -117,28 +117,6 @@ static void line_list__free(struct list_head *head)
117117
}
118118

119119
/* Dwarf FL wrappers */
120-
121-
static int __linux_kernel_find_elf(Dwfl_Module *mod,
122-
void **userdata,
123-
const char *module_name,
124-
Dwarf_Addr base,
125-
char **file_name, Elf **elfp)
126-
{
127-
int fd;
128-
const char *path = kernel_get_module_path(module_name);
129-
130-
if (path) {
131-
fd = open(path, O_RDONLY);
132-
if (fd >= 0) {
133-
*file_name = strdup(path);
134-
return fd;
135-
}
136-
}
137-
/* If failed, try to call standard method */
138-
return dwfl_linux_kernel_find_elf(mod, userdata, module_name, base,
139-
file_name, elfp);
140-
}
141-
142120
static char *debuginfo_path; /* Currently dummy */
143121

144122
static const Dwfl_Callbacks offline_callbacks = {
@@ -151,14 +129,6 @@ static const Dwfl_Callbacks offline_callbacks = {
151129
.find_elf = dwfl_build_id_find_elf,
152130
};
153131

154-
static const Dwfl_Callbacks kernel_callbacks = {
155-
.find_debuginfo = dwfl_standard_find_debuginfo,
156-
.debuginfo_path = &debuginfo_path,
157-
158-
.find_elf = __linux_kernel_find_elf,
159-
.section_address = dwfl_linux_kernel_module_section_address,
160-
};
161-
162132
/* Get a Dwarf from offline image */
163133
static Dwarf *dwfl_init_offline_dwarf(int fd, Dwfl **dwflp, Dwarf_Addr *bias)
164134
{
@@ -185,6 +155,38 @@ static Dwarf *dwfl_init_offline_dwarf(int fd, Dwfl **dwflp, Dwarf_Addr *bias)
185155
return dbg;
186156
}
187157

158+
#if _ELFUTILS_PREREQ(0, 148)
159+
/* This method is buggy if elfutils is older than 0.148 */
160+
static int __linux_kernel_find_elf(Dwfl_Module *mod,
161+
void **userdata,
162+
const char *module_name,
163+
Dwarf_Addr base,
164+
char **file_name, Elf **elfp)
165+
{
166+
int fd;
167+
const char *path = kernel_get_module_path(module_name);
168+
169+
pr_debug2("Use file %s for %s\n", path, module_name);
170+
if (path) {
171+
fd = open(path, O_RDONLY);
172+
if (fd >= 0) {
173+
*file_name = strdup(path);
174+
return fd;
175+
}
176+
}
177+
/* If failed, try to call standard method */
178+
return dwfl_linux_kernel_find_elf(mod, userdata, module_name, base,
179+
file_name, elfp);
180+
}
181+
182+
static const Dwfl_Callbacks kernel_callbacks = {
183+
.find_debuginfo = dwfl_standard_find_debuginfo,
184+
.debuginfo_path = &debuginfo_path,
185+
186+
.find_elf = __linux_kernel_find_elf,
187+
.section_address = dwfl_linux_kernel_module_section_address,
188+
};
189+
188190
/* Get a Dwarf from live kernel image */
189191
static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr, Dwfl **dwflp,
190192
Dwarf_Addr *bias)
@@ -205,11 +207,34 @@ static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr, Dwfl **dwflp,
205207
dbg = dwfl_addrdwarf(*dwflp, addr, bias);
206208
/* Here, check whether we could get a real dwarf */
207209
if (!dbg) {
210+
pr_debug("Failed to find kernel dwarf at %lx\n",
211+
(unsigned long)addr);
208212
dwfl_end(*dwflp);
209213
*dwflp = NULL;
210214
}
211215
return dbg;
212216
}
217+
#else
218+
/* With older elfutils, this just support kernel module... */
219+
static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr __used, Dwfl **dwflp,
220+
Dwarf_Addr *bias)
221+
{
222+
int fd;
223+
const char *path = kernel_get_module_path("kernel");
224+
225+
if (!path) {
226+
pr_err("Failed to find vmlinux path\n");
227+
return NULL;
228+
}
229+
230+
pr_debug2("Use file %s for debuginfo\n", path);
231+
fd = open(path, O_RDONLY);
232+
if (fd < 0)
233+
return NULL;
234+
235+
return dwfl_init_offline_dwarf(fd, dwflp, bias);
236+
}
237+
#endif
213238

214239
/* Dwarf wrappers */
215240

tools/perf/util/string.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space)
259259
if (!*pat) /* Tail wild card matches all */
260260
return true;
261261
while (*str)
262-
if (strglobmatch(str++, pat))
262+
if (__match_glob(str++, pat, ignore_space))
263263
return true;
264264
}
265265
return !*str && !*pat;

tools/perf/util/symbol.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,8 +1780,8 @@ static int machine__create_modules(struct machine *self)
17801780
return -1;
17811781
}
17821782

1783-
static int dso__load_vmlinux(struct dso *self, struct map *map,
1784-
const char *vmlinux, symbol_filter_t filter)
1783+
int dso__load_vmlinux(struct dso *self, struct map *map,
1784+
const char *vmlinux, symbol_filter_t filter)
17851785
{
17861786
int err = -1, fd;
17871787

tools/perf/util/symbol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ void dso__sort_by_name(struct dso *self, enum map_type type);
166166
struct dso *__dsos__findnew(struct list_head *head, const char *name);
167167

168168
int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
169+
int dso__load_vmlinux(struct dso *self, struct map *map,
170+
const char *vmlinux, symbol_filter_t filter);
169171
int dso__load_vmlinux_path(struct dso *self, struct map *map,
170172
symbol_filter_t filter);
171173
int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map,

0 commit comments

Comments
 (0)