LCOV - code coverage report
Current view: top level - backends - ppc64_unwind.c (source / functions) Hit Total Coverage
Test: elfutils-0.183 Lines: 12 15 80.0 %
Date: 2021-02-07 19:08:58 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 12 58.3 %

           Branch data     Line data    Source code
       1                 :            : /* Get previous frame state for an existing frame state.
       2                 :            :    Copyright (C) 2017 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                 :            : #define BACKEND ppc64_
      34                 :            : 
      35                 :            : #define LR_REG 65 /* Not 108, see ppc_dwarf_to_regno.  */
      36                 :            : #define SP_REG  1
      37                 :            : 
      38                 :            : #define LR_OFFSET 16
      39                 :            : 
      40                 :            : #include "libebl_CPU.h"
      41                 :            : 
      42                 :            : /* Simplistic fallback frame unwinder. SP points to the backchain (contains
      43                 :            :    address of previous stack pointer). At SP offset 16 is the LR save area
      44                 :            :    (contains the value of the previous LR).  */
      45                 :            : 
      46                 :            : bool
      47                 :         10 : EBLHOOK(unwind) (Ebl *ebl __attribute__ ((unused)),
      48                 :            :                  Dwarf_Addr pc __attribute__ ((unused)),
      49                 :            :                  ebl_tid_registers_t *setfunc, ebl_tid_registers_get_t *getfunc,
      50                 :            :                  ebl_pid_memory_read_t *readfunc, void *arg,
      51                 :            :                  bool *signal_framep __attribute__ ((unused)))
      52                 :            : {
      53                 :         10 :   Dwarf_Word sp, newSp, lr, newLr;
      54                 :            : 
      55                 :            :   /* Stack pointer points to the backchain which contains the previous sp.  */
      56         [ -  + ]:         10 :   if (! getfunc (SP_REG, 1, &sp, arg))
      57                 :          0 :     sp = 0;
      58                 :            : 
      59                 :            :   /* Link register contains previous program counter.  */
      60         [ +  - ]:         10 :   if (! getfunc (LR_REG, 1, &lr, arg)
      61         [ +  + ]:         10 :       || lr == 0
      62         [ -  + ]:          8 :       || ! setfunc (-1, 1, &lr, arg))
      63                 :          2 :     return false;
      64                 :            : 
      65         [ -  + ]:          8 :   if (! readfunc(sp, &newSp, arg))
      66                 :          0 :     newSp = 0;
      67                 :            : 
      68         [ -  + ]:          8 :   if (! readfunc(newSp + LR_OFFSET, &newLr, arg))
      69                 :          0 :     newLr = 0;
      70                 :            : 
      71                 :          8 :   setfunc(SP_REG, 1, &newSp, arg);
      72                 :          8 :   setfunc(LR_REG, 1, &newLr, arg);
      73                 :            : 
      74                 :            :   /* Sanity check the stack grows down.  */
      75                 :          8 :   return newSp > sp;
      76                 :            : }

Generated by: LCOV version 1.13