LCOV - code coverage report
Current view: top level - backends - x86_64_regs.c (source / functions) Hit Total Coverage
Test: elfutils-0.178 Lines: 103 103 100.0 %
Date: 2019-11-26 23:55:16 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          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       13814 : 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       13814 :   if (name == NULL)
      47             :     return 67;
      48             : 
      49       13801 :   if (regno < 0 || regno > 66 || namelen < 7)
      50             :     return -1;
      51             : 
      52       13801 :   *prefix = "%";
      53       13801 :   *bits = 64;
      54       13801 :   *type = DW_ATE_unsigned;
      55       13801 :   if (regno < 17)
      56             :     {
      57       13275 :       *setname = "integer";
      58       13275 :       *type = DW_ATE_signed;
      59             :     }
      60         526 :   else if (regno < 33)
      61             :     {
      62         160 :       *setname = "SSE";
      63         160 :       *bits = 128;
      64             :     }
      65         366 :   else if (regno < 41)
      66             :     {
      67          80 :       *setname = "x87";
      68          80 :       *type = DW_ATE_float;
      69          80 :       *bits = 80;
      70             :     }
      71         286 :   else if (regno < 49)
      72          64 :     *setname = "MMX";
      73         222 :   else if (regno > 49 && regno < 60)
      74             :     {
      75         144 :       *setname = "segment";
      76         144 :       *bits = 16;
      77             :     }
      78             :   else
      79          78 :     *setname = "control";
      80             : 
      81       13801 :   switch (regno)
      82             :     {
      83        3026 :       static const char baseregs[][2] =
      84             :         {
      85             :           "ax", "dx", "cx", "bx", "si", "di", "bp", "sp"
      86             :         };
      87             : 
      88        3026 :     case 6 ... 7:
      89        3026 :       *type = DW_ATE_address;
      90        6661 :       FALLTHROUGH;
      91        6661 :     case 0 ... 5:
      92        6661 :       name[0] = 'r';
      93        6661 :       name[1] = baseregs[regno][0];
      94        6661 :       name[2] = baseregs[regno][1];
      95        6661 :       namelen = 3;
      96        6661 :       break;
      97             : 
      98          32 :     case 8 ... 9:
      99          32 :       name[0] = 'r';
     100          32 :       name[1] = regno - 8 + '8';
     101          32 :       namelen = 2;
     102          32 :       break;
     103             : 
     104        6461 :     case 10 ... 15:
     105        6461 :       name[0] = 'r';
     106        6461 :       name[1] = '1';
     107        6461 :       name[2] = regno - 10 + '0';
     108        6461 :       namelen = 3;
     109        6461 :       break;
     110             : 
     111         121 :     case 16:
     112         121 :       *type = DW_ATE_address;
     113         121 :       name[0] = 'r';
     114         121 :       name[1] = 'i';
     115         121 :       name[2] = 'p';
     116         121 :       namelen = 3;
     117         121 :       break;
     118             : 
     119         100 :     case 17 ... 26:
     120         100 :       name[0] = 'x';
     121         100 :       name[1] = 'm';
     122         100 :       name[2] = 'm';
     123         100 :       name[3] = regno - 17 + '0';
     124         100 :       namelen = 4;
     125         100 :       break;
     126             : 
     127          60 :     case 27 ... 32:
     128          60 :       name[0] = 'x';
     129          60 :       name[1] = 'm';
     130          60 :       name[2] = 'm';
     131          60 :       name[3] = '1';
     132          60 :       name[4] = regno - 27 + '0';
     133          60 :       namelen = 5;
     134          60 :       break;
     135             : 
     136          80 :     case 33 ... 40:
     137          80 :       name[0] = 's';
     138          80 :       name[1] = 't';
     139          80 :       name[2] = regno - 33 + '0';
     140          80 :       namelen = 3;
     141          80 :       break;
     142             : 
     143          64 :     case 41 ... 48:
     144          64 :       name[0] = 'm';
     145          64 :       name[1] = 'm';
     146          64 :       name[2] = regno - 41 + '0';
     147          64 :       namelen = 3;
     148          64 :       break;
     149             : 
     150          96 :     case 50 ... 55:
     151          96 :       name[0] = "ecsdfg"[regno - 50];
     152          96 :       name[1] = 's';
     153          96 :       namelen = 2;
     154          96 :       break;
     155             : 
     156          32 :     case 58 ... 59:
     157          32 :       *type = DW_ATE_address;
     158          32 :       *bits = 64;
     159          32 :       name[0] = regno - 58 + 'f';
     160          64 :       return stpcpy (&name[1], "s.base") + 1 - name;
     161             : 
     162          16 :     case 49:
     163          16 :       *setname = "integer";
     164          32 :       return stpcpy (name, "rflags") + 1 - name;
     165             :     case 62:
     166          16 :       return stpcpy (name, "tr") + 1 - name;
     167             :     case 63:
     168          16 :       return stpcpy (name, "ldtr") + 1 - name;
     169             :     case 64:
     170          20 :       return stpcpy (name, "mxcsr") + 1 - name;
     171             : 
     172          20 :     case 65 ... 66:
     173          20 :       *bits = 16;
     174          20 :       name[0] = 'f';
     175          20 :       name[1] = "cs"[regno - 65];
     176          20 :       name[2] = 'w';
     177          20 :       namelen = 3;
     178          20 :       break;
     179             : 
     180             :     default:
     181             :       return 0;
     182             :     }
     183             : 
     184       13695 :   name[namelen++] = '\0';
     185       13695 :   return namelen;
     186             : }

Generated by: LCOV version 1.13