LCOV - code coverage report
Current view: top level - backends - libebl_CPU.h (source / functions) Hit Total Coverage
Test: elfutils-0.191 Lines: 13 13 100.0 %
Date: 2024-07-23 19:52:03 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 12 66.7 %

           Branch data     Line data    Source code
       1                 :            : /* Common interface for libebl modules.
       2                 :            :    Copyright (C) 2000, 2001, 2002, 2003, 2005, 2013, 2014 Red Hat, Inc.
       3                 :            :    Copyright (C) 2023 Mark J. Wielaard <mark@klomp.org>
       4                 :            :    This file is part of elfutils.
       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                 :            : #ifndef _LIBEBL_CPU_H
      31                 :            : #define _LIBEBL_CPU_H 1
      32                 :            : 
      33                 :            : #include <dwarf.h>
      34                 :            : #include <libeblP.h>
      35                 :            : 
      36                 :            : #define EBLHOOK(name)   EBLHOOK_1(BACKEND, name)
      37                 :            : #define EBLHOOK_1(a, b) EBLHOOK_2(a, b)
      38                 :            : #define EBLHOOK_2(a, b) a##b
      39                 :            : 
      40                 :            : /* Constructor.  */
      41                 :            : extern Ebl *EBLHOOK(init) (Elf *elf, GElf_Half machine, Ebl *eh);
      42                 :            : 
      43                 :            : #include "ebl-hooks.h"
      44                 :            : 
      45                 :            : #define HOOK(eh, name)  eh->name = EBLHOOK(name)
      46                 :            : 
      47                 :            : extern bool (*generic_debugscn_p) (const char *) attribute_hidden;
      48                 :            : 
      49                 :            : /* Helper for retval.  Return dwarf_tag (die), but calls return -1
      50                 :            :    if there where previous errors that leave die NULL.  */
      51                 :            : #define DWARF_TAG_OR_RETURN(die)  \
      52                 :            :   ({ Dwarf_Die *_die = (die);     \
      53                 :            :      if (_die == NULL) return -1; \
      54                 :            :      dwarf_tag (_die); })
      55                 :            : 
      56                 :            : /* Get a type die corresponding to DIE.  Peel CV qualifiers off
      57                 :            :    it.  Returns zero if the DIE doesn't have a type, or the type
      58                 :            :    is DW_TAG_unspecified_type.  Returns -1 on error.  Otherwise
      59                 :            :    returns the result tag DW_AT value.  */
      60                 :            : static inline int
      61                 :      30824 : dwarf_peeled_die_type (Dwarf_Die *die, Dwarf_Die *result)
      62                 :            : {
      63                 :      30824 :   Dwarf_Attribute attr_mem;
      64                 :      30824 :   Dwarf_Attribute *attr = dwarf_attr_integrate (die, DW_AT_type, &attr_mem);
      65         [ +  + ]:      30824 :   if (attr == NULL)
      66                 :            :     /* The function has no return value, like a `void' function in C.  */
      67                 :            :     return 0;
      68                 :            : 
      69         [ +  - ]:      24722 :   if (result == NULL)
      70                 :            :     return -1;
      71                 :            : 
      72         [ +  - ]:      24722 :   if (dwarf_formref_die (attr, result) == NULL)
      73                 :            :     return -1;
      74                 :            : 
      75         [ +  - ]:      24722 :   if (dwarf_peel_type (result, result) != 0)
      76                 :            :     return -1;
      77                 :            : 
      78                 :      24722 :   int tag = dwarf_tag (result);
      79         [ +  + ]:      24722 :   if (tag == DW_TAG_unspecified_type)
      80                 :            :     return 0; /* Treat an unspecified type as if there was no type.  */
      81                 :            : 
      82                 :            :   return tag;
      83                 :            : }
      84                 :            : 
      85                 :            : static inline bool
      86                 :          2 : dwarf_is_pointer (int tag)
      87                 :            : {
      88                 :          2 :   return tag == DW_TAG_pointer_type
      89         [ +  - ]:          2 :          || tag == DW_TAG_ptr_to_member_type
      90                 :            :          || tag == DW_TAG_reference_type
      91                 :          2 :          || tag == DW_TAG_rvalue_reference_type;
      92                 :            : }
      93                 :            : 
      94                 :            : #define CASE_POINTER \
      95                 :            :   case DW_TAG_pointer_type: \
      96                 :            :   case DW_TAG_ptr_to_member_type: \
      97                 :            :   case DW_TAG_reference_type: \
      98                 :            :   case DW_TAG_rvalue_reference_type
      99                 :            : 
     100                 :            : #endif  /* libebl_CPU.h */

Generated by: LCOV version 1.16