~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/util/unwind-libunwind.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 #include "unwind.h"
  3 #include "dso.h"
  4 #include "map.h"
  5 #include "thread.h"
  6 #include "session.h"
  7 #include "debug.h"
  8 #include "env.h"
  9 #include "callchain.h"
 10 
 11 struct unwind_libunwind_ops __weak *local_unwind_libunwind_ops;
 12 struct unwind_libunwind_ops __weak *x86_32_unwind_libunwind_ops;
 13 struct unwind_libunwind_ops __weak *arm64_unwind_libunwind_ops;
 14 
 15 int unwind__prepare_access(struct maps *maps, struct map *map, bool *initialized)
 16 {
 17         const char *arch;
 18         enum dso_type dso_type;
 19         struct unwind_libunwind_ops *ops = local_unwind_libunwind_ops;
 20         struct dso *dso = map__dso(map);
 21         struct machine *machine;
 22         int err;
 23 
 24         if (!dwarf_callchain_users)
 25                 return 0;
 26 
 27         if (maps__addr_space(maps)) {
 28                 pr_debug("unwind: thread map already set, dso=%s\n", dso__name(dso));
 29                 if (initialized)
 30                         *initialized = true;
 31                 return 0;
 32         }
 33 
 34         machine = maps__machine(maps);
 35         /* env->arch is NULL for live-mode (i.e. perf top) */
 36         if (!machine->env || !machine->env->arch)
 37                 goto out_register;
 38 
 39         dso_type = dso__type(dso, machine);
 40         if (dso_type == DSO__TYPE_UNKNOWN)
 41                 return 0;
 42 
 43         arch = perf_env__arch(machine->env);
 44 
 45         if (!strcmp(arch, "x86")) {
 46                 if (dso_type != DSO__TYPE_64BIT)
 47                         ops = x86_32_unwind_libunwind_ops;
 48         } else if (!strcmp(arch, "arm64") || !strcmp(arch, "arm")) {
 49                 if (dso_type == DSO__TYPE_64BIT)
 50                         ops = arm64_unwind_libunwind_ops;
 51         }
 52 
 53         if (!ops) {
 54                 pr_warning_once("unwind: target platform=%s is not supported\n", arch);
 55                 return 0;
 56         }
 57 out_register:
 58         maps__set_unwind_libunwind_ops(maps, ops);
 59 
 60         err = maps__unwind_libunwind_ops(maps)->prepare_access(maps);
 61         if (initialized)
 62                 *initialized = err ? false : true;
 63         return err;
 64 }
 65 
 66 void unwind__flush_access(struct maps *maps)
 67 {
 68         const struct unwind_libunwind_ops *ops = maps__unwind_libunwind_ops(maps);
 69 
 70         if (ops)
 71                 ops->flush_access(maps);
 72 }
 73 
 74 void unwind__finish_access(struct maps *maps)
 75 {
 76         const struct unwind_libunwind_ops *ops = maps__unwind_libunwind_ops(maps);
 77 
 78         if (ops)
 79                 ops->finish_access(maps);
 80 }
 81 
 82 int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
 83                          struct thread *thread,
 84                          struct perf_sample *data, int max_stack,
 85                          bool best_effort)
 86 {
 87         const struct unwind_libunwind_ops *ops = maps__unwind_libunwind_ops(thread__maps(thread));
 88 
 89         if (ops)
 90                 return ops->get_entries(cb, arg, thread, data, max_stack, best_effort);
 91         return 0;
 92 }
 93 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php