Commit | Line | Data |
---|---|---|
a7068b60 TT |
1 | /* GDB target debugging macros |
2 | ||
e2882c85 | 3 | Copyright (C) 2014-2018 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) \ | |
45 | fputs_unfiltered ((E), gdb_stdlog); | |
46 | ||
47 | #define target_debug_print_struct_target_ops_p(X) \ | |
48 | target_debug_do_print (host_address_to_string (X)) | |
49 | #define target_debug_print_enum_target_object(X) \ | |
50 | target_debug_do_print (plongest (X)) | |
51 | #define target_debug_print_CORE_ADDR(X) \ | |
52 | target_debug_do_print (core_addr_to_string (X)) | |
53 | #define target_debug_print_const_char_p(X) \ | |
54 | target_debug_do_print (((X) ? (X) : "(null)")) | |
55 | #define target_debug_print_char_p(X) \ | |
56 | target_debug_do_print (((X) ? (X) : "(null)")) | |
57 | #define target_debug_print_int(X) \ | |
58 | target_debug_do_print (plongest (X)) | |
649a140c PA |
59 | #define target_debug_print_bool(X) \ |
60 | target_debug_do_print ((X) ? "true" : "false") | |
a7068b60 TT |
61 | #define target_debug_print_long(X) \ |
62 | target_debug_do_print (plongest (X)) | |
63 | #define target_debug_print_enum_target_xfer_status(X) \ | |
64 | target_debug_do_print (plongest (X)) | |
65 | #define target_debug_print_enum_exec_direction_kind(X) \ | |
66 | target_debug_do_print (plongest (X)) | |
67 | #define target_debug_print_enum_trace_find_type(X) \ | |
68 | target_debug_do_print (plongest (X)) | |
69 | #define target_debug_print_enum_btrace_read_type(X) \ | |
70 | target_debug_do_print (plongest (X)) | |
71 | #define target_debug_print_enum_btrace_error(X) \ | |
72 | target_debug_do_print (plongest (X)) | |
73 | #define target_debug_print_ptid_t(X) \ | |
74 | target_debug_do_print (plongest (ptid_get_pid (X))) | |
75 | #define target_debug_print_struct_gdbarch_p(X) \ | |
76 | target_debug_do_print (gdbarch_bfd_arch_info (X)->printable_name) | |
77 | #define target_debug_print_const_gdb_byte_p(X) \ | |
78 | target_debug_do_print (host_address_to_string (X)) | |
79 | #define target_debug_print_gdb_byte_p(X) \ | |
80 | target_debug_do_print (host_address_to_string (X)) | |
81 | #define target_debug_print_gdb_byte_pp(X) \ | |
82 | target_debug_do_print (host_address_to_string (*(X))) | |
83 | #define target_debug_print_enum_gdb_signal(X) \ | |
84 | target_debug_do_print (gdb_signal_to_name (X)) | |
85 | #define target_debug_print_ULONGEST(X) \ | |
86 | target_debug_do_print (hex_string (X)) | |
87 | #define target_debug_print_ULONGEST_p(X) \ | |
88 | target_debug_do_print (hex_string (*(X))) | |
89 | #define target_debug_print_LONGEST(X) \ | |
90 | target_debug_do_print (phex (X, 0)) | |
91 | #define target_debug_print_LONGEST_p(X) \ | |
92 | target_debug_do_print (phex (*(X), 0)) | |
93 | #define target_debug_print_struct_address_space_p(X) \ | |
94 | target_debug_do_print (plongest (address_space_num (X))) | |
95 | #define target_debug_print_struct_bp_target_info_p(X) \ | |
96 | target_debug_do_print (core_addr_to_string ((X)->placed_address)) | |
97 | #define target_debug_print_struct_expression_p(X) \ | |
98 | target_debug_do_print (host_address_to_string (X)) | |
99 | #define target_debug_print_CORE_ADDR_p(X) \ | |
100 | target_debug_do_print (core_addr_to_string (*(X))) | |
101 | #define target_debug_print_int_p(X) \ | |
102 | target_debug_do_print (plongest (*(X))) | |
103 | #define target_debug_print_struct_regcache_p(X) \ | |
104 | target_debug_do_print (host_address_to_string (X)) | |
105 | #define target_debug_print_struct_thread_info_p(X) \ | |
106 | target_debug_do_print (host_address_to_string (X)) | |
107 | #define target_debug_print_struct_ui_file_p(X) \ | |
108 | target_debug_do_print (host_address_to_string (X)) | |
109 | #define target_debug_print_struct_target_section_table_p(X) \ | |
110 | target_debug_do_print (host_address_to_string (X)) | |
111 | #define target_debug_print_async_callback_ftype_p(X) \ | |
112 | target_debug_do_print (host_address_to_string (X)) | |
113 | #define target_debug_print_void_p(X) \ | |
114 | target_debug_do_print (host_address_to_string (X)) | |
115 | #define target_debug_print_find_memory_region_ftype(X) \ | |
116 | target_debug_do_print (host_address_to_string (X)) | |
117 | #define target_debug_print_bfd_p(X) \ | |
118 | target_debug_do_print (host_address_to_string (X)) | |
1e97a227 | 119 | #define target_debug_print_std_vector_mem_region(X) \ |
a664f67e | 120 | target_debug_do_print (host_address_to_string (X.data ())) |
5d9310c4 SM |
121 | #define target_debug_print_std_vector_static_tracepoint_marker(X) \ |
122 | target_debug_do_print (host_address_to_string (X.data ())) | |
a7068b60 TT |
123 | #define target_debug_print_const_struct_target_desc_p(X) \ |
124 | target_debug_do_print (host_address_to_string (X)) | |
125 | #define target_debug_print_struct_bp_location_p(X) \ | |
126 | target_debug_do_print (host_address_to_string (X)) | |
127 | #define target_debug_print_struct_trace_state_variable_p(X) \ | |
128 | target_debug_do_print (host_address_to_string (X)) | |
c252925c SM |
129 | #define target_debug_print_const_trace_state_variable_r(X) \ |
130 | target_debug_do_print (host_address_to_string (&X)) | |
a7068b60 TT |
131 | #define target_debug_print_struct_trace_status_p(X) \ |
132 | target_debug_do_print (host_address_to_string (X)) | |
133 | #define target_debug_print_struct_breakpoint_p(X) \ | |
134 | target_debug_do_print (host_address_to_string (X)) | |
135 | #define target_debug_print_struct_uploaded_tp_p(X) \ | |
136 | target_debug_do_print (host_address_to_string (X)) | |
137 | #define target_debug_print_struct_uploaded_tp_pp(X) \ | |
138 | target_debug_do_print (host_address_to_string (X)) | |
139 | #define target_debug_print_struct_uploaded_tsv_pp(X) \ | |
140 | target_debug_do_print (host_address_to_string (X)) | |
5d9310c4 | 141 | #define target_debug_print_static_tracepoint_marker_p(X) \ |
a7068b60 TT |
142 | target_debug_do_print (host_address_to_string (X)) |
143 | #define target_debug_print_struct_traceframe_info_p(X) \ | |
144 | target_debug_do_print (host_address_to_string (X)) | |
145 | #define target_debug_print_struct_btrace_target_info_p(X) \ | |
146 | target_debug_do_print (host_address_to_string (X)) | |
147 | #define target_debug_print_VEC__btrace_block_s__pp(X) \ | |
148 | target_debug_do_print (host_address_to_string (X)) | |
149 | #define target_debug_print_const_struct_frame_unwind_p(X) \ | |
150 | target_debug_do_print (host_address_to_string (X)) | |
734b0e4b MM |
151 | #define target_debug_print_struct_btrace_data_p(X) \ |
152 | target_debug_do_print (host_address_to_string (X)) | |
043c3577 MM |
153 | #define target_debug_print_enum_btrace_format(X) \ |
154 | target_debug_do_print (plongest (X)) | |
b158a20f TW |
155 | #define target_debug_print_enum_record_method(X) \ |
156 | target_debug_do_print (plongest (X)) | |
f4abbc16 MM |
157 | #define target_debug_print_const_struct_btrace_config_p(X) \ |
158 | target_debug_do_print (host_address_to_string (X)) | |
159 | #define target_debug_print_const_struct_btrace_target_info_p(X) \ | |
160 | target_debug_do_print (host_address_to_string (X)) | |
f486487f SM |
161 | #define target_debug_print_enum_target_hw_bp_type(X) \ |
162 | target_debug_do_print (plongest (X)) | |
163 | #define target_debug_print_enum_bptype(X) \ | |
164 | target_debug_do_print (plongest (X)) | |
94585166 DB |
165 | #define target_debug_print_struct_inferior_p(X) \ |
166 | target_debug_do_print (host_address_to_string (X)) | |
73971819 PA |
167 | #define target_debug_print_enum_remove_bp_reason(X) \ |
168 | target_debug_do_print (plongest (X)) | |
9a24775b PA |
169 | #define target_debug_print_gdb_disassembly_flags(X) \ |
170 | target_debug_do_print (plongest (X)) | |
2098b393 SM |
171 | #define target_debug_print_traceframe_info_up(X) \ |
172 | target_debug_do_print (host_address_to_string (X.get ())) | |
649a140c PA |
173 | #define target_debug_print_gdb_array_view_const_int(X) \ |
174 | target_debug_do_print (host_address_to_string (X.data ())) | |
6e1e1966 SM |
175 | #define target_debug_print_inferior_p(inf) \ |
176 | target_debug_do_print (host_address_to_string (inf)) | |
0cb7c7b0 SM |
177 | #define target_debug_print_record_print_flags(X) \ |
178 | target_debug_do_print (plongest (X)) | |
f6ac5f3d PA |
179 | #define target_debug_print_enum_info_proc_what(X) \ |
180 | target_debug_do_print (plongest (X)) | |
181 | #define target_debug_print_thread_control_capabilities(X) \ | |
182 | target_debug_do_print (plongest (X)) | |
183 | #define target_debug_print_thread_info_p(X) \ | |
184 | target_debug_do_print (host_address_to_string (X)) | |
00431a78 PA |
185 | #define target_debug_print_thread_info_pp(X) \ |
186 | target_debug_do_print (host_address_to_string (X)) | |
a7068b60 TT |
187 | |
188 | static void | |
189 | target_debug_print_struct_target_waitstatus_p (struct target_waitstatus *status) | |
190 | { | |
23fdd69e | 191 | std::string str = target_waitstatus_to_string (status); |
a7068b60 | 192 | |
23fdd69e | 193 | fputs_unfiltered (str.c_str (), gdb_stdlog); |
a7068b60 TT |
194 | } |
195 | ||
196 | \f | |
197 | ||
198 | /* Macros or functions that are used via TARGET_DEBUG_PRINTER. */ | |
199 | ||
200 | #define target_debug_print_step(X) \ | |
201 | target_debug_do_print ((X) ? "step" : "continue") | |
202 | ||
203 | static void | |
204 | target_debug_print_options (int options) | |
205 | { | |
206 | char *str = target_options_to_string (options); | |
207 | ||
208 | fputs_unfiltered (str, gdb_stdlog); | |
209 | xfree (str); | |
210 | } | |
211 | ||
212 | static void | |
213 | target_debug_print_signals (unsigned char *sigs) | |
214 | { | |
215 | fputs_unfiltered ("{", gdb_stdlog); | |
216 | if (sigs != NULL) | |
217 | { | |
218 | int i; | |
219 | ||
220 | for (i = 0; i < GDB_SIGNAL_LAST; i++) | |
221 | if (sigs[i]) | |
aead7601 SM |
222 | { |
223 | fprintf_unfiltered (gdb_stdlog, " %s", | |
224 | gdb_signal_to_name ((enum gdb_signal) i)); | |
225 | } | |
a7068b60 TT |
226 | } |
227 | fputs_unfiltered (" }", gdb_stdlog); | |
228 | } | |
229 | ||
230 | #endif /* TARGET_DEBUG_H */ |