/src/elfutils/libdwfl/dwfl_frame_regs.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Get Dwarf Frame state from modules present in DWFL. |
2 | | Copyright (C) 2013 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 "libdwflP.h" |
34 | | |
35 | | bool |
36 | | dwfl_thread_state_registers (Dwfl_Thread *thread, int firstreg, |
37 | | unsigned nregs, const Dwarf_Word *regs) |
38 | 0 | { |
39 | 0 | Dwfl_Frame *state = thread->unwound; |
40 | 0 | assert (state && state->unwound == NULL); |
41 | 0 | assert (state->initial_frame); |
42 | | |
43 | 0 | if (firstreg == -2 && nregs == 1) { |
44 | 0 | thread->aarch64.pauth_insn_mask = regs[0]; |
45 | 0 | return true; |
46 | 0 | } |
47 | | |
48 | 0 | for (unsigned regno = firstreg; regno < firstreg + nregs; regno++) |
49 | 0 | if (! __libdwfl_frame_reg_set (state, regno, regs[regno - firstreg])) |
50 | 0 | { |
51 | 0 | __libdwfl_seterrno (DWFL_E_INVALID_REGISTER); |
52 | 0 | return false; |
53 | 0 | } |
54 | 0 | return true; |
55 | 0 | } |
56 | | INTDEF(dwfl_thread_state_registers) |
57 | | |
58 | | void |
59 | | dwfl_thread_state_register_pc (Dwfl_Thread *thread, Dwarf_Word pc) |
60 | 0 | { |
61 | 0 | Dwfl_Frame *state = thread->unwound; |
62 | 0 | assert (state && state->unwound == NULL); |
63 | 0 | assert (state->initial_frame); |
64 | 0 | state->pc = pc; |
65 | 0 | state->pc_state = DWFL_FRAME_STATE_PC_SET; |
66 | 0 | } |
67 | | INTDEF(dwfl_thread_state_register_pc) |
68 | | |
69 | | int |
70 | | dwfl_frame_reg (Dwfl_Frame *state, unsigned regno, Dwarf_Word *val) |
71 | 0 | { |
72 | 0 | int res = __libdwfl_frame_reg_get (state, regno, val); |
73 | 0 | if (res == -1) |
74 | 0 | __libdwfl_seterrno (DWFL_E_INVALID_REGISTER); |
75 | 0 | else if (res == 1) |
76 | 0 | __libdwfl_seterrno (DWFL_E_REGISTER_VAL_UNKNOWN); |
77 | 0 | return res; |
78 | 0 | } |
79 | | INTDEF(dwfl_frame_reg) |