GNU Binutils with patches for OS216
Revisión | bef62542b4f0f650e65ddcb72611116e73df9269 (tree) |
---|---|
Tiempo | 2019-06-05 17:17:16 |
Autor | Pedro Alves <palves@redh...> |
Commiter | Pedro Alves |
Make ui_out::message support %pF, %pS, %pN
@@ -4927,10 +4927,10 @@ watchpoint_check (bpstat bs) | ||
4927 | 4927 | if (uiout->is_mi_like_p ()) |
4928 | 4928 | uiout->field_string |
4929 | 4929 | ("reason", async_reason_lookup (EXEC_ASYNC_WATCHPOINT_SCOPE)); |
4930 | - uiout->text ("\nWatchpoint "); | |
4931 | - uiout->field_int ("wpnum", b->number); | |
4932 | - uiout->text (" deleted because the program has left the block in\n" | |
4933 | - "which its expression is valid.\n"); | |
4930 | + uiout->message ("\nWatchpoint %pF deleted because the program has " | |
4931 | + "left the block in\n" | |
4932 | + "which its expression is valid.\n", | |
4933 | + int_field ("wpnum", b->number).ptr ()); | |
4934 | 4934 | } |
4935 | 4935 | |
4936 | 4936 | /* Make sure the watchpoint's commands aren't executed. */ |
@@ -6245,9 +6245,8 @@ print_one_breakpoint_location (struct breakpoint *b, | ||
6245 | 6245 | if (!part_of_multiple && b->ignore_count) |
6246 | 6246 | { |
6247 | 6247 | annotate_field (8); |
6248 | - uiout->text ("\tignore next "); | |
6249 | - uiout->field_int ("ignore", b->ignore_count); | |
6250 | - uiout->text (" hits\n"); | |
6248 | + uiout->message ("\tignore next %pF hits\n", | |
6249 | + int_field ("ignore", b->ignore_count).ptr ()); | |
6251 | 6250 | } |
6252 | 6251 | |
6253 | 6252 | /* Note that an enable count of 1 corresponds to "enable once" |
@@ -12428,18 +12427,18 @@ bkpt_print_it (bpstat bs) | ||
12428 | 12427 | annotate_breakpoint (b->number); |
12429 | 12428 | maybe_print_thread_hit_breakpoint (uiout); |
12430 | 12429 | |
12431 | - if (bp_temp) | |
12432 | - uiout->text ("Temporary breakpoint "); | |
12433 | - else | |
12434 | - uiout->text ("Breakpoint "); | |
12435 | 12430 | if (uiout->is_mi_like_p ()) |
12436 | 12431 | { |
12437 | 12432 | uiout->field_string ("reason", |
12438 | 12433 | async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT)); |
12439 | 12434 | uiout->field_string ("disp", bpdisp_text (b->disposition)); |
12440 | 12435 | } |
12441 | - uiout->field_int ("bkptno", b->number); | |
12442 | - uiout->text (", "); | |
12436 | + if (bp_temp) | |
12437 | + uiout->message ("Temporary breakpoint %pF, ", | |
12438 | + int_field ("bkptno", b->number).ptr ()); | |
12439 | + else | |
12440 | + uiout->message ("Breakpoint %pF, ", | |
12441 | + int_field ("bkptno", b->number).ptr ()); | |
12443 | 12442 | |
12444 | 12443 | return PRINT_SRC_AND_LOC; |
12445 | 12444 | } |
@@ -20,7 +20,7 @@ | ||
20 | 20 | #include "common-defs.h" |
21 | 21 | #include "format.h" |
22 | 22 | |
23 | -format_pieces::format_pieces (const char **arg) | |
23 | +format_pieces::format_pieces (const char **arg, bool gdb_extensions) | |
24 | 24 | { |
25 | 25 | const char *s; |
26 | 26 | char *f, *string; |
@@ -251,6 +251,19 @@ format_pieces::format_pieces (const char **arg) | ||
251 | 251 | bad = 1; |
252 | 252 | if (seen_hash || seen_zero || seen_space || seen_plus) |
253 | 253 | bad = 1; |
254 | + | |
255 | + if (gdb_extensions) | |
256 | + { | |
257 | + switch (f[1]) | |
258 | + { | |
259 | + case 'S': | |
260 | + case 'F': | |
261 | + case 'N': | |
262 | + f++; | |
263 | + break; | |
264 | + } | |
265 | + } | |
266 | + | |
254 | 267 | break; |
255 | 268 | |
256 | 269 | case 's': |
@@ -70,7 +70,7 @@ class format_pieces | ||
70 | 70 | { |
71 | 71 | public: |
72 | 72 | |
73 | - format_pieces (const char **arg); | |
73 | + format_pieces (const char **arg, bool gdb_extensions = false); | |
74 | 74 | ~format_pieces () = default; |
75 | 75 | |
76 | 76 | DISABLE_COPY_AND_ASSIGN (format_pieces); |
@@ -24,6 +24,7 @@ | ||
24 | 24 | #include "expression.h" /* For language.h */ |
25 | 25 | #include "language.h" |
26 | 26 | #include "ui-out.h" |
27 | +#include "common/format.h" | |
27 | 28 | |
28 | 29 | #include <vector> |
29 | 30 | #include <memory> |
@@ -547,7 +548,7 @@ ui_out::text (const char *string) | ||
547 | 548 | } |
548 | 549 | |
549 | 550 | void |
550 | -ui_out::message (const char *format, ...) | |
551 | +ui_out::call_do_message (const char *format, ...) | |
551 | 552 | { |
552 | 553 | va_list args; |
553 | 554 |
@@ -557,6 +558,89 @@ ui_out::message (const char *format, ...) | ||
557 | 558 | } |
558 | 559 | |
559 | 560 | void |
561 | +ui_out::message (const char *format, ...) | |
562 | +{ | |
563 | + format_pieces fpieces (&format, true); | |
564 | + | |
565 | + va_list args; | |
566 | + va_start (args, format); | |
567 | + | |
568 | + for (auto &&piece : fpieces) | |
569 | + { | |
570 | + const char *current_substring = piece.string; | |
571 | + | |
572 | + switch (piece.argclass) | |
573 | + { | |
574 | + case string_arg: | |
575 | + call_do_message (current_substring, va_arg (args, const char *)); | |
576 | + break; | |
577 | + case wide_string_arg: | |
578 | + /* FIXME */ | |
579 | + break; | |
580 | + case wide_char_arg: | |
581 | + /* FIXME */ | |
582 | + break; | |
583 | + case long_long_arg: | |
584 | +#ifdef PRINTF_HAS_LONG_LONG | |
585 | + call_do_message (current_substring, va_arg (args, long long)); | |
586 | + break; | |
587 | +#else | |
588 | + error (_("long long not supported in ui_out::message")); | |
589 | +#endif | |
590 | + case int_arg: | |
591 | + call_do_message (current_substring, va_arg (args, int)); | |
592 | + break; | |
593 | + case long_arg: | |
594 | + call_do_message (current_substring, va_arg (args, long)); | |
595 | + break; | |
596 | + /* Handle floating-point values. */ | |
597 | + case double_arg: | |
598 | + case long_double_arg: | |
599 | + case dec32float_arg: | |
600 | + case dec64float_arg: | |
601 | + case dec128float_arg: | |
602 | + /* FIXME */ | |
603 | + break; | |
604 | + case ptr_arg: | |
605 | + switch (current_substring[2]) | |
606 | + { | |
607 | + case 'F': | |
608 | + { | |
609 | + int_field *field = va_arg (args, int_field *); | |
610 | + field_int (field->name (), field->val ()); | |
611 | + } | |
612 | + break; | |
613 | + case 'S': | |
614 | + /* Push style on stack? */ | |
615 | + break; | |
616 | + case 'N': | |
617 | + /* Pop style from stack? */ | |
618 | + break; | |
619 | + default: | |
620 | + call_do_message (current_substring, va_arg (args, void *)); | |
621 | + break; | |
622 | + } | |
623 | + break; | |
624 | + case literal_piece: | |
625 | + /* Print a portion of the format string that has no | |
626 | + directives. Note that this will not include any ordinary | |
627 | + %-specs, but it might include "%%". That is why we use | |
628 | + printf_filtered and not puts_filtered here. Also, we | |
629 | + pass a dummy argument because some platforms have | |
630 | + modified GCC to include -Wformat-security by default, | |
631 | + which will warn here if there is no argument. */ | |
632 | + call_do_message (current_substring, 0); | |
633 | + break; | |
634 | + default: | |
635 | + internal_error (__FILE__, __LINE__, | |
636 | + _("failed internal consistency check")); | |
637 | + } | |
638 | + } | |
639 | + | |
640 | + va_end (args); | |
641 | +} | |
642 | + | |
643 | +void | |
560 | 644 | ui_out::wrap_hint (const char *identstring) |
561 | 645 | { |
562 | 646 | do_wrap_hint (identstring); |
@@ -83,6 +83,26 @@ enum class ui_out_style_kind | ||
83 | 83 | ADDRESS |
84 | 84 | }; |
85 | 85 | |
86 | +struct int_field | |
87 | +{ | |
88 | + int_field (const char *name, int val) | |
89 | + : m_name (name), | |
90 | + m_val (val) | |
91 | + { | |
92 | + } | |
93 | + | |
94 | + /* We need this because we can't pass a reference via | |
95 | + va_args. */ | |
96 | + const int_field *ptr () const { return this; } | |
97 | + | |
98 | + const char *name () const {return m_name; } | |
99 | + int val () const {return m_val; } | |
100 | + | |
101 | +private: | |
102 | + const char *m_name; | |
103 | + int m_val; | |
104 | +}; | |
105 | + | |
86 | 106 | class ui_out |
87 | 107 | { |
88 | 108 | public: |
@@ -181,6 +201,7 @@ class ui_out | ||
181 | 201 | { return false; } |
182 | 202 | |
183 | 203 | private: |
204 | + void call_do_message (const char *format, ...); | |
184 | 205 | |
185 | 206 | ui_out_flags m_flags; |
186 | 207 |