LCOV - code coverage report
Current view: top level - libdwfl - dwfl_frame_regs.c (source / functions) Hit Total Coverage
Test: elfutils-0.189 Lines: 21 22 95.5 %
Date: 2023-04-18 20:09:22 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 13 20 65.0 %

           Branch data     Line data    Source code
       1                 :            : /* Get Dwarf Frame state from modules present in DWFL.
       2                 :            :    Copyright (C) 2013 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 "libdwflP.h"
      34                 :            : 
      35                 :            : bool
      36                 :        773 : dwfl_thread_state_registers (Dwfl_Thread *thread, int firstreg,
      37                 :            :                              unsigned nregs, const Dwarf_Word *regs)
      38                 :            : {
      39                 :        773 :   Dwfl_Frame *state = thread->unwound;
      40   [ +  -  -  + ]:        773 :   assert (state && state->unwound == NULL);
      41         [ -  + ]:        773 :   assert (state->initial_frame);
      42         [ +  + ]:       1634 :   for (unsigned regno = firstreg; regno < firstreg + nregs; regno++)
      43         [ +  + ]:        869 :     if (! __libdwfl_frame_reg_set (state, regno, regs[regno - firstreg]))
      44                 :            :       {
      45                 :          8 :         __libdwfl_seterrno (DWFL_E_INVALID_REGISTER);
      46                 :          8 :         return false;
      47                 :            :       }
      48                 :            :   return true;
      49                 :            : }
      50                 :            : INTDEF(dwfl_thread_state_registers)
      51                 :            : 
      52                 :            : void
      53                 :         14 : dwfl_thread_state_register_pc (Dwfl_Thread *thread, Dwarf_Word pc)
      54                 :            : {
      55                 :         14 :   Dwfl_Frame *state = thread->unwound;
      56   [ +  -  -  + ]:         14 :   assert (state && state->unwound == NULL);
      57         [ -  + ]:         14 :   assert (state->initial_frame);
      58                 :         14 :   state->pc = pc;
      59                 :         14 :   state->pc_state = DWFL_FRAME_STATE_PC_SET;
      60                 :         14 : }
      61                 :            : INTDEF(dwfl_thread_state_register_pc)
      62                 :            : 
      63                 :            : int
      64                 :       2884 : dwfl_frame_reg (Dwfl_Frame *state, unsigned regno, Dwarf_Word *val)
      65                 :            : {
      66                 :       2884 :   int res = __libdwfl_frame_reg_get (state, regno, val);
      67         [ -  + ]:       2884 :   if (res == -1)
      68                 :          0 :       __libdwfl_seterrno (DWFL_E_INVALID_REGISTER);
      69         [ +  + ]:       2884 :   else if (res == 1)
      70                 :        886 :       __libdwfl_seterrno (DWFL_E_REGISTER_VAL_UNKNOWN);
      71                 :       2884 :   return res;
      72                 :            : }
      73                 :            : INTDEF(dwfl_frame_reg)

Generated by: LCOV version 1.14