LCOV - code coverage report
Current view: top level - libdw - dwarf_getabbrevattr.c (source / functions) Coverage Total Hit
Test: elfutils-0.193 Lines: 100.0 % 26 26
Test Date: 2025-08-30 14:31:09 Functions: 100.0 % 2 2
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 75.0 % 16 12

             Branch data     Line data    Source code
       1                 :             : /* Get specific attribute of abbreviation.
       2                 :             :    Copyright (C) 2003, 2004, 2005, 2014, 2017 Red Hat, Inc.
       3                 :             :    This file is part of elfutils.
       4                 :             :    Written by Ulrich Drepper <drepper@redhat.com>, 2003.
       5                 :             : 
       6                 :             :    This file is free software; you can redistribute it and/or modify
       7                 :             :    it under the terms of either
       8                 :             : 
       9                 :             :      * the GNU Lesser General Public License as published by the Free
      10                 :             :        Software Foundation; either version 3 of the License, or (at
      11                 :             :        your option) any later version
      12                 :             : 
      13                 :             :    or
      14                 :             : 
      15                 :             :      * the GNU General Public License as published by the Free
      16                 :             :        Software Foundation; either version 2 of the License, or (at
      17                 :             :        your option) any later version
      18                 :             : 
      19                 :             :    or both in parallel, as here.
      20                 :             : 
      21                 :             :    elfutils is distributed in the hope that it will be useful, but
      22                 :             :    WITHOUT ANY WARRANTY; without even the implied warranty of
      23                 :             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      24                 :             :    General Public License for more details.
      25                 :             : 
      26                 :             :    You should have received copies of the GNU General Public License and
      27                 :             :    the GNU Lesser General Public License along with this program.  If
      28                 :             :    not, see <http://www.gnu.org/licenses/>.  */
      29                 :             : 
      30                 :             : #ifdef HAVE_CONFIG_H
      31                 :             : # include <config.h>
      32                 :             : #endif
      33                 :             : 
      34                 :             : #include <assert.h>
      35                 :             : #include <dwarf.h>
      36                 :             : #include "libdwP.h"
      37                 :             : 
      38                 :             : 
      39                 :             : int
      40                 :      942090 : dwarf_getabbrevattr_data (Dwarf_Abbrev *abbrev, size_t idx,
      41                 :             :                           unsigned int *namep, unsigned int *formp,
      42                 :             :                           Dwarf_Sword *datap, Dwarf_Off *offsetp)
      43                 :             : {
      44         [ -  + ]:      942090 :   if (abbrev == NULL)
      45                 :             :     return -1;
      46                 :             : 
      47                 :      942090 :   size_t cnt = 0;
      48                 :      942090 :   const unsigned char *attrp = abbrev->attrp;
      49                 :     3750110 :   const unsigned char *start_attrp;
      50                 :     3750110 :   unsigned int name;
      51                 :     3750110 :   unsigned int form;
      52                 :     3750110 :   Dwarf_Word data;
      53                 :             : 
      54                 :     3750110 :   do
      55                 :             :     {
      56                 :     3750110 :       start_attrp = attrp;
      57                 :             : 
      58                 :             :       /* Attribute code and form are encoded as ULEB128 values.
      59                 :             :          Already checked when Dwarf_Abbrev was created, read unchecked.  */
      60                 :     3750110 :       get_uleb128_unchecked (name, attrp);
      61                 :     3750110 :       get_uleb128_unchecked (form, attrp);
      62                 :             : 
      63         [ +  + ]:     3750110 :       if (form == DW_FORM_implicit_const)
      64                 :      287158 :         get_sleb128_unchecked (data, attrp);
      65                 :             :       else
      66                 :             :         data = 0;
      67                 :             : 
      68                 :             :       /* If both values are zero the index is out of range.  */
      69         [ +  + ]:     3750110 :       if (name == 0 && form == 0)
      70                 :             :         return -1;
      71                 :             :     }
      72         [ +  + ]:     3585876 :   while (cnt++ < idx);
      73                 :             : 
      74                 :             :   /* Store the result if requested.  */
      75         [ +  - ]:      777856 :   if (namep != NULL)
      76                 :      777856 :     *namep = name;
      77         [ +  - ]:      777856 :   if (formp != NULL)
      78                 :      777856 :     *formp = form;
      79         [ +  + ]:      777856 :   if (datap != NULL)
      80                 :      777330 :     *datap = data;
      81         [ +  - ]:      777856 :   if (offsetp != NULL)
      82                 :      777856 :     *offsetp = (start_attrp - abbrev->attrp) + abbrev->offset;
      83                 :             : 
      84                 :             :   return 0;
      85                 :             : }
      86                 :             : INTDEF(dwarf_getabbrevattr_data)
      87                 :             : 
      88                 :             : int
      89                 :         526 : dwarf_getabbrevattr (Dwarf_Abbrev *abbrev, size_t idx, unsigned int *namep,
      90                 :             :                      unsigned int *formp, Dwarf_Off *offsetp)
      91                 :             : {
      92                 :         526 :   return INTUSE(dwarf_getabbrevattr_data) (abbrev, idx, namep, formp,
      93                 :             :                                            NULL, offsetp);
      94                 :             : }
        

Generated by: LCOV version 2.0-1