aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2012-07-02 11:12:57 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-07-02 13:03:50 -0400
commit7ed97ad41ffa94040dfd593948962a7e9e7b0db9 (patch)
tree7f59d9930002bc94b139c742ea3212cdb4326c59
parent207b5792696206663a38e525b9793644895bad3b (diff)
perf kvm: Fix segfault with report and mixed guestmount use
Using the guestmount option on record: $ perf kvm --guest --host --guestmount=/tmp/guest-mount record -ag But not the subsequent report: $ perf kvm report causes a SEGFAULT in the usual place: (gdb) bt 0 0x0000000000470356 in machine__mmap_name (self=0x0, bf=0x7fffffffbdb0 " z\370\367\377\177", size= 4096) at util/map.c:712 1 0x00000000004453e8 in perf_event__process_kernel_mmap (tool=0x7fffffffde10, event=0x7ffff7f87e38, machine=0x0) at util/event.c:550 2 0x00000000004458c9 in perf_event__process_mmap (tool=0x7fffffffde10, event=0x7ffff7f87e38, sample= 0x7fffffffd2a0, machine=0x0) at util/event.c:656 3 0x00000000004733e0 in perf_session_deliver_event (session=0x91aca0, event=0x7ffff7f87e38, sample= 0x7fffffffd2a0, tool=0x7fffffffde10, file_offset=7736) at util/session.c:979 ... The MMAP events in this case already contain the full path to the module. No need to require it for the report path to. Signed-off-by: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1341241977-71535-1-git-send-email-dsahern@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/map.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 35ae56864e4f..a1f4e3669142 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -669,25 +669,26 @@ struct machine *machines__find(struct rb_root *self, pid_t pid)
669struct machine *machines__findnew(struct rb_root *self, pid_t pid) 669struct machine *machines__findnew(struct rb_root *self, pid_t pid)
670{ 670{
671 char path[PATH_MAX]; 671 char path[PATH_MAX];
672 const char *root_dir; 672 const char *root_dir = "";
673 struct machine *machine = machines__find(self, pid); 673 struct machine *machine = machines__find(self, pid);
674 674
675 if (!machine || machine->pid != pid) { 675 if (machine && (machine->pid == pid))
676 if (pid == HOST_KERNEL_ID || pid == DEFAULT_GUEST_KERNEL_ID) 676 goto out;
677 root_dir = ""; 677
678 else { 678 if ((pid != HOST_KERNEL_ID) &&
679 if (!symbol_conf.guestmount) 679 (pid != DEFAULT_GUEST_KERNEL_ID) &&
680 goto out; 680 (symbol_conf.guestmount)) {
681 sprintf(path, "%s/%d", symbol_conf.guestmount, pid); 681 sprintf(path, "%s/%d", symbol_conf.guestmount, pid);
682 if (access(path, R_OK)) { 682 if (access(path, R_OK)) {
683 pr_err("Can't access file %s\n", path); 683 pr_err("Can't access file %s\n", path);
684 goto out; 684 machine = NULL;
685 } 685 goto out;
686 root_dir = path;
687 } 686 }
688 machine = machines__add(self, pid, root_dir); 687 root_dir = path;
689 } 688 }
690 689
690 machine = machines__add(self, pid, root_dir);
691
691out: 692out:
692 return machine; 693 return machine;
693} 694}