Coverage Report

Created: 2025-07-12 06:44

/src/elfutils/backends/sparc_regs.c
Line
Count
Source (jump to first uncovered line)
1
/* Register names and numbers for SPARC DWARF.
2
   Copyright (C) 2005, 2006, 2015 Red Hat, Inc.
3
   This file is part of elfutils.
4
5
   This file is free software; you can redistribute it and/or modify
6
   it under the terms of either
7
8
     * the GNU Lesser General Public License as published by the Free
9
       Software Foundation; either version 3 of the License, or (at
10
       your option) any later version
11
12
   or
13
14
     * the GNU General Public License as published by the Free
15
       Software Foundation; either version 2 of the License, or (at
16
       your option) any later version
17
18
   or both in parallel, as here.
19
20
   elfutils is distributed in the hope that it will be useful, but
21
   WITHOUT ANY WARRANTY; without even the implied warranty of
22
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23
   General Public License for more details.
24
25
   You should have received copies of the GNU General Public License and
26
   the GNU Lesser General Public License along with this program.  If
27
   not, see <http://www.gnu.org/licenses/>.  */
28
29
#ifdef HAVE_CONFIG_H
30
# include <config.h>
31
#endif
32
33
#include <string.h>
34
#include <dwarf.h>
35
36
#define BACKEND sparc_
37
#include "libebl_CPU.h"
38
39
ssize_t
40
sparc_register_info (Ebl *ebl,
41
         int regno, char *name, size_t namelen,
42
         const char **prefix, const char **setname,
43
         int *bits, int *type)
44
0
{
45
0
  const int nfp = 32 + (ebl->class == ELFCLASS32 ? 0 : 16);
46
0
  const int nspec = ebl->class == ELFCLASS32 ? 8 : 6;
47
48
0
  if (name == NULL)
49
0
    return 32 + nfp + nspec;
50
51
0
  if (regno < 0 || regno >= 32 + nfp + nspec || namelen < 6)
52
0
    return -1;
53
54
0
  *bits = ebl->class == ELFCLASS32 ? 32 : 64;
55
0
  *type = DW_ATE_signed;
56
57
0
  *prefix = "%";
58
59
0
  if (regno >= 32 + nfp)
60
0
    {
61
0
      regno -= 32 + nfp;
62
0
      static const char names[2][8][6] =
63
0
  {
64
0
    { "y", "psr", "wim", "tbr", "pc", "npc", "fsr", "csr" }, /* v8 */
65
0
    { "pc", "npc", "state", "fsr", "fprs", "y" } /* v9 */
66
0
  };
67
0
      *setname = "control";
68
0
      *type = DW_ATE_unsigned;
69
0
      if ((ebl->class == ELFCLASS64 ? 0 : 4) + 1 - (unsigned int) regno <= 1)
70
0
  *type = DW_ATE_address;
71
0
      return stpncpy (name, names[ebl->class == ELFCLASS64][regno],
72
0
          namelen) + 1 - name;
73
0
    }
74
75
0
  if (regno < 32)
76
0
    {
77
0
      *setname = "integer";
78
0
      name[0] = "goli"[regno >> 3];
79
0
      name[1] = (regno & 7) + '0';
80
0
      namelen = 2;
81
0
      if ((regno & 8) && (regno & 7) == 6)
82
0
  *type = DW_ATE_address;
83
0
    }
84
0
  else
85
0
    {
86
0
      *setname = "FPU";
87
0
      *type = DW_ATE_float;
88
89
0
      regno -= 32;
90
0
      if (regno >= 32)
91
0
  regno = 32 + 2 * (regno - 32);
92
0
      else
93
0
  *bits = 32;
94
95
0
      name[0] = 'f';
96
0
      if (regno < 10)
97
0
  {
98
0
    name[1] = regno + '0';
99
0
    namelen = 2;
100
0
  }
101
0
      else
102
0
  {
103
0
    name[1] = regno / 10 + '0';
104
0
    name[2] = regno % 10 + '0';
105
0
    namelen = 3;
106
0
  }
107
0
    }
108
109
0
  name[namelen++] = '\0';
110
0
  return namelen;
111
0
}