• 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ónad89c4348a82c78beb4b590c50fdb8bf48919c24 (tree)
Tiempo2019-06-07 01:35:18
AutorTom Tromey <tom@trom...>
CommiterTom Tromey

Log Message

Remove the ui_out_style_kind enum

This also converts a few more spots to use %ps, just to try it out.

Cambiar Resumen

Diferencia incremental

--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5836,14 +5836,14 @@ print_breakpoint_location (struct breakpoint *b,
58365836 {
58375837 uiout->text ("in ");
58385838 uiout->field_string ("func", SYMBOL_PRINT_NAME (sym),
5839- ui_out_style_kind::FUNCTION);
5839+ function_name_style.style ());
58405840 uiout->text (" ");
58415841 uiout->wrap_hint (wrap_indent_at_field (uiout, "what"));
58425842 uiout->text ("at ");
58435843 }
58445844 uiout->field_string ("file",
58455845 symtab_to_filename_for_display (loc->symtab),
5846- ui_out_style_kind::FILE);
5846+ file_name_style.style ());
58475847 uiout->text (":");
58485848
58495849 if (uiout->is_mi_like_p ())
@@ -6693,9 +6693,9 @@ describe_other_breakpoints (struct gdbarch *gdbarch,
66936693 (others > 1) ? ","
66946694 : ((others == 1) ? " and" : ""));
66956695 }
6696- current_uiout->message (_("also set at pc %pS%s%pN.\n"),
6697- ptr (ui_out_style_kind::ADDRESS),
6698- paddress (gdbarch, pc), nullptr);
6696+ current_uiout->message (_("also set at pc %ps.\n"),
6697+ styled_string (address_style.style (),
6698+ paddress (gdbarch, pc)).ptr ());
66996699 }
67006700 }
67016701
@@ -13355,12 +13355,12 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
1335513355 if (sym)
1335613356 {
1335713357 uiout->field_string ("func", SYMBOL_PRINT_NAME (sym),
13358- ui_out_style_kind::FUNCTION);
13358+ function_name_style.style ());
1335913359 uiout->text (" at ");
1336013360 }
1336113361 uiout->field_string ("file",
1336213362 symtab_to_filename_for_display (sal2.symtab),
13363- ui_out_style_kind::FILE);
13363+ file_name_style.style ());
1336413364 uiout->text (":");
1336513365
1336613366 if (uiout->is_mi_like_p ())
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -73,7 +73,7 @@ cli_ui_out::do_table_header (int width, ui_align alignment,
7373 return;
7474
7575 do_field_string (0, width, alignment, 0, col_hdr.c_str (),
76- ui_out_style_kind::DEFAULT);
76+ ui_file_style ());
7777 }
7878
7979 /* Mark beginning of a list */
@@ -102,7 +102,7 @@ cli_ui_out::do_field_int (int fldno, int width, ui_align alignment,
102102 std::string str = string_printf ("%d", value);
103103
104104 do_field_string (fldno, width, alignment, fldname, str.c_str (),
105- ui_out_style_kind::DEFAULT);
105+ ui_file_style ());
106106 }
107107
108108 /* used to omit a field */
@@ -115,28 +115,7 @@ cli_ui_out::do_field_skip (int fldno, int width, ui_align alignment,
115115 return;
116116
117117 do_field_string (fldno, width, alignment, fldname, "",
118- ui_out_style_kind::DEFAULT);
119-}
120-
121-static ui_file_style
122-style_from_style_kind (ui_out_style_kind kind)
123-{
124- switch (kind)
125- {
126- case ui_out_style_kind::DEFAULT:
127- /* Nothing. */
128- return {};
129- case ui_out_style_kind::FILE:
130- return file_name_style.style ();
131- case ui_out_style_kind::FUNCTION:
132- return function_name_style.style ();
133- case ui_out_style_kind::VARIABLE:
134- return variable_name_style.style ();
135- case ui_out_style_kind::ADDRESS:
136- return address_style.style ();
137- default:
138- gdb_assert_not_reached ("missing case");
139- }
118+ ui_file_style ());
140119 }
141120
142121 /* other specific cli_field_* end up here so alignment and field
@@ -145,7 +124,7 @@ style_from_style_kind (ui_out_style_kind kind)
145124 void
146125 cli_ui_out::do_field_string (int fldno, int width, ui_align align,
147126 const char *fldname, const char *string,
148- ui_out_style_kind style)
127+ const ui_file_style &style)
149128 {
150129 int before = 0;
151130 int after = 0;
@@ -180,10 +159,7 @@ cli_ui_out::do_field_string (int fldno, int width, ui_align align,
180159 spaces (before);
181160
182161 if (string)
183- {
184- ui_file_style fstyle = style_from_style_kind (style);
185- fputs_styled (string, fstyle, m_streams.back ());
186- }
162+ fputs_styled (string, style, m_streams.back ());
187163
188164 if (after)
189165 spaces (after);
@@ -205,7 +181,7 @@ cli_ui_out::do_field_fmt (int fldno, int width, ui_align align,
205181 std::string str = string_vprintf (format, args);
206182
207183 do_field_string (fldno, width, align, fldname, str.c_str (),
208- ui_out_style_kind::DEFAULT);
184+ ui_file_style ());
209185 }
210186
211187 void
@@ -227,14 +203,13 @@ cli_ui_out::do_text (const char *string)
227203 }
228204
229205 void
230-cli_ui_out::do_message (ui_out_style_kind style,
206+cli_ui_out::do_message (const ui_file_style &style,
231207 const char *format, va_list args)
232208 {
233209 if (m_suppress_output)
234210 return;
235211
236- ui_file_style fstyle = style_from_style_kind (style);
237- vfprintf_styled (m_streams.back (), fstyle, format, args);
212+ vfprintf_styled (m_streams.back (), style, format, args);
238213 }
239214
240215 void
--- a/gdb/cli-out.h
+++ b/gdb/cli-out.h
@@ -52,14 +52,14 @@ protected:
5252 virtual void do_field_string (int fldno, int width, ui_align align,
5353 const char *fldname,
5454 const char *string,
55- ui_out_style_kind style) override;
55+ const ui_file_style &style) override;
5656 virtual void do_field_fmt (int fldno, int width, ui_align align,
5757 const char *fldname, const char *format,
5858 va_list args)
5959 override ATTRIBUTE_PRINTF (6,0);
6060 virtual void do_spaces (int numspaces) override;
6161 virtual void do_text (const char *string) override;
62- virtual void do_message (ui_out_style_kind style,
62+ virtual void do_message (const ui_file_style &style,
6363 const char *format, va_list args) override
6464 ATTRIBUTE_PRINTF (3,0);
6565 virtual void do_wrap_hint (const char *identstring) override;
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -31,6 +31,7 @@
3131 #include <algorithm>
3232 #include "common/gdb_optional.h"
3333 #include "valprint.h"
34+#include "cli/cli-style.h"
3435
3536 /* Disassemble functions.
3637 FIXME: We should get rid of all the duplicate code in gdb that does
@@ -245,7 +246,7 @@ gdb_pretty_print_disassembler::pretty_print_insn (struct ui_out *uiout,
245246 uiout->text (" <");
246247 if ((flags & DISASSEMBLY_OMIT_FNAME) == 0)
247248 uiout->field_string ("func-name", name.c_str (),
248- ui_out_style_kind::FUNCTION);
249+ function_name_style.style ());
249250 uiout->text ("+");
250251 uiout->field_int ("offset", offset);
251252 uiout->text (">:\t");
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -70,9 +70,9 @@ mi_ui_out::do_table_header (int width, ui_align alignment,
7070 do_field_int (0, 0, ui_center, "width", width);
7171 do_field_int (0, 0, ui_center, "alignment", alignment);
7272 do_field_string (0, 0, ui_center, "col_name", col_name.c_str (),
73- ui_out_style_kind::DEFAULT);
73+ ui_file_style ());
7474 do_field_string (0, width, alignment, "colhdr", col_hdr.c_str (),
75- ui_out_style_kind::DEFAULT);
75+ ui_file_style ());
7676 close (ui_out_type_tuple);
7777 }
7878
@@ -102,7 +102,7 @@ mi_ui_out::do_field_int (int fldno, int width, ui_align alignment,
102102
103103 xsnprintf (buffer, sizeof (buffer), "%d", value);
104104 do_field_string (fldno, width, alignment, fldname, buffer,
105- ui_out_style_kind::DEFAULT);
105+ ui_file_style ());
106106 }
107107
108108 /* Used to omit a field. */
@@ -119,7 +119,7 @@ mi_ui_out::do_field_skip (int fldno, int width, ui_align alignment,
119119 void
120120 mi_ui_out::do_field_string (int fldno, int width, ui_align align,
121121 const char *fldname, const char *string,
122- ui_out_style_kind style)
122+ const ui_file_style &style)
123123 {
124124 ui_file *stream = m_streams.back ();
125125 field_separator ();
@@ -159,7 +159,7 @@ mi_ui_out::do_text (const char *string)
159159 }
160160
161161 void
162-mi_ui_out::do_message (ui_out_style_kind style,
162+mi_ui_out::do_message (const ui_file_style &style,
163163 const char *format, va_list args)
164164 {
165165 }
--- a/gdb/mi/mi-out.h
+++ b/gdb/mi/mi-out.h
@@ -58,13 +58,13 @@ protected:
5858 const char *fldname) override;
5959 virtual void do_field_string (int fldno, int width, ui_align align,
6060 const char *fldname, const char *string,
61- ui_out_style_kind style) override;
61+ const ui_file_style &style) override;
6262 virtual void do_field_fmt (int fldno, int width, ui_align align,
6363 const char *fldname, const char *format, va_list args)
6464 override ATTRIBUTE_PRINTF (6,0);
6565 virtual void do_spaces (int numspaces) override;
6666 virtual void do_text (const char *string) override;
67- virtual void do_message (ui_out_style_kind style,
67+ virtual void do_message (const ui_file_style &style,
6868 const char *format, va_list args) override
6969 ATTRIBUTE_PRINTF (3,0);
7070 virtual void do_wrap_hint (const char *identstring) override;
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -31,6 +31,7 @@
3131 #include "mi/mi-cmds.h"
3232 #include "python-internal.h"
3333 #include "common/gdb_optional.h"
34+#include "cli/cli-style.h"
3435
3536 enum mi_print_types
3637 {
@@ -898,7 +899,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
898899 if (function == NULL)
899900 out->field_skip ("func");
900901 else
901- out->field_string ("func", function, ui_out_style_kind::FUNCTION);
902+ out->field_string ("func", function, function_name_style.style ());
902903 }
903904 }
904905
@@ -935,7 +936,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
935936 out->text (" at ");
936937 annotate_frame_source_file ();
937938 out->field_string ("file", filename.get (),
938- ui_out_style_kind::FILE);
939+ file_name_style.style ());
939940 annotate_frame_source_file_end ();
940941 }
941942 }
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -41,6 +41,7 @@
4141 #include "common/vec.h"
4242 #include "inferior.h"
4343 #include <algorithm>
44+#include "cli/cli-style.h"
4445
4546 static const target_info record_btrace_target_info = {
4647 "record-btrace",
@@ -1091,7 +1092,7 @@ btrace_call_history_src_line (struct ui_out *uiout,
10911092
10921093 uiout->field_string ("file",
10931094 symtab_to_filename_for_display (symbol_symtab (sym)),
1094- ui_out_style_kind::FILE);
1095+ file_name_style.style ());
10951096
10961097 btrace_compute_src_line_range (bfun, &begin, &end);
10971098 if (end < begin)
@@ -1183,13 +1184,13 @@ btrace_call_history (struct ui_out *uiout,
11831184
11841185 if (sym != NULL)
11851186 uiout->field_string ("function", SYMBOL_PRINT_NAME (sym),
1186- ui_out_style_kind::FUNCTION);
1187+ function_name_style.style ());
11871188 else if (msym != NULL)
11881189 uiout->field_string ("function", MSYMBOL_PRINT_NAME (msym),
1189- ui_out_style_kind::FUNCTION);
1190+ function_name_style.style ());
11901191 else if (!uiout->is_mi_like_p ())
11911192 uiout->field_string ("function", "??",
1192- ui_out_style_kind::FUNCTION);
1193+ function_name_style.style ());
11931194
11941195 if ((flags & RECORD_PRINT_INSN_RANGE) != 0)
11951196 {
--- a/gdb/skip.c
+++ b/gdb/skip.c
@@ -36,6 +36,7 @@
3636 #include "gdb_regex.h"
3737 #include "common/gdb_optional.h"
3838 #include <list>
39+#include "cli/cli-style.h"
3940
4041 /* True if we want to print debug printouts related to file/function
4142 skipping. */
@@ -414,7 +415,7 @@ info_skip_command (const char *arg, int from_tty)
414415 current_uiout->field_string ("file",
415416 e.file ().empty () ? "<none>"
416417 : e.file ().c_str (),
417- ui_out_style_kind::FILE); /* 4 */
418+ file_name_style.style ()); /* 4 */
418419 if (e.function_is_regexp ())
419420 current_uiout->field_string ("regexp", "y"); /* 5 */
420421 else
@@ -423,7 +424,7 @@ info_skip_command (const char *arg, int from_tty)
423424 current_uiout->field_string ("function",
424425 e.function ().empty () ? "<none>"
425426 : e.function ().c_str (),
426- ui_out_style_kind::FUNCTION); /* 6 */
427+ function_name_style.style ()); /* 6 */
427428
428429 current_uiout->text ("\n");
429430 }
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -47,6 +47,7 @@
4747 #include "gdb_bfd.h"
4848 #include "common/filestuff.h"
4949 #include "source.h"
50+#include "cli/cli-style.h"
5051
5152 /* Architecture-specific operations. */
5253
@@ -1104,7 +1105,7 @@ info_sharedlibrary_command (const char *pattern, int from_tty)
11041105 else
11051106 uiout->field_string ("syms-read", so->symbols_loaded ? "Yes" : "No");
11061107
1107- uiout->field_string ("name", so->so_name, ui_out_style_kind::FILE);
1108+ uiout->field_string ("name", so->so_name, file_name_style.style ());
11081109
11091110 uiout->text ("\n");
11101111 }
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -46,6 +46,7 @@
4646 #include <algorithm>
4747 #include "common/pathstuff.h"
4848 #include "source-cache.h"
49+#include "cli/cli-style.h"
4950
5051 #define OPEN_MODE (O_RDONLY | O_BINARY)
5152 #define FDOPEN_MODE FOPEN_RB
@@ -1306,7 +1307,7 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
13061307 not for TUI. */
13071308 if (uiout->is_mi_like_p () || uiout->test_flags (ui_source_list))
13081309 uiout->field_string ("file", symtab_to_filename_for_display (s),
1309- ui_out_style_kind::FILE);
1310+ file_name_style.style ());
13101311 if (uiout->is_mi_like_p () || !uiout->test_flags (ui_source_list))
13111312 {
13121313 const char *s_fullname = symtab_to_fullname (s);
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -53,6 +53,7 @@
5353 #include "observable.h"
5454 #include "common/def-vector.h"
5555 #include "cli/cli-option.h"
56+#include "cli/cli-style.h"
5657
5758 /* The possible choices of "set print frame-arguments", and the value
5859 of this setting. */
@@ -341,7 +342,7 @@ print_frame_arg (const frame_print_options &fp_opts,
341342 if (arg->entry_kind == print_entry_values_only
342343 || arg->entry_kind == print_entry_values_compact)
343344 stb.puts ("@entry");
344- uiout->field_stream ("name", stb, ui_out_style_kind::VARIABLE);
345+ uiout->field_stream ("name", stb, variable_name_style.style ());
345346 annotate_arg_name_end ();
346347 uiout->text ("=");
347348
@@ -909,18 +910,18 @@ print_frame_info (const frame_print_options &fp_opts,
909910 {
910911 annotate_function_call ();
911912 uiout->field_string ("func", "<function called from gdb>",
912- ui_out_style_kind::FUNCTION);
913+ function_name_style.style ());
913914 }
914915 else if (get_frame_type (frame) == SIGTRAMP_FRAME)
915916 {
916917 annotate_signal_handler_caller ();
917918 uiout->field_string ("func", "<signal handler called>",
918- ui_out_style_kind::FUNCTION);
919+ function_name_style.style ());
919920 }
920921 else if (get_frame_type (frame) == ARCH_FRAME)
921922 {
922923 uiout->field_string ("func", "<cross-architecture call>",
923- ui_out_style_kind::FUNCTION);
924+ function_name_style.style ());
924925 }
925926 uiout->text ("\n");
926927 annotate_frame_end ();
@@ -1262,7 +1263,7 @@ print_frame (const frame_print_options &fp_opts,
12621263 uiout->field_core_addr ("addr", gdbarch, pc);
12631264 else
12641265 uiout->field_string ("addr", "<unavailable>",
1265- ui_out_style_kind::ADDRESS);
1266+ address_style.style ());
12661267 annotate_frame_address_end ();
12671268 uiout->text (" in ");
12681269 }
@@ -1271,7 +1272,7 @@ print_frame (const frame_print_options &fp_opts,
12711272 string_file stb;
12721273 fprintf_symbol_filtered (&stb, funname ? funname.get () : "??",
12731274 funlang, DMGL_ANSI);
1274- uiout->field_stream ("func", stb, ui_out_style_kind::FUNCTION);
1275+ uiout->field_stream ("func", stb, function_name_style.style ());
12751276 uiout->wrap_hint (" ");
12761277 annotate_frame_args ();
12771278
@@ -1313,7 +1314,8 @@ print_frame (const frame_print_options &fp_opts,
13131314 uiout->wrap_hint (" ");
13141315 uiout->text (" at ");
13151316 annotate_frame_source_file ();
1316- uiout->field_string ("file", filename_display, ui_out_style_kind::FILE);
1317+ uiout->field_string ("file", filename_display,
1318+ file_name_style.style ());
13171319 if (uiout->is_mi_like_p ())
13181320 {
13191321 const char *fullname = symtab_to_fullname (sal.symtab);
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1115,11 +1115,9 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name,
11151115 if (deprecated_pre_add_symbol_hook)
11161116 deprecated_pre_add_symbol_hook (name);
11171117 else
1118- {
1119- puts_filtered (_("Reading symbols from "));
1120- fputs_styled (name, file_name_style.style (), gdb_stdout);
1121- puts_filtered ("...\n");
1122- }
1118+ current_uiout->message (_("Reading symbols from %ps...\n"),
1119+ styled_string (file_name_style.style (),
1120+ name).ptr ());
11231121 }
11241122 syms_from_objfile (objfile, addrs, add_flags);
11251123
@@ -1131,7 +1129,9 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name,
11311129 if ((flags & OBJF_READNOW))
11321130 {
11331131 if (should_print)
1134- printf_filtered (_("Expanding full symbols from %s...\n"), name);
1132+ current_uiout->message (_("Expanding full symbols from %ps...\n"),
1133+ styled_string (file_name_style.style (),
1134+ name).ptr ());
11351135
11361136 if (objfile->sf)
11371137 objfile->sf->qf->expand_all_symtabs (objfile);
@@ -1143,7 +1143,9 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name,
11431143 file, and so printing it twice is just redundant. */
11441144 if (should_print && !objfile_has_symbols (objfile)
11451145 && objfile->separate_debug_objfile == nullptr)
1146- printf_filtered (_("(No debugging symbols found in %s)\n"), name);
1146+ current_uiout->message (_("(No debugging symbols found in %ps)\n"),
1147+ styled_string (file_name_style.style (),
1148+ name).ptr ());
11471149
11481150 if (should_print)
11491151 {
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4605,7 +4605,7 @@ print_symbol_info (enum search_domain kind,
46054605 {
46064606 current_uiout->message
46074607 (_("\nFile %ps:\n"),
4608- styled_string (ui_out_style_kind::FILE, s_filename).ptr ());
4608+ styled_string (file_name_style.style (), s_filename).ptr ());
46094609 }
46104610
46114611 if (SYMBOL_LINE (sym) != 0)
@@ -4652,13 +4652,13 @@ print_msymbol_info (struct bound_minimal_symbol msymbol)
46524652 tmp = hex_string_custom (BMSYMBOL_VALUE_ADDRESS (msymbol),
46534653 16);
46544654
4655- ui_out_style_kind sym_style = (msymbol.minsym->text_p ()
4656- ? ui_out_style_kind::FUNCTION
4657- : ui_out_style_kind::DEFAULT);
4655+ ui_file_style sym_style = (msymbol.minsym->text_p ()
4656+ ? function_name_style.style ()
4657+ : ui_file_style ());
46584658
46594659 current_uiout->message
46604660 (_("%ps %ps\n"),
4661- styled_string (ui_out_style_kind::ADDRESS, tmp).ptr (),
4661+ styled_string (address_style.style (), tmp).ptr (),
46624662 styled_string (sym_style, MSYMBOL_PRINT_NAME (msymbol.minsym)).ptr ());
46634663 }
46644664
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -57,6 +57,7 @@
5757 #include "tracefile.h"
5858 #include "location.h"
5959 #include <algorithm>
60+#include "cli/cli-style.h"
6061
6162 /* readline include files */
6263 #include "readline/readline.h"
@@ -3690,7 +3691,7 @@ print_one_static_tracepoint_marker (int count,
36903691 {
36913692 uiout->text ("in ");
36923693 uiout->field_string ("func", SYMBOL_PRINT_NAME (sym),
3693- ui_out_style_kind::FUNCTION);
3694+ function_name_style.style ());
36943695 uiout->wrap_hint (wrap_indent);
36953696 uiout->text (" at ");
36963697 }
@@ -3701,7 +3702,7 @@ print_one_static_tracepoint_marker (int count,
37013702 {
37023703 uiout->field_string ("file",
37033704 symtab_to_filename_for_display (sal.symtab),
3704- ui_out_style_kind::FILE);
3705+ file_name_style.style ());
37053706 uiout->text (":");
37063707
37073708 if (uiout->is_mi_like_p ())
--- a/gdb/tui/tui-out.c
+++ b/gdb/tui/tui-out.c
@@ -52,7 +52,7 @@ tui_ui_out::do_field_int (int fldno, int width, ui_align alignment,
5252 void
5353 tui_ui_out::do_field_string (int fldno, int width, ui_align align,
5454 const char *fldname, const char *string,
55- ui_out_style_kind style)
55+ const ui_file_style &style)
5656 {
5757 if (suppress_output ())
5858 return;
--- a/gdb/tui/tui-out.h
+++ b/gdb/tui/tui-out.h
@@ -35,7 +35,7 @@ protected:
3535 void do_field_int (int fldno, int width, ui_align align, const char *fldname,
3636 int value) override;
3737 void do_field_string (int fldno, int width, ui_align align, const char *fldname,
38- const char *string, ui_out_style_kind style) override;
38+ const char *string, const ui_file_style &style) override;
3939 void do_field_fmt (int fldno, int width, ui_align align, const char *fldname,
4040 const char *format, va_list args) override
4141 ATTRIBUTE_PRINTF (6,0);
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -25,6 +25,7 @@
2525 #include "language.h"
2626 #include "ui-out.h"
2727 #include "common/format.h"
28+#include "cli/cli-style.h"
2829
2930 #include <vector>
3031 #include <memory>
@@ -470,12 +471,12 @@ ui_out::field_core_addr (const char *fldname, struct gdbarch *gdbarch,
470471 CORE_ADDR address)
471472 {
472473 field_string (fldname, print_core_address (gdbarch, address),
473- ui_out_style_kind::ADDRESS);
474+ address_style.style ());
474475 }
475476
476477 void
477478 ui_out::field_stream (const char *fldname, string_file &stream,
478- ui_out_style_kind style)
479+ const ui_file_style &style)
479480 {
480481 if (!stream.empty ())
481482 field_string (fldname, stream.c_str (), style);
@@ -500,7 +501,7 @@ ui_out::field_skip (const char *fldname)
500501
501502 void
502503 ui_out::field_string (const char *fldname, const char *string,
503- ui_out_style_kind style)
504+ const ui_file_style &style)
504505 {
505506 int fldno;
506507 int width;
@@ -548,7 +549,8 @@ ui_out::text (const char *string)
548549 }
549550
550551 void
551-ui_out::call_do_message (ui_out_style_kind style, const char *format, ...)
552+ui_out::call_do_message (const ui_file_style &style, const char *format,
553+ ...)
552554 {
553555 va_list args;
554556
@@ -562,7 +564,7 @@ ui_out::message (const char *format, ...)
562564 {
563565 format_pieces fpieces (&format, true);
564566
565- ui_out_style_kind style = ui_out_style_kind::DEFAULT;
567+ ui_file_style style;
566568
567569 va_list args;
568570 va_start (args, format);
@@ -618,13 +620,13 @@ ui_out::message (const char *format, ...)
618620 call_do_message (ss->style (), "%s", ss->str ());
619621 }
620622 break;
621- case 'S':
622- style = *va_arg (args, ui_out_style_kind *);
623- break;
624- case 'N':
625- va_arg (args, void *);
626- style = ui_out_style_kind::DEFAULT;
627- break;
623+ /* case 'S': */
624+ /* style = *va_arg (args, const ui_file_style *); */
625+ /* break; */
626+ /* case 'N': */
627+ /* va_arg (args, void *); */
628+ /* style = nullptr; */
629+ /* break; */
628630 default:
629631 call_do_message (style, current_substring, va_arg (args, void *));
630632 break;
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -26,6 +26,7 @@
2626 #include <vector>
2727
2828 #include "common/enum-flags.h"
29+#include "ui-style.h"
2930
3031 class ui_out_level;
3132 class ui_out_table;
@@ -67,22 +68,6 @@ enum ui_out_type
6768 ui_out_type_list
6869 };
6970
70-/* Possible kinds of styling. */
71-
72-enum class ui_out_style_kind
73-{
74- /* The default (plain) style. */
75- DEFAULT,
76- /* File name. */
77- FILE,
78- /* Function name. */
79- FUNCTION,
80- /* Variable name. */
81- VARIABLE,
82- /* Address. */
83- ADDRESS
84-};
85-
8671 struct int_field
8772 {
8873 int_field (const char *name, int val)
@@ -105,7 +90,7 @@ private:
10590
10691 struct styled_string
10792 {
108- styled_string (ui_out_style_kind style, const char *str)
93+ styled_string (const ui_file_style &style, const char *str)
10994 : m_style (style),
11095 m_str (str)
11196 {
@@ -115,32 +100,14 @@ struct styled_string
115100 va_args. */
116101 const styled_string *ptr () const { return this; }
117102
118- ui_out_style_kind style () const {return m_style; }
103+ const ui_file_style &style () const { return m_style; }
119104 const char *str () const {return m_str; }
120105
121106 private:
122- ui_out_style_kind m_style;
107+ ui_file_style m_style;
123108 const char *m_str;
124109 };
125110
126-/* Wrap a ui_out_style_kind in a pointer to a temporary. */
127-
128-/* XXX: Make a template? */
129-struct ptrS
130-{
131- ptrS (ui_out_style_kind t) : m_t (t) {}
132-
133- const ui_out_style_kind *ptr () const { return &m_t; }
134-
135- ui_out_style_kind m_t;
136-};
137-
138-static inline const ui_out_style_kind *
139-ptr (ptrS &&t)
140-{
141- return t.ptr ();
142-}
143-
144111 class ui_out
145112 {
146113 public:
@@ -171,10 +138,10 @@ class ui_out
171138 void field_core_addr (const char *fldname, struct gdbarch *gdbarch,
172139 CORE_ADDR address);
173140 void field_string (const char *fldname, const char *string,
174- ui_out_style_kind style = ui_out_style_kind::DEFAULT);
141+ const ui_file_style &style = ui_file_style ());
175142 void field_string (const char *fldname, const std::string &string);
176143 void field_stream (const char *fldname, string_file &stream,
177- ui_out_style_kind style = ui_out_style_kind::DEFAULT);
144+ const ui_file_style &style = ui_file_style ());
178145 void field_skip (const char *fldname);
179146 void field_fmt (const char *fldname, const char *format, ...)
180147 ATTRIBUTE_PRINTF (3, 4);
@@ -219,14 +186,14 @@ class ui_out
219186 const char *fldname) = 0;
220187 virtual void do_field_string (int fldno, int width, ui_align align,
221188 const char *fldname, const char *string,
222- ui_out_style_kind style) = 0;
189+ const ui_file_style &style) = 0;
223190 virtual void do_field_fmt (int fldno, int width, ui_align align,
224191 const char *fldname, const char *format,
225192 va_list args)
226193 ATTRIBUTE_PRINTF (6,0) = 0;
227194 virtual void do_spaces (int numspaces) = 0;
228195 virtual void do_text (const char *string) = 0;
229- virtual void do_message (ui_out_style_kind style,
196+ virtual void do_message (const ui_file_style &style,
230197 const char *format, va_list args)
231198 ATTRIBUTE_PRINTF (3,0) = 0;
232199 virtual void do_wrap_hint (const char *identstring) = 0;
@@ -240,7 +207,8 @@ class ui_out
240207 { return false; }
241208
242209 private:
243- void call_do_message (ui_out_style_kind style, const char *format, ...);
210+ void call_do_message (const ui_file_style &style, const char *format,
211+ ...);
244212
245213 ui_out_flags m_flags;
246214