LCOV - code coverage report
Current view: top level - elfutils/libdw - dwarf_formblock.c (source / functions) Hit Total Coverage
Test: lcov.out Lines: 16 20 80.0 %
Date: 2012-10-31 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 19 36.8 %

           Branch data     Line data    Source code
       1                 :            : /* Return block represented by attribute.
       2                 :            :    Copyright (C) 2004-2010 Red Hat, Inc.
       3                 :            :    This file is part of elfutils.
       4                 :            :    Written by Ulrich Drepper <drepper@redhat.com>, 2004.
       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 <dwarf.h>
      35                 :            : #include "libdwP.h"
      36                 :            : 
      37                 :            : 
      38                 :            : int
      39                 :      90850 : dwarf_formblock (attr, return_block)
      40                 :            :      Dwarf_Attribute *attr;
      41                 :            :      Dwarf_Block *return_block;
      42                 :            : {
      43         [ +  - ]:      90850 :   if (attr == NULL)
      44                 :            :     return -1;
      45                 :            : 
      46                 :            :   const unsigned char *datap;
      47                 :            : 
      48   [ +  +  -  +  :      90850 :   switch (attr->form)
                      - ]
      49                 :            :     {
      50                 :            :     case DW_FORM_block1:
      51                 :         72 :       return_block->length = *(uint8_t *) attr->valp;
      52                 :         72 :       return_block->data = attr->valp + 1;
      53                 :         72 :       break;
      54                 :            : 
      55                 :            :     case DW_FORM_block2:
      56 [ -  + ][ #  # ]:          1 :       return_block->length = read_2ubyte_unaligned (attr->cu->dbg, attr->valp);
      57                 :          1 :       return_block->data = attr->valp + 2;
      58                 :          1 :       break;
      59                 :            : 
      60                 :            :     case DW_FORM_block4:
      61 [ #  # ][ #  # ]:          0 :       return_block->length = read_4ubyte_unaligned (attr->cu->dbg, attr->valp);
      62                 :          0 :       return_block->data = attr->valp + 4;
      63                 :          0 :       break;
      64                 :            : 
      65                 :            :     case DW_FORM_block:
      66                 :            :     case DW_FORM_exprloc:
      67                 :      90777 :       datap = attr->valp;
      68         [ -  + ]:      90777 :       get_uleb128 (return_block->length, datap);
      69                 :      90777 :       return_block->data = (unsigned char *) datap;
      70                 :      90777 :       break;
      71                 :            : 
      72                 :            :     default:
      73                 :          0 :       __libdw_seterrno (DWARF_E_NO_BLOCK);
      74                 :            :       return -1;
      75                 :            :     }
      76                 :            : 
      77         [ -  + ]:      90850 :   if (unlikely (cu_data (attr->cu)->d_size
      78                 :            :                 - (return_block->data
      79                 :            :                    - (unsigned char *) cu_data (attr->cu)->d_buf)
      80                 :            :                 < return_block->length))
      81                 :            :     {
      82                 :            :       /* Block does not fit.  */
      83                 :      90850 :       __libdw_seterrno (DWARF_E_INVALID_DWARF);
      84                 :            :       return -1;
      85                 :            :     }
      86                 :            : 
      87                 :            :   return 0;
      88                 :            : }
      89                 :      90850 : INTDEF(dwarf_formblock)

Generated by: LCOV version 1.9