LCOV - code coverage report
Current view: top level - backends - aarch64_initreg.c (source / functions) Hit Total Coverage
Test: elfutils-0.191 Lines: 0 2 0.0 %
Date: 2024-10-18 09:49:44 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                 :            : # include <asm/ptrace.h>
      40                 :            : /* Deal with old glibc defining user_pt_regs instead of user_regs_struct.  */
      41                 :            : # ifndef HAVE_SYS_USER_REGS
      42                 :            : #  define user_regs_struct user_pt_regs
      43                 :            : #  define user_fpsimd_struct user_fpsimd_state
      44                 :            : # endif
      45                 :            : #endif
      46                 :            : 
      47                 :            : #define BACKEND aarch64_
      48                 :            : #include "libebl_CPU.h"
      49                 :            : 
      50                 :            : bool
      51                 :          0 : aarch64_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
      52                 :            :                           ebl_tid_registers_t *setfunc __attribute__ ((unused)),
      53                 :            :                                 void *arg __attribute__ ((unused)))
      54                 :            : {
      55                 :            : #if !defined(__aarch64__) || !defined(__linux__)
      56                 :          0 :   return false;
      57                 :            : #else /* __aarch64__ */
      58                 :            : 
      59                 :            :   /* General registers.  */
      60                 :            :   struct user_regs_struct gregs;
      61                 :            :   struct user_pac_mask pac_mask;
      62                 :            :   struct iovec iovec;
      63                 :            :   iovec.iov_base = &gregs;
      64                 :            :   iovec.iov_len = sizeof (gregs);
      65                 :            :   if (ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, &iovec) != 0)
      66                 :            :     return false;
      67                 :            : 
      68                 :            :   iovec.iov_base = &pac_mask;
      69                 :            :   iovec.iov_len = sizeof (pac_mask);
      70                 :            :   if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_PAC_MASK, &iovec) != 0)
      71                 :            :     pac_mask.insn_mask = 0;
      72                 :            : 
      73                 :            :   /* X0..X30 plus SP.  */
      74                 :            :   if (! setfunc (0, 32, (Dwarf_Word *) &gregs.regs[0], arg))
      75                 :            :     return false;
      76                 :            : 
      77                 :            :   /* PC.  */
      78                 :            :   if (! setfunc (-1, 1, (Dwarf_Word *) &gregs.pc, arg))
      79                 :            :     return false;
      80                 :            : 
      81                 :            :   if (! setfunc (-2, 1, (Dwarf_Word *) &pac_mask.insn_mask, arg))
      82                 :            :     return false;
      83                 :            : 
      84                 :            :   /* ELR cannot be found.  */
      85                 :            : 
      86                 :            :   /* RA_SIGN_STATE cannot be found */
      87                 :            : 
      88                 :            :   /* FP registers (only 64bits are used).  */
      89                 :            :   struct user_fpsimd_struct fregs;
      90                 :            :   iovec.iov_base = &fregs;
      91                 :            :   iovec.iov_len = sizeof (fregs);
      92                 :            :   if (ptrace (PTRACE_GETREGSET, tid, NT_FPREGSET, &iovec) != 0)
      93                 :            :     return false;
      94                 :            : 
      95                 :            :   Dwarf_Word dwarf_fregs[32];
      96                 :            :   for (int r = 0; r < 32; r++)
      97                 :            :     dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
      98                 :            : 
      99                 :            :   if (! setfunc (64, 32, dwarf_fregs, arg))
     100                 :            :     return false;
     101                 :            : 
     102                 :            :   return true;
     103                 :            : #endif /* __aarch64__ */
     104                 :            : }

Generated by: LCOV version 1.16