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

TOMOYO Linux Cross Reference
Linux/tools/perf/util/dwarf-regs.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 ] ~

Diff markup

Differences between /tools/perf/util/dwarf-regs.c (Architecture sparc) and /tools/perf/util/dwarf-regs.c (Architecture i386)


  1 // SPDX-License-Identifier: GPL-2.0                 1 // SPDX-License-Identifier: GPL-2.0
  2 /*                                                  2 /*
  3  * dwarf-regs.c : Mapping of DWARF debug regis      3  * dwarf-regs.c : Mapping of DWARF debug register numbers into register names.
  4  *                                                  4  *
  5  * Written by: Masami Hiramatsu <mhiramat@kern      5  * Written by: Masami Hiramatsu <mhiramat@kernel.org>
  6  */                                                 6  */
  7                                                     7 
  8 #include <stdlib.h>                                 8 #include <stdlib.h>
  9 #include <string.h>                                 9 #include <string.h>
 10 #include <debug.h>                                 10 #include <debug.h>
 11 #include <dwarf-regs.h>                            11 #include <dwarf-regs.h>
 12 #include <elf.h>                                   12 #include <elf.h>
 13 #include <errno.h>                                 13 #include <errno.h>
 14 #include <linux/kernel.h>                          14 #include <linux/kernel.h>
 15                                                    15 
 16 #ifndef EM_AARCH64                                 16 #ifndef EM_AARCH64
 17 #define EM_AARCH64      183  /* ARM 64 bit */      17 #define EM_AARCH64      183  /* ARM 64 bit */
 18 #endif                                             18 #endif
 19                                                    19 
 20 #ifndef EM_LOONGARCH                               20 #ifndef EM_LOONGARCH
 21 #define EM_LOONGARCH    258 /* LoongArch */        21 #define EM_LOONGARCH    258 /* LoongArch */
 22 #endif                                             22 #endif
 23                                                    23 
 24 /* Define const char * {arch}_register_tbl[] *     24 /* Define const char * {arch}_register_tbl[] */
 25 #define DEFINE_DWARF_REGSTR_TABLE                  25 #define DEFINE_DWARF_REGSTR_TABLE
 26 #include "../arch/x86/include/dwarf-regs-table     26 #include "../arch/x86/include/dwarf-regs-table.h"
 27 #include "../arch/arm/include/dwarf-regs-table     27 #include "../arch/arm/include/dwarf-regs-table.h"
 28 #include "../arch/arm64/include/dwarf-regs-tab     28 #include "../arch/arm64/include/dwarf-regs-table.h"
 29 #include "../arch/sh/include/dwarf-regs-table.     29 #include "../arch/sh/include/dwarf-regs-table.h"
 30 #include "../arch/powerpc/include/dwarf-regs-t     30 #include "../arch/powerpc/include/dwarf-regs-table.h"
 31 #include "../arch/s390/include/dwarf-regs-tabl     31 #include "../arch/s390/include/dwarf-regs-table.h"
 32 #include "../arch/sparc/include/dwarf-regs-tab     32 #include "../arch/sparc/include/dwarf-regs-table.h"
 33 #include "../arch/xtensa/include/dwarf-regs-ta     33 #include "../arch/xtensa/include/dwarf-regs-table.h"
 34 #include "../arch/mips/include/dwarf-regs-tabl     34 #include "../arch/mips/include/dwarf-regs-table.h"
 35 #include "../arch/loongarch/include/dwarf-regs     35 #include "../arch/loongarch/include/dwarf-regs-table.h"
 36                                                    36 
 37 #define __get_dwarf_regstr(tbl, n) (((n) < ARR     37 #define __get_dwarf_regstr(tbl, n) (((n) < ARRAY_SIZE(tbl)) ? (tbl)[(n)] : NULL)
 38                                                    38 
 39 /* Return architecture dependent register stri     39 /* Return architecture dependent register string (for kprobe-tracer) */
 40 const char *get_dwarf_regstr(unsigned int n, u     40 const char *get_dwarf_regstr(unsigned int n, unsigned int machine)
 41 {                                                  41 {
 42         switch (machine) {                         42         switch (machine) {
 43         case EM_NONE:   /* Generic arch - use      43         case EM_NONE:   /* Generic arch - use host arch */
 44                 return get_arch_regstr(n);         44                 return get_arch_regstr(n);
 45         case EM_386:                               45         case EM_386:
 46                 return __get_dwarf_regstr(x86_     46                 return __get_dwarf_regstr(x86_32_regstr_tbl, n);
 47         case EM_X86_64:                            47         case EM_X86_64:
 48                 return __get_dwarf_regstr(x86_     48                 return __get_dwarf_regstr(x86_64_regstr_tbl, n);
 49         case EM_ARM:                               49         case EM_ARM:
 50                 return __get_dwarf_regstr(arm_     50                 return __get_dwarf_regstr(arm_regstr_tbl, n);
 51         case EM_AARCH64:                           51         case EM_AARCH64:
 52                 return __get_dwarf_regstr(aarc     52                 return __get_dwarf_regstr(aarch64_regstr_tbl, n);
 53         case EM_SH:                                53         case EM_SH:
 54                 return __get_dwarf_regstr(sh_r     54                 return __get_dwarf_regstr(sh_regstr_tbl, n);
 55         case EM_S390:                              55         case EM_S390:
 56                 return __get_dwarf_regstr(s390     56                 return __get_dwarf_regstr(s390_regstr_tbl, n);
 57         case EM_PPC:                               57         case EM_PPC:
 58         case EM_PPC64:                             58         case EM_PPC64:
 59                 return __get_dwarf_regstr(powe     59                 return __get_dwarf_regstr(powerpc_regstr_tbl, n);
 60         case EM_SPARC:                             60         case EM_SPARC:
 61         case EM_SPARCV9:                           61         case EM_SPARCV9:
 62                 return __get_dwarf_regstr(spar     62                 return __get_dwarf_regstr(sparc_regstr_tbl, n);
 63         case EM_XTENSA:                            63         case EM_XTENSA:
 64                 return __get_dwarf_regstr(xten     64                 return __get_dwarf_regstr(xtensa_regstr_tbl, n);
 65         case EM_MIPS:                              65         case EM_MIPS:
 66                 return __get_dwarf_regstr(mips     66                 return __get_dwarf_regstr(mips_regstr_tbl, n);
 67         case EM_LOONGARCH:                         67         case EM_LOONGARCH:
 68                 return __get_dwarf_regstr(loon     68                 return __get_dwarf_regstr(loongarch_regstr_tbl, n);
 69         default:                                   69         default:
 70                 pr_err("ELF MACHINE %x is not      70                 pr_err("ELF MACHINE %x is not supported.\n", machine);
 71         }                                          71         }
 72         return NULL;                               72         return NULL;
 73 }                                                  73 }
 74                                                    74 
 75 __weak int get_arch_regnum(const char *name __     75 __weak int get_arch_regnum(const char *name __maybe_unused)
 76 {                                                  76 {
 77         return -ENOTSUP;                           77         return -ENOTSUP;
 78 }                                                  78 }
 79                                                    79 
 80 /* Return DWARF register number from architect     80 /* Return DWARF register number from architecture register name */
 81 int get_dwarf_regnum(const char *name, unsigne     81 int get_dwarf_regnum(const char *name, unsigned int machine)
 82 {                                                  82 {
 83         char *regname = strdup(name);              83         char *regname = strdup(name);
 84         int reg = -1;                              84         int reg = -1;
 85         char *p;                                   85         char *p;
 86                                                    86 
 87         if (regname == NULL)                       87         if (regname == NULL)
 88                 return -EINVAL;                    88                 return -EINVAL;
 89                                                    89 
 90         /* For convenience, remove trailing ch     90         /* For convenience, remove trailing characters */
 91         p = strpbrk(regname, " ,)");               91         p = strpbrk(regname, " ,)");
 92         if (p)                                     92         if (p)
 93                 *p = '\0';                         93                 *p = '\0';
 94                                                    94 
 95         switch (machine) {                         95         switch (machine) {
 96         case EM_NONE:   /* Generic arch - use      96         case EM_NONE:   /* Generic arch - use host arch */
 97                 reg = get_arch_regnum(regname)     97                 reg = get_arch_regnum(regname);
 98                 break;                             98                 break;
 99         default:                                   99         default:
100                 pr_err("ELF MACHINE %x is not     100                 pr_err("ELF MACHINE %x is not supported.\n", machine);
101         }                                         101         }
102         free(regname);                            102         free(regname);
103         return reg;                               103         return reg;
104 }                                                 104 }
105                                                   105 

~ [ 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