• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisiónbef62542b4f0f650e65ddcb72611116e73df9269 (tree)
Tiempo2019-06-05 17:17:16
AutorPedro Alves <palves@redh...>
CommiterPedro Alves

Log Message

Make ui_out::message support %pF, %pS, %pN

Cambiar Resumen

Diferencia incremental

--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -4927,10 +4927,10 @@ watchpoint_check (bpstat bs)
49274927 if (uiout->is_mi_like_p ())
49284928 uiout->field_string
49294929 ("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 ());
49344934 }
49354935
49364936 /* Make sure the watchpoint's commands aren't executed. */
@@ -6245,9 +6245,8 @@ print_one_breakpoint_location (struct breakpoint *b,
62456245 if (!part_of_multiple && b->ignore_count)
62466246 {
62476247 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 ());
62516250 }
62526251
62536252 /* Note that an enable count of 1 corresponds to "enable once"
@@ -12428,18 +12427,18 @@ bkpt_print_it (bpstat bs)
1242812427 annotate_breakpoint (b->number);
1242912428 maybe_print_thread_hit_breakpoint (uiout);
1243012429
12431- if (bp_temp)
12432- uiout->text ("Temporary breakpoint ");
12433- else
12434- uiout->text ("Breakpoint ");
1243512430 if (uiout->is_mi_like_p ())
1243612431 {
1243712432 uiout->field_string ("reason",
1243812433 async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT));
1243912434 uiout->field_string ("disp", bpdisp_text (b->disposition));
1244012435 }
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 ());
1244312442
1244412443 return PRINT_SRC_AND_LOC;
1244512444 }
--- a/gdb/common/format.c
+++ b/gdb/common/format.c
@@ -20,7 +20,7 @@
2020 #include "common-defs.h"
2121 #include "format.h"
2222
23-format_pieces::format_pieces (const char **arg)
23+format_pieces::format_pieces (const char **arg, bool gdb_extensions)
2424 {
2525 const char *s;
2626 char *f, *string;
@@ -251,6 +251,19 @@ format_pieces::format_pieces (const char **arg)
251251 bad = 1;
252252 if (seen_hash || seen_zero || seen_space || seen_plus)
253253 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+
254267 break;
255268
256269 case 's':
--- a/gdb/common/format.h
+++ b/gdb/common/format.h
@@ -70,7 +70,7 @@ class format_pieces
7070 {
7171 public:
7272
73- format_pieces (const char **arg);
73+ format_pieces (const char **arg, bool gdb_extensions = false);
7474 ~format_pieces () = default;
7575
7676 DISABLE_COPY_AND_ASSIGN (format_pieces);
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -24,6 +24,7 @@
2424 #include "expression.h" /* For language.h */
2525 #include "language.h"
2626 #include "ui-out.h"
27+#include "common/format.h"
2728
2829 #include <vector>
2930 #include <memory>
@@ -547,7 +548,7 @@ ui_out::text (const char *string)
547548 }
548549
549550 void
550-ui_out::message (const char *format, ...)
551+ui_out::call_do_message (const char *format, ...)
551552 {
552553 va_list args;
553554
@@ -557,6 +558,89 @@ ui_out::message (const char *format, ...)
557558 }
558559
559560 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
560644 ui_out::wrap_hint (const char *identstring)
561645 {
562646 do_wrap_hint (identstring);
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -83,6 +83,26 @@ enum class ui_out_style_kind
8383 ADDRESS
8484 };
8585
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+
86106 class ui_out
87107 {
88108 public:
@@ -181,6 +201,7 @@ class ui_out
181201 { return false; }
182202
183203 private:
204+ void call_do_message (const char *format, ...);
184205
185206 ui_out_flags m_flags;
186207