GDB (xrefs)
Loading...
Searching...
No Matches
call-site.h
Go to the documentation of this file.
1/* Call site information.
2
3 Copyright (C) 2011-2023 Free Software Foundation, Inc.
4
5 Contributed by Cygnus Support, using pieces from other GDB modules.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22#ifndef CALL_SITE_H
23#define CALL_SITE_H
24
25#include "dwarf2/types.h"
26#include "../frame.h"
27#include "gdbsupport/function-view.h"
28
32
33/* struct call_site_parameter can be referenced in callees by several ways. */
34
36{
37 /* * Use field call_site_parameter.u.dwarf_reg. */
39
40 /* * Use field call_site_parameter.u.fb_offset. */
42
43 /* * Use field call_site_parameter.u.param_offset. */
45};
46
48{
49 /* The kind of location held by this call site target. */
50 enum kind
51 {
52 /* An address. */
54 /* A name. */
56 /* A DWARF block. */
58 /* An array of addresses. */
60 };
61
62 void set_loc_physaddr (unrelocated_addr physaddr)
63 {
65 m_loc.physaddr = physaddr;
66 }
67
68 void set_loc_physname (const char *physname)
69 {
71 m_loc.physname = physname;
72 }
73
79
80 void set_loc_array (unsigned length, const unrelocated_addr *data)
81 {
83 m_loc.addresses.length = length;
84 m_loc.addresses.values = data;
85 }
86
87 /* Callback type for iterate_over_addresses. */
88
89 using iterate_ftype = gdb::function_view<void (CORE_ADDR)>;
90
91 /* Call CALLBACK for each DW_TAG_call_site's DW_AT_call_target
92 address. CALLER_FRAME (for registers) can be NULL if it is not
93 known. This function always may throw NO_ENTRY_VALUE_ERROR. */
94
95 void iterate_over_addresses (struct gdbarch *call_site_gdbarch,
96 const struct call_site *call_site,
97 frame_info_ptr caller_frame,
98 iterate_ftype callback) const;
99
100private:
101
102 union
103 {
104 /* Address. */
105 unrelocated_addr physaddr;
106 /* Mangled name. */
107 const char *physname;
108 /* DWARF block. */
110 /* Array of addresses. */
111 struct
112 {
113 unsigned length;
114 const unrelocated_addr *values;
117
118 /* * Discriminant for union field_location. */
120};
121
123{
124 /* * DW_TAG_formal_parameter's DW_AT_location's DW_OP_regX
125 as DWARF register number, for register passed
126 parameters. */
127
129
130 /* * Offset from the callee's frame base, for stack passed
131 parameters. This equals offset from the caller's stack
132 pointer. */
133
134 CORE_ADDR fb_offset;
135
136 /* * Offset relative to the start of this PER_CU to
137 DW_TAG_formal_parameter which is referenced by both
138 caller and the callee. */
139
140 cu_offset param_cu_off;
141};
142
144{
145 ENUM_BITFIELD (call_site_parameter_kind) kind : 2;
146
148
149 /* * DW_TAG_formal_parameter's DW_AT_call_value. It is never NULL. */
150
151 const gdb_byte *value;
153
154 /* * DW_TAG_formal_parameter's DW_AT_call_data_value.
155 It may be NULL if not provided by DWARF. */
156
157 const gdb_byte *data_value;
159};
160
161/* * A place where a function gets called from, represented by
162 DW_TAG_call_site. It can be looked up from symtab->call_site_htab. */
163
165{
170
171 static int
172 eq (const call_site *a, const call_site *b)
173 {
174 return a->m_unrelocated_pc == b->m_unrelocated_pc;
175 }
176
177 static hashval_t
178 hash (const call_site *a)
179 {
180 return (hashval_t) a->m_unrelocated_pc;
181 }
182
183 static int
184 eq (const void *a, const void *b)
185 {
186 return eq ((const call_site *)a, (const call_site *)b);
187 }
188
189 static hashval_t
190 hash (const void *a)
191 {
192 return hash ((const call_site *)a);
193 }
194
195 /* Return the address of the first instruction after this call. */
196
197 CORE_ADDR pc () const;
198
199 /* Call CALLBACK for each target address. CALLER_FRAME (for
200 registers) can be NULL if it is not known. This function may
201 throw NO_ENTRY_VALUE_ERROR. */
202
203 void iterate_over_addresses (struct gdbarch *call_site_gdbarch,
204 frame_info_ptr caller_frame,
206 const
207 {
208 return target.iterate_over_addresses (call_site_gdbarch, this,
209 caller_frame, callback);
210 }
211
212 /* * List successor with head in FUNC_TYPE.TAIL_CALL_LIST. */
213
214 struct call_site *tail_call_next = nullptr;
215
216 /* * Describe DW_AT_call_target. Missing attribute uses
217 FIELD_LOC_KIND_DWARF_BLOCK with FIELD_DWARF_BLOCK == NULL. */
218
220
221 /* * Size of the PARAMETER array. */
222
223 unsigned parameter_count = 0;
224
225 /* * CU of the function where the call is located. It gets used
226 for DWARF blocks execution in the parameter array below. */
227
228 dwarf2_per_cu_data *const per_cu = nullptr;
229
230 /* objfile of the function where the call is located. */
231
233
234private:
235 /* Unrelocated address of the first instruction after this call. */
236 const unrelocated_addr m_unrelocated_pc;
237
238public:
239 /* * Describe DW_TAG_call_site's DW_TAG_formal_parameter. */
240
242};
243
244#endif /* CALL_SITE_H */
call_site_parameter_kind
Definition call-site.h:36
@ CALL_SITE_PARAMETER_FB_OFFSET
Definition call-site.h:41
@ CALL_SITE_PARAMETER_DWARF_REG
Definition call-site.h:38
@ CALL_SITE_PARAMETER_PARAM_OFFSET
Definition call-site.h:44
__extension__ enum call_site_parameter_kind kind
Definition call-site.h:145
const gdb_byte * value
Definition call-site.h:151
union call_site_parameter_u u
Definition call-site.h:147
const gdb_byte * data_value
Definition call-site.h:157
const unrelocated_addr * values
Definition call-site.h:114
struct dwarf2_locexpr_baton * dwarf_block
Definition call-site.h:109
enum kind m_loc_kind
Definition call-site.h:119
void iterate_over_addresses(struct gdbarch *call_site_gdbarch, const struct call_site *call_site, frame_info_ptr caller_frame, iterate_ftype callback) const
Definition loc.c:653
void set_loc_dwarf_block(dwarf2_locexpr_baton *dwarf_block)
Definition call-site.h:74
void set_loc_physname(const char *physname)
Definition call-site.h:68
const char * physname
Definition call-site.h:107
unrelocated_addr physaddr
Definition call-site.h:105
void set_loc_physaddr(unrelocated_addr physaddr)
Definition call-site.h:62
struct call_site_target::@40::@41 addresses
unsigned length
Definition call-site.h:113
void set_loc_array(unsigned length, const unrelocated_addr *data)
Definition call-site.h:80
gdb::function_view< void(CORE_ADDR)> iterate_ftype
Definition call-site.h:89
union call_site_target::@40 m_loc
unsigned parameter_count
Definition call-site.h:223
static hashval_t hash(const call_site *a)
Definition call-site.h:178
static int eq(const void *a, const void *b)
Definition call-site.h:184
const unrelocated_addr m_unrelocated_pc
Definition call-site.h:236
struct call_site_parameter parameter[]
Definition call-site.h:241
CORE_ADDR pc() const
Definition gdbtypes.c:6188
void iterate_over_addresses(struct gdbarch *call_site_gdbarch, frame_info_ptr caller_frame, call_site_target::iterate_ftype callback) const
Definition call-site.h:203
call_site(unrelocated_addr pc, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile)
Definition call-site.h:166
static int eq(const call_site *a, const call_site *b)
Definition call-site.h:172
static hashval_t hash(const void *a)
Definition call-site.h:190
struct call_site * tail_call_next
Definition call-site.h:214
dwarf2_per_cu_data *const per_cu
Definition call-site.h:228
dwarf2_per_objfile *const per_objfile
Definition call-site.h:232