hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/tools/perf/util/unwind-libunwind-local.c
....@@ -25,6 +25,7 @@
2525 #include <unistd.h>
2626 #include <sys/mman.h>
2727 #include <linux/list.h>
28
+#include <linux/zalloc.h>
2829 #ifndef REMOTE_UNWIND_LIBUNWIND
2930 #include <libunwind.h>
3031 #include <libunwind-ptrace.h>
....@@ -34,8 +35,8 @@
3435 #include "session.h"
3536 #include "perf_regs.h"
3637 #include "unwind.h"
38
+#include "map.h"
3739 #include "symbol.h"
38
-#include "util.h"
3940 #include "debug.h"
4041 #include "asm/bug.h"
4142 #include "dso.h"
....@@ -242,7 +243,7 @@
242243 * encoded_t fde_addr;
243244 * } binary_search_table[fde_count];
244245 */
245
- char data[0];
246
+ char data[];
246247 } __packed;
247248
248249 static int unwind_spec_ehframe(struct dso *dso, struct machine *machine,
....@@ -344,7 +345,7 @@
344345 __func__,
345346 dso->symsrc_filename,
346347 debuglink);
347
- free(dso->symsrc_filename);
348
+ zfree(&dso->symsrc_filename);
348349 }
349350 dso->symsrc_filename = debuglink;
350351 } else {
....@@ -574,9 +575,10 @@
574575 struct unwind_entry e;
575576 struct addr_location al;
576577
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;
580582
581583 pr_debug("unwind: %s:ip = 0x%" PRIx64 " (0x%" PRIx64 ")\n",
582584 al.sym ? al.sym->name : "''",
....@@ -614,32 +616,26 @@
614616 .get_proc_name = get_proc_name,
615617 };
616618
617
-static int _unwind__prepare_access(struct thread *thread)
619
+static int _unwind__prepare_access(struct maps *maps)
618620 {
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) {
623623 pr_err("unwind: Can't create unwind address space.\n");
624624 return -ENOMEM;
625625 }
626626
627
- unw_set_caching_policy(thread->addr_space, UNW_CACHE_GLOBAL);
627
+ unw_set_caching_policy(maps->addr_space, UNW_CACHE_GLOBAL);
628628 return 0;
629629 }
630630
631
-static void _unwind__flush_access(struct thread *thread)
631
+static void _unwind__flush_access(struct maps *maps)
632632 {
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);
636634 }
637635
638
-static void _unwind__finish_access(struct thread *thread)
636
+static void _unwind__finish_access(struct maps *maps)
639637 {
640
- if (!dwarf_callchain_users)
641
- return;
642
- unw_destroy_addr_space(thread->addr_space);
638
+ unw_destroy_addr_space(maps->addr_space);
643639 }
644640
645641 static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
....@@ -664,7 +660,7 @@
664660 */
665661 if (max_stack - 1 > 0) {
666662 WARN_ONCE(!ui->thread, "WARNING: ui->thread is NULL");
667
- addr_space = ui->thread->addr_space;
663
+ addr_space = ui->thread->maps->addr_space;
668664
669665 if (addr_space == NULL)
670666 return -1;
....@@ -713,7 +709,7 @@
713709 struct unwind_info ui = {
714710 .sample = data,
715711 .thread = thread,
716
- .machine = thread->mg->machine,
712
+ .machine = thread->maps->machine,
717713 };
718714
719715 if (!data->user_regs.regs)