LCOV - code coverage report
Current view: top level - backends - x86_64_regs.c (source / functions) Hit Total Coverage
Test: elfutils-0.191 Lines: 107 108 99.1 %
Date: 2024-03-01 16:42:08 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 34 37 91.9 %

           Branch data     Line data    Source code
       1                 :            : /* Register names and numbers for x86-64 DWARF.
       2                 :            :    Copyright (C) 2005, 2006, 2007 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 <assert.h>
      34                 :            : #include <dwarf.h>
      35                 :            : #include <string.h>
      36                 :            : 
      37                 :            : #define BACKEND x86_64_
      38                 :            : #include "libebl_CPU.h"
      39                 :            : 
      40                 :            : ssize_t
      41                 :      88506 : x86_64_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         [ +  + ]:      88506 :   if (name == NULL)
      47                 :         26 :     return 67;
      48                 :            : 
      49   [ +  -  +  -  :      88480 :   if (regno < 0 || regno > 66 || namelen < 7)
                   -  + ]
      50                 :          0 :     return -1;
      51                 :            : 
      52                 :      88480 :   *prefix = "%";
      53                 :      88480 :   *bits = 64;
      54                 :      88480 :   *type = DW_ATE_unsigned;
      55         [ +  + ]:      88480 :   if (regno < 17)
      56                 :            :     {
      57                 :      87428 :       *setname = "integer";
      58                 :      87428 :       *type = DW_ATE_signed;
      59                 :            :     }
      60         [ +  + ]:       1052 :   else if (regno < 33)
      61                 :            :     {
      62                 :        320 :       *setname = "SSE";
      63                 :        320 :       *bits = 128;
      64                 :            :     }
      65         [ +  + ]:        732 :   else if (regno < 41)
      66                 :            :     {
      67                 :        160 :       *setname = "x87";
      68                 :        160 :       *type = DW_ATE_float;
      69                 :        160 :       *bits = 80;
      70                 :            :     }
      71         [ +  + ]:        572 :   else if (regno < 49)
      72                 :        128 :     *setname = "MMX";
      73   [ +  +  +  + ]:        444 :   else if (regno > 49 && regno < 60)
      74                 :            :     {
      75                 :        288 :       *setname = "segment";
      76                 :        288 :       *bits = 16;
      77                 :            :     }
      78                 :            :   else
      79                 :        156 :     *setname = "control";
      80                 :            : 
      81   [ +  +  +  +  :      88480 :   switch (regno)
          +  +  +  +  +  
          +  +  +  +  +  
                +  +  + ]
      82                 :            :     {
      83                 :            :       static const char baseregs[][2] =
      84                 :            :         {
      85                 :            :           "ax", "dx", "cx", "bx", "si", "di", "bp", "sp"
      86                 :            :         };
      87                 :            : 
      88                 :      84478 :     case 6 ... 7:
      89                 :      84478 :       *type = DW_ATE_address;
      90                 :            :       FALLTHROUGH;
      91                 :      85972 :     case 0 ... 5:
      92                 :      85972 :       name[0] = 'r';
      93                 :      85972 :       name[1] = baseregs[regno][0];
      94                 :      85972 :       name[2] = baseregs[regno][1];
      95                 :      85972 :       namelen = 3;
      96                 :      85972 :       break;
      97                 :            : 
      98                 :         64 :     case 8 ... 9:
      99                 :         64 :       name[0] = 'r';
     100                 :         64 :       name[1] = regno - 8 + '8';
     101                 :         64 :       namelen = 2;
     102                 :         64 :       break;
     103                 :            : 
     104                 :       1016 :     case 10 ... 15:
     105                 :       1016 :       name[0] = 'r';
     106                 :       1016 :       name[1] = '1';
     107                 :       1016 :       name[2] = regno - 10 + '0';
     108                 :       1016 :       namelen = 3;
     109                 :       1016 :       break;
     110                 :            : 
     111                 :        376 :     case 16:
     112                 :        376 :       *type = DW_ATE_address;
     113                 :        376 :       name[0] = 'r';
     114                 :        376 :       name[1] = 'i';
     115                 :        376 :       name[2] = 'p';
     116                 :        376 :       namelen = 3;
     117                 :        376 :       break;
     118                 :            : 
     119                 :        200 :     case 17 ... 26:
     120                 :        200 :       name[0] = 'x';
     121                 :        200 :       name[1] = 'm';
     122                 :        200 :       name[2] = 'm';
     123                 :        200 :       name[3] = regno - 17 + '0';
     124                 :        200 :       namelen = 4;
     125                 :        200 :       break;
     126                 :            : 
     127                 :        120 :     case 27 ... 32:
     128                 :        120 :       name[0] = 'x';
     129                 :        120 :       name[1] = 'm';
     130                 :        120 :       name[2] = 'm';
     131                 :        120 :       name[3] = '1';
     132                 :        120 :       name[4] = regno - 27 + '0';
     133                 :        120 :       namelen = 5;
     134                 :        120 :       break;
     135                 :            : 
     136                 :        160 :     case 33 ... 40:
     137                 :        160 :       name[0] = 's';
     138                 :        160 :       name[1] = 't';
     139                 :        160 :       name[2] = regno - 33 + '0';
     140                 :        160 :       namelen = 3;
     141                 :        160 :       break;
     142                 :            : 
     143                 :        128 :     case 41 ... 48:
     144                 :        128 :       name[0] = 'm';
     145                 :        128 :       name[1] = 'm';
     146                 :        128 :       name[2] = regno - 41 + '0';
     147                 :        128 :       namelen = 3;
     148                 :        128 :       break;
     149                 :            : 
     150                 :        192 :     case 50 ... 55:
     151                 :        192 :       name[0] = "ecsdfg"[regno - 50];
     152                 :        192 :       name[1] = 's';
     153                 :        192 :       namelen = 2;
     154                 :        192 :       break;
     155                 :            : 
     156                 :         64 :     case 58 ... 59:
     157                 :         64 :       *type = DW_ATE_address;
     158                 :         64 :       *bits = 64;
     159                 :         64 :       name[0] = regno - 58 + 'f';
     160                 :         64 :       return stpcpy (&name[1], "s.base") + 1 - name;
     161                 :            : 
     162                 :         32 :     case 49:
     163                 :         32 :       *setname = "integer";
     164                 :         32 :       return stpcpy (name, "rflags") + 1 - name;
     165                 :         16 :     case 62:
     166                 :         16 :       return stpcpy (name, "tr") + 1 - name;
     167                 :         16 :     case 63:
     168                 :         16 :       return stpcpy (name, "ldtr") + 1 - name;
     169                 :         20 :     case 64:
     170                 :         20 :       return stpcpy (name, "mxcsr") + 1 - name;
     171                 :            : 
     172                 :         40 :     case 65 ... 66:
     173                 :         40 :       *bits = 16;
     174                 :         40 :       name[0] = 'f';
     175                 :         40 :       name[1] = "cs"[regno - 65];
     176                 :         40 :       name[2] = 'w';
     177                 :         40 :       namelen = 3;
     178                 :         40 :       break;
     179                 :            : 
     180                 :         64 :     default:
     181                 :         64 :       return 0;
     182                 :            :     }
     183                 :            : 
     184                 :      88268 :   name[namelen++] = '\0';
     185                 :      88268 :   return namelen;
     186                 :            : }

Generated by: LCOV version 1.14