. Fix kernel start address lookup in report code (Simon Que)
 
 . Fix segfault in cumulative.callchain report (Jiri Olsa)
 
 Signed-off-by: Jiri Olsa <jolsa@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJTo+RiAAoJEPZqUSBWB3s9fQUQAIYBA9FrCk6WydvWZLUQaj/i
 +oQ/uUKscHE8agO/eihgYqt1bIT016JGWD+SFpHlaUkK4UUoC3ioSyhdKLKiJaeX
 Pcho49ZrgCPb/pCIoMB2VcQwLl2GN4MaNZ9h68iLm2Qz8nhvs2mOLBNAYBHJPx7Q
 KbCa9EzplMMD/dZ9JEaZA5iUiasJ7wC+JEKjy2hBTGyb73zLMyXa5KGlCZUCs9JJ
 o+Asy1qH/nC9M/KexN5paUfphYsyjGdvIWQML/vffnFkn8YgeYLTSu/xUdoleeuE
 TOgPLU2TNc/AzXuXOV7ttv8ubBzfq0tqmH4IZhPGnkiok4Dk+9oWxf7MXklGG6SM
 QKW2o34X/7VhEWlZLWxSEKmVNYzm8dSbtGcNy88lZvWaYExNYanUtdpdvSPEa74G
 8UTGCX4IU6X6rxmf4RulUdGQq1BYcMkgGbDtgwgYh4nhtL94d/ZBxSOlGNvFWhtI
 38WpT+eNv+CgPU1rwvg7lVcHMEKwc8BTl7vA3Fw6QCW+GKbmbOjyL4QzE2srF6pU
 iHgajsU5ehxc+7QdK0Ye5h1PiX+sk0rPxRQdxM1vItEWKsk74zHegc4A7hQLKYRU
 uvNm2YThwFcwmBLj8W8C18582uPedaXkwzJq9Pl5Lq44W5bZbiePbTvtSCech1wc
 TzMrh/ooV/ffT8eH+N1Q
 =t/9d
 -----END PGP SIGNATURE-----

Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf into perf/urgent

Pull perf/urgent fixes from Jiri Olsa:

  * Fix kernel start address lookup in report code (Simon Que)

  * Fix segfault in cumulative.callchain report (Jiri Olsa)

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Ingo Molnar 2014-06-25 07:40:45 +02:00
Родитель a497c3ba1d a93f0e551a
Коммит 0bdb3ccd02
2 изменённых файлов: 38 добавлений и 37 удалений

Просмотреть файл

@ -17,6 +17,7 @@
#include "../util.h"
#include "../ui.h"
#include "map.h"
#include "annotate.h"
struct hist_browser {
struct ui_browser b;
@ -1593,13 +1594,18 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
bi->to.sym->name) > 0)
annotate_t = nr_options++;
} else {
if (browser->selection != NULL &&
browser->selection->sym != NULL &&
!browser->selection->map->dso->annotate_warned &&
asprintf(&options[nr_options], "Annotate %s",
browser->selection->sym->name) > 0)
annotate = nr_options++;
!browser->selection->map->dso->annotate_warned) {
struct annotation *notes;
notes = symbol__annotation(browser->selection->sym);
if (notes->src &&
asprintf(&options[nr_options], "Annotate %s",
browser->selection->sym->name) > 0)
annotate = nr_options++;
}
}
if (thread != NULL &&
@ -1656,6 +1662,7 @@ retry_popup_menu:
if (choice == annotate || choice == annotate_t || choice == annotate_f) {
struct hist_entry *he;
struct annotation *notes;
int err;
do_annotate:
if (!objdump_path && perf_session_env__lookup_objdump(env))
@ -1679,6 +1686,10 @@ do_annotate:
he->ms.map = he->branch_info->to.map;
}
notes = symbol__annotation(he->ms.sym);
if (!notes->src)
continue;
/*
* Don't let this be freed, say, by hists__decay_entry.
*/

Просмотреть файл

@ -496,18 +496,6 @@ struct process_args {
u64 start;
};
static int symbol__in_kernel(void *arg, const char *name,
char type __maybe_unused, u64 start)
{
struct process_args *args = arg;
if (strchr(name, '['))
return 0;
args->start = start;
return 1;
}
static void machine__get_kallsyms_filename(struct machine *machine, char *buf,
size_t bufsz)
{
@ -517,27 +505,41 @@ static void machine__get_kallsyms_filename(struct machine *machine, char *buf,
scnprintf(buf, bufsz, "%s/proc/kallsyms", machine->root_dir);
}
/* Figure out the start address of kernel map from /proc/kallsyms */
static u64 machine__get_kernel_start_addr(struct machine *machine)
const char *ref_reloc_sym_names[] = {"_text", "_stext", NULL};
/* Figure out the start address of kernel map from /proc/kallsyms.
* Returns the name of the start symbol in *symbol_name. Pass in NULL as
* symbol_name if it's not that important.
*/
static u64 machine__get_kernel_start_addr(struct machine *machine,
const char **symbol_name)
{
char filename[PATH_MAX];
struct process_args args;
int i;
const char *name;
u64 addr = 0;
machine__get_kallsyms_filename(machine, filename, PATH_MAX);
if (symbol__restricted_filename(filename, "/proc/kallsyms"))
return 0;
if (kallsyms__parse(filename, &args, symbol__in_kernel) <= 0)
return 0;
for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) {
addr = kallsyms__get_function_start(filename, name);
if (addr)
break;
}
return args.start;
if (symbol_name)
*symbol_name = name;
return addr;
}
int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel)
{
enum map_type type;
u64 start = machine__get_kernel_start_addr(machine);
u64 start = machine__get_kernel_start_addr(machine, NULL);
for (type = 0; type < MAP__NR_TYPES; ++type) {
struct kmap *kmap;
@ -852,23 +854,11 @@ static int machine__create_modules(struct machine *machine)
return 0;
}
const char *ref_reloc_sym_names[] = {"_text", "_stext", NULL};
int machine__create_kernel_maps(struct machine *machine)
{
struct dso *kernel = machine__get_kernel(machine);
char filename[PATH_MAX];
const char *name;
u64 addr = 0;
int i;
machine__get_kallsyms_filename(machine, filename, PATH_MAX);
for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) {
addr = kallsyms__get_function_start(filename, name);
if (addr)
break;
}
u64 addr = machine__get_kernel_start_addr(machine, &name);
if (!addr)
return -1;