GDB (xrefs)
Loading...
Searching...
No Matches
trad-frame.h
Go to the documentation of this file.
1/* Traditional frame unwind support, for GDB the GNU Debugger.
2
3 Copyright (C) 2003-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 TRAD_FRAME_H
21#define TRAD_FRAME_H
22
23#include "frame.h"
24
25class frame_info_ptr;
27struct trad_frame_cache;
28
29/* A simple, or traditional frame cache.
30
31 The entire cache is populated in a single pass and then generic
32 routines are used to extract the various cache values. */
33
35
36/* This frame's ID. */
37void trad_frame_set_id (struct trad_frame_cache *this_trad_cache,
38 struct frame_id this_id);
39void trad_frame_get_id (struct trad_frame_cache *this_trad_cache,
40 struct frame_id *this_id);
41void trad_frame_set_this_base (struct trad_frame_cache *this_trad_cache,
42 CORE_ADDR this_base);
43CORE_ADDR trad_frame_get_this_base (struct trad_frame_cache *this_trad_cache);
44
45void trad_frame_set_reg_realreg (struct trad_frame_cache *this_trad_cache,
46 int regnum, int realreg);
47void trad_frame_set_reg_addr (struct trad_frame_cache *this_trad_cache,
48 int regnum, CORE_ADDR addr);
49void 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);
52void trad_frame_set_reg_value (struct trad_frame_cache *this_cache,
53 int regnum, LONGEST val);
54
55/* Given the cache in THIS_TRAD_CACHE, set the value of REGNUM to the bytes
56 contained in BYTES with size SIZE. */
57void trad_frame_set_reg_value_bytes (struct trad_frame_cache *this_trad_cache,
58 int regnum,
59 gdb::array_view<const gdb_byte> bytes);
60
61struct value *trad_frame_get_register (struct trad_frame_cache *this_trad_cache,
62 frame_info_ptr this_frame,
63 int regnum);
64
65/* Describes the kind of encoding a stored register has. */
67{
68 /* Register value is unknown. */
69 UNKNOWN = 0,
70 /* Register value is a constant. */
71 VALUE,
72 /* Register value is in another register. */
73 REALREG,
74 /* Register value is at an address. */
75 ADDR,
76 /* Register value is a sequence of bytes. */
78};
79
80/* A struct that describes a saved register in a frame. */
81
83{
84 /* Setters */
85
86 /* Encode that the saved register's value is constant VAL in the
87 trad-frame. */
88 void set_value (LONGEST val)
89 {
91 m_reg.value = val;
92 }
93
94 /* Encode that the saved register's value is stored in register REALREG. */
100
101 /* Encode that the saved register's value is stored in memory at ADDR. */
102 void set_addr (LONGEST addr)
103 {
105 m_reg.addr = addr;
106 }
107
108 /* Encode that the saved register's value is unknown. */
113
114 /* Encode that the saved register's value is stored as a sequence of bytes.
115 This is useful when the value is larger than what primitive types
116 can hold. */
117 void set_value_bytes (gdb::array_view<const gdb_byte> bytes)
118 {
119 /* Allocate the space and copy the data bytes. */
120 gdb_byte *data = FRAME_OBSTACK_CALLOC (bytes.size (), gdb_byte);
121 memcpy (data, bytes.data (), bytes.size ());
122
124 m_reg.value_bytes = data;
125 }
126
127 /* Getters */
128
129 LONGEST value () const
130 {
132 return m_reg.value;
133 }
134
135 int realreg () const
136 {
138 return m_reg.realreg;
139 }
140
141 LONGEST addr () const
142 {
144 return m_reg.addr;
145 }
146
147 const gdb_byte *value_bytes () const
148 {
150 return m_reg.value_bytes;
151 }
152
153 /* Convenience functions, return true if the register has been
154 encoded as specified. Return false otherwise. */
155 bool is_value () const
156 {
158 }
159
160 bool is_realreg () const
161 {
163 }
164
165 bool is_addr () const
166 {
168 }
169
170 bool is_unknown () const
171 {
173 }
174
175 bool is_value_bytes () const
176 {
178 }
179
180private:
181
183
184 union {
185 LONGEST value;
187 LONGEST addr;
188 const gdb_byte *value_bytes;
190};
191
192/* Reset the saved regs cache, setting register values to REALREG. */
195
196/* Return a freshly allocated (and initialized) trad_frame array. */
199
200/* Given the trad_frame info, return the location of the specified
201 register. */
203 trad_frame_saved_reg this_saved_regs[],
204 int regnum);
205
206#endif
int regnum
#define FRAME_OBSTACK_CALLOC(NUMBER, TYPE)
Definition frame.h:827
size_t size
Definition go32-nat.c:239
static int regmap[]
Definition regcache.h:111
struct frame_id this_id
Definition trad-frame.c:35
CORE_ADDR this_base
Definition trad-frame.c:33
bool is_addr() const
Definition trad-frame.h:165
const gdb_byte * value_bytes() const
Definition trad-frame.h:147
void set_value_bytes(gdb::array_view< const gdb_byte > bytes)
Definition trad-frame.h:117
void set_realreg(int realreg)
Definition trad-frame.h:95
void set_addr(LONGEST addr)
Definition trad-frame.h:102
int realreg() const
Definition trad-frame.h:135
bool is_realreg() const
Definition trad-frame.h:160
trad_frame_saved_reg_kind m_kind
Definition trad-frame.h:182
union trad_frame_saved_reg::@190 m_reg
LONGEST value() const
Definition trad-frame.h:129
bool is_value_bytes() const
Definition trad-frame.h:175
void set_value(LONGEST val)
Definition trad-frame.h:88
bool is_unknown() const
Definition trad-frame.h:170
const gdb_byte * value_bytes
Definition trad-frame.h:188
LONGEST addr() const
Definition trad-frame.h:141
bool is_value() const
Definition trad-frame.h:155
Definition value.h:130
void trad_frame_set_reg_realreg(struct trad_frame_cache *this_trad_cache, int regnum, int realreg)
Definition trad-frame.c:103
struct trad_frame_cache * trad_frame_cache_zalloc(frame_info_ptr)
Definition trad-frame.c:39
void trad_frame_set_reg_value_bytes(struct trad_frame_cache *this_trad_cache, int regnum, gdb::array_view< const gdb_byte > bytes)
Definition trad-frame.c:175
struct value * trad_frame_get_prev_register(frame_info_ptr this_frame, trad_frame_saved_reg this_saved_regs[], int regnum)
Definition trad-frame.c:187
void trad_frame_set_reg_addr(struct trad_frame_cache *this_trad_cache, int regnum, CORE_ADDR addr)
Definition trad-frame.c:110
void trad_frame_set_reg_regmap(struct trad_frame_cache *this_trad_cache, const struct regcache_map_entry *regmap, CORE_ADDR addr, size_t size)
Definition trad-frame.c:117
void trad_frame_reset_saved_regs(struct gdbarch *gdbarch, trad_frame_saved_reg *regs)
Definition trad-frame.c:52
trad_frame_saved_reg_kind
Definition trad-frame.h:67
void trad_frame_get_id(struct trad_frame_cache *this_trad_cache, struct frame_id *this_id)
Definition trad-frame.c:227
trad_frame_saved_reg * trad_frame_alloc_saved_regs(frame_info_ptr)
Definition trad-frame.c:86
void trad_frame_set_id(struct trad_frame_cache *this_trad_cache, struct frame_id this_id)
Definition trad-frame.c:220
CORE_ADDR trad_frame_get_this_base(struct trad_frame_cache *this_trad_cache)
Definition trad-frame.c:241
void trad_frame_set_this_base(struct trad_frame_cache *this_trad_cache, CORE_ADDR this_base)
Definition trad-frame.c:234
void trad_frame_set_reg_value(struct trad_frame_cache *this_cache, int regnum, LONGEST val)
Definition trad-frame.c:94
struct value * trad_frame_get_register(struct trad_frame_cache *this_trad_cache, frame_info_ptr this_frame, int regnum)
Definition trad-frame.c:211