fa0241acb2d68c1d56c4db87ab9b8159028dfe41
[binutils-gdb.git] / gdb / tramp-frame.h
1 /* Signal trampoline unwinder.
2
3 Copyright (C) 2004-2023 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #ifndef TRAMP_FRAME_H
21 #define TRAMP_FRAME_H
22
23 #include "frame.h" /* For "enum frame_type". */
24
25 class frame_info_ptr;
26 struct trad_frame_cache;
27
28 /* A trampoline consists of a small sequence of instructions placed at
29 an unspecified location in the inferior's address space. The only
30 identifying attribute of the trampoline's address is that it does
31 not fall inside an object file's section.
32
33 The only way to identify a trampoline is to perform a brute force
34 examination of the instructions at and around the PC.
35
36 This module provides a convenient interface for performing that
37 operation. */
38
39 /* A trampoline descriptor. */
40
41 /* Magic instruction that to mark the end of the signal trampoline
42 instruction sequence. */
43 #define TRAMP_SENTINEL_INSN ULONGEST_MAX
44
45 struct tramp_frame
46 {
47 /* The trampoline's type, some a signal trampolines, some are normal
48 call-frame trampolines (aka thunks). */
49 enum frame_type frame_type;
50 /* The trampoline's entire instruction sequence. It consists of a
51 bytes/mask pair. Search for this in the inferior at or around
52 the frame's PC. It is assumed that the PC is INSN_SIZE aligned,
53 and that each element of TRAMP contains one INSN_SIZE
54 instruction. It is also assumed that INSN[0] contains the first
55 instruction of the trampoline and hence the address of the
56 instruction matching INSN[0] is the trampoline's "func" address.
57 The instruction sequence is terminated by
58 TRAMP_SENTINEL_INSN. */
59 int insn_size;
60 struct
61 {
62 ULONGEST bytes;
63 ULONGEST mask;
64 } insn[48];
65 /* Initialize a trad-frame cache corresponding to the tramp-frame.
66 FUNC is the address of the instruction TRAMP[0] in memory. */
67 void (*init) (const struct tramp_frame *self,
68 frame_info_ptr this_frame,
69 struct trad_frame_cache *this_cache,
70 CORE_ADDR func);
71 /* Return non-zero if the tramp-frame is valid for the PC requested.
72 Adjust the PC to point to the address to check the instruction
73 sequence against if required. If this is NULL, then the tramp-frame
74 is valid for any PC. */
75 int (*validate) (const struct tramp_frame *self,
76 frame_info_ptr this_frame,
77 CORE_ADDR *pc);
78 };
79
80 void tramp_frame_prepend_unwinder (struct gdbarch *gdbarch,
81 const struct tramp_frame *tramp);
82
83 #endif