LCOV - code coverage report
Current view: top level - backends - aarch64_initreg.c (source / functions) Hit Total Coverage
Test: elfutils-0.189 Lines: 0 2 0.0 %
Date: 2023-04-23 01:46:39 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* Fetch live process registers from TID.
       2                 :            :    Copyright (C) 2013, 2014 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 "system.h"
      34                 :            : #include <assert.h>
      35                 :            : #if defined(__aarch64__) && defined(__linux__)
      36                 :            : # include <linux/uio.h>
      37                 :            : # include <sys/user.h>
      38                 :            : # include <sys/ptrace.h>
      39                 :            : /* Deal with old glibc defining user_pt_regs instead of user_regs_struct.  */
      40                 :            : # ifndef HAVE_SYS_USER_REGS
      41                 :            : #  define user_regs_struct user_pt_regs
      42                 :            : #  define user_fpsimd_struct user_fpsimd_state
      43                 :            : # endif
      44                 :            : #endif
      45                 :            : 
      46                 :            : #define BACKEND aarch64_
      47                 :            : #include "libebl_CPU.h"
      48                 :            : 
      49                 :            : bool
      50                 :          0 : aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
      51                 :            :                           ebl_tid_registers_t *setfunc __attribute__ ((unused)),
      52                 :            :                                 void *arg __attribute__ ((unused)))
      53                 :            : {
      54                 :            : #if !defined(__aarch64__) || !defined(__linux__)
      55                 :          0 :   return false;
      56                 :            : #else /* __aarch64__ */
      57                 :            : 
      58                 :            :   /* General registers.  */
      59                 :            :   struct user_regs_struct gregs;
      60                 :            :   struct iovec iovec;
      61                 :            :   iovec.iov_base = &gregs;
      62                 :            :   iovec.iov_len = sizeof (gregs);
      63                 :            :   if (ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, &iovec) != 0)
      64                 :            :     return false;
      65                 :            : 
      66                 :            :   /* X0..X30 plus SP.  */
      67                 :            :   if (! setfunc (0, 32, (Dwarf_Word *) &gregs.regs[0], arg))
      68                 :            :     return false;
      69                 :            : 
      70                 :            :   /* PC.  */
      71                 :            :   if (! setfunc (-1, 1, (Dwarf_Word *) &gregs.pc, arg))
      72                 :            :     return false;
      73                 :            : 
      74                 :            :   /* ELR cannot be found.  */
      75                 :            : 
      76                 :            :   /* FP registers (only 64bits are used).  */
      77                 :            :   struct user_fpsimd_struct fregs;
      78                 :            :   iovec.iov_base = &fregs;
      79                 :            :   iovec.iov_len = sizeof (fregs);
      80                 :            :   if (ptrace (PTRACE_GETREGSET, tid, NT_FPREGSET, &iovec) != 0)
      81                 :            :     return false;
      82                 :            : 
      83                 :            :   Dwarf_Word dwarf_fregs[32];
      84                 :            :   for (int r = 0; r < 32; r++)
      85                 :            :     dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
      86                 :            : 
      87                 :            :   if (! setfunc (64, 32, dwarf_fregs, arg))
      88                 :            :     return false;
      89                 :            : 
      90                 :            :   return true;
      91                 :            : #endif /* __aarch64__ */
      92                 :            : }

Generated by: LCOV version 1.14