Coverage Report

Created: 2025-07-11 06:46

/src/elfutils/backends/mips_regs.c
Line
Count
Source (jump to first uncovered line)
1
/* Register names and numbers for mips DWARF.
2
   Copyright (C) 2006 Red Hat, Inc.
3
   Copyright (C) 2024 CIP United Inc.
4
   This file is part of elfutils.
5
6
   This file is free software; you can redistribute it and/or modify
7
   it under the terms of either
8
9
     * the GNU Lesser General Public License as published by the Free
10
       Software Foundation; either version 3 of the License, or (at
11
       your option) any later version
12
13
   or
14
15
     * the GNU General Public License as published by the Free
16
       Software Foundation; either version 2 of the License, or (at
17
       your option) any later version
18
19
   or both in parallel, as here.
20
21
   elfutils is distributed in the hope that it will be useful, but
22
   WITHOUT ANY WARRANTY; without even the implied warranty of
23
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24
   General Public License for more details.
25
26
   You should have received copies of the GNU General Public License and
27
   the GNU Lesser General Public License along with this program.  If
28
   not, see <http://www.gnu.org/licenses/>.  */
29
30
#ifdef HAVE_CONFIG_H
31
# include <config.h>
32
#endif
33
34
#include <assert.h>
35
#include <dwarf.h>
36
#include <string.h>
37
38
#define BACKEND mips_
39
#include "libebl_CPU.h"
40
#include <system.h>
41
ssize_t
42
mips_register_info (Ebl *ebl __attribute__ ((unused)),
43
          int regno, char *name, size_t namelen,
44
          const char **prefix, const char **setname,
45
          int *bits, int *type)
46
0
{
47
0
  if (name == NULL)
48
0
    return 72;
49
50
0
  if (regno < 0 || regno > 71 || namelen < 4)
51
0
    return -1;
52
53
0
  *prefix = "$";
54
0
  if (regno < 38)
55
0
    {
56
0
      *setname = "integer";
57
0
      *type = DW_ATE_signed;
58
0
      *bits = 32;
59
0
    }
60
0
  else
61
0
    {
62
0
      *setname = "FPU";
63
0
      *type = DW_ATE_float;
64
0
      *bits = 64;
65
0
    }
66
67
0
  if (regno < 32)
68
0
    {
69
0
      if (regno < 10)
70
0
  {
71
0
    name[0] = regno + '0';
72
0
    namelen = 1;
73
0
  }
74
0
      else
75
0
  {
76
0
    name[0] = (regno / 10) + '0';
77
0
    name[1] = (regno % 10) + '0';
78
0
    namelen = 2;
79
0
  }
80
0
      if (regno == 28 || regno == 29 || regno == 31)
81
0
  *type = DW_ATE_address;
82
0
    }
83
0
  else if (regno == 32)
84
0
    {
85
0
      return stpcpy (name, "lo") + 1 - name;
86
0
    }
87
0
  else if (regno == 33)
88
0
    {
89
0
      return stpcpy (name, "hi") + 1 - name;
90
0
    }
91
0
  else if (regno == 34)
92
0
    {
93
0
      return stpcpy (name, "pc") + 1 - name;
94
0
    }
95
0
  else if (regno == 35)
96
0
    {
97
0
      *type = DW_ATE_address;
98
0
      return stpcpy (name, "bad") + 1 - name;
99
0
    }
100
0
  else if (regno == 36)
101
0
    {
102
0
      return stpcpy (name, "sr") + 1 - name;
103
0
    }
104
0
  else if (regno == 37)
105
0
    {
106
0
      *type = DW_ATE_address;
107
0
      return stpcpy (name, "cause") + 1 - name;
108
0
    }
109
0
  else if (regno < 70)
110
0
    {
111
0
      name[0] = 'f';
112
0
      if (regno < 38 + 10)
113
0
      {
114
0
  name[1] = (regno - 38) + '0';
115
0
  namelen = 2;
116
0
      }
117
0
      else
118
0
      {
119
0
  name[1] = (regno - 38) / 10 + '0';
120
0
  name[2] = (regno - 38) % 10 + '0';
121
0
  namelen = 3;
122
0
      }
123
0
    }
124
0
  else if (regno == 70)
125
0
    {
126
0
      return stpcpy (name, "fsr") + 1 - name;
127
0
    }
128
0
  else if (regno == 71)
129
0
    {
130
0
      return stpcpy (name, "fir") + 1 - name;
131
0
    }
132
133
0
  name[namelen++] = '\0';
134
0
  return namelen;
135
0
}