• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

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

修訂43436142530dc00cee6f3f7379bd1c2694ef2e14 (tree)
時間2019-07-02 04:15:58
作者Pedro Alves <palves@redh...>
CommiterPedro Alves

Log Message

Introduce string_field

For ... string fields.

Change Summary

差異

--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -6193,10 +6193,9 @@ print_one_breakpoint_location (struct breakpoint *b,
61936193 && breakpoint_condition_evaluation_mode ()
61946194 == condition_evaluation_target)
61956195 {
6196- uiout->text (" (");
6197- uiout->field_string ("evaluated-by",
6198- bp_condition_evaluator (b));
6199- uiout->text (" evals)");
6196+ uiout->message (" (%pF evals)",
6197+ string_field ("evaluated-by",
6198+ bp_condition_evaluator (b)));
62006199 }
62016200 uiout->text ("\n");
62026201 }
@@ -12752,10 +12751,9 @@ tracepoint_print_one_detail (const struct breakpoint *self,
1275212751 {
1275312752 gdb_assert (self->type == bp_static_tracepoint);
1275412753
12755- uiout->text ("\tmarker id is ");
12756- uiout->field_string ("static-tracepoint-marker-string-id",
12757- tp->static_trace_marker_id);
12758- uiout->text ("\n");
12754+ uiout->message ("\tmarker id is %pF\n",
12755+ string_field ("static-tracepoint-marker-string-id",
12756+ tp->static_trace_marker_id.c_str ()));
1275912757 }
1276012758 }
1276112759
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -7641,24 +7641,19 @@ print_exited_reason (struct ui_out *uiout, int exitstatus)
76417641 {
76427642 if (uiout->is_mi_like_p ())
76437643 uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_EXITED));
7644- uiout->text ("[Inferior ");
7645- uiout->text (plongest (inf->num));
7646- uiout->text (" (");
7647- uiout->text (pidstr.c_str ());
7648- uiout->text (") exited with code ");
7649- uiout->field_fmt ("exit-code", "0%o", (unsigned int) exitstatus);
7650- uiout->text ("]\n");
7644+ std::string exit_code_str
7645+ = string_printf ("0%o", (unsigned int) exitstatus);
7646+ uiout->message ("[Inferior %s (%s) exited with code %pF]\n",
7647+ plongest (inf->num), pidstr.c_str (),
7648+ string_field ("exit-code", exit_code_str.c_str ()));
76517649 }
76527650 else
76537651 {
76547652 if (uiout->is_mi_like_p ())
76557653 uiout->field_string
76567654 ("reason", async_reason_lookup (EXEC_ASYNC_EXITED_NORMALLY));
7657- uiout->text ("[Inferior ");
7658- uiout->text (plongest (inf->num));
7659- uiout->text (" (");
7660- uiout->text (pidstr.c_str ());
7661- uiout->text (") exited normally]\n");
7655+ uiout->message ("[Inferior %s (%s) exited normally]\n",
7656+ plongest (inf->num), pidstr.c_str ());
76627657 }
76637658 }
76647659
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -607,8 +607,22 @@ ui_out::vmessage (const char *format, va_list args)
607607 {
608608 case 'F':
609609 {
610- int_field_s *field = va_arg (args, int_field_s *);
611- field_int (field->name, field->val);
610+ base_field_s *bf = va_arg (args, base_field_s *);
611+ switch (bf->kind)
612+ {
613+ case field_kind::INT:
614+ {
615+ auto *f = (int_field_s *) bf;
616+ field_int (f->name, f->val);
617+ }
618+ break;
619+ case field_kind::STRING:
620+ {
621+ auto *f = (string_field_s *) bf;
622+ field_string (f->name, f->str);
623+ }
624+ break;
625+ }
612626 }
613627 break;
614628 case 's':
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -68,11 +68,25 @@ enum ui_out_type
6868 ui_out_type_list
6969 };
7070
71+/* The possible kinds of fields. */
72+enum class field_kind
73+ {
74+ INT,
75+ STRING,
76+ };
77+
7178 /* An int field, to be passed to %pF in format strings. */
7279
73-struct int_field_s
80+struct base_field_s
7481 {
7582 const char *name;
83+ field_kind kind;
84+};
85+
86+/* An int field, to be passed to %pF in format strings. */
87+
88+struct int_field_s : base_field_s
89+{
7690 int val;
7791 };
7892
@@ -85,10 +99,32 @@ int_field (const char *name, int val,
8599 int_field_s &&tmp = {})
86100 {
87101 tmp.name = name;
102+ tmp.kind = field_kind::INT;
88103 tmp.val = val;
89104 return &tmp;
90105 }
91106
107+/* A string field, to be passed to %pF in format strings. */
108+
109+struct string_field_s : base_field_s
110+{
111+ const char *str;
112+};
113+
114+/* Construct a temporary string_field_s on the caller's stack and
115+ return a pointer to the constructed object. We use this because
116+ it's not possible to pass a reference via va_args. */
117+
118+static inline string_field_s *
119+string_field (const char *name, const char *str,
120+ string_field_s &&tmp = {})
121+{
122+ tmp.name = name;
123+ tmp.kind = field_kind::STRING;
124+ tmp.str = str;
125+ return &tmp;
126+}
127+
92128 /* A styled string. */
93129
94130 struct styled_string_s