]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/target-debug.h
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / target-debug.h
CommitLineData
a7068b60
TT
1/* GDB target debugging macros
2
1d506c26 3 Copyright (C) 2014-2024 Free Software Foundation, Inc.
a7068b60
TT
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 TARGET_DEBUG_H
21#define TARGET_DEBUG_H
22
23/* Printers for the debug target. Each prints an object of a given
24 type to a string that needn't be freed. Most printers are macros,
25 for brevity, but a few are static functions where more complicated
26 behavior is needed.
27
28 References to these printers are automatically generated by
29 make-target-delegates. See the generated file target-delegates.c.
30
31 In a couple cases, a special printing function is defined and then
32 used via the TARGET_DEBUG_PRINTER macro. See target.h.
33
34 A few methods still have some explicit targetdebug code in
35 target.c. In most cases this is because target delegation hasn't
36 been done for the method; but individual cases vary. For instance,
37 target_store_registers does some special register printing that is
38 more simply done there, and target_xfer_partial additionally
39 bypasses the debug target. */
40
41
42/* Helper macro. */
43
44#define target_debug_do_print(E) \
0426ad51 45 gdb_puts ((E), gdb_stdlog);
a7068b60 46
e7bb5090 47#define target_debug_print_target_object(X) \
a7068b60
TT
48 target_debug_do_print (plongest (X))
49#define target_debug_print_CORE_ADDR(X) \
50 target_debug_do_print (core_addr_to_string (X))
51#define target_debug_print_const_char_p(X) \
52 target_debug_do_print (((X) ? (X) : "(null)"))
53#define target_debug_print_char_p(X) \
54 target_debug_do_print (((X) ? (X) : "(null)"))
55#define target_debug_print_int(X) \
56 target_debug_do_print (plongest (X))
649a140c
PA
57#define target_debug_print_bool(X) \
58 target_debug_do_print ((X) ? "true" : "false")
a7068b60
TT
59#define target_debug_print_long(X) \
60 target_debug_do_print (plongest (X))
e7bb5090 61#define target_debug_print_target_xfer_status(X) \
a7068b60 62 target_debug_do_print (plongest (X))
e7bb5090 63#define target_debug_print_exec_direction_kind(X) \
a7068b60 64 target_debug_do_print (plongest (X))
e7bb5090 65#define target_debug_print_trace_find_type(X) \
a7068b60 66 target_debug_do_print (plongest (X))
e7bb5090 67#define target_debug_print_btrace_read_type(X) \
a7068b60 68 target_debug_do_print (plongest (X))
e7bb5090 69#define target_debug_print_btrace_error(X) \
a7068b60
TT
70 target_debug_do_print (plongest (X))
71#define target_debug_print_ptid_t(X) \
e99b03dc 72 target_debug_do_print (plongest (X.pid ()))
e7bb5090 73#define target_debug_print_gdbarch_p(X) \
a7068b60
TT
74 target_debug_do_print (gdbarch_bfd_arch_info (X)->printable_name)
75#define target_debug_print_const_gdb_byte_p(X) \
76 target_debug_do_print (host_address_to_string (X))
77#define target_debug_print_gdb_byte_p(X) \
78 target_debug_do_print (host_address_to_string (X))
3fe639b8 79#define target_debug_print_const_gdb_byte_pp(X) \
a7068b60 80 target_debug_do_print (host_address_to_string (*(X)))
e7bb5090 81#define target_debug_print_gdb_signal(X) \
a7068b60
TT
82 target_debug_do_print (gdb_signal_to_name (X))
83#define target_debug_print_ULONGEST(X) \
84 target_debug_do_print (hex_string (X))
85#define target_debug_print_ULONGEST_p(X) \
86 target_debug_do_print (hex_string (*(X)))
87#define target_debug_print_LONGEST(X) \
88 target_debug_do_print (phex (X, 0))
89#define target_debug_print_LONGEST_p(X) \
90 target_debug_do_print (phex (*(X), 0))
e7bb5090 91#define target_debug_print_address_space_p(X) \
b382c166 92 target_debug_do_print (plongest ((X)->num ()))
e7bb5090 93#define target_debug_print_bp_target_info_p(X) \
a7068b60 94 target_debug_do_print (core_addr_to_string ((X)->placed_address))
e7bb5090 95#define target_debug_print_expression_p(X) \
a7068b60
TT
96 target_debug_do_print (host_address_to_string (X))
97#define target_debug_print_CORE_ADDR_p(X) \
98 target_debug_do_print (core_addr_to_string (*(X)))
99#define target_debug_print_int_p(X) \
100 target_debug_do_print (plongest (*(X)))
e7bb5090 101#define target_debug_print_regcache_p(X) \
a7068b60 102 target_debug_do_print (host_address_to_string (X))
e7bb5090 103#define target_debug_print_thread_info_p(X) \
a7068b60 104 target_debug_do_print (host_address_to_string (X))
e7bb5090 105#define target_debug_print_ui_file_p(X) \
a7068b60 106 target_debug_do_print (host_address_to_string (X))
25b5a04e
SM
107#define target_debug_print_const_std_vector_target_section_p(X) \
108 target_debug_do_print (host_address_to_string (X->data ()))
a7068b60
TT
109#define target_debug_print_void_p(X) \
110 target_debug_do_print (host_address_to_string (X))
111#define target_debug_print_find_memory_region_ftype(X) \
112 target_debug_do_print (host_address_to_string (X))
113#define target_debug_print_bfd_p(X) \
114 target_debug_do_print (host_address_to_string (X))
1e97a227 115#define target_debug_print_std_vector_mem_region(X) \
a664f67e 116 target_debug_do_print (host_address_to_string (X.data ()))
5d9310c4
SM
117#define target_debug_print_std_vector_static_tracepoint_marker(X) \
118 target_debug_do_print (host_address_to_string (X.data ()))
e7bb5090 119#define target_debug_print_const_target_desc_p(X) \
a7068b60 120 target_debug_do_print (host_address_to_string (X))
e7bb5090 121#define target_debug_print_bp_location_p(X) \
a7068b60 122 target_debug_do_print (host_address_to_string (X))
c252925c
SM
123#define target_debug_print_const_trace_state_variable_r(X) \
124 target_debug_do_print (host_address_to_string (&X))
e7bb5090 125#define target_debug_print_trace_status_p(X) \
a7068b60 126 target_debug_do_print (host_address_to_string (X))
e7bb5090 127#define target_debug_print_breakpoint_p(X) \
a7068b60 128 target_debug_do_print (host_address_to_string (X))
01bccc56
TT
129#define target_debug_print_tracepoint_p(X) \
130 target_debug_do_print (host_address_to_string (X))
e7bb5090 131#define target_debug_print_uploaded_tp_p(X) \
a7068b60 132 target_debug_do_print (host_address_to_string (X))
e7bb5090 133#define target_debug_print_uploaded_tp_pp(X) \
a7068b60 134 target_debug_do_print (host_address_to_string (X))
e7bb5090 135#define target_debug_print_uploaded_tsv_pp(X) \
a7068b60 136 target_debug_do_print (host_address_to_string (X))
5d9310c4 137#define target_debug_print_static_tracepoint_marker_p(X) \
a7068b60 138 target_debug_do_print (host_address_to_string (X))
e7bb5090 139#define target_debug_print_btrace_target_info_p(X) \
a7068b60 140 target_debug_do_print (host_address_to_string (X))
e7bb5090 141#define target_debug_print_const_frame_unwind_p(X) \
a7068b60 142 target_debug_do_print (host_address_to_string (X))
e7bb5090 143#define target_debug_print_btrace_data_p(X) \
734b0e4b 144 target_debug_do_print (host_address_to_string (X))
e7bb5090 145#define target_debug_print_record_method(X) \
b158a20f 146 target_debug_do_print (plongest (X))
e7bb5090 147#define target_debug_print_const_btrace_config_p(X) \
f4abbc16 148 target_debug_do_print (host_address_to_string (X))
e7bb5090 149#define target_debug_print_const_btrace_target_info_p(X) \
f4abbc16 150 target_debug_do_print (host_address_to_string (X))
e7bb5090 151#define target_debug_print_target_hw_bp_type(X) \
f486487f 152 target_debug_do_print (plongest (X))
e7bb5090 153#define target_debug_print_bptype(X) \
f486487f 154 target_debug_do_print (plongest (X))
e7bb5090 155#define target_debug_print_inferior_p(X) \
94585166 156 target_debug_do_print (host_address_to_string (X))
e7bb5090 157#define target_debug_print_remove_bp_reason(X) \
73971819 158 target_debug_do_print (plongest (X))
9a24775b
PA
159#define target_debug_print_gdb_disassembly_flags(X) \
160 target_debug_do_print (plongest (X))
2098b393
SM
161#define target_debug_print_traceframe_info_up(X) \
162 target_debug_do_print (host_address_to_string (X.get ()))
649a140c
PA
163#define target_debug_print_gdb_array_view_const_int(X) \
164 target_debug_do_print (host_address_to_string (X.data ()))
0cb7c7b0
SM
165#define target_debug_print_record_print_flags(X) \
166 target_debug_do_print (plongest (X))
f6ac5f3d
PA
167#define target_debug_print_thread_control_capabilities(X) \
168 target_debug_do_print (plongest (X))
169#define target_debug_print_thread_info_p(X) \
170 target_debug_do_print (host_address_to_string (X))
a068643d
TT
171#define target_debug_print_std_string(X) \
172 target_debug_do_print ((X).c_str ())
3d6c6204
KB
173#define target_debug_print_gdb_byte_vector(X) \
174 target_debug_do_print (host_address_to_string (X.data ()))
24f5300a
SM
175#define target_debug_print_gdb_unique_xmalloc_ptr_char(X) \
176 target_debug_do_print (X.get ())
3a849a34
SM
177#define target_debug_print_target_waitkind(X) \
178 target_debug_do_print (pulongest (X))
65c459ab
PA
179#define target_debug_print_gdb_thread_options(X) \
180 target_debug_do_print (to_string (X).c_str ())
a7068b60
TT
181
182static void
e7bb5090 183target_debug_print_target_waitstatus_p (struct target_waitstatus *status)
a7068b60 184{
0426ad51 185 gdb_puts (status->to_string ().c_str (), gdb_stdlog);
a7068b60
TT
186}
187
188\f
189
190/* Macros or functions that are used via TARGET_DEBUG_PRINTER. */
191
192#define target_debug_print_step(X) \
193 target_debug_do_print ((X) ? "step" : "continue")
194
195static void
b60cea74 196target_debug_print_target_wait_flags (target_wait_flags options)
a7068b60 197{
09ce46f2 198 std::string str = target_options_to_string (options);
a7068b60 199
0426ad51 200 gdb_puts (str.c_str (), gdb_stdlog);
a7068b60
TT
201}
202
203static void
adc6a863 204target_debug_print_signals (gdb::array_view<const unsigned char> sigs)
a7068b60 205{
0426ad51 206 gdb_puts ("{", gdb_stdlog);
adc6a863
PA
207
208 for (size_t i = 0; i < sigs.size (); i++)
209 if (sigs[i] != 0)
210 {
6cb06a8c
TT
211 gdb_printf (gdb_stdlog, " %s",
212 gdb_signal_to_name ((enum gdb_signal) i));
adc6a863 213 }
0426ad51 214 gdb_puts (" }", gdb_stdlog);
a7068b60
TT
215}
216
dbe692af
LM
217static void
218target_debug_print_size_t (size_t size)
219{
6cb06a8c 220 gdb_printf (gdb_stdlog, "%s", pulongest (size));
dbe692af
LM
221}
222
223static void
1f08d324 224target_debug_print_gdb_array_view_const_gdb_byte (gdb::array_view<const gdb_byte> vector)
dbe692af 225{
0426ad51 226 gdb_puts ("{", gdb_stdlog);
dbe692af
LM
227
228 for (size_t i = 0; i < vector.size (); i++)
229 {
6cb06a8c
TT
230 gdb_printf (gdb_stdlog, " %s",
231 phex_nz (vector[i], 1));
dbe692af 232 }
0426ad51 233 gdb_puts (" }", gdb_stdlog);
dbe692af
LM
234}
235
1f08d324
TV
236static void
237target_debug_print_const_gdb_byte_vector_r (const gdb::byte_vector &vector)
238{
239 target_debug_print_gdb_array_view_const_gdb_byte (vector);
240}
241
dbe692af
LM
242static void
243target_debug_print_gdb_byte_vector_r (gdb::byte_vector &vector)
244{
245 target_debug_print_const_gdb_byte_vector_r (vector);
246}
a388ab0b
JB
247
248static void
249target_debug_print_x86_xsave_layout (const x86_xsave_layout &layout)
250{
251 gdb_puts ("{", gdb_stdlog);
252 gdb_printf (gdb_stdlog, " sizeof_xsave=%d", layout.sizeof_xsave);
253#define POFFS(region) \
254 if (layout.region##_offset != 0) \
255 gdb_printf (gdb_stdlog, ", %s_offset=%d", #region, \
256 layout.region##_offset)
257 POFFS(avx);
258 POFFS(bndregs);
259 POFFS(bndcfg);
260 POFFS(k);
261 POFFS(zmm_h);
262 POFFS(zmm);
263 POFFS(pkru);
264#undef POFFS
265 gdb_puts (" }", gdb_stdlog);
266}
a7068b60 267#endif /* TARGET_DEBUG_H */