Coverage Report

Created: 2025-08-24 06:28

/src/elfutils/backends/linux-perf-regs.c
Line
Count
Source (jump to first uncovered line)
1
/* Common pieces for handling registers in 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
static Dwarf_Word
30
perf_sample_find_reg (const Dwarf_Word *regs, uint32_t n_regs,
31
          uint64_t regs_mask,
32
          int target)
33
0
{
34
0
  int j, k; uint64_t bit;
35
0
  for (j = 0, k = 0, bit = 1; k < PERF_REG_X86_64_MAX; k++, bit <<= 1)
36
0
    {
37
0
      if (bit & regs_mask) {
38
0
  if (n_regs <= (uint32_t) j)
39
0
    return 0; /* regs_mask count doesn't match n_regs */
40
0
  if (k == target)
41
0
    return regs[j];
42
0
  if (k > target)
43
0
    return 0; /* regs_mask doesn't include desired reg */
44
0
  j++;
45
0
      }
46
0
    }
47
0
  return 0;
48
0
}
Unexecuted instantiation: i386_initreg_sample.c:perf_sample_find_reg
Unexecuted instantiation: x86_64_initreg_sample.c:perf_sample_find_reg