1 /* Traditional frame unwind support, for GDB the GNU Debugger.
3 Copyright (C) 2003-2020 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
23 #include "frame.h" /* For "struct frame_id". */
26 struct regcache_map_entry
;
27 struct trad_frame_cache
;
29 /* A simple, or traditional frame cache.
31 The entire cache is populated in a single pass and then generic
32 routines are used to extract the various cache values. */
34 struct trad_frame_cache
*trad_frame_cache_zalloc (struct frame_info
*);
36 /* This frame's ID. */
37 void trad_frame_set_id (struct trad_frame_cache
*this_trad_cache
,
38 struct frame_id this_id
);
39 void trad_frame_get_id (struct trad_frame_cache
*this_trad_cache
,
40 struct frame_id
*this_id
);
41 void trad_frame_set_this_base (struct trad_frame_cache
*this_trad_cache
,
43 CORE_ADDR
trad_frame_get_this_base (struct trad_frame_cache
*this_trad_cache
);
45 void trad_frame_set_reg_realreg (struct trad_frame_cache
*this_trad_cache
,
46 int regnum
, int realreg
);
47 void trad_frame_set_reg_addr (struct trad_frame_cache
*this_trad_cache
,
48 int regnum
, CORE_ADDR addr
);
49 void trad_frame_set_reg_regmap (struct trad_frame_cache
*this_trad_cache
,
50 const struct regcache_map_entry
*regmap
,
51 CORE_ADDR addr
, size_t size
);
52 void trad_frame_set_reg_value (struct trad_frame_cache
*this_cache
,
53 int regnum
, LONGEST val
);
55 /* Given the cache in THIS_TRAD_CACHE, set the value of REGNUM to the bytes
56 contained in BYTES with size SIZE. */
57 void trad_frame_set_reg_value_bytes (struct trad_frame_cache
*this_trad_cache
,
58 int regnum
, const gdb_byte
*bytes
,
61 struct value
*trad_frame_get_register (struct trad_frame_cache
*this_trad_cache
,
62 struct frame_info
*this_frame
,
65 /* A traditional saved regs table, indexed by REGNUM, encoding where
66 the value of REGNUM for the previous frame can be found in this
69 The table is initialized with an identity encoding (ADDR == -1,
70 REALREG == REGNUM) indicating that the value of REGNUM in the
71 previous frame can be found in register REGNUM (== REALREG) in this
74 The initial encoding can then be changed:
76 Modify ADDR (REALREG >= 0, ADDR != -1) to indicate that the value
77 of register REGNUM in the previous frame can be found in memory at
78 ADDR in this frame (addr_p, !realreg_p, !value_p).
80 Modify REALREG (REALREG >= 0, ADDR == -1) to indicate that the
81 value of register REGNUM in the previous frame is found in register
82 REALREG in this frame (!addr_p, realreg_p, !value_p).
84 Call trad_frame_set_value (REALREG == -1) to indicate that the
85 value of register REGNUM in the previous frame is found in ADDR
86 (!addr_p, !realreg_p, value_p).
88 Call trad_frame_set_unknown (REALREG == -2) to indicate that the
89 register's value is not known. */
91 struct trad_frame_saved_reg
93 LONGEST addr
; /* A CORE_ADDR fits in a longest. */
95 /* Register data (for values that don't fit in ADDR). */
99 /* Encode REGNUM value in the trad-frame. */
100 void trad_frame_set_value (struct trad_frame_saved_reg this_saved_regs
[],
101 int regnum
, LONGEST val
);
103 /* Encode REGNUM is in REALREG in the trad-frame. */
104 void trad_frame_set_realreg (struct trad_frame_saved_reg this_saved_regs
[],
105 int regnum
, int realreg
);
107 /* Encode REGNUM is at address ADDR in the trad-frame. */
108 void trad_frame_set_addr (struct trad_frame_saved_reg this_trad_cache
[],
109 int regnum
, CORE_ADDR addr
);
111 /* Mark REGNUM as unknown. */
112 void trad_frame_set_unknown (struct trad_frame_saved_reg this_saved_regs
[],
115 /* Encode REGNUM value in the trad-frame as a sequence of bytes. This is
116 useful when the value is larger than what primitive types can hold. */
117 void trad_frame_set_value_bytes (struct trad_frame_saved_reg this_saved_regs
[],
118 int regnum
, const gdb_byte
*bytes
,
121 /* Convenience functions, return non-zero if the register has been
122 encoded as specified. */
123 int trad_frame_value_p (struct trad_frame_saved_reg this_saved_regs
[],
125 int trad_frame_addr_p (struct trad_frame_saved_reg this_saved_regs
[],
127 int trad_frame_realreg_p (struct trad_frame_saved_reg this_saved_regs
[],
130 /* Return TRUE if REGNUM is stored as a sequence of bytes, and FALSE
132 bool trad_frame_value_bytes_p (struct trad_frame_saved_reg this_saved_regs
[],
135 /* Reset the save regs cache, setting register values to -1. */
136 void trad_frame_reset_saved_regs (struct gdbarch
*gdbarch
,
137 struct trad_frame_saved_reg
*regs
);
139 /* Return a freshly allocated (and initialized) trad_frame array. */
140 struct trad_frame_saved_reg
*trad_frame_alloc_saved_regs (struct frame_info
*);
141 struct trad_frame_saved_reg
*trad_frame_alloc_saved_regs (struct gdbarch
*);
143 /* Given the trad_frame info, return the location of the specified
145 struct value
*trad_frame_get_prev_register (struct frame_info
*this_frame
,
146 struct trad_frame_saved_reg this_saved_regs
[],