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

             Branch data     Line data    Source code
       1                 :             : /* Peel type aliases and qualifier tags from a type DIE.
       2                 :             :    Copyright (C) 2014, 2015, 2016 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 "libdwP.h"
      34                 :             : #include <dwarf.h>
      35                 :             : #include <string.h>
      36                 :             : 
      37                 :             : 
      38                 :             : int
      39                 :      382792 : dwarf_peel_type (Dwarf_Die *die, Dwarf_Die *result)
      40                 :             : {
      41                 :      382792 :   int tag;
      42                 :             : 
      43                 :             :   /* Ignore previous errors.  */
      44         [ +  + ]:      382792 :   if (die == NULL)
      45                 :             :     return -1;
      46                 :             : 
      47                 :       30762 :   *result = *die;
      48                 :       30762 :   tag = INTUSE (dwarf_tag) (result);
      49                 :             : 
      50                 :             : /* Stack 8 of all these modifiers, after that it gets silly.  */
      51                 :             : #define MAX_DEPTH (8 * 8)
      52                 :       30762 :   int max_depth = MAX_DEPTH;
      53                 :       30762 :   while ((tag == DW_TAG_typedef
      54                 :       38302 :           || tag == DW_TAG_const_type
      55                 :             :           || tag == DW_TAG_volatile_type
      56                 :             :           || tag == DW_TAG_restrict_type
      57                 :             :           || tag == DW_TAG_atomic_type
      58                 :             :           || tag == DW_TAG_immutable_type
      59                 :             :           || tag == DW_TAG_packed_type
      60                 :             :           || tag == DW_TAG_shared_type)
      61   [ +  +  +  - ]:       38302 :         && max_depth-- > 0)
      62                 :             :     {
      63                 :        7540 :       Dwarf_Attribute attr_mem;
      64                 :        7540 :       Dwarf_Attribute *attr = INTUSE (dwarf_attr_integrate) (result, DW_AT_type,
      65                 :             :                                                              &attr_mem);
      66         [ +  - ]:        7540 :       if (attr == NULL)
      67                 :           0 :         return 1;
      68                 :             : 
      69         [ +  - ]:        7540 :       if (INTUSE (dwarf_formref_die) (attr, result) == NULL)
      70                 :             :         return -1;
      71                 :             : 
      72                 :        7540 :       tag = INTUSE (dwarf_tag) (result);
      73                 :             :     }
      74                 :             : 
      75         [ -  + ]:       30762 :   if (tag == DW_TAG_invalid || max_depth <= 0)
      76                 :             :     return -1;
      77                 :             : 
      78                 :             :   return 0;
      79                 :             : }
      80                 :             : INTDEF(dwarf_peel_type)
        

Generated by: LCOV version 2.0-1