LCOV - code coverage report
Current view: top level - libdw - dwarf_func_inline.c (source / functions) Hit Total Coverage
Test: elfutils-0.191 Lines: 25 27 92.6 %
Date: 2024-03-01 16:42:08 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 11 14 78.6 %

           Branch data     Line data    Source code
       1                 :            : /* Convenience functions for handling DWARF descriptions of inline functions.
       2                 :            :    Copyright (C) 2005,2006,2015 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                 :            : 
      36                 :            : struct visitor_info
      37                 :            : {
      38                 :            :   void *die_addr;
      39                 :            :   int (*callback) (Dwarf_Die *, void *);
      40                 :            :   void *arg;
      41                 :            : };
      42                 :            : 
      43                 :            : static int
      44                 :      10802 : scope_visitor (unsigned int depth __attribute__ ((unused)),
      45                 :            :                struct Dwarf_Die_Chain *die, void *arg)
      46                 :            : {
      47                 :      10802 :   struct visitor_info *const v = arg;
      48                 :            : 
      49         [ +  + ]:      10802 :   if (INTUSE(dwarf_tag) (&die->die) != DW_TAG_inlined_subroutine)
      50                 :      10392 :     return DWARF_CB_OK;
      51                 :            : 
      52                 :            :   Dwarf_Attribute attr_mem;
      53                 :        410 :   Dwarf_Attribute *attr = INTUSE(dwarf_attr) (&die->die, DW_AT_abstract_origin,
      54                 :            :                                               &attr_mem);
      55         [ -  + ]:        410 :   if (attr == NULL)
      56                 :          0 :     return DWARF_CB_OK;
      57                 :            : 
      58                 :            :   Dwarf_Die origin_mem;
      59                 :        410 :   Dwarf_Die *origin = INTUSE(dwarf_formref_die) (attr, &origin_mem);
      60         [ -  + ]:        410 :   if (origin == NULL)
      61                 :          0 :     return DWARF_CB_ABORT;
      62                 :            : 
      63         [ +  + ]:        410 :   if (origin->addr != v->die_addr)
      64                 :         36 :     return DWARF_CB_OK;
      65                 :            : 
      66                 :        374 :   return (*v->callback) (&die->die, v->arg);
      67                 :            : }
      68                 :            : 
      69                 :            : int
      70                 :      10994 : dwarf_func_inline (Dwarf_Die *func)
      71                 :            : {
      72                 :            :   Dwarf_Attribute attr_mem;
      73                 :            :   Dwarf_Word val;
      74         [ +  + ]:      10994 :   if (INTUSE(dwarf_formudata) (INTUSE(dwarf_attr) (func, DW_AT_inline,
      75                 :            :                                                    &attr_mem),
      76                 :            :                                &val) == 0)
      77   [ +  +  +  - ]:         80 :   switch (val)
      78                 :            :     {
      79                 :          2 :     case DW_INL_not_inlined:
      80                 :          2 :       return 0;
      81                 :            : 
      82                 :         22 :     case DW_INL_declared_not_inlined:
      83                 :         22 :       return -1;
      84                 :            : 
      85                 :         56 :     case DW_INL_inlined:
      86                 :            :     case DW_INL_declared_inlined:
      87                 :         56 :       return 1;
      88                 :            :     }
      89                 :            : 
      90                 :      10914 :   return 0;
      91                 :            : }
      92                 :            : 
      93                 :            : int
      94                 :         50 : dwarf_func_inline_instances (Dwarf_Die *func,
      95                 :            :                              int (*callback) (Dwarf_Die *, void *),
      96                 :            :                              void *arg)
      97                 :            : {
      98                 :         50 :   struct visitor_info v = { func->addr, callback, arg };
      99                 :         50 :   struct Dwarf_Die_Chain cu = { .die = CUDIE (func->cu), .parent = NULL };
     100                 :         50 :   return __libdw_visit_scopes (0, &cu, NULL, &scope_visitor, NULL, &v);
     101                 :            : }

Generated by: LCOV version 1.14