| 1 | /* |
| 2 | * Copyright (C) 2009, Neil Horman <[email protected]> |
| 3 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * This is a translator. given an input address, this will convert it into a |
| 8 | * function and offset. Unless overridden, it will automatically determine |
| 9 | * translations using the following methods, in order of priority: |
| 10 | * 1) /usr/lib/debug/<kernel version> using libbfd |
| 11 | * 2) /proc/kallsyms |
| 12 | */ |
| 13 | |
| 14 | #include "config.h" |
| 15 | |
| 16 | #include <stdlib.h> |
| 17 | #include <asm/types.h> |
| 18 | |
| 19 | |
| 20 | /* |
| 21 | * Initialization routine |
| 22 | * INPUTS: |
| 23 | * method - enum describing how to do translation |
| 24 | * * METHOD_NULL : Just print pc values, not symbols |
| 25 | * * METHOD_AUTO : automatic search for best method |
| 26 | * * METHOD_DEBUGINFO : use debuginfo package |
| 27 | * * METHOD_KALLSYMS : use /proc/kallsyms |
| 28 | * returns: |
| 29 | * * 0 : initalization succeeded |
| 30 | * * < 0 : initalization failed |
| 31 | */ |
| 32 | typedef enum { |
| 33 | METHOD_NULL = 0, |
| 34 | METHOD_AUTO, |
| 35 | #ifdef HAVE_BFD_H |
| 36 | METHOD_DEBUGINFO, |
| 37 | #endif |
| 38 | METHOD_KALLSYMS |
| 39 | } lookup_init_method_t; |
| 40 | |
| 41 | struct loc_result { |
| 42 | const char *symbol; |
| 43 | __u64 offset; |
| 44 | }; |
| 45 | |
| 46 | int init_lookup(lookup_init_method_t method); |
| 47 | int lookup_symbol(void *pc, struct loc_result *location); |
| 48 | |
| 49 | struct lookup_methods { |
| 50 | int (*lookup_init)(void); |
| 51 | int(*get_symbol)(void *pc, struct loc_result *location); |
| 52 | }; |
| 53 | |
| 54 |