LCOV - code coverage report
Current view: top level - backends - x86_64_initreg_sample.c (source / functions) Coverage Total Hit
Test: elfutils-0.193 Lines: 0.0 % 8 0
Test Date: 2025-08-30 14:31:09 Functions: 0.0 % 3 0
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 0.0 % 2 0

             Branch data     Line data    Source code
       1                 :             : /* Populate process registers from a linux perf_events sample.
       2                 :             :    Copyright (C) 2025 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 <stdlib.h>
      34                 :             : #if defined(__x86_64__) && defined(__linux__)
      35                 :             : # include <linux/perf_event.h>
      36                 :             : # include <asm/perf_regs.h>
      37                 :             : #endif
      38                 :             : 
      39                 :             : #define BACKEND x86_64_
      40                 :             : #include "libebl_CPU.h"
      41                 :             : #include "libebl_PERF_FLAGS.h"
      42                 :             : #if defined(__x86_64__) && defined(__linux__)
      43                 :             : # include "linux-perf-regs.c"
      44                 :             : # include "x86_initreg_sample.c"
      45                 :             : #endif
      46                 :             : 
      47                 :             : /* Register ordering cf. linux arch/x86/include/uapi/asm/perf_regs.h,
      48                 :             :    enum perf_event_x86_regs: */
      49                 :             : Dwarf_Word
      50                 :           0 : x86_64_sample_base_addr (const Dwarf_Word *regs, uint32_t n_regs,
      51                 :             :                          uint64_t regs_mask,
      52                 :             :                          /* XXX hypothetically needed if abi varies
      53                 :             :                             between samples in the same process;
      54                 :             :                             not needed on x86*/
      55                 :             :                          uint32_t abi __attribute__((unused)))
      56                 :             : {
      57                 :             : #if !defined(__x86_64__) || !defined(__linux__)
      58                 :             :   (void)regs;
      59                 :             :   (void)n_regs;
      60                 :             :   (void)regs_mask;
      61                 :             :   return 0;
      62                 :             : #else /* __x86_64__ */
      63                 :           0 :   return perf_sample_find_reg (regs, n_regs, regs_mask,
      64                 :             :                                7 /* index into perf_event_x86_regs */);
      65                 :             : #endif
      66                 :             : }
      67                 :             : 
      68                 :             : Dwarf_Word
      69                 :           0 : x86_64_sample_pc (const Dwarf_Word *regs, uint32_t n_regs,
      70                 :             :                   uint64_t regs_mask,
      71                 :             :                   uint32_t abi __attribute__((unused)))
      72                 :             : {
      73                 :             : #if !defined(__x86_64__) || !defined(__linux__)
      74                 :             :   (void)regs;
      75                 :             :   (void)n_regs;
      76                 :             :   (void)regs_mask;
      77                 :             :   return 0;
      78                 :             : #else /* __x86_64__ */
      79                 :           0 :   return perf_sample_find_reg (regs, n_regs, regs_mask,
      80                 :             :                                8 /* index into perf_event_x86_regs */);
      81                 :             : #endif
      82                 :             : }
      83                 :             : 
      84                 :             : bool
      85                 :           0 : x86_64_set_initial_registers_sample (const Dwarf_Word *regs, uint32_t n_regs,
      86                 :             :                                      uint64_t regs_mask, uint32_t abi,
      87                 :             :                                      ebl_tid_registers_t *setfunc,
      88                 :             :                                      void *arg)
      89                 :             : {
      90                 :             : #if !defined(__x86_64__) || !defined(__linux__)
      91                 :             :   (void)regs;
      92                 :             :   (void)n_regs;
      93                 :             :   (void)regs_mask;
      94                 :             :   (void)abi;
      95                 :             :   (void)setfunc;
      96                 :             :   (void)arg;
      97                 :             :   return false;
      98                 :             : #else /* __x86_64__ */
      99                 :           0 :   Dwarf_Word dwarf_regs[17];
     100         [ #  # ]:           0 :   if (!x86_set_initial_registers_sample (regs, n_regs, regs_mask,
     101                 :             :                                          abi, dwarf_regs, 9))
     102                 :             :     return false;
     103                 :           0 :   return setfunc (0, 17, dwarf_regs, arg);
     104                 :             : #endif
     105                 :             : }
     106                 :             : 
        

Generated by: LCOV version 2.0-1