LCOV - code coverage report
Current view: top level - libdwfl - dwfl_frame_regs.c (source / functions) Hit Total Coverage
Test: elfutils-0.190 Lines: 21 22 95.5 %
Date: 2024-03-01 03:34:13 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                 :       1546 : dwfl_thread_state_registers (Dwfl_Thread *thread, int firstreg,
      37                 :            :                              unsigned nregs, const Dwarf_Word *regs)
      38                 :            : {
      39                 :       1546 :   Dwfl_Frame *state = thread->unwound;
      40   [ +  -  -  + ]:       1546 :   assert (state && state->unwound == NULL);
      41         [ -  + ]:       1546 :   assert (state->initial_frame);
      42         [ +  + ]:       3268 :   for (unsigned regno = firstreg; regno < firstreg + nregs; regno++)
      43         [ +  + ]:       1738 :     if (! __libdwfl_frame_reg_set (state, regno, regs[regno - firstreg]))
      44                 :            :       {
      45                 :         16 :         __libdwfl_seterrno (DWFL_E_INVALID_REGISTER);
      46                 :         16 :         return false;
      47                 :            :       }
      48                 :            :   return true;
      49                 :            : }
      50                 :            : INTDEF(dwfl_thread_state_registers)
      51                 :            : 
      52                 :            : void
      53                 :         28 : dwfl_thread_state_register_pc (Dwfl_Thread *thread, Dwarf_Word pc)
      54                 :            : {
      55                 :         28 :   Dwfl_Frame *state = thread->unwound;
      56   [ +  -  -  + ]:         28 :   assert (state && state->unwound == NULL);
      57         [ -  + ]:         28 :   assert (state->initial_frame);
      58                 :         28 :   state->pc = pc;
      59                 :         28 :   state->pc_state = DWFL_FRAME_STATE_PC_SET;
      60                 :         28 : }
      61                 :            : INTDEF(dwfl_thread_state_register_pc)
      62                 :            : 
      63                 :            : int
      64                 :       5910 : dwfl_frame_reg (Dwfl_Frame *state, unsigned regno, Dwarf_Word *val)
      65                 :            : {
      66                 :       5910 :   int res = __libdwfl_frame_reg_get (state, regno, val);
      67         [ -  + ]:       5910 :   if (res == -1)
      68                 :          0 :       __libdwfl_seterrno (DWFL_E_INVALID_REGISTER);
      69         [ +  + ]:       5910 :   else if (res == 1)
      70                 :       1774 :       __libdwfl_seterrno (DWFL_E_REGISTER_VAL_UNKNOWN);
      71                 :       5910 :   return res;
      72                 :            : }
      73                 :            : INTDEF(dwfl_frame_reg)

Generated by: LCOV version 1.16