LCOV - code coverage report
Current view: top level - backends - x86_64_regs.c (source / functions) Coverage Total Hit
Test: elfutils-0.193 Lines: 99.1 % 108 107
Test Date: 2025-04-25 16:41:10 Functions: 100.0 % 1 1
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 91.9 % 37 34

             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                 :       92840 : 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         [ +  + ]:       92840 :   if (name == NULL)
      47                 :          26 :     return 67;
      48                 :             : 
      49   [ +  -  +  -  :       92814 :   if (regno < 0 || regno > 66 || namelen < 7)
                   -  + ]
      50                 :           0 :     return -1;
      51                 :             : 
      52                 :       92814 :   *prefix = "%";
      53                 :       92814 :   *bits = 64;
      54                 :       92814 :   *type = DW_ATE_unsigned;
      55         [ +  + ]:       92814 :   if (regno < 17)
      56                 :             :     {
      57                 :       91762 :       *setname = "integer";
      58                 :       91762 :       *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   [ +  +  +  +  :       92814 :   switch (regno)
          +  +  +  +  +  
          +  +  +  +  +  
                +  +  + ]
      82                 :             :     {
      83                 :             :       static const char baseregs[][2] =
      84                 :             :         {
      85                 :             :           {'a', 'x'},
      86                 :             :           {'d', 'x'},
      87                 :             :           {'c', 'x'},
      88                 :             :           {'b', 'x'},
      89                 :             :           {'s', 'i'},
      90                 :             :           {'d', 'i'},
      91                 :             :           {'b', 'p'},
      92                 :             :           {'s', 'p'},
      93                 :             :         };
      94                 :             : 
      95                 :       88984 :     case 6 ... 7:
      96                 :       88984 :       *type = DW_ATE_address;
      97                 :             :       FALLTHROUGH;
      98                 :       90424 :     case 0 ... 5:
      99                 :       90424 :       name[0] = 'r';
     100                 :       90424 :       name[1] = baseregs[regno][0];
     101                 :       90424 :       name[2] = baseregs[regno][1];
     102                 :       90424 :       namelen = 3;
     103                 :       90424 :       break;
     104                 :             : 
     105                 :          64 :     case 8 ... 9:
     106                 :          64 :       name[0] = 'r';
     107                 :          64 :       name[1] = regno - 8 + '8';
     108                 :          64 :       namelen = 2;
     109                 :          64 :       break;
     110                 :             : 
     111                 :         954 :     case 10 ... 15:
     112                 :         954 :       name[0] = 'r';
     113                 :         954 :       name[1] = '1';
     114                 :         954 :       name[2] = regno - 10 + '0';
     115                 :         954 :       namelen = 3;
     116                 :         954 :       break;
     117                 :             : 
     118                 :         320 :     case 16:
     119                 :         320 :       *type = DW_ATE_address;
     120                 :         320 :       name[0] = 'r';
     121                 :         320 :       name[1] = 'i';
     122                 :         320 :       name[2] = 'p';
     123                 :         320 :       namelen = 3;
     124                 :         320 :       break;
     125                 :             : 
     126                 :         200 :     case 17 ... 26:
     127                 :         200 :       name[0] = 'x';
     128                 :         200 :       name[1] = 'm';
     129                 :         200 :       name[2] = 'm';
     130                 :         200 :       name[3] = regno - 17 + '0';
     131                 :         200 :       namelen = 4;
     132                 :         200 :       break;
     133                 :             : 
     134                 :         120 :     case 27 ... 32:
     135                 :         120 :       name[0] = 'x';
     136                 :         120 :       name[1] = 'm';
     137                 :         120 :       name[2] = 'm';
     138                 :         120 :       name[3] = '1';
     139                 :         120 :       name[4] = regno - 27 + '0';
     140                 :         120 :       namelen = 5;
     141                 :         120 :       break;
     142                 :             : 
     143                 :         160 :     case 33 ... 40:
     144                 :         160 :       name[0] = 's';
     145                 :         160 :       name[1] = 't';
     146                 :         160 :       name[2] = regno - 33 + '0';
     147                 :         160 :       namelen = 3;
     148                 :         160 :       break;
     149                 :             : 
     150                 :         128 :     case 41 ... 48:
     151                 :         128 :       name[0] = 'm';
     152                 :         128 :       name[1] = 'm';
     153                 :         128 :       name[2] = regno - 41 + '0';
     154                 :         128 :       namelen = 3;
     155                 :         128 :       break;
     156                 :             : 
     157                 :         192 :     case 50 ... 55:
     158                 :         192 :       name[0] = "ecsdfg"[regno - 50];
     159                 :         192 :       name[1] = 's';
     160                 :         192 :       namelen = 2;
     161                 :         192 :       break;
     162                 :             : 
     163                 :          64 :     case 58 ... 59:
     164                 :          64 :       *type = DW_ATE_address;
     165                 :          64 :       *bits = 64;
     166                 :          64 :       name[0] = regno - 58 + 'f';
     167                 :          64 :       return stpcpy (&name[1], "s.base") + 1 - name;
     168                 :             : 
     169                 :          32 :     case 49:
     170                 :          32 :       *setname = "integer";
     171                 :          32 :       return stpcpy (name, "rflags") + 1 - name;
     172                 :          16 :     case 62:
     173                 :          16 :       return stpcpy (name, "tr") + 1 - name;
     174                 :          16 :     case 63:
     175                 :          16 :       return stpcpy (name, "ldtr") + 1 - name;
     176                 :          20 :     case 64:
     177                 :          20 :       return stpcpy (name, "mxcsr") + 1 - name;
     178                 :             : 
     179                 :          40 :     case 65 ... 66:
     180                 :          40 :       *bits = 16;
     181                 :          40 :       name[0] = 'f';
     182                 :          40 :       name[1] = "cs"[regno - 65];
     183                 :          40 :       name[2] = 'w';
     184                 :          40 :       namelen = 3;
     185                 :          40 :       break;
     186                 :             : 
     187                 :          64 :     default:
     188                 :          64 :       return 0;
     189                 :             :     }
     190                 :             : 
     191                 :       92602 :   name[namelen++] = '\0';
     192                 :       92602 :   return namelen;
     193                 :             : }
        

Generated by: LCOV version 2.0-1