• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Register names and numbers for BPF DWARF.
2    This file is part of elfutils.
3 
4    This file is free software; you can redistribute it and/or modify
5    it under the terms of either
6 
7      * the GNU Lesser General Public License as published by the Free
8        Software Foundation; either version 3 of the License, or (at
9        your option) any later version
10 
11    or
12 
13      * the GNU General Public License as published by the Free
14        Software Foundation; either version 2 of the License, or (at
15        your option) any later version
16 
17    or both in parallel, as here.
18 
19    elfutils is distributed in the hope that it will be useful, but
20    WITHOUT ANY WARRANTY; without even the implied warranty of
21    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22    General Public License for more details.
23 
24    You should have received copies of the GNU General Public License and
25    the GNU Lesser General Public License along with this program.  If
26    not, see <http://www.gnu.org/licenses/>.  */
27 
28 #ifdef HAVE_CONFIG_H
29 # include <config.h>
30 #endif
31 
32 #include <stdio.h>
33 #include <string.h>
34 
35 #include "bpf.h"
36 
37 #define BACKEND bpf_
38 #include "libebl_CPU.h"
39 
40 ssize_t
bpf_register_info(Ebl * ebl,int regno,char * name,size_t namelen,const char ** prefix,const char ** setname,int * bits,int * type)41 bpf_register_info (Ebl *ebl __attribute__ ((unused)),
42 		   int regno, char *name, size_t namelen,
43 		   const char **prefix, const char **setname,
44 		   int *bits, int *type)
45 {
46   ssize_t len;
47 
48   if (name == NULL)
49     return MAX_BPF_REG;
50   if (regno < 0 || regno >= MAX_BPF_REG)
51     return -1;
52 
53   *prefix = "";
54   *setname = "integer";
55   *bits = 64;
56   *type = DW_ATE_signed;
57 
58   len = snprintf(name, namelen, "r%d", regno);
59   return ((size_t)len < namelen ? len : -1);
60 }
61