LCOV - code coverage report
Current view: top level - backends - loongarch_initreg_sample.c (source / functions) Coverage Total Hit
Test: elfutils-0.197 Lines: 0.0 % 20 0
Test Date: 2026-11-20 23:40:54 Functions: 0.0 % 2 0
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 0.0 % 22 0

             Branch data     Line data    Source code
       1                 :             : /* Populate process registers from a register sample.
       2                 :             :    Copyright (C) 2026 WANG Xuerui.
       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                 :             : #define BACKEND loongarch_
      34                 :             : #include "libebl_CPU.h"
      35                 :             : #include "libebl_PERF_FLAGS.h"
      36                 :             : 
      37                 :             : bool
      38                 :           0 : loongarch_sample_sp_pc (const Dwarf_Word *regs, uint32_t n_regs,
      39                 :             :                         const int *regs_mapping, size_t n_regs_mapping,
      40                 :             :                         Dwarf_Word *sp, Dwarf_Word *pc)
      41                 :             : {
      42                 :           0 :   return generic_sample_sp_pc (regs, n_regs, regs_mapping, n_regs_mapping,
      43                 :             :                                sp, 3 /* index of sp in dwarf_regs */,
      44                 :             :                                pc, 0 /* index of pc in dwarf_regs */);
      45                 :             : }
      46                 :             : 
      47                 :             : bool
      48                 :           0 : loongarch_set_initial_registers_sample (const Dwarf_Word *regs,
      49                 :             :                                         uint32_t n_regs,
      50                 :             :                                         const int *regs_mapping,
      51                 :             :                                         size_t n_regs_mapping,
      52                 :             :                                         ebl_tid_registers_t *setfunc,
      53                 :             :                                         void *arg)
      54                 :             : {
      55                 :             :   /* LoongArch defines no PC in DWARF so here we reuse r0 (constant zero) as
      56                 :             :      PC.  */
      57                 :             : #define N_GPRS 32
      58                 :           0 :   Dwarf_Word dwarf_regs[N_GPRS];
      59                 :           0 :   bool scratch_present = false;
      60                 :           0 :   size_t i;
      61         [ #  # ]:           0 :   for (i = 0; i < N_GPRS; i++)
      62                 :           0 :     dwarf_regs[i] = 0x0;
      63         [ #  # ]:           0 :   for (i = 0; i < n_regs; i++)
      64                 :             :     {
      65         [ #  # ]:           0 :       if (i >= n_regs_mapping)
      66                 :             :         break;
      67         [ #  # ]:           0 :       if (regs_mapping[i] < 0 || regs_mapping[i] >= N_GPRS)
      68                 :           0 :         continue;
      69         [ #  # ]:           0 :       if (regs_mapping[i] >= 4 && regs_mapping[i] < 21)
      70                 :             :         /* $a0 to $t8 inclusive.  */
      71                 :           0 :         scratch_present = true;
      72                 :           0 :       dwarf_regs[regs_mapping[i]] = regs[i];
      73                 :             :     }
      74                 :             : 
      75                 :             :   /* $a0 (r4) through $t8 (r20) only if present.  */
      76   [ #  #  #  # ]:           0 :   if (scratch_present && ! setfunc (4, 21 - 4, &dwarf_regs[4], arg))
      77                 :             :     return false;
      78                 :             : 
      79                 :             :   /* $fp/$s9 (r22) plus $s0 (r23)..$s8 (r31).  */
      80         [ #  # ]:           0 :   if (! setfunc (22, 32 - 22, &dwarf_regs[22], arg))
      81                 :             :     return false;
      82                 :             : 
      83                 :             :   /* RA.  */
      84         [ #  # ]:           0 :   if (! setfunc (1, 1, &dwarf_regs[1], arg))
      85                 :             :     return false;
      86                 :             : 
      87                 :             :   /* SP.  */
      88         [ #  # ]:           0 :   if (! setfunc (3, 1, &dwarf_regs[3], arg))
      89                 :             :     return false;
      90                 :             : 
      91                 :             :   /* PC.  */
      92         [ #  # ]:           0 :   if (! setfunc (-1, 1, &dwarf_regs[0], arg))
      93                 :             :     return false;
      94                 :             : 
      95                 :             :   /* XXX Skip FP registers.  */
      96                 :             :   return true;
      97                 :             : }
        

Generated by: LCOV version 2.0-1