LCOV - code coverage report
Current view: top level - backends - mips_unwind.c (source / functions) Hit Total Coverage
Test: elfutils-0.192 Lines: 0 19 0.0 %
Date: 2024-11-07 15:12:49 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 18 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* Get previous frame state for an existing frame state.
       2                 :            :    Copyright (C) 2016 The Qt Company Ltd.
       3                 :            :    Copyright (C) 2024 CIP United Inc.
       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                 :            : #ifdef HAVE_CONFIG_H
      31                 :            : # include <config.h>
      32                 :            : #endif
      33                 :            : 
      34                 :            : #define BACKEND mips_
      35                 :            : #define SP_REG 29
      36                 :            : #define FP_REG 30
      37                 :            : #define LR_REG 31
      38                 :            : #define FP_OFFSET 0
      39                 :            : #define LR_OFFSET 8
      40                 :            : #define SP_OFFSET 16
      41                 :            : 
      42                 :            : #include "libebl_CPU.h"
      43                 :            : 
      44                 :            : /* There was no CFI. Maybe we happen to have a frame pointer and can unwind from that?  */
      45                 :            : 
      46                 :            : bool
      47                 :          0 : EBLHOOK(unwind) (Ebl *ebl __attribute__ ((unused)), Dwarf_Addr pc __attribute__ ((unused)),
      48                 :            :                  ebl_tid_registers_t *setfunc, ebl_tid_registers_get_t *getfunc,
      49                 :            :                  ebl_pid_memory_read_t *readfunc, void *arg,
      50                 :            :                  bool *signal_framep __attribute__ ((unused)))
      51                 :            : {
      52                 :          0 :   Dwarf_Word fp, lr, sp;
      53                 :            : 
      54         [ #  # ]:          0 :   if (!getfunc(LR_REG, 1, &lr, arg))
      55                 :            :     return false;
      56                 :            : 
      57   [ #  #  #  # ]:          0 :   if (lr == 0 || !setfunc(-1, 1, &lr, arg))
      58                 :          0 :     return false;
      59                 :            : 
      60         [ #  # ]:          0 :   if (!getfunc(FP_REG, 1, &fp, arg))
      61                 :          0 :     fp = 0;
      62                 :            : 
      63         [ #  # ]:          0 :   if (!getfunc(SP_REG, 1, &sp, arg))
      64                 :          0 :     sp = 0;
      65                 :            : 
      66                 :          0 :   Dwarf_Word newLr, newFp, newSp;
      67                 :            : 
      68         [ #  # ]:          0 :   if (!readfunc(fp + LR_OFFSET, &newLr, arg))
      69                 :          0 :     newLr = 0;
      70                 :            : 
      71         [ #  # ]:          0 :   if (!readfunc(fp + FP_OFFSET, &newFp, arg))
      72                 :          0 :     newFp = 0;
      73                 :            : 
      74                 :          0 :   newSp = fp + SP_OFFSET;
      75                 :            : 
      76                 :            :   // These are not fatal if they don't work. They will just prevent unwinding at the next frame.
      77                 :          0 :   setfunc(LR_REG, 1, &newLr, arg);
      78                 :          0 :   setfunc(FP_REG, 1, &newFp, arg);
      79                 :          0 :   setfunc(SP_REG, 1, &newSp, arg);
      80                 :            : 
      81                 :            :   // If the fp is invalid, we might still have a valid lr.
      82                 :            :   // But if the fp is valid, then the stack should be moving in the right direction.
      83   [ #  #  #  # ]:          0 :   return fp == 0 || newSp > sp;
      84                 :            : }

Generated by: LCOV version 1.16