LCOV - code coverage report
Current view: top level - libdw - dwarf_cu_info.c (source / functions) Hit Total Coverage
Test: elfutils-0.189 Lines: 28 32 87.5 %
Date: 2023-04-14 15:57:06 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 25 30 83.3 %

           Branch data     Line data    Source code
       1                 :            : /* Provides information and DIEs associated with the Dwarf_CU unit.
       2                 :            :    Copyright (C) 2018 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                 :            : 
      30                 :            : #ifdef HAVE_CONFIG_H
      31                 :            : # include <config.h>
      32                 :            : #endif
      33                 :            : 
      34                 :            : #include <string.h>
      35                 :            : #include "libdwP.h"
      36                 :            : 
      37                 :            : 
      38                 :            : int
      39                 :       6218 : dwarf_cu_info (Dwarf_CU *cu,
      40                 :            :                Dwarf_Half *version, uint8_t *unit_type,
      41                 :            :                Dwarf_Die *cudie, Dwarf_Die *subdie,
      42                 :            :                uint64_t *unit_id,
      43                 :            :                uint8_t *address_size, uint8_t *offset_size)
      44                 :            : {
      45         [ +  - ]:       6218 :   if (cu == NULL)
      46                 :            :     return -1;
      47                 :            : 
      48         [ +  + ]:       6218 :   if (version != NULL)
      49                 :       2272 :     *version = cu->version;
      50                 :            : 
      51         [ +  + ]:       6218 :   if (unit_type != NULL)
      52                 :       6161 :     *unit_type = cu->unit_type;
      53                 :            : 
      54         [ +  + ]:       6218 :   if (cudie != NULL)
      55                 :            :     {
      56         [ +  - ]:       4579 :       if (cu->version >= 2 && cu->version <= 5
      57         [ -  + ]:       4579 :           && cu->unit_type >= DW_UT_compile
      58         [ -  + ]:       4579 :           && cu->unit_type <= DW_UT_split_type)
      59                 :       4579 :         *cudie = CUDIE (cu);
      60                 :            :       else
      61                 :            :         {
      62                 :          0 :         invalid:
      63                 :          0 :           __libdw_seterrno (DWARF_E_INVALID_DWARF);
      64                 :          0 :           return -1;
      65                 :            :         }
      66                 :            :     }
      67                 :            : 
      68         [ +  + ]:       6218 :   if (subdie != NULL)
      69                 :            :     {
      70         [ +  - ]:       5967 :       if (cu->version >= 2 && cu->version <= 5)
      71                 :            :         {
      72                 :            :           /* For types, return the actual type DIE.  For skeletons,
      73                 :            :              find the associated split compile unit and return its
      74                 :            :              DIE.  */
      75                 :       5967 :           if (cu->unit_type == DW_UT_type
      76         [ +  + ]:       5967 :               || cu->unit_type == DW_UT_split_type)
      77                 :          4 :             *subdie = SUBDIE(cu);
      78         [ +  + ]:       5963 :           else if (cu->unit_type == DW_UT_skeleton)
      79                 :            :             {
      80                 :         33 :               Dwarf_CU *split_cu = __libdw_find_split_unit (cu);
      81         [ +  + ]:         33 :               if (split_cu != NULL)
      82                 :         32 :                 *subdie = CUDIE(split_cu);
      83                 :            :               else
      84                 :          1 :                 memset (subdie, '\0', sizeof (Dwarf_Die));
      85                 :            :             }
      86                 :            :           else
      87                 :       5930 :             memset (subdie, '\0', sizeof (Dwarf_Die));
      88                 :            :         }
      89                 :            :       else
      90                 :          0 :         goto invalid;
      91                 :            :     }
      92                 :            : 
      93         [ +  + ]:       6218 :   if (unit_id != NULL)
      94                 :       2480 :     *unit_id = cu->unit_id8;
      95                 :            : 
      96         [ +  + ]:       6218 :   if (address_size != NULL)
      97                 :       2272 :     *address_size = cu->address_size;
      98                 :            : 
      99         [ +  + ]:       6218 :   if (offset_size != NULL)
     100                 :       2272 :     *offset_size = cu->offset_size;
     101                 :            : 
     102                 :            :   return 0;
     103                 :            : }

Generated by: LCOV version 1.14