GNU Binutils with patches for OS216
修訂 | c36205f0ccc36ac47b0191c02ceb5c06459ebea3 (tree) |
---|---|
時間 | 2019-07-02 04:19:04 |
作者 | Pedro Alves <palves@redh...> |
Commiter | Pedro Alves |
Document the gdb-specific formatters
@@ -189,8 +189,54 @@ class ui_out | ||
189 | 189 | |
190 | 190 | void spaces (int numspaces); |
191 | 191 | void text (const char *string); |
192 | + | |
193 | + /* Output a printf-style formatted string. In addition to the usual | |
194 | + printf format specs, this supports a few GDB-specific | |
195 | + formatters: | |
196 | + | |
197 | + - '%pF' - output a field. | |
198 | + | |
199 | + The argument is a field, wrapped in any of the base_field_s | |
200 | + subclasses. int_field for integer fields, styled_field for | |
201 | + string fields. This is preferred over separate | |
202 | + uiout->field_int(), uiout_>field_string() etc. calls when the | |
203 | + formatted message is translatable. E.g.: | |
204 | + | |
205 | + uiout->message (_("\nWatchpoint %pF deleted because the program has " | |
206 | + "left the block in\n" | |
207 | + "which its expression is valid.\n"), | |
208 | + int_field ("wpnum", b->number)); | |
209 | + | |
210 | + - '%p[' - output the following text in a specified style. | |
211 | + '%p]' - output the following text in the default style. | |
212 | + | |
213 | + The argument to '%p[' is a ui_file_style pointer. The argument | |
214 | + to '%p]' must be nullptr. | |
215 | + | |
216 | + This is useful when you want to output some portion of a string | |
217 | + literal in some style. E.g.: | |
218 | + | |
219 | + uiout->message (_(" %p[<repeats %u times>%p]"), | |
220 | + metadata_style.style ().ptr (), | |
221 | + reps, repeats, nullptr); | |
222 | + | |
223 | + - '%ps' - output a styled string. | |
224 | + | |
225 | + The argument is the result of a call to styled_string. This is | |
226 | + useful when you want to output some runtime-generated string in | |
227 | + some style. E.g.: | |
228 | + | |
229 | + uiout->message (_("this is a target address %ps.\n"), | |
230 | + styled_string (address_style.style (), | |
231 | + paddress (gdbarch, pc))); | |
232 | + | |
233 | + Note that these all "abuse" the %p printf format spec, in order | |
234 | + to be compatible with GCC's printf format checking. This is OK | |
235 | + because code in GDB that wants to print a host address should use | |
236 | + host_address_to_string instead of %p. */ | |
192 | 237 | void message (const char *format, ...) ATTRIBUTE_PRINTF (2, 3); |
193 | 238 | void vmessage (const char *format, va_list args) ATTRIBUTE_PRINTF (2, 0); |
239 | + | |
194 | 240 | void wrap_hint (const char *identstring); |
195 | 241 | |
196 | 242 | void flush (); |
@@ -349,7 +349,10 @@ extern struct ui_file *gdb_stdtargin; | ||
349 | 349 | extern void set_screen_width_and_height (int width, int height); |
350 | 350 | |
351 | 351 | /* More generic printf like operations. Filtered versions may return |
352 | - non-locally on error. */ | |
352 | + non-locally on error. As an extension over plain printf, these | |
353 | + support some GDB-specific format specifiers. Particularly useful | |
354 | + here are the styling formatters: '%p[', '%p]' and '%ps'. See | |
355 | + ui_out::message for details. */ | |
353 | 356 | |
354 | 357 | extern void fputs_filtered (const char *, struct ui_file *); |
355 | 358 |