LCOV - code coverage report
Current view: top level - backends - i386_regs.c (source / functions) Hit Total Coverage
Test: elfutils-0.191 Lines: 73 73 100.0 %
Date: 2024-04-17 19:42:11 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 27 28 96.4 %

           Branch data     Line data    Source code
       1                 :            : /* Register names and numbers for i386 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 <string.h>
      34                 :            : #include <dwarf.h>
      35                 :            : 
      36                 :            : #define BACKEND i386_
      37                 :            : #include "libebl_CPU.h"
      38                 :            : 
      39                 :            : ssize_t
      40                 :        716 : i386_register_info (Ebl *ebl __attribute__ ((unused)),
      41                 :            :                     int regno, char *name, size_t namelen,
      42                 :            :                     const char **prefix, const char **setname,
      43                 :            :                     int *bits, int *type)
      44                 :            : {
      45         [ +  + ]:        716 :   if (name == NULL)
      46                 :            :     return 46;
      47                 :            : 
      48         [ +  - ]:        708 :   if (regno < 0 || regno > 45 || namelen < 6)
      49                 :            :     return -1;
      50                 :            : 
      51                 :        708 :   *prefix = "%";
      52                 :        708 :   *bits = 32;
      53                 :        708 :   *type = DW_ATE_unsigned;
      54         [ +  + ]:        708 :   if (regno < 11)
      55                 :            :     {
      56                 :        474 :       *setname = "integer";
      57         [ +  + ]:        474 :       if (regno < 9)
      58                 :        458 :         *type = DW_ATE_signed;
      59                 :            :     }
      60         [ +  + ]:        234 :   else if (regno < 19)
      61                 :            :     {
      62                 :         48 :       *setname = "x87";
      63                 :         48 :       *type = DW_ATE_float;
      64                 :         48 :       *bits = 80;
      65                 :            :     }
      66         [ +  + ]:        186 :   else if (regno < 29)
      67                 :            :     {
      68                 :         60 :       *setname = "SSE";
      69                 :         60 :       *bits = 128;
      70                 :            :     }
      71         [ +  + ]:        126 :   else if (regno < 37)
      72                 :            :     {
      73                 :         48 :       *setname = "MMX";
      74                 :         48 :       *bits = 64;
      75                 :            :     }
      76         [ +  + ]:         78 :   else if (regno < 40)
      77                 :         18 :     *setname = "FPU-control";
      78                 :            :   else
      79                 :            :     {
      80                 :         60 :       *setname = "segment";
      81                 :         60 :       *bits = 16;
      82                 :            :     }
      83                 :            : 
      84   [ +  +  +  +  :        708 :   switch (regno)
          +  +  +  +  +  
                +  +  + ]
      85                 :            :     {
      86                 :        278 :       static const char baseregs[][2] =
      87                 :            :         {
      88                 :            :           "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", "ip"
      89                 :            :         };
      90                 :            : 
      91                 :        278 :     case 4:
      92                 :            :     case 5:
      93                 :            :     case 8:
      94                 :        278 :       *type = DW_ATE_address;
      95                 :        458 :       FALLTHROUGH;
      96                 :        458 :     case 0 ... 3:
      97                 :            :     case 6 ... 7:
      98                 :        458 :       name[0] = 'e';
      99                 :        458 :       name[1] = baseregs[regno][0];
     100                 :        458 :       name[2] = baseregs[regno][1];
     101                 :        458 :       namelen = 3;
     102                 :        458 :       break;
     103                 :            : 
     104                 :            :     case 9:
     105                 :         10 :       return stpcpy (name, "eflags") + 1 - name;
     106                 :            :     case 10:
     107                 :          6 :       return stpcpy (name, "trapno") + 1 - name;
     108                 :            : 
     109                 :         48 :     case 11 ... 18:
     110                 :         48 :       name[0] = 's';
     111                 :         48 :       name[1] = 't';
     112                 :         48 :       name[2] = regno - 11 + '0';
     113                 :         48 :       namelen = 3;
     114                 :         48 :       break;
     115                 :            : 
     116                 :         48 :     case 21 ... 28:
     117                 :         48 :       name[0] = 'x';
     118                 :         48 :       name[1] = 'm';
     119                 :         48 :       name[2] = 'm';
     120                 :         48 :       name[3] = regno - 21 + '0';
     121                 :         48 :       namelen = 4;
     122                 :         48 :       break;
     123                 :            : 
     124                 :         48 :     case 29 ... 36:
     125                 :         48 :       name[0] = 'm';
     126                 :         48 :       name[1] = 'm';
     127                 :         48 :       name[2] = regno - 29 + '0';
     128                 :         48 :       namelen = 3;
     129                 :         48 :       break;
     130                 :            : 
     131                 :          6 :     case 37:
     132                 :          6 :       *bits = 16;
     133                 :          6 :       return stpcpy (name, "fctrl") + 1 - name;
     134                 :          6 :     case 38:
     135                 :          6 :       *bits = 16;
     136                 :          6 :       return stpcpy (name, "fstat") + 1 - name;
     137                 :            :     case 39:
     138                 :          6 :       return stpcpy (name, "mxcsr") + 1 - name;
     139                 :            : 
     140                 :         60 :     case 40 ... 45:
     141                 :         60 :       name[0] = "ecsdfg"[regno - 40];
     142                 :         60 :       name[1] = 's';
     143                 :         60 :       namelen = 2;
     144                 :         60 :       break;
     145                 :            : 
     146                 :         12 :     default:
     147                 :         12 :       *setname = NULL;
     148                 :         12 :       return 0;
     149                 :            :     }
     150                 :            : 
     151                 :        662 :   name[namelen++] = '\0';
     152                 :        662 :   return namelen;
     153                 :            : }

Generated by: LCOV version 1.16