LCOV - code coverage report
Current view: top level - elfutils/libdw - dwarf_tag.c (source / functions) Hit Total Coverage
Test: lcov.out Lines: 22 22 100.0 %
Date: 2012-10-31 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 18 18 100.0 %

           Branch data     Line data    Source code
       1                 :            : /* Return tag of given DIE.
       2                 :            :    Copyright (C) 2003-2011 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                 :    3377797 : __libdw_findabbrev (struct Dwarf_CU *cu, unsigned int code)
      40                 :            : {
      41                 :            :   Dwarf_Abbrev *abb;
      42                 :            : 
      43                 :            :   /* Abbreviation code can never have a value of 0.  */
      44         [ +  + ]:    3377797 :   if (unlikely (code == 0))
      45                 :            :     return DWARF_END_ABBREV;
      46                 :            : 
      47                 :            :   /* See whether the entry is already in the hash table.  */
      48                 :    3377795 :   abb = Dwarf_Abbrev_Hash_find (&cu->abbrev_hash, code, NULL);
      49         [ +  + ]:    3377795 :   if (abb == NULL)
      50         [ +  + ]:     867162 :     while (cu->last_abbrev_offset != (size_t) -1l)
      51                 :            :       {
      52                 :            :         size_t length;
      53                 :            : 
      54                 :            :         /* Find the next entry.  It gets automatically added to the
      55                 :            :            hash table.  */
      56                 :     867161 :         abb = __libdw_getabbrev (cu->dbg, cu, cu->last_abbrev_offset, &length,
      57                 :            :                                  NULL);
      58         [ +  + ]:     867161 :         if (abb == NULL || abb == DWARF_END_ABBREV)
      59                 :            :           {
      60                 :            :             /* Make sure we do not try to search for it again.  */
      61                 :          1 :             cu->last_abbrev_offset = (size_t) -1l;
      62                 :            :             return DWARF_END_ABBREV;
      63                 :            :           }
      64                 :            : 
      65                 :     867160 :         cu->last_abbrev_offset += length;
      66                 :            : 
      67                 :            :         /* Is this the code we are looking for?  */
      68         [ +  + ]:     867160 :         if (abb->code == code)
      69                 :            :           break;
      70                 :            :       }
      71                 :            : 
      72                 :            :   /* This is our second (or third, etc.) call to __libdw_findabbrev
      73                 :            :      and the code is invalid.  */
      74         [ +  + ]:    3377794 :   if (unlikely (abb == NULL))
      75                 :          1 :     abb = DWARF_END_ABBREV;
      76                 :            : 
      77                 :    3377797 :   return abb;
      78                 :            : }
      79                 :            : 
      80                 :            : 
      81                 :            : int
      82                 :    3070294 : dwarf_tag (die)
      83                 :            :      Dwarf_Die *die;
      84                 :            : {
      85                 :            :   /* Do we already know the abbreviation?  */
      86         [ +  + ]:    3070294 :   if (die->abbrev == NULL)
      87                 :            :     {
      88                 :            :       /* Get the abbreviation code.  */
      89                 :            :       unsigned int u128;
      90                 :    3041915 :       const unsigned char *addr = die->addr;
      91         [ +  + ]:    3041915 :       get_uleb128 (u128, addr);
      92                 :            : 
      93                 :            :       /* Find the abbreviation.  */
      94                 :    3041915 :       die->abbrev = __libdw_findabbrev (die->cu, u128);
      95                 :            :     }
      96                 :            : 
      97         [ +  + ]:    3070294 :   if (unlikely (die->abbrev == DWARF_END_ABBREV))
      98                 :            :     {
      99                 :          4 :       __libdw_seterrno (DWARF_E_INVALID_DWARF);
     100                 :          4 :       return DW_TAG_invalid;
     101                 :            :     }
     102                 :            : 
     103                 :    3070294 :   return die->abbrev->tag;
     104                 :            : }
     105                 :            : INTDEF(dwarf_tag)

Generated by: LCOV version 1.9