| .. | .. |
|---|
| 25 | 25 | #include <unistd.h> |
|---|
| 26 | 26 | #include <sys/mman.h> |
|---|
| 27 | 27 | #include <linux/list.h> |
|---|
| 28 | +#include <linux/zalloc.h> |
|---|
| 28 | 29 | #ifndef REMOTE_UNWIND_LIBUNWIND |
|---|
| 29 | 30 | #include <libunwind.h> |
|---|
| 30 | 31 | #include <libunwind-ptrace.h> |
|---|
| .. | .. |
|---|
| 34 | 35 | #include "session.h" |
|---|
| 35 | 36 | #include "perf_regs.h" |
|---|
| 36 | 37 | #include "unwind.h" |
|---|
| 38 | +#include "map.h" |
|---|
| 37 | 39 | #include "symbol.h" |
|---|
| 38 | | -#include "util.h" |
|---|
| 39 | 40 | #include "debug.h" |
|---|
| 40 | 41 | #include "asm/bug.h" |
|---|
| 41 | 42 | #include "dso.h" |
|---|
| .. | .. |
|---|
| 242 | 243 | * encoded_t fde_addr; |
|---|
| 243 | 244 | * } binary_search_table[fde_count]; |
|---|
| 244 | 245 | */ |
|---|
| 245 | | - char data[0]; |
|---|
| 246 | + char data[]; |
|---|
| 246 | 247 | } __packed; |
|---|
| 247 | 248 | |
|---|
| 248 | 249 | static int unwind_spec_ehframe(struct dso *dso, struct machine *machine, |
|---|
| .. | .. |
|---|
| 344 | 345 | __func__, |
|---|
| 345 | 346 | dso->symsrc_filename, |
|---|
| 346 | 347 | debuglink); |
|---|
| 347 | | - free(dso->symsrc_filename); |
|---|
| 348 | + zfree(&dso->symsrc_filename); |
|---|
| 348 | 349 | } |
|---|
| 349 | 350 | dso->symsrc_filename = debuglink; |
|---|
| 350 | 351 | } else { |
|---|
| .. | .. |
|---|
| 574 | 575 | struct unwind_entry e; |
|---|
| 575 | 576 | struct addr_location al; |
|---|
| 576 | 577 | |
|---|
| 577 | | - e.sym = thread__find_symbol(thread, PERF_RECORD_MISC_USER, ip, &al); |
|---|
| 578 | | - e.ip = ip; |
|---|
| 579 | | - e.map = al.map; |
|---|
| 578 | + e.ms.sym = thread__find_symbol(thread, PERF_RECORD_MISC_USER, ip, &al); |
|---|
| 579 | + e.ip = ip; |
|---|
| 580 | + e.ms.map = al.map; |
|---|
| 581 | + e.ms.maps = al.maps; |
|---|
| 580 | 582 | |
|---|
| 581 | 583 | pr_debug("unwind: %s:ip = 0x%" PRIx64 " (0x%" PRIx64 ")\n", |
|---|
| 582 | 584 | al.sym ? al.sym->name : "''", |
|---|
| .. | .. |
|---|
| 614 | 616 | .get_proc_name = get_proc_name, |
|---|
| 615 | 617 | }; |
|---|
| 616 | 618 | |
|---|
| 617 | | -static int _unwind__prepare_access(struct thread *thread) |
|---|
| 619 | +static int _unwind__prepare_access(struct maps *maps) |
|---|
| 618 | 620 | { |
|---|
| 619 | | - if (!dwarf_callchain_users) |
|---|
| 620 | | - return 0; |
|---|
| 621 | | - thread->addr_space = unw_create_addr_space(&accessors, 0); |
|---|
| 622 | | - if (!thread->addr_space) { |
|---|
| 621 | + maps->addr_space = unw_create_addr_space(&accessors, 0); |
|---|
| 622 | + if (!maps->addr_space) { |
|---|
| 623 | 623 | pr_err("unwind: Can't create unwind address space.\n"); |
|---|
| 624 | 624 | return -ENOMEM; |
|---|
| 625 | 625 | } |
|---|
| 626 | 626 | |
|---|
| 627 | | - unw_set_caching_policy(thread->addr_space, UNW_CACHE_GLOBAL); |
|---|
| 627 | + unw_set_caching_policy(maps->addr_space, UNW_CACHE_GLOBAL); |
|---|
| 628 | 628 | return 0; |
|---|
| 629 | 629 | } |
|---|
| 630 | 630 | |
|---|
| 631 | | -static void _unwind__flush_access(struct thread *thread) |
|---|
| 631 | +static void _unwind__flush_access(struct maps *maps) |
|---|
| 632 | 632 | { |
|---|
| 633 | | - if (!dwarf_callchain_users) |
|---|
| 634 | | - return; |
|---|
| 635 | | - unw_flush_cache(thread->addr_space, 0, 0); |
|---|
| 633 | + unw_flush_cache(maps->addr_space, 0, 0); |
|---|
| 636 | 634 | } |
|---|
| 637 | 635 | |
|---|
| 638 | | -static void _unwind__finish_access(struct thread *thread) |
|---|
| 636 | +static void _unwind__finish_access(struct maps *maps) |
|---|
| 639 | 637 | { |
|---|
| 640 | | - if (!dwarf_callchain_users) |
|---|
| 641 | | - return; |
|---|
| 642 | | - unw_destroy_addr_space(thread->addr_space); |
|---|
| 638 | + unw_destroy_addr_space(maps->addr_space); |
|---|
| 643 | 639 | } |
|---|
| 644 | 640 | |
|---|
| 645 | 641 | static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb, |
|---|
| .. | .. |
|---|
| 664 | 660 | */ |
|---|
| 665 | 661 | if (max_stack - 1 > 0) { |
|---|
| 666 | 662 | WARN_ONCE(!ui->thread, "WARNING: ui->thread is NULL"); |
|---|
| 667 | | - addr_space = ui->thread->addr_space; |
|---|
| 663 | + addr_space = ui->thread->maps->addr_space; |
|---|
| 668 | 664 | |
|---|
| 669 | 665 | if (addr_space == NULL) |
|---|
| 670 | 666 | return -1; |
|---|
| .. | .. |
|---|
| 713 | 709 | struct unwind_info ui = { |
|---|
| 714 | 710 | .sample = data, |
|---|
| 715 | 711 | .thread = thread, |
|---|
| 716 | | - .machine = thread->mg->machine, |
|---|
| 712 | + .machine = thread->maps->machine, |
|---|
| 717 | 713 | }; |
|---|
| 718 | 714 | |
|---|
| 719 | 715 | if (!data->user_regs.regs) |
|---|