LCOV - code coverage report
Current view: top level - backends - sparc_regs.c (source / functions) Hit Total Coverage
Test: elfutils-0.191 Lines: 40 40 100.0 %
Date: 2024-10-16 15:22:04 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 25 28 89.3 %

           Branch data     Line data    Source code
       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                 :        320 : 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                 :            : {
      45         [ +  + ]:        320 :   const int nfp = 32 + (ebl->class == ELFCLASS32 ? 0 : 16);
      46         [ +  + ]:        320 :   const int nspec = ebl->class == ELFCLASS32 ? 8 : 6;
      47                 :            : 
      48         [ +  + ]:        320 :   if (name == NULL)
      49                 :          4 :     return 32 + nfp + nspec;
      50                 :            : 
      51   [ +  -  +  -  :        316 :   if (regno < 0 || regno >= 32 + nfp + nspec || namelen < 6)
                   +  - ]
      52                 :            :     return -1;
      53                 :            : 
      54         [ +  + ]:        316 :   *bits = ebl->class == ELFCLASS32 ? 32 : 64;
      55                 :        316 :   *type = DW_ATE_signed;
      56                 :            : 
      57                 :        316 :   *prefix = "%";
      58                 :            : 
      59         [ +  + ]:        316 :   if (regno >= 32 + nfp)
      60                 :            :     {
      61                 :         28 :       regno -= 32 + nfp;
      62                 :         28 :       static const char names[2][8][6] =
      63                 :            :         {
      64                 :            :           { "y", "psr", "wim", "tbr", "pc", "npc", "fsr", "csr" }, /* v8 */
      65                 :            :           { "pc", "npc", "state", "fsr", "fprs", "y" } /* v9 */
      66                 :            :         };
      67                 :         28 :       *setname = "control";
      68                 :         28 :       *type = DW_ATE_unsigned;
      69   [ +  +  +  + ]:         44 :       if ((ebl->class == ELFCLASS64 ? 0 : 4) + 1 - (unsigned int) regno <= 1)
      70                 :          8 :         *type = DW_ATE_address;
      71                 :         28 :       return stpncpy (name, names[ebl->class == ELFCLASS64][regno],
      72                 :         28 :                       namelen) + 1 - name;
      73                 :            :     }
      74                 :            : 
      75         [ +  + ]:        288 :   if (regno < 32)
      76                 :            :     {
      77                 :        128 :       *setname = "integer";
      78                 :        128 :       name[0] = "goli"[regno >> 3];
      79                 :        128 :       name[1] = (regno & 7) + '0';
      80                 :        128 :       namelen = 2;
      81         [ +  + ]:        128 :       if ((regno & 8) && (regno & 7) == 6)
      82                 :          8 :         *type = DW_ATE_address;
      83                 :            :     }
      84                 :            :   else
      85                 :            :     {
      86                 :        160 :       *setname = "FPU";
      87                 :        160 :       *type = DW_ATE_float;
      88                 :            : 
      89                 :        160 :       regno -= 32;
      90         [ +  + ]:        160 :       if (regno >= 32)
      91                 :         32 :         regno = 32 + 2 * (regno - 32);
      92                 :            :       else
      93                 :        128 :         *bits = 32;
      94                 :            : 
      95                 :        160 :       name[0] = 'f';
      96         [ +  + ]:        160 :       if (regno < 10)
      97                 :            :         {
      98                 :         40 :           name[1] = regno + '0';
      99                 :         40 :           namelen = 2;
     100                 :            :         }
     101                 :            :       else
     102                 :            :         {
     103                 :        120 :           name[1] = regno / 10 + '0';
     104                 :        120 :           name[2] = regno % 10 + '0';
     105                 :        120 :           namelen = 3;
     106                 :            :         }
     107                 :            :     }
     108                 :            : 
     109                 :        288 :   name[namelen++] = '\0';
     110                 :        288 :   return namelen;
     111                 :            : }

Generated by: LCOV version 1.16