ui-out.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  1. /* Output generating routines for GDB.
  2. Copyright (C) 1999-2022 Free Software Foundation, Inc.
  3. Contributed by Cygnus Solutions.
  4. Written by Fernando Nasser for Cygnus.
  5. This file is part of GDB.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  16. #include "defs.h"
  17. #include "expression.h" /* For language.h */
  18. #include "language.h"
  19. #include "ui-out.h"
  20. #include "gdbsupport/format.h"
  21. #include "cli/cli-style.h"
  22. #include "diagnostics.h"
  23. #include <vector>
  24. #include <memory>
  25. #include <string>
  26. namespace {
  27. /* A header of a ui_out_table. */
  28. class ui_out_hdr
  29. {
  30. public:
  31. explicit ui_out_hdr (int number, int min_width, ui_align alignment,
  32. const std::string &name, const std::string &header)
  33. : m_number (number),
  34. m_min_width (min_width),
  35. m_alignment (alignment),
  36. m_name (name),
  37. m_header (header)
  38. {
  39. }
  40. int number () const
  41. {
  42. return m_number;
  43. }
  44. int min_width () const
  45. {
  46. return m_min_width;
  47. }
  48. ui_align alignment () const
  49. {
  50. return m_alignment;
  51. }
  52. const std::string &header () const
  53. {
  54. return m_header;
  55. }
  56. const std::string &name () const
  57. {
  58. return m_name;
  59. }
  60. private:
  61. /* The number of the table column this header represents, 1-based. */
  62. int m_number;
  63. /* Minimal column width in characters. May or may not be applicable,
  64. depending on the actual implementation of ui_out. */
  65. int m_min_width;
  66. /* Alignment of the content in the column. May or may not be applicable,
  67. depending on the actual implementation of ui_out. */
  68. ui_align m_alignment;
  69. /* Internal column name, used to internally refer to the column. */
  70. std::string m_name;
  71. /* Printed header text of the column. */
  72. std::string m_header;
  73. };
  74. } // namespace
  75. /* A level of nesting (either a list or a tuple) in a ui_out output. */
  76. class ui_out_level
  77. {
  78. public:
  79. explicit ui_out_level (ui_out_type type)
  80. : m_type (type),
  81. m_field_count (0)
  82. {
  83. }
  84. ui_out_type type () const
  85. {
  86. return m_type;
  87. }
  88. int field_count () const
  89. {
  90. return m_field_count;
  91. }
  92. void inc_field_count ()
  93. {
  94. m_field_count++;
  95. }
  96. private:
  97. /* The type of this level. */
  98. ui_out_type m_type;
  99. /* Count each field; the first element is for non-list fields. */
  100. int m_field_count;
  101. };
  102. /* Tables are special. Maintain a separate structure that tracks
  103. their state. At present an output can only contain a single table
  104. but that restriction might eventually be lifted. */
  105. class ui_out_table
  106. {
  107. public:
  108. /* States (steps) of a table generation. */
  109. enum class state
  110. {
  111. /* We are generating the table headers. */
  112. HEADERS,
  113. /* We are generating the table body. */
  114. BODY,
  115. };
  116. explicit ui_out_table (int entry_level, int nr_cols, const std::string &id)
  117. : m_state (state::HEADERS),
  118. m_entry_level (entry_level),
  119. m_nr_cols (nr_cols),
  120. m_id (id)
  121. {
  122. }
  123. /* Start building the body of the table. */
  124. void start_body ();
  125. /* Add a new header to the table. */
  126. void append_header (int width, ui_align alignment,
  127. const std::string &col_name, const std::string &col_hdr);
  128. void start_row ();
  129. /* Extract the format information for the next header and advance
  130. the header iterator. Return false if there was no next header. */
  131. bool get_next_header (int *colno, int *width, ui_align *alignment,
  132. const char **col_hdr);
  133. bool query_field (int colno, int *width, int *alignment,
  134. const char **col_name) const;
  135. state current_state () const;
  136. int entry_level () const;
  137. private:
  138. state m_state;
  139. /* The level at which each entry of the table is to be found. A row
  140. (a tuple) is made up of entries. Consequently ENTRY_LEVEL is one
  141. above that of the table. */
  142. int m_entry_level;
  143. /* Number of table columns (as specified in the table_begin call). */
  144. int m_nr_cols;
  145. /* String identifying the table (as specified in the table_begin
  146. call). */
  147. std::string m_id;
  148. /* Pointers to the column headers. */
  149. std::vector<std::unique_ptr<ui_out_hdr>> m_headers;
  150. /* Iterator over the headers vector, used when printing successive fields. */
  151. std::vector<std::unique_ptr<ui_out_hdr>>::const_iterator m_headers_iterator;
  152. };
  153. /* See ui-out.h. */
  154. void ui_out_table::start_body ()
  155. {
  156. if (m_state != state::HEADERS)
  157. internal_error (__FILE__, __LINE__,
  158. _("extra table_body call not allowed; there must be only "
  159. "one table_body after a table_begin and before a "
  160. "table_end."));
  161. /* Check if the number of defined headers matches the number of expected
  162. columns. */
  163. if (m_headers.size () != m_nr_cols)
  164. internal_error (__FILE__, __LINE__,
  165. _("number of headers differ from number of table "
  166. "columns."));
  167. m_state = state::BODY;
  168. m_headers_iterator = m_headers.begin ();
  169. }
  170. /* See ui-out.h. */
  171. void ui_out_table::append_header (int width, ui_align alignment,
  172. const std::string &col_name,
  173. const std::string &col_hdr)
  174. {
  175. if (m_state != state::HEADERS)
  176. internal_error (__FILE__, __LINE__,
  177. _("table header must be specified after table_begin and "
  178. "before table_body."));
  179. std::unique_ptr<ui_out_hdr> header (new ui_out_hdr (m_headers.size () + 1,
  180. width, alignment,
  181. col_name, col_hdr));
  182. m_headers.push_back (std::move (header));
  183. }
  184. /* See ui-out.h. */
  185. void ui_out_table::start_row ()
  186. {
  187. m_headers_iterator = m_headers.begin ();
  188. }
  189. /* See ui-out.h. */
  190. bool ui_out_table::get_next_header (int *colno, int *width, ui_align *alignment,
  191. const char **col_hdr)
  192. {
  193. /* There may be no headers at all or we may have used all columns. */
  194. if (m_headers_iterator == m_headers.end ())
  195. return false;
  196. ui_out_hdr *hdr = m_headers_iterator->get ();
  197. *colno = hdr->number ();
  198. *width = hdr->min_width ();
  199. *alignment = hdr->alignment ();
  200. *col_hdr = hdr->header ().c_str ();
  201. /* Advance the header pointer to the next entry. */
  202. m_headers_iterator++;
  203. return true;
  204. }
  205. /* See ui-out.h. */
  206. bool ui_out_table::query_field (int colno, int *width, int *alignment,
  207. const char **col_name) const
  208. {
  209. /* Column numbers are 1-based, so convert to 0-based index. */
  210. int index = colno - 1;
  211. if (index >= 0 && index < m_headers.size ())
  212. {
  213. ui_out_hdr *hdr = m_headers[index].get ();
  214. gdb_assert (colno == hdr->number ());
  215. *width = hdr->min_width ();
  216. *alignment = hdr->alignment ();
  217. *col_name = hdr->name ().c_str ();
  218. return true;
  219. }
  220. else
  221. return false;
  222. }
  223. /* See ui-out.h. */
  224. ui_out_table::state ui_out_table::current_state () const
  225. {
  226. return m_state;
  227. }
  228. /* See ui-out.h. */
  229. int ui_out_table::entry_level () const
  230. {
  231. return m_entry_level;
  232. }
  233. int
  234. ui_out::level () const
  235. {
  236. return m_levels.size ();
  237. }
  238. /* The current (inner most) level. */
  239. ui_out_level *
  240. ui_out::current_level () const
  241. {
  242. return m_levels.back ().get ();
  243. }
  244. /* Create a new level, of TYPE. */
  245. void
  246. ui_out::push_level (ui_out_type type)
  247. {
  248. std::unique_ptr<ui_out_level> level (new ui_out_level (type));
  249. m_levels.push_back (std::move (level));
  250. }
  251. /* Discard the current level. TYPE is the type of the level being
  252. discarded. */
  253. void
  254. ui_out::pop_level (ui_out_type type)
  255. {
  256. /* We had better not underflow the buffer. */
  257. gdb_assert (m_levels.size () > 0);
  258. gdb_assert (current_level ()->type () == type);
  259. m_levels.pop_back ();
  260. }
  261. /* Mark beginning of a table. */
  262. void
  263. ui_out::table_begin (int nr_cols, int nr_rows, const std::string &tblid)
  264. {
  265. if (m_table_up != nullptr)
  266. internal_error (__FILE__, __LINE__,
  267. _("tables cannot be nested; table_begin found before \
  268. previous table_end."));
  269. m_table_up.reset (new ui_out_table (level () + 1, nr_cols, tblid));
  270. do_table_begin (nr_cols, nr_rows, tblid.c_str ());
  271. }
  272. void
  273. ui_out::table_header (int width, ui_align alignment,
  274. const std::string &col_name, const std::string &col_hdr)
  275. {
  276. if (m_table_up == nullptr)
  277. internal_error (__FILE__, __LINE__,
  278. _("table_header outside a table is not valid; it must be \
  279. after a table_begin and before a table_body."));
  280. m_table_up->append_header (width, alignment, col_name, col_hdr);
  281. do_table_header (width, alignment, col_name, col_hdr);
  282. }
  283. void
  284. ui_out::table_body ()
  285. {
  286. if (m_table_up == nullptr)
  287. internal_error (__FILE__, __LINE__,
  288. _("table_body outside a table is not valid; it must be "
  289. "after a table_begin and before a table_end."));
  290. m_table_up->start_body ();
  291. do_table_body ();
  292. }
  293. void
  294. ui_out::table_end ()
  295. {
  296. if (m_table_up == nullptr)
  297. internal_error (__FILE__, __LINE__,
  298. _("misplaced table_end or missing table_begin."));
  299. do_table_end ();
  300. m_table_up = nullptr;
  301. }
  302. void
  303. ui_out::begin (ui_out_type type, const char *id)
  304. {
  305. /* Be careful to verify the ``field'' before the new tuple/list is
  306. pushed onto the stack. That way the containing list/table/row is
  307. verified and not the newly created tuple/list. This verification
  308. is needed (at least) for the case where a table row entry
  309. contains either a tuple/list. For that case bookkeeping such as
  310. updating the column count or advancing to the next heading still
  311. needs to be performed. */
  312. {
  313. int fldno;
  314. int width;
  315. ui_align align;
  316. verify_field (&fldno, &width, &align);
  317. }
  318. push_level (type);
  319. /* If the push puts us at the same level as a table row entry, we've
  320. got a new table row. Put the header pointer back to the start. */
  321. if (m_table_up != nullptr
  322. && m_table_up->current_state () == ui_out_table::state::BODY
  323. && m_table_up->entry_level () == level ())
  324. m_table_up->start_row ();
  325. do_begin (type, id);
  326. }
  327. void
  328. ui_out::end (ui_out_type type)
  329. {
  330. pop_level (type);
  331. do_end (type);
  332. }
  333. void
  334. ui_out::field_signed (const char *fldname, LONGEST value)
  335. {
  336. int fldno;
  337. int width;
  338. ui_align align;
  339. verify_field (&fldno, &width, &align);
  340. do_field_signed (fldno, width, align, fldname, value);
  341. }
  342. void
  343. ui_out::field_fmt_signed (int input_width, ui_align input_align,
  344. const char *fldname, LONGEST value)
  345. {
  346. int fldno;
  347. int width;
  348. ui_align align;
  349. verify_field (&fldno, &width, &align);
  350. do_field_signed (fldno, input_width, input_align, fldname, value);
  351. }
  352. /* See ui-out.h. */
  353. void
  354. ui_out::field_unsigned (const char *fldname, ULONGEST value)
  355. {
  356. int fldno;
  357. int width;
  358. ui_align align;
  359. verify_field (&fldno, &width, &align);
  360. do_field_unsigned (fldno, width, align, fldname, value);
  361. }
  362. /* Documented in ui-out.h. */
  363. void
  364. ui_out::field_core_addr (const char *fldname, struct gdbarch *gdbarch,
  365. CORE_ADDR address)
  366. {
  367. field_string (fldname, print_core_address (gdbarch, address),
  368. address_style.style ());
  369. }
  370. void
  371. ui_out::field_stream (const char *fldname, string_file &stream,
  372. const ui_file_style &style)
  373. {
  374. if (!stream.empty ())
  375. field_string (fldname, stream.c_str (), style);
  376. else
  377. field_skip (fldname);
  378. stream.clear ();
  379. }
  380. /* Used to omit a field. */
  381. void
  382. ui_out::field_skip (const char *fldname)
  383. {
  384. int fldno;
  385. int width;
  386. ui_align align;
  387. verify_field (&fldno, &width, &align);
  388. do_field_skip (fldno, width, align, fldname);
  389. }
  390. void
  391. ui_out::field_string (const char *fldname, const char *string,
  392. const ui_file_style &style)
  393. {
  394. int fldno;
  395. int width;
  396. ui_align align;
  397. verify_field (&fldno, &width, &align);
  398. do_field_string (fldno, width, align, fldname, string, style);
  399. }
  400. /* VARARGS */
  401. void
  402. ui_out::field_fmt (const char *fldname, const char *format, ...)
  403. {
  404. va_list args;
  405. int fldno;
  406. int width;
  407. ui_align align;
  408. verify_field (&fldno, &width, &align);
  409. va_start (args, format);
  410. do_field_fmt (fldno, width, align, fldname, ui_file_style (), format, args);
  411. va_end (args);
  412. }
  413. void
  414. ui_out::field_fmt (const char *fldname, const ui_file_style &style,
  415. const char *format, ...)
  416. {
  417. va_list args;
  418. int fldno;
  419. int width;
  420. ui_align align;
  421. verify_field (&fldno, &width, &align);
  422. va_start (args, format);
  423. do_field_fmt (fldno, width, align, fldname, style, format, args);
  424. va_end (args);
  425. }
  426. void
  427. ui_out::spaces (int numspaces)
  428. {
  429. do_spaces (numspaces);
  430. }
  431. void
  432. ui_out::text (const char *string)
  433. {
  434. do_text (string);
  435. }
  436. void
  437. ui_out::call_do_message (const ui_file_style &style, const char *format,
  438. ...)
  439. {
  440. va_list args;
  441. va_start (args, format);
  442. /* Since call_do_message is only used as a helper of vmessage, silence the
  443. warning here once instead of at all call sites in vmessage, if we were
  444. to put a "format" attribute on call_do_message. */
  445. DIAGNOSTIC_PUSH
  446. DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
  447. do_message (style, format, args);
  448. DIAGNOSTIC_POP
  449. va_end (args);
  450. }
  451. void
  452. ui_out::vmessage (const ui_file_style &in_style, const char *format,
  453. va_list args)
  454. {
  455. format_pieces fpieces (&format, true);
  456. ui_file_style style = in_style;
  457. for (auto &&piece : fpieces)
  458. {
  459. const char *current_substring = piece.string;
  460. gdb_assert (piece.n_int_args >= 0 && piece.n_int_args <= 2);
  461. int intvals[2] = { 0, 0 };
  462. for (int i = 0; i < piece.n_int_args; ++i)
  463. intvals[i] = va_arg (args, int);
  464. /* The only ones we support for now. */
  465. gdb_assert (piece.n_int_args == 0
  466. || piece.argclass == string_arg
  467. || piece.argclass == int_arg
  468. || piece.argclass == long_arg);
  469. switch (piece.argclass)
  470. {
  471. case string_arg:
  472. {
  473. const char *str = va_arg (args, const char *);
  474. switch (piece.n_int_args)
  475. {
  476. case 0:
  477. call_do_message (style, current_substring, str);
  478. break;
  479. case 1:
  480. call_do_message (style, current_substring, intvals[0], str);
  481. break;
  482. case 2:
  483. call_do_message (style, current_substring,
  484. intvals[0], intvals[1], str);
  485. break;
  486. }
  487. }
  488. break;
  489. case wide_string_arg:
  490. gdb_assert_not_reached ("wide_string_arg not supported in vmessage");
  491. break;
  492. case wide_char_arg:
  493. gdb_assert_not_reached ("wide_char_arg not supported in vmessage");
  494. break;
  495. case long_long_arg:
  496. call_do_message (style, current_substring, va_arg (args, long long));
  497. break;
  498. case int_arg:
  499. {
  500. int val = va_arg (args, int);
  501. switch (piece.n_int_args)
  502. {
  503. case 0:
  504. call_do_message (style, current_substring, val);
  505. break;
  506. case 1:
  507. call_do_message (style, current_substring, intvals[0], val);
  508. break;
  509. case 2:
  510. call_do_message (style, current_substring,
  511. intvals[0], intvals[1], val);
  512. break;
  513. }
  514. }
  515. break;
  516. case long_arg:
  517. {
  518. long val = va_arg (args, long);
  519. switch (piece.n_int_args)
  520. {
  521. case 0:
  522. call_do_message (style, current_substring, val);
  523. break;
  524. case 1:
  525. call_do_message (style, current_substring, intvals[0], val);
  526. break;
  527. case 2:
  528. call_do_message (style, current_substring,
  529. intvals[0], intvals[1], val);
  530. break;
  531. }
  532. }
  533. break;
  534. case size_t_arg:
  535. {
  536. size_t val = va_arg (args, size_t);
  537. switch (piece.n_int_args)
  538. {
  539. case 0:
  540. call_do_message (style, current_substring, val);
  541. break;
  542. case 1:
  543. call_do_message (style, current_substring, intvals[0], val);
  544. break;
  545. case 2:
  546. call_do_message (style, current_substring,
  547. intvals[0], intvals[1], val);
  548. break;
  549. }
  550. }
  551. break;
  552. case double_arg:
  553. call_do_message (style, current_substring, va_arg (args, double));
  554. break;
  555. case long_double_arg:
  556. gdb_assert_not_reached ("long_double_arg not supported in vmessage");
  557. break;
  558. case dec32float_arg:
  559. gdb_assert_not_reached ("dec32float_arg not supported in vmessage");
  560. break;
  561. case dec64float_arg:
  562. gdb_assert_not_reached ("dec64float_arg not supported in vmessage");
  563. break;
  564. case dec128float_arg:
  565. gdb_assert_not_reached ("dec128float_arg not supported in vmessage");
  566. break;
  567. case ptr_arg:
  568. switch (current_substring[2])
  569. {
  570. case 'F':
  571. {
  572. gdb_assert (!test_flags (disallow_ui_out_field));
  573. base_field_s *bf = va_arg (args, base_field_s *);
  574. switch (bf->kind)
  575. {
  576. case field_kind::FIELD_SIGNED:
  577. {
  578. auto *f = (signed_field_s *) bf;
  579. field_signed (f->name, f->val);
  580. }
  581. break;
  582. case field_kind::FIELD_STRING:
  583. {
  584. auto *f = (string_field_s *) bf;
  585. field_string (f->name, f->str);
  586. }
  587. break;
  588. }
  589. }
  590. break;
  591. case 's':
  592. {
  593. styled_string_s *ss = va_arg (args, styled_string_s *);
  594. call_do_message (ss->style, "%s", ss->str);
  595. }
  596. break;
  597. case '[':
  598. style = *va_arg (args, const ui_file_style *);
  599. break;
  600. case ']':
  601. {
  602. void *arg = va_arg (args, void *);
  603. gdb_assert (arg == nullptr);
  604. style = {};
  605. }
  606. break;
  607. default:
  608. call_do_message (style, current_substring, va_arg (args, void *));
  609. break;
  610. }
  611. break;
  612. case literal_piece:
  613. /* Print a portion of the format string that has no
  614. directives. Note that this will not include any ordinary
  615. %-specs, but it might include "%%". That is why we use
  616. call_do_message here. Also, we pass a dummy argument
  617. because some platforms have modified GCC to include
  618. -Wformat-security by default, which will warn here if
  619. there is no argument. */
  620. call_do_message (style, current_substring, 0);
  621. break;
  622. default:
  623. internal_error (__FILE__, __LINE__,
  624. _("failed internal consistency check"));
  625. }
  626. }
  627. }
  628. void
  629. ui_out::message (const char *format, ...)
  630. {
  631. va_list args;
  632. va_start (args, format);
  633. vmessage (ui_file_style (), format, args);
  634. va_end (args);
  635. }
  636. void
  637. ui_out::wrap_hint (int indent)
  638. {
  639. do_wrap_hint (indent);
  640. }
  641. void
  642. ui_out::flush ()
  643. {
  644. do_flush ();
  645. }
  646. void
  647. ui_out::redirect (ui_file *outstream)
  648. {
  649. do_redirect (outstream);
  650. }
  651. /* Test the flags against the mask given. */
  652. ui_out_flags
  653. ui_out::test_flags (ui_out_flags mask)
  654. {
  655. return m_flags & mask;
  656. }
  657. bool
  658. ui_out::is_mi_like_p () const
  659. {
  660. return do_is_mi_like_p ();
  661. }
  662. /* Verify that the field/tuple/list is correctly positioned. Return
  663. the field number and corresponding alignment (if
  664. available/applicable). */
  665. void
  666. ui_out::verify_field (int *fldno, int *width, ui_align *align)
  667. {
  668. ui_out_level *current = current_level ();
  669. const char *text;
  670. if (m_table_up != nullptr
  671. && m_table_up->current_state () != ui_out_table::state::BODY)
  672. {
  673. internal_error (__FILE__, __LINE__,
  674. _("table_body missing; table fields must be \
  675. specified after table_body and inside a list."));
  676. }
  677. current->inc_field_count ();
  678. if (m_table_up != nullptr
  679. && m_table_up->current_state () == ui_out_table::state::BODY
  680. && m_table_up->entry_level () == level ()
  681. && m_table_up->get_next_header (fldno, width, align, &text))
  682. {
  683. if (*fldno != current->field_count ())
  684. internal_error (__FILE__, __LINE__,
  685. _("ui-out internal error in handling headers."));
  686. }
  687. else
  688. {
  689. *width = 0;
  690. *align = ui_noalign;
  691. *fldno = current->field_count ();
  692. }
  693. }
  694. /* Access table field parameters. */
  695. bool
  696. ui_out::query_table_field (int colno, int *width, int *alignment,
  697. const char **col_name)
  698. {
  699. if (m_table_up == nullptr)
  700. return false;
  701. return m_table_up->query_field (colno, width, alignment, col_name);
  702. }
  703. /* The constructor. */
  704. ui_out::ui_out (ui_out_flags flags)
  705. : m_flags (flags)
  706. {
  707. /* Create the ui-out level #1, the default level. */
  708. push_level (ui_out_type_tuple);
  709. }
  710. ui_out::~ui_out ()
  711. {
  712. }