LCOV - code coverage report
Current view: top level - libdw - dwarf_tag.c (source / functions) Coverage Total Hit
Test: elfutils-0.194 Lines: 100.0 % 26 26
Test Date: 2026-03-06 15:09:22 Functions: 100.0 % 2 2
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 100.0 % 16 16

             Branch data     Line data    Source code
       1                 :             : /* Return tag of given DIE.
       2                 :             :    Copyright (C) 2003-2011, 2014 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 "libdwP.h"
      35                 :             : 
      36                 :             : 
      37                 :             : Dwarf_Abbrev *
      38                 :             : internal_function
      39                 :    39600368 : __libdw_findabbrev (struct Dwarf_CU *cu, unsigned int code)
      40                 :             : {
      41                 :    39600368 :   Dwarf_Abbrev *abb;
      42                 :             : 
      43                 :             :   /* Abbreviation code can never have a value of 0.  */
      44         [ +  + ]:    39600368 :   if (unlikely (code == 0))
      45                 :             :     return DWARF_END_ABBREV;
      46                 :             : 
      47                 :             :   /* See whether the entry is already in the hash table.  */
      48                 :    39600362 :   abb = Dwarf_Abbrev_Hash_find (&cu->abbrev_hash, code);
      49         [ +  + ]:    39600362 :   if (abb == NULL)
      50                 :             :     {
      51                 :      578508 :       mutex_lock (cu->abbrev_lock);
      52                 :             : 
      53                 :             :       /* Check once more in case entry was added before abbrev_lock
      54                 :             :          was aquired.  */
      55         [ +  + ]:      578508 :       if (cu->last_abbrev_offset == (size_t) -1l)
      56                 :           4 :         abb = Dwarf_Abbrev_Hash_find (&cu->abbrev_hash, code);
      57                 :             : 
      58         [ +  + ]:     2793332 :       while (cu->last_abbrev_offset != (size_t) -1l)
      59                 :             :         {
      60                 :     2793328 :           size_t length;
      61                 :             : 
      62                 :             :           /* Find the next entry.  It gets automatically added to the
      63                 :             :              hash table.  */
      64                 :     2793328 :           abb = __libdw_getabbrev (cu->dbg, cu, cu->last_abbrev_offset,
      65                 :             :                                    &length);
      66                 :             : 
      67         [ +  + ]:     2793328 :           if (abb == NULL || abb == DWARF_END_ABBREV)
      68                 :             :             {
      69                 :             :               /* Make sure we do not try to search for it again.  */
      70                 :           2 :               cu->last_abbrev_offset = (size_t) -1l;
      71                 :           2 :               mutex_unlock (cu->abbrev_lock);
      72                 :           2 :               return DWARF_END_ABBREV;
      73                 :             :             }
      74                 :             : 
      75                 :     2793326 :           cu->last_abbrev_offset += length;
      76                 :             : 
      77                 :             :           /* Is this the code we are looking for?  */
      78         [ +  + ]:     2793326 :           if (abb->code == code)
      79                 :             :             break;
      80                 :             :         }
      81                 :             : 
      82                 :      578506 :       mutex_unlock (cu->abbrev_lock);
      83                 :             :     }
      84                 :             : 
      85                 :             :   /* This is our second (or third, etc.) call to __libdw_findabbrev
      86                 :             :      and the code is invalid.  */
      87         [ +  + ]:      578506 :   if (unlikely (abb == NULL))
      88                 :          12 :     abb = DWARF_END_ABBREV;
      89                 :             : 
      90                 :             :   return abb;
      91                 :             : }
      92                 :             : 
      93                 :             : 
      94                 :             : int
      95                 :    61526206 : dwarf_tag (Dwarf_Die *die)
      96                 :             : {
      97                 :             :   /* Find the abbreviation entry.  */
      98                 :    61526206 :   Dwarf_Abbrev *abbrevp = __libdw_dieabbrev (die, NULL);
      99         [ +  + ]:    61526206 :   if (unlikely (abbrevp == DWARF_END_ABBREV))
     100                 :             :     {
     101                 :       14658 :       __libdw_seterrno (DWARF_E_INVALID_DWARF);
     102                 :       14658 :       return DW_TAG_invalid;
     103                 :             :     }
     104                 :             : 
     105                 :    61511548 :   return abbrevp->tag;
     106                 :             : }
     107                 :             : INTDEF(dwarf_tag)
        

Generated by: LCOV version 2.0-1