Commit 5c9b9bc6 authored by Ingo Molnar's avatar Ingo Molnar

Merge tag 'perf-core-for-mingo' of...

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

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

User visible changes:

  - Make Ctrl-C stop processing on TUI, allowing interrupting the load of big
    perf.data files (Namhyung Kim)

  - Fix 'perf annotate' -i option, which is currently ignored (Martin Liška)

  - Add ARM64 perf_regs_load to support libunwind and enable testing (Wang Nan)

Infrastructure changes:

  - Fix thread ref-counting in db-export (Adrian Hunter)

  - Fix compiler warning about may be accessing uninitialized (Arnaldo Carvalho de Melo)

  - No need to have two lists for user and kernel DSOs, unify them (Arnaldo Carvalho de Melo)

  - Function namespace consistency fixups (Arnaldo Carvalho de Melo)

  - Do not fail on missing Build file, fixing the build on MIPS (Jiri Olsa)

  - Fix up syscall tests, making those tests pass on ARM64 (Riku Voipio)

  - Fix 'function unused' warning in 'perf probe' (Wang Nan)
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parents f1942b96 ed426915
...@@ -37,7 +37,7 @@ subdir-obj-y := ...@@ -37,7 +37,7 @@ subdir-obj-y :=
# Build definitions # Build definitions
build-file := $(dir)/Build build-file := $(dir)/Build
include $(build-file) -include $(build-file)
quiet_cmd_flex = FLEX $@ quiet_cmd_flex = FLEX $@
quiet_cmd_bison = BISON $@ quiet_cmd_bison = BISON $@
......
...@@ -2,6 +2,7 @@ ex-y += ex.o ...@@ -2,6 +2,7 @@ ex-y += ex.o
ex-y += a.o ex-y += a.o
ex-y += b.o ex-y += b.o
ex-y += empty/ ex-y += empty/
ex-y += empty2/
libex-y += c.o libex-y += c.o
libex-y += d.o libex-y += d.o
......
This directory is left intentionally without Build file
to test proper nesting into Build-less directories.
libperf-y += util/ libperf-y += util/
libperf-$(CONFIG_DWARF_UNWIND) += tests/
...@@ -5,8 +5,11 @@ ...@@ -5,8 +5,11 @@
#include <linux/types.h> #include <linux/types.h>
#include <asm/perf_regs.h> #include <asm/perf_regs.h>
void perf_regs_load(u64 *regs);
#define PERF_REGS_MASK ((1ULL << PERF_REG_ARM64_MAX) - 1) #define PERF_REGS_MASK ((1ULL << PERF_REG_ARM64_MAX) - 1)
#define PERF_REGS_MAX PERF_REG_ARM64_MAX #define PERF_REGS_MAX PERF_REG_ARM64_MAX
#define PERF_SAMPLE_REGS_ABI PERF_SAMPLE_REGS_ABI_64
#define PERF_REG_IP PERF_REG_ARM64_PC #define PERF_REG_IP PERF_REG_ARM64_PC
#define PERF_REG_SP PERF_REG_ARM64_SP #define PERF_REG_SP PERF_REG_ARM64_SP
......
libperf-y += regs_load.o
libperf-y += dwarf-unwind.o
#include <string.h>
#include "perf_regs.h"
#include "thread.h"
#include "map.h"
#include "event.h"
#include "debug.h"
#include "tests/tests.h"
#define STACK_SIZE 8192
static int sample_ustack(struct perf_sample *sample,
struct thread *thread, u64 *regs)
{
struct stack_dump *stack = &sample->user_stack;
struct map *map;
unsigned long sp;
u64 stack_size, *buf;
buf = malloc(STACK_SIZE);
if (!buf) {
pr_debug("failed to allocate sample uregs data\n");
return -1;
}
sp = (unsigned long) regs[PERF_REG_ARM64_SP];
map = map_groups__find(thread->mg, MAP__VARIABLE, (u64) sp);
if (!map) {
pr_debug("failed to get stack map\n");
free(buf);
return -1;
}
stack_size = map->end - sp;
stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size;
memcpy(buf, (void *) sp, stack_size);
stack->data = (char *) buf;
stack->size = stack_size;
return 0;
}
int test__arch_unwind_sample(struct perf_sample *sample,
struct thread *thread)
{
struct regs_dump *regs = &sample->user_regs;
u64 *buf;
buf = calloc(1, sizeof(u64) * PERF_REGS_MAX);
if (!buf) {
pr_debug("failed to allocate sample uregs data\n");
return -1;
}
perf_regs_load(buf);
regs->abi = PERF_SAMPLE_REGS_ABI;
regs->regs = buf;
regs->mask = PERF_REGS_MASK;
return sample_ustack(sample, thread, buf);
}
#include <linux/linkage.h>
.text
.type perf_regs_load,%function
#define STR_REG(r) str x##r, [x0, 8 * r]
#define LDR_REG(r) ldr x##r, [x0, 8 * r]
#define SP (8 * 31)
#define PC (8 * 32)
ENTRY(perf_regs_load)
STR_REG(0)
STR_REG(1)
STR_REG(2)
STR_REG(3)
STR_REG(4)
STR_REG(5)
STR_REG(6)
STR_REG(7)
STR_REG(8)
STR_REG(9)
STR_REG(10)
STR_REG(11)
STR_REG(12)
STR_REG(13)
STR_REG(14)
STR_REG(15)
STR_REG(16)
STR_REG(17)
STR_REG(18)
STR_REG(19)
STR_REG(20)
STR_REG(21)
STR_REG(22)
STR_REG(23)
STR_REG(24)
STR_REG(25)
STR_REG(26)
STR_REG(27)
STR_REG(28)
STR_REG(29)
STR_REG(30)
mov x1, sp
str x1, [x0, #SP]
str x30, [x0, #PC]
LDR_REG(1)
ret
ENDPROC(perf_regs_load)
...@@ -289,7 +289,6 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) ...@@ -289,7 +289,6 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
}, },
}; };
struct perf_data_file file = { struct perf_data_file file = {
.path = input_name,
.mode = PERF_DATA_MODE_READ, .mode = PERF_DATA_MODE_READ,
}; };
const struct option options[] = { const struct option options[] = {
...@@ -346,6 +345,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused) ...@@ -346,6 +345,8 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
else if (annotate.use_gtk) else if (annotate.use_gtk)
use_browser = 2; use_browser = 2;
file.path = input_name;
setup_browser(true); setup_browser(true);
annotate.session = perf_session__new(&file, false, &annotate.tool); annotate.session = perf_session__new(&file, false, &annotate.tool);
......
...@@ -644,7 +644,7 @@ static char *compact_gfp_flags(char *gfp_flags) ...@@ -644,7 +644,7 @@ static char *compact_gfp_flags(char *gfp_flags)
{ {
char *orig_flags = strdup(gfp_flags); char *orig_flags = strdup(gfp_flags);
char *new_flags = NULL; char *new_flags = NULL;
char *str, *pos; char *str, *pos = NULL;
size_t len = 0; size_t len = 0;
if (orig_flags == NULL) if (orig_flags == NULL)
......
...@@ -3,9 +3,9 @@ perf-y += parse-events.o ...@@ -3,9 +3,9 @@ perf-y += parse-events.o
perf-y += dso-data.o perf-y += dso-data.o
perf-y += attr.o perf-y += attr.o
perf-y += vmlinux-kallsyms.o perf-y += vmlinux-kallsyms.o
perf-y += open-syscall.o perf-y += openat-syscall.o
perf-y += open-syscall-all-cpus.o perf-y += openat-syscall-all-cpus.o
perf-y += open-syscall-tp-fields.o perf-y += openat-syscall-tp-fields.o
perf-y += mmap-basic.o perf-y += mmap-basic.o
perf-y += perf-record.o perf-y += perf-record.o
perf-y += rdpmc.o perf-y += rdpmc.o
...@@ -34,7 +34,7 @@ perf-y += kmod-path.o ...@@ -34,7 +34,7 @@ perf-y += kmod-path.o
perf-$(CONFIG_X86) += perf-time-to-tsc.o perf-$(CONFIG_X86) += perf-time-to-tsc.o
ifeq ($(ARCH),$(filter $(ARCH),x86 arm)) ifeq ($(ARCH),$(filter $(ARCH),x86 arm arm64))
perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
endif endif
......
...@@ -23,12 +23,12 @@ static struct test { ...@@ -23,12 +23,12 @@ static struct test {
.func = test__vmlinux_matches_kallsyms, .func = test__vmlinux_matches_kallsyms,
}, },
{ {
.desc = "detect open syscall event", .desc = "detect openat syscall event",
.func = test__open_syscall_event, .func = test__openat_syscall_event,
}, },
{ {
.desc = "detect open syscall event on all cpus", .desc = "detect openat syscall event on all cpus",
.func = test__open_syscall_event_on_all_cpus, .func = test__openat_syscall_event_on_all_cpus,
}, },
{ {
.desc = "read samples using the mmap interface", .desc = "read samples using the mmap interface",
...@@ -73,8 +73,8 @@ static struct test { ...@@ -73,8 +73,8 @@ static struct test {
.func = test__perf_evsel__tp_sched_test, .func = test__perf_evsel__tp_sched_test,
}, },
{ {
.desc = "Generate and check syscalls:sys_enter_open event fields", .desc = "Generate and check syscalls:sys_enter_openat event fields",
.func = test__syscall_open_tp_fields, .func = test__syscall_openat_tp_fields,
}, },
{ {
.desc = "struct perf_event_attr setup", .desc = "struct perf_event_attr setup",
...@@ -126,7 +126,7 @@ static struct test { ...@@ -126,7 +126,7 @@ static struct test {
.desc = "Test parsing with no sample_id_all bit set", .desc = "Test parsing with no sample_id_all bit set",
.func = test__parse_no_sample_id_all, .func = test__parse_no_sample_id_all,
}, },
#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) #if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__)
#ifdef HAVE_DWARF_UNWIND_SUPPORT #ifdef HAVE_DWARF_UNWIND_SUPPORT
{ {
.desc = "Test dwarf unwind", .desc = "Test dwarf unwind",
......
...@@ -121,8 +121,7 @@ struct machine *setup_fake_machine(struct machines *machines) ...@@ -121,8 +121,7 @@ struct machine *setup_fake_machine(struct machines *machines)
size_t k; size_t k;
struct dso *dso; struct dso *dso;
dso = __dsos__findnew(&machine->user_dsos, dso = machine__findnew_dso(machine, fake_symbols[i].dso_name);
fake_symbols[i].dso_name);
if (dso == NULL) if (dso == NULL)
goto out; goto out;
......
...@@ -23,10 +23,8 @@ int test__basic_mmap(void) ...@@ -23,10 +23,8 @@ int test__basic_mmap(void)
struct cpu_map *cpus; struct cpu_map *cpus;
struct perf_evlist *evlist; struct perf_evlist *evlist;
cpu_set_t cpu_set; cpu_set_t cpu_set;
const char *syscall_names[] = { "getsid", "getppid", "getpgrp", const char *syscall_names[] = { "getsid", "getppid", "getpgid", };
"getpgid", }; pid_t (*syscalls[])(void) = { (void *)getsid, getppid, (void*)getpgid };
pid_t (*syscalls[])(void) = { (void *)getsid, getppid, getpgrp,
(void*)getpgid };
#define nsyscalls ARRAY_SIZE(syscall_names) #define nsyscalls ARRAY_SIZE(syscall_names)
unsigned int nr_events[nsyscalls], unsigned int nr_events[nsyscalls],
expected_nr_events[nsyscalls], i, j; expected_nr_events[nsyscalls], i, j;
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
#include "cpumap.h" #include "cpumap.h"
#include "debug.h" #include "debug.h"
int test__open_syscall_event_on_all_cpus(void) int test__openat_syscall_event_on_all_cpus(void)
{ {
int err = -1, fd, cpu; int err = -1, fd, cpu;
struct cpu_map *cpus; struct cpu_map *cpus;
struct perf_evsel *evsel; struct perf_evsel *evsel;
unsigned int nr_open_calls = 111, i; unsigned int nr_openat_calls = 111, i;
cpu_set_t cpu_set; cpu_set_t cpu_set;
struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX); struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
char sbuf[STRERR_BUFSIZE]; char sbuf[STRERR_BUFSIZE];
...@@ -27,7 +27,7 @@ int test__open_syscall_event_on_all_cpus(void) ...@@ -27,7 +27,7 @@ int test__open_syscall_event_on_all_cpus(void)
CPU_ZERO(&cpu_set); CPU_ZERO(&cpu_set);
evsel = perf_evsel__newtp("syscalls", "sys_enter_open"); evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
if (evsel == NULL) { if (evsel == NULL) {
if (tracefs_configured()) if (tracefs_configured())
pr_debug("is tracefs mounted on /sys/kernel/tracing?\n"); pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
...@@ -46,7 +46,7 @@ int test__open_syscall_event_on_all_cpus(void) ...@@ -46,7 +46,7 @@ int test__open_syscall_event_on_all_cpus(void)
} }
for (cpu = 0; cpu < cpus->nr; ++cpu) { for (cpu = 0; cpu < cpus->nr; ++cpu) {
unsigned int ncalls = nr_open_calls + cpu; unsigned int ncalls = nr_openat_calls + cpu;
/* /*
* XXX eventually lift this restriction in a way that * XXX eventually lift this restriction in a way that
* keeps perf building on older glibc installations * keeps perf building on older glibc installations
...@@ -66,7 +66,7 @@ int test__open_syscall_event_on_all_cpus(void) ...@@ -66,7 +66,7 @@ int test__open_syscall_event_on_all_cpus(void)
goto out_close_fd; goto out_close_fd;
} }
for (i = 0; i < ncalls; ++i) { for (i = 0; i < ncalls; ++i) {
fd = open("/etc/passwd", O_RDONLY); fd = openat(0, "/etc/passwd", O_RDONLY);
close(fd); close(fd);
} }
CPU_CLR(cpus->map[cpu], &cpu_set); CPU_CLR(cpus->map[cpu], &cpu_set);
...@@ -96,7 +96,7 @@ int test__open_syscall_event_on_all_cpus(void) ...@@ -96,7 +96,7 @@ int test__open_syscall_event_on_all_cpus(void)
break; break;
} }
expected = nr_open_calls + cpu; expected = nr_openat_calls + cpu;
if (evsel->counts->cpu[cpu].val != expected) { if (evsel->counts->cpu[cpu].val != expected) {
pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %" PRIu64 "\n", pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %" PRIu64 "\n",
expected, cpus->map[cpu], evsel->counts->cpu[cpu].val); expected, cpus->map[cpu], evsel->counts->cpu[cpu].val);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "tests.h" #include "tests.h"
#include "debug.h" #include "debug.h"
int test__syscall_open_tp_fields(void) int test__syscall_openat_tp_fields(void)
{ {
struct record_opts opts = { struct record_opts opts = {
.target = { .target = {
...@@ -29,7 +29,7 @@ int test__syscall_open_tp_fields(void) ...@@ -29,7 +29,7 @@ int test__syscall_open_tp_fields(void)
goto out; goto out;
} }
evsel = perf_evsel__newtp("syscalls", "sys_enter_open"); evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
if (evsel == NULL) { if (evsel == NULL) {
pr_debug("%s: perf_evsel__newtp\n", __func__); pr_debug("%s: perf_evsel__newtp\n", __func__);
goto out_delete_evlist; goto out_delete_evlist;
...@@ -66,7 +66,7 @@ int test__syscall_open_tp_fields(void) ...@@ -66,7 +66,7 @@ int test__syscall_open_tp_fields(void)
/* /*
* Generate the event: * Generate the event:
*/ */
open(filename, flags); openat(AT_FDCWD, filename, flags);
while (1) { while (1) {
int before = nr_events; int before = nr_events;
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
#include "debug.h" #include "debug.h"
#include "tests.h" #include "tests.h"
int test__open_syscall_event(void) int test__openat_syscall_event(void)
{ {
int err = -1, fd; int err = -1, fd;
struct perf_evsel *evsel; struct perf_evsel *evsel;
unsigned int nr_open_calls = 111, i; unsigned int nr_openat_calls = 111, i;
struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX); struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX);
char sbuf[STRERR_BUFSIZE]; char sbuf[STRERR_BUFSIZE];
...@@ -16,7 +16,7 @@ int test__open_syscall_event(void) ...@@ -16,7 +16,7 @@ int test__open_syscall_event(void)
return -1; return -1;
} }
evsel = perf_evsel__newtp("syscalls", "sys_enter_open"); evsel = perf_evsel__newtp("syscalls", "sys_enter_openat");
if (evsel == NULL) { if (evsel == NULL) {
if (tracefs_configured()) if (tracefs_configured())
pr_debug("is tracefs mounted on /sys/kernel/tracing?\n"); pr_debug("is tracefs mounted on /sys/kernel/tracing?\n");
...@@ -34,8 +34,8 @@ int test__open_syscall_event(void) ...@@ -34,8 +34,8 @@ int test__open_syscall_event(void)
goto out_evsel_delete; goto out_evsel_delete;
} }
for (i = 0; i < nr_open_calls; ++i) { for (i = 0; i < nr_openat_calls; ++i) {
fd = open("/etc/passwd", O_RDONLY); fd = openat(0, "/etc/passwd", O_RDONLY);
close(fd); close(fd);
} }
...@@ -44,9 +44,9 @@ int test__open_syscall_event(void) ...@@ -44,9 +44,9 @@ int test__open_syscall_event(void)
goto out_close_fd; goto out_close_fd;
} }
if (evsel->counts->cpu[0].val != nr_open_calls) { if (evsel->counts->cpu[0].val != nr_openat_calls) {
pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls, got %" PRIu64 "\n", pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls, got %" PRIu64 "\n",
nr_open_calls, evsel->counts->cpu[0].val); nr_openat_calls, evsel->counts->cpu[0].val);
goto out_close_fd; goto out_close_fd;
} }
......
...@@ -427,7 +427,7 @@ static int test__checkevent_list(struct perf_evlist *evlist) ...@@ -427,7 +427,7 @@ static int test__checkevent_list(struct perf_evlist *evlist)
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv); TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
/* syscalls:sys_enter_open:k */ /* syscalls:sys_enter_openat:k */
evsel = perf_evsel__next(evsel); evsel = perf_evsel__next(evsel);
TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type);
TEST_ASSERT_VAL("wrong sample_type", TEST_ASSERT_VAL("wrong sample_type",
...@@ -665,7 +665,7 @@ static int test__group3(struct perf_evlist *evlist __maybe_unused) ...@@ -665,7 +665,7 @@ static int test__group3(struct perf_evlist *evlist __maybe_unused)
TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries);
TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups); TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
/* group1 syscalls:sys_enter_open:H */ /* group1 syscalls:sys_enter_openat:H */
evsel = leader = perf_evlist__first(evlist); evsel = leader = perf_evlist__first(evlist);
TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type);
TEST_ASSERT_VAL("wrong sample_type", TEST_ASSERT_VAL("wrong sample_type",
...@@ -1293,7 +1293,7 @@ struct evlist_test { ...@@ -1293,7 +1293,7 @@ struct evlist_test {
static struct evlist_test test__events[] = { static struct evlist_test test__events[] = {
{ {
.name = "syscalls:sys_enter_open", .name = "syscalls:sys_enter_openat",
.check = test__checkevent_tracepoint, .check = test__checkevent_tracepoint,
.id = 0, .id = 0,
}, },
...@@ -1353,7 +1353,7 @@ static struct evlist_test test__events[] = { ...@@ -1353,7 +1353,7 @@ static struct evlist_test test__events[] = {
.id = 11, .id = 11,
}, },
{ {
.name = "syscalls:sys_enter_open:k", .name = "syscalls:sys_enter_openat:k",
.check = test__checkevent_tracepoint_modifier, .check = test__checkevent_tracepoint_modifier,
.id = 12, .id = 12,
}, },
...@@ -1408,7 +1408,7 @@ static struct evlist_test test__events[] = { ...@@ -1408,7 +1408,7 @@ static struct evlist_test test__events[] = {
.id = 22, .id = 22,
}, },
{ {
.name = "r1,syscalls:sys_enter_open:k,1:1:hp", .name = "r1,syscalls:sys_enter_openat:k,1:1:hp",
.check = test__checkevent_list, .check = test__checkevent_list,
.id = 23, .id = 23,
}, },
...@@ -1443,7 +1443,7 @@ static struct evlist_test test__events[] = { ...@@ -1443,7 +1443,7 @@ static struct evlist_test test__events[] = {
.id = 29, .id = 29,
}, },
{ {
.name = "group1{syscalls:sys_enter_open:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u", .name = "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u",
.check = test__group3, .check = test__group3,
.id = 30, .id = 30,
}, },
......
...@@ -26,14 +26,14 @@ enum { ...@@ -26,14 +26,14 @@ enum {
/* Tests */ /* Tests */
int test__vmlinux_matches_kallsyms(void); int test__vmlinux_matches_kallsyms(void);
int test__open_syscall_event(void); int test__openat_syscall_event(void);
int test__open_syscall_event_on_all_cpus(void); int test__openat_syscall_event_on_all_cpus(void);
int test__basic_mmap(void); int test__basic_mmap(void);
int test__PERF_RECORD(void); int test__PERF_RECORD(void);
int test__rdpmc(void); int test__rdpmc(void);
int test__perf_evsel__roundtrip_name_test(void); int test__perf_evsel__roundtrip_name_test(void);
int test__perf_evsel__tp_sched_test(void); int test__perf_evsel__tp_sched_test(void);
int test__syscall_open_tp_fields(void); int test__syscall_openat_tp_fields(void);
int test__pmu(void); int test__pmu(void);
int test__attr(void); int test__attr(void);
int test__dso_data(void); int test__dso_data(void);
...@@ -62,7 +62,7 @@ int test__fdarray__filter(void); ...@@ -62,7 +62,7 @@ int test__fdarray__filter(void);
int test__fdarray__add(void); int test__fdarray__add(void);
int test__kmod_path__parse(void); int test__kmod_path__parse(void);
#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) #if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__)
#ifdef HAVE_DWARF_UNWIND_SUPPORT #ifdef HAVE_DWARF_UNWIND_SUPPORT
struct thread; struct thread;
struct perf_sample; struct perf_sample;
......
...@@ -838,6 +838,10 @@ int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel, ...@@ -838,6 +838,10 @@ int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel, int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,
struct hist_browser_timer *hbt) struct hist_browser_timer *hbt)
{ {
/* reset abort key so that it can get Ctrl-C as a key */
SLang_reset_tty();
SLang_init_tty(0, 0, 0);
return map_symbol__tui_annotate(&he->ms, evsel, hbt); return map_symbol__tui_annotate(&he->ms, evsel, hbt);
} }
......
...@@ -1741,6 +1741,10 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, ...@@ -1741,6 +1741,10 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
if (browser == NULL) if (browser == NULL)
return -1; return -1;
/* reset abort key so that it can get Ctrl-C as a key */
SLang_reset_tty();
SLang_init_tty(0, 0, 0);
if (min_pcnt) { if (min_pcnt) {
browser->min_pcnt = min_pcnt; browser->min_pcnt = min_pcnt;
hist_browser__update_nr_entries(browser); hist_browser__update_nr_entries(browser);
......
...@@ -129,7 +129,7 @@ int ui__init(void) ...@@ -129,7 +129,7 @@ int ui__init(void)
err = SLsmg_init_smg(); err = SLsmg_init_smg();
if (err < 0) if (err < 0)
goto out; goto out;
err = SLang_init_tty(0, 0, 0); err = SLang_init_tty(-1, 0, 0);
if (err < 0) if (err < 0)
goto out; goto out;
......
...@@ -162,15 +162,20 @@ static int write_buildid(const char *name, size_t name_len, u8 *build_id, ...@@ -162,15 +162,20 @@ static int write_buildid(const char *name, size_t name_len, u8 *build_id,
return write_padded(fd, name, name_len + 1, len); return write_padded(fd, name, name_len + 1, len);
} }
static int __dsos__write_buildid_table(struct list_head *head, static int machine__write_buildid_table(struct machine *machine, int fd)
struct machine *machine,
pid_t pid, u16 misc, int fd)
{ {
int err = 0;
char nm[PATH_MAX]; char nm[PATH_MAX];
struct dso *pos; struct dso *pos;
u16 kmisc = PERF_RECORD_MISC_KERNEL,
umisc = PERF_RECORD_MISC_USER;
if (!machine__is_host(machine)) {
kmisc = PERF_RECORD_MISC_GUEST_KERNEL;
umisc = PERF_RECORD_MISC_GUEST_USER;
}
dsos__for_each_with_build_id(pos, head) { dsos__for_each_with_build_id(pos, &machine->dsos.head) {
int err;
const char *name; const char *name;
size_t name_len; size_t name_len;
...@@ -189,32 +194,12 @@ static int __dsos__write_buildid_table(struct list_head *head, ...@@ -189,32 +194,12 @@ static int __dsos__write_buildid_table(struct list_head *head,
name_len = pos->long_name_len + 1; name_len = pos->long_name_len + 1;
} }
err = write_buildid(name, name_len, pos->build_id, err = write_buildid(name, name_len, pos->build_id, machine->pid,
pid, misc, fd); pos->kernel ? kmisc : umisc, fd);
if (err) if (err)
return err; break;
}
return 0;
}
static int machine__write_buildid_table(struct machine *machine, int fd)
{
int err;
u16 kmisc = PERF_RECORD_MISC_KERNEL,
umisc = PERF_RECORD_MISC_USER;
if (!machine__is_host(machine)) {
kmisc = PERF_RECORD_MISC_GUEST_KERNEL;
umisc = PERF_RECORD_MISC_GUEST_USER;
} }
err = __dsos__write_buildid_table(&machine->kernel_dsos.head, machine,
machine->pid, kmisc, fd);
if (err == 0)
err = __dsos__write_buildid_table(&machine->user_dsos.head,
machine, machine->pid, umisc,
fd);
return err; return err;
} }
...@@ -247,13 +232,7 @@ static int __dsos__hit_all(struct list_head *head) ...@@ -247,13 +232,7 @@ static int __dsos__hit_all(struct list_head *head)
static int machine__hit_all_dsos(struct machine *machine) static int machine__hit_all_dsos(struct machine *machine)
{ {
int err; return __dsos__hit_all(&machine->dsos.head);
err = __dsos__hit_all(&machine->kernel_dsos.head);
if (err)
return err;
return __dsos__hit_all(&machine->user_dsos.head);
} }
int dsos__hit_all(struct perf_session *session) int dsos__hit_all(struct perf_session *session)
...@@ -493,9 +472,7 @@ static int __dsos__cache_build_ids(struct list_head *head, ...@@ -493,9 +472,7 @@ static int __dsos__cache_build_ids(struct list_head *head,
static int machine__cache_build_ids(struct machine *machine) static int machine__cache_build_ids(struct machine *machine)
{ {
int ret = __dsos__cache_build_ids(&machine->kernel_dsos.head, machine); return __dsos__cache_build_ids(&machine->dsos.head, machine);
ret |= __dsos__cache_build_ids(&machine->user_dsos.head, machine);
return ret;
} }
int perf_session__cache_build_ids(struct perf_session *session) int perf_session__cache_build_ids(struct perf_session *session)
...@@ -520,11 +497,7 @@ int perf_session__cache_build_ids(struct perf_session *session) ...@@ -520,11 +497,7 @@ int perf_session__cache_build_ids(struct perf_session *session)
static bool machine__read_build_ids(struct machine *machine, bool with_hits) static bool machine__read_build_ids(struct machine *machine, bool with_hits)
{ {
bool ret; return __dsos__read_build_ids(&machine->dsos.head, with_hits);
ret = __dsos__read_build_ids(&machine->kernel_dsos.head, with_hits);
ret |= __dsos__read_build_ids(&machine->user_dsos.head, with_hits);
return ret;
} }
bool perf_session__read_build_ids(struct perf_session *session, bool with_hits) bool perf_session__read_build_ids(struct perf_session *session, bool with_hits)
......
...@@ -234,7 +234,7 @@ int db_export__symbol(struct db_export *dbe, struct symbol *sym, ...@@ -234,7 +234,7 @@ int db_export__symbol(struct db_export *dbe, struct symbol *sym,
static struct thread *get_main_thread(struct machine *machine, struct thread *thread) static struct thread *get_main_thread(struct machine *machine, struct thread *thread)
{ {
if (thread->pid_ == thread->tid) if (thread->pid_ == thread->tid)
return thread; return thread__get(thread);
if (thread->pid_ == -1) if (thread->pid_ == -1)
return NULL; return NULL;
...@@ -308,19 +308,18 @@ int db_export__sample(struct db_export *dbe, union perf_event *event, ...@@ -308,19 +308,18 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
if (err) if (err)
return err; return err;
/* FIXME: check refcounting for get_main_thread, that calls machine__find_thread... */
main_thread = get_main_thread(al->machine, thread); main_thread = get_main_thread(al->machine, thread);
if (main_thread) if (main_thread)
comm = machine__thread_exec_comm(al->machine, main_thread); comm = machine__thread_exec_comm(al->machine, main_thread);
err = db_export__thread(dbe, thread, al->machine, comm); err = db_export__thread(dbe, thread, al->machine, comm);
if (err) if (err)
return err; goto out_put;
if (comm) { if (comm) {
err = db_export__comm(dbe, comm, main_thread); err = db_export__comm(dbe, comm, main_thread);
if (err) if (err)
return err; goto out_put;
es.comm_db_id = comm->db_id; es.comm_db_id = comm->db_id;
} }
...@@ -328,7 +327,7 @@ int db_export__sample(struct db_export *dbe, union perf_event *event, ...@@ -328,7 +327,7 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
err = db_ids_from_al(dbe, al, &es.dso_db_id, &es.sym_db_id, &es.offset); err = db_ids_from_al(dbe, al, &es.dso_db_id, &es.sym_db_id, &es.offset);
if (err) if (err)
return err; goto out_put;
if ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) && if ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) &&
sample_addr_correlates_sym(&evsel->attr)) { sample_addr_correlates_sym(&evsel->attr)) {
...@@ -338,20 +337,22 @@ int db_export__sample(struct db_export *dbe, union perf_event *event, ...@@ -338,20 +337,22 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
err = db_ids_from_al(dbe, &addr_al, &es.addr_dso_db_id, err = db_ids_from_al(dbe, &addr_al, &es.addr_dso_db_id,
&es.addr_sym_db_id, &es.addr_offset); &es.addr_sym_db_id, &es.addr_offset);
if (err) if (err)
return err; goto out_put;
if (dbe->crp) { if (dbe->crp) {
err = thread_stack__process(thread, comm, sample, al, err = thread_stack__process(thread, comm, sample, al,
&addr_al, es.db_id, &addr_al, es.db_id,
dbe->crp); dbe->crp);
if (err) if (err)
return err; goto out_put;
} }
} }
if (dbe->export_sample) if (dbe->export_sample)
return dbe->export_sample(dbe, &es); err = dbe->export_sample(dbe, &es);
return 0; out_put:
thread__put(main_thread);
return err;
} }
static struct { static struct {
......
...@@ -827,13 +827,13 @@ struct map *dso__new_map(const char *name) ...@@ -827,13 +827,13 @@ struct map *dso__new_map(const char *name)
return map; return map;
} }
struct dso *dso__kernel_findnew(struct machine *machine, const char *name, struct dso *machine__findnew_kernel(struct machine *machine, const char *name,
const char *short_name, int dso_type) const char *short_name, int dso_type)
{ {
/* /*
* The kernel dso could be created by build_id processing. * The kernel dso could be created by build_id processing.
*/ */
struct dso *dso = __dsos__findnew(&machine->kernel_dsos, name); struct dso *dso = machine__findnew_dso(machine, name);
/* /*
* We need to run this in all cases, since during the build_id * We need to run this in all cases, since during the build_id
......
...@@ -294,8 +294,8 @@ ssize_t dso__data_read_addr(struct dso *dso, struct map *map, ...@@ -294,8 +294,8 @@ ssize_t dso__data_read_addr(struct dso *dso, struct map *map,
bool dso__data_status_seen(struct dso *dso, enum dso_data_status_seen by); bool dso__data_status_seen(struct dso *dso, enum dso_data_status_seen by);
struct map *dso__new_map(const char *name); struct map *dso__new_map(const char *name);
struct dso *dso__kernel_findnew(struct machine *machine, const char *name, struct dso *machine__findnew_kernel(struct machine *machine, const char *name,
const char *short_name, int dso_type); const char *short_name, int dso_type);
void dsos__add(struct dsos *dsos, struct dso *dso); void dsos__add(struct dsos *dsos, struct dso *dso);
struct dso *dsos__addnew(struct dsos *dsos, const char *name); struct dso *dsos__addnew(struct dsos *dsos, const char *name);
......
...@@ -1238,7 +1238,6 @@ static int __event_process_build_id(struct build_id_event *bev, ...@@ -1238,7 +1238,6 @@ static int __event_process_build_id(struct build_id_event *bev,
struct perf_session *session) struct perf_session *session)
{ {
int err = -1; int err = -1;
struct dsos *dsos;
struct machine *machine; struct machine *machine;
u16 misc; u16 misc;
struct dso *dso; struct dso *dso;
...@@ -1253,22 +1252,19 @@ static int __event_process_build_id(struct build_id_event *bev, ...@@ -1253,22 +1252,19 @@ static int __event_process_build_id(struct build_id_event *bev,
switch (misc) { switch (misc) {
case PERF_RECORD_MISC_KERNEL: case PERF_RECORD_MISC_KERNEL:
dso_type = DSO_TYPE_KERNEL; dso_type = DSO_TYPE_KERNEL;
dsos = &machine->kernel_dsos;
break; break;
case PERF_RECORD_MISC_GUEST_KERNEL: case PERF_RECORD_MISC_GUEST_KERNEL:
dso_type = DSO_TYPE_GUEST_KERNEL; dso_type = DSO_TYPE_GUEST_KERNEL;
dsos = &machine->kernel_dsos;
break; break;
case PERF_RECORD_MISC_USER: case PERF_RECORD_MISC_USER:
case PERF_RECORD_MISC_GUEST_USER: case PERF_RECORD_MISC_GUEST_USER:
dso_type = DSO_TYPE_USER; dso_type = DSO_TYPE_USER;
dsos = &machine->user_dsos;
break; break;
default: default:
goto out; goto out;
} }
dso = __dsos__findnew(dsos, filename); dso = machine__findnew_dso(machine, filename);
if (dso != NULL) { if (dso != NULL) {
char sbuild_id[BUILD_ID_SIZE * 2 + 1]; char sbuild_id[BUILD_ID_SIZE * 2 + 1];
......
...@@ -26,8 +26,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid) ...@@ -26,8 +26,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
{ {
map_groups__init(&machine->kmaps, machine); map_groups__init(&machine->kmaps, machine);
RB_CLEAR_NODE(&machine->rb_node); RB_CLEAR_NODE(&machine->rb_node);
dsos__init(&machine->user_dsos); dsos__init(&machine->dsos);
dsos__init(&machine->kernel_dsos);
machine->threads = RB_ROOT; machine->threads = RB_ROOT;
pthread_rwlock_init(&machine->threads_lock, NULL); pthread_rwlock_init(&machine->threads_lock, NULL);
...@@ -111,9 +110,8 @@ void machine__delete_threads(struct machine *machine) ...@@ -111,9 +110,8 @@ void machine__delete_threads(struct machine *machine)
void machine__exit(struct machine *machine) void machine__exit(struct machine *machine)
{ {
map_groups__exit(&machine->kmaps); map_groups__exit(&machine->kmaps);
dsos__delete(&machine->user_dsos); dsos__delete(&machine->dsos);
dsos__delete(&machine->kernel_dsos); machine__exit_vdso(machine);
vdso__exit(machine);
zfree(&machine->root_dir); zfree(&machine->root_dir);
zfree(&machine->current_tid); zfree(&machine->current_tid);
pthread_rwlock_destroy(&machine->threads_lock); pthread_rwlock_destroy(&machine->threads_lock);
...@@ -490,9 +488,9 @@ machine__module_dso(struct machine *machine, struct kmod_path *m, ...@@ -490,9 +488,9 @@ machine__module_dso(struct machine *machine, struct kmod_path *m,
{ {
struct dso *dso; struct dso *dso;
dso = dsos__find(&machine->kernel_dsos, m->name, true); dso = dsos__find(&machine->dsos, m->name, true);
if (!dso) { if (!dso) {
dso = dsos__addnew(&machine->kernel_dsos, m->name); dso = dsos__addnew(&machine->dsos, m->name);
if (dso == NULL) if (dso == NULL)
return NULL; return NULL;
...@@ -561,13 +559,11 @@ struct map *machine__new_module(struct machine *machine, u64 start, ...@@ -561,13 +559,11 @@ struct map *machine__new_module(struct machine *machine, u64 start,
size_t machines__fprintf_dsos(struct machines *machines, FILE *fp) size_t machines__fprintf_dsos(struct machines *machines, FILE *fp)
{ {
struct rb_node *nd; struct rb_node *nd;
size_t ret = __dsos__fprintf(&machines->host.kernel_dsos.head, fp) + size_t ret = __dsos__fprintf(&machines->host.dsos.head, fp);
__dsos__fprintf(&machines->host.user_dsos.head, fp);
for (nd = rb_first(&machines->guests); nd; nd = rb_next(nd)) { for (nd = rb_first(&machines->guests); nd; nd = rb_next(nd)) {
struct machine *pos = rb_entry(nd, struct machine, rb_node); struct machine *pos = rb_entry(nd, struct machine, rb_node);
ret += __dsos__fprintf(&pos->kernel_dsos.head, fp); ret += __dsos__fprintf(&pos->dsos.head, fp);
ret += __dsos__fprintf(&pos->user_dsos.head, fp);
} }
return ret; return ret;
...@@ -576,8 +572,7 @@ size_t machines__fprintf_dsos(struct machines *machines, FILE *fp) ...@@ -576,8 +572,7 @@ size_t machines__fprintf_dsos(struct machines *machines, FILE *fp)
size_t machine__fprintf_dsos_buildid(struct machine *m, FILE *fp, size_t machine__fprintf_dsos_buildid(struct machine *m, FILE *fp,
bool (skip)(struct dso *dso, int parm), int parm) bool (skip)(struct dso *dso, int parm), int parm)
{ {
return __dsos__fprintf_buildid(&m->kernel_dsos.head, fp, skip, parm) + return __dsos__fprintf_buildid(&m->dsos.head, fp, skip, parm);
__dsos__fprintf_buildid(&m->user_dsos.head, fp, skip, parm);
} }
size_t machines__fprintf_dsos_buildid(struct machines *machines, FILE *fp, size_t machines__fprintf_dsos_buildid(struct machines *machines, FILE *fp,
...@@ -640,9 +635,8 @@ static struct dso *machine__get_kernel(struct machine *machine) ...@@ -640,9 +635,8 @@ static struct dso *machine__get_kernel(struct machine *machine)
if (!vmlinux_name) if (!vmlinux_name)
vmlinux_name = "[kernel.kallsyms]"; vmlinux_name = "[kernel.kallsyms]";
kernel = dso__kernel_findnew(machine, vmlinux_name, kernel = machine__findnew_kernel(machine, vmlinux_name,
"[kernel]", "[kernel]", DSO_TYPE_KERNEL);
DSO_TYPE_KERNEL);
} else { } else {
char bf[PATH_MAX]; char bf[PATH_MAX];
...@@ -652,9 +646,9 @@ static struct dso *machine__get_kernel(struct machine *machine) ...@@ -652,9 +646,9 @@ static struct dso *machine__get_kernel(struct machine *machine)
vmlinux_name = machine__mmap_name(machine, bf, vmlinux_name = machine__mmap_name(machine, bf,
sizeof(bf)); sizeof(bf));
kernel = dso__kernel_findnew(machine, vmlinux_name, kernel = machine__findnew_kernel(machine, vmlinux_name,
"[guest.kernel]", "[guest.kernel]",
DSO_TYPE_GUEST_KERNEL); DSO_TYPE_GUEST_KERNEL);
} }
if (kernel != NULL && (!kernel->has_build_id)) if (kernel != NULL && (!kernel->has_build_id))
...@@ -1107,7 +1101,7 @@ static bool machine__uses_kcore(struct machine *machine) ...@@ -1107,7 +1101,7 @@ static bool machine__uses_kcore(struct machine *machine)
{ {
struct dso *dso; struct dso *dso;
list_for_each_entry(dso, &machine->kernel_dsos.head, node) { list_for_each_entry(dso, &machine->dsos.head, node) {
if (dso__is_kcore(dso)) if (dso__is_kcore(dso))
return true; return true;
} }
...@@ -1154,8 +1148,8 @@ static int machine__process_kernel_mmap_event(struct machine *machine, ...@@ -1154,8 +1148,8 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
struct dso *kernel = NULL; struct dso *kernel = NULL;
struct dso *dso; struct dso *dso;
list_for_each_entry(dso, &machine->kernel_dsos.head, node) { list_for_each_entry(dso, &machine->dsos.head, node) {
if (is_kernel_module(dso->long_name)) if (dso->kernel && is_kernel_module(dso->long_name))
continue; continue;
kernel = dso; kernel = dso;
...@@ -1163,8 +1157,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine, ...@@ -1163,8 +1157,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
} }
if (kernel == NULL) if (kernel == NULL)
kernel = __dsos__findnew(&machine->kernel_dsos, kernel = machine__findnew_dso(machine, kmmap_prefix);
kmmap_prefix);
if (kernel == NULL) if (kernel == NULL)
goto out_problem; goto out_problem;
...@@ -1922,3 +1915,8 @@ int machine__get_kernel_start(struct machine *machine) ...@@ -1922,3 +1915,8 @@ int machine__get_kernel_start(struct machine *machine)
} }
return err; return err;
} }
struct dso *machine__findnew_dso(struct machine *machine, const char *filename)
{
return __dsos__findnew(&machine->dsos, filename);
}
...@@ -34,8 +34,7 @@ struct machine { ...@@ -34,8 +34,7 @@ struct machine {
struct list_head dead_threads; struct list_head dead_threads;
struct thread *last_match; struct thread *last_match;
struct vdso_info *vdso_info; struct vdso_info *vdso_info;
struct dsos user_dsos; struct dsos dsos;
struct dsos kernel_dsos;
struct map_groups kmaps; struct map_groups kmaps;
struct map *vmlinux_maps[MAP__NR_TYPES]; struct map *vmlinux_maps[MAP__NR_TYPES];
u64 kernel_start; u64 kernel_start;
...@@ -155,6 +154,8 @@ static inline bool machine__is_host(struct machine *machine) ...@@ -155,6 +154,8 @@ static inline bool machine__is_host(struct machine *machine)
struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid); struct thread *__machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid);
struct thread *machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid); struct thread *machine__findnew_thread(struct machine *machine, pid_t pid, pid_t tid);
struct dso *machine__findnew_dso(struct machine *machine, const char *filename);
size_t machine__fprintf(struct machine *machine, FILE *fp); size_t machine__fprintf(struct machine *machine, FILE *fp);
static inline static inline
......
...@@ -178,9 +178,9 @@ struct map *map__new(struct machine *machine, u64 start, u64 len, ...@@ -178,9 +178,9 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
if (vdso) { if (vdso) {
pgoff = 0; pgoff = 0;
dso = vdso__dso_findnew(machine, thread); dso = machine__findnew_vdso(machine, thread);
} else } else
dso = __dsos__findnew(&machine->user_dsos, filename); dso = machine__findnew_dso(machine, filename);
if (dso == NULL) if (dso == NULL)
goto out_delete; goto out_delete;
......
...@@ -200,38 +200,6 @@ static void put_target_map(struct map *map, bool user) ...@@ -200,38 +200,6 @@ static void put_target_map(struct map *map, bool user)
} }
static int kernel_get_module_dso(const char *module, struct dso **pdso)
{
struct dso *dso;
struct map *map;
const char *vmlinux_name;
int ret = 0;
if (module) {
list_for_each_entry(dso, &host_machine->kernel_dsos.head,
node) {
if (strncmp(dso->short_name + 1, module,
dso->short_name_len - 2) == 0)
goto found;
}
pr_debug("Failed to find module %s.\n", module);
return -ENOENT;
}
map = host_machine->vmlinux_maps[MAP__FUNCTION];
dso = map->dso;
vmlinux_name = symbol_conf.vmlinux_name;
dso->load_errno = 0;
if (vmlinux_name)
ret = dso__load_vmlinux(dso, map, vmlinux_name, false, NULL);
else
ret = dso__load_vmlinux_path(dso, map, NULL);
found:
*pdso = dso;
return ret;
}
static int convert_exec_to_group(const char *exec, char **result) static int convert_exec_to_group(const char *exec, char **result)
{ {
char *ptr1, *ptr2, *exec_copy; char *ptr1, *ptr2, *exec_copy;
...@@ -279,6 +247,40 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs) ...@@ -279,6 +247,40 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs)
} }
#ifdef HAVE_DWARF_SUPPORT #ifdef HAVE_DWARF_SUPPORT
static int kernel_get_module_dso(const char *module, struct dso **pdso)
{
struct dso *dso;
struct map *map;
const char *vmlinux_name;
int ret = 0;
if (module) {
list_for_each_entry(dso, &host_machine->dsos.head, node) {
if (!dso->kernel)
continue;
if (strncmp(dso->short_name + 1, module,
dso->short_name_len - 2) == 0)
goto found;
}
pr_debug("Failed to find module %s.\n", module);
return -ENOENT;
}
map = host_machine->vmlinux_maps[MAP__FUNCTION];
dso = map->dso;
vmlinux_name = symbol_conf.vmlinux_name;
dso->load_errno = 0;
if (vmlinux_name)
ret = dso__load_vmlinux(dso, map, vmlinux_name, false, NULL);
else
ret = dso__load_vmlinux_path(dso, map, NULL);
found:
*pdso = dso;
return ret;
}
/* /*
* Some binaries like glibc have special symbols which are on the symbol * Some binaries like glibc have special symbols which are on the symbol
* table, but not in the debuginfo. If we can find the address of the * table, but not in the debuginfo. If we can find the address of the
......
...@@ -1031,11 +1031,7 @@ int dso__load_sym(struct dso *dso, struct map *map, ...@@ -1031,11 +1031,7 @@ int dso__load_sym(struct dso *dso, struct map *map,
} }
curr_dso->symtab_type = dso->symtab_type; curr_dso->symtab_type = dso->symtab_type;
map_groups__insert(kmaps, curr_map); map_groups__insert(kmaps, curr_map);
/* dsos__add(&map->groups->machine->dsos, curr_dso);
* The new DSO should go to the kernel DSOS
*/
dsos__add(&map->groups->machine->kernel_dsos,
curr_dso);
dso__set_loaded(curr_dso, map->type); dso__set_loaded(curr_dso, map->type);
} else } else
curr_dso = curr_map->dso; curr_dso = curr_map->dso;
......
...@@ -101,7 +101,7 @@ static char *get_file(struct vdso_file *vdso_file) ...@@ -101,7 +101,7 @@ static char *get_file(struct vdso_file *vdso_file)
return vdso; return vdso;
} }
void vdso__exit(struct machine *machine) void machine__exit_vdso(struct machine *machine)
{ {
struct vdso_info *vdso_info = machine->vdso_info; struct vdso_info *vdso_info = machine->vdso_info;
...@@ -120,14 +120,14 @@ void vdso__exit(struct machine *machine) ...@@ -120,14 +120,14 @@ void vdso__exit(struct machine *machine)
zfree(&machine->vdso_info); zfree(&machine->vdso_info);
} }
static struct dso *vdso__new(struct machine *machine, const char *short_name, static struct dso *machine__addnew_vdso(struct machine *machine, const char *short_name,
const char *long_name) const char *long_name)
{ {
struct dso *dso; struct dso *dso;
dso = dso__new(short_name); dso = dso__new(short_name);
if (dso != NULL) { if (dso != NULL) {
dsos__add(&machine->user_dsos, dso); dsos__add(&machine->dsos, dso);
dso__set_long_name(dso, long_name, false); dso__set_long_name(dso, long_name, false);
} }
...@@ -236,7 +236,7 @@ static struct dso *vdso__findnew_compat(struct machine *machine, ...@@ -236,7 +236,7 @@ static struct dso *vdso__findnew_compat(struct machine *machine,
const char *file_name; const char *file_name;
struct dso *dso; struct dso *dso;
dso = dsos__find(&machine->user_dsos, vdso_file->dso_name, true); dso = dsos__find(&machine->dsos, vdso_file->dso_name, true);
if (dso) if (dso)
return dso; return dso;
...@@ -244,10 +244,10 @@ static struct dso *vdso__findnew_compat(struct machine *machine, ...@@ -244,10 +244,10 @@ static struct dso *vdso__findnew_compat(struct machine *machine,
if (!file_name) if (!file_name)
return NULL; return NULL;
return vdso__new(machine, vdso_file->dso_name, file_name); return machine__addnew_vdso(machine, vdso_file->dso_name, file_name);
} }
static int vdso__dso_findnew_compat(struct machine *machine, static int machine__findnew_vdso_compat(struct machine *machine,
struct thread *thread, struct thread *thread,
struct vdso_info *vdso_info, struct vdso_info *vdso_info,
struct dso **dso) struct dso **dso)
...@@ -281,8 +281,8 @@ static int vdso__dso_findnew_compat(struct machine *machine, ...@@ -281,8 +281,8 @@ static int vdso__dso_findnew_compat(struct machine *machine,
#endif #endif
struct dso *vdso__dso_findnew(struct machine *machine, struct dso *machine__findnew_vdso(struct machine *machine,
struct thread *thread __maybe_unused) struct thread *thread __maybe_unused)
{ {
struct vdso_info *vdso_info; struct vdso_info *vdso_info;
struct dso *dso; struct dso *dso;
...@@ -295,11 +295,11 @@ struct dso *vdso__dso_findnew(struct machine *machine, ...@@ -295,11 +295,11 @@ struct dso *vdso__dso_findnew(struct machine *machine,
return NULL; return NULL;
#if BITS_PER_LONG == 64 #if BITS_PER_LONG == 64
if (vdso__dso_findnew_compat(machine, thread, vdso_info, &dso)) if (machine__findnew_vdso_compat(machine, thread, vdso_info, &dso))
return dso; return dso;
#endif #endif
dso = dsos__find(&machine->user_dsos, DSO__NAME_VDSO, true); dso = dsos__find(&machine->dsos, DSO__NAME_VDSO, true);
if (!dso) { if (!dso) {
char *file; char *file;
...@@ -307,7 +307,7 @@ struct dso *vdso__dso_findnew(struct machine *machine, ...@@ -307,7 +307,7 @@ struct dso *vdso__dso_findnew(struct machine *machine,
if (!file) if (!file)
return NULL; return NULL;
dso = vdso__new(machine, DSO__NAME_VDSO, file); dso = machine__addnew_vdso(machine, DSO__NAME_VDSO, file);
} }
return dso; return dso;
......
...@@ -23,7 +23,7 @@ bool dso__is_vdso(struct dso *dso); ...@@ -23,7 +23,7 @@ bool dso__is_vdso(struct dso *dso);
struct machine; struct machine;
struct thread; struct thread;
struct dso *vdso__dso_findnew(struct machine *machine, struct thread *thread); struct dso *machine__findnew_vdso(struct machine *machine, struct thread *thread);
void vdso__exit(struct machine *machine); void machine__exit_vdso(struct machine *machine);
#endif /* __PERF_VDSO__ */ #endif /* __PERF_VDSO__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment