gdb/ui-out.h - gdb

Data types defined

Macros defined

Source code

  1. /* Output generating routines for GDB.

  2.    Copyright (C) 1999-2015 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. #ifndef UI_OUT_H
  17. #define UI_OUT_H 1

  18. /* The ui_out structure */

  19. struct ui_out;
  20. struct ui_file;

  21. /* the current ui_out */

  22. /* FIXME: This should not be a global but something passed down from main.c
  23.    or top.c.  */
  24. extern struct ui_out *current_uiout;

  25. /* alignment enum */
  26. enum ui_align
  27.   {
  28.     ui_left = -1,
  29.     ui_center,
  30.     ui_right,
  31.     ui_noalign
  32.   };

  33. /* flags enum */
  34. enum ui_flags
  35.   {
  36.     ui_from_tty = 1,
  37.     ui_source_list = 2
  38.   };


  39. /* Prototypes for ui-out API.  */

  40. /* A result is a recursive data structure consisting of lists and
  41.    tuples.  */

  42. enum ui_out_type
  43.   {
  44.     ui_out_type_tuple,
  45.     ui_out_type_list
  46.   };

  47. extern void ui_out_begin (struct ui_out *uiout,
  48.                           enum ui_out_type level_type,
  49.                           const char *id);

  50. extern void ui_out_end (struct ui_out *uiout, enum ui_out_type type);

  51. extern struct cleanup *ui_out_begin_cleanup_end (struct ui_out *uiout,
  52.                                                  enum ui_out_type level_type,
  53.                                                  const char *id);

  54. /* A table can be considered a special tuple/list combination with the
  55.    implied structure: ``table = { hdr = { header, ... } , body = [ {
  56.    field, ... }, ... ] }''.  If NR_ROWS is negative then there is at
  57.    least one row.  */
  58. extern void ui_out_table_header (struct ui_out *uiout, int width,
  59.                                  enum ui_align align, const char *col_name,
  60.                                  const char *colhdr);

  61. extern void ui_out_table_body (struct ui_out *uiout);

  62. extern struct cleanup *make_cleanup_ui_out_table_begin_end (struct ui_out *ui_out,
  63.                                                             int nr_cols,
  64.                                                             int nr_rows,
  65.                                                             const char *tblid);
  66. /* Compatibility wrappers.  */

  67. extern struct cleanup *make_cleanup_ui_out_list_begin_end (struct ui_out *uiout,
  68.                                                            const char *id);

  69. extern struct cleanup *make_cleanup_ui_out_tuple_begin_end (struct ui_out *uiout,
  70.                                                             const char *id);

  71. extern void ui_out_field_int (struct ui_out *uiout, const char *fldname,
  72.                               int value);

  73. extern void ui_out_field_fmt_int (struct ui_out *uiout, int width,
  74.                                   enum ui_align align, const char *fldname,
  75.                                    int value);

  76. /* Output a field containing an address.  */

  77. extern void ui_out_field_core_addr (struct ui_out *uiout, const char *fldname,
  78.                                     struct gdbarch *gdbarch, CORE_ADDR address);

  79. extern void ui_out_field_string (struct ui_out * uiout, const char *fldname,
  80.                                  const char *string);

  81. extern void ui_out_field_stream (struct ui_out *uiout, const char *fldname,
  82.                                  struct ui_file *stream);

  83. extern void ui_out_field_fmt (struct ui_out *uiout, const char *fldname,
  84.                               const char *format, ...)
  85.      ATTRIBUTE_PRINTF (3, 4);

  86. extern void ui_out_field_skip (struct ui_out *uiout, const char *fldname);

  87. extern void ui_out_spaces (struct ui_out *uiout, int numspaces);

  88. extern void ui_out_text (struct ui_out *uiout, const char *string);

  89. extern void ui_out_message (struct ui_out *uiout, int verbosity,
  90.                             const char *format, ...)
  91.      ATTRIBUTE_PRINTF (3, 4);

  92. extern void ui_out_wrap_hint (struct ui_out *uiout, char *identstring);

  93. extern void ui_out_flush (struct ui_out *uiout);

  94. extern int ui_out_set_flags (struct ui_out *uiout, int mask);

  95. extern int ui_out_clear_flags (struct ui_out *uiout, int mask);

  96. extern int ui_out_get_verblvl (struct ui_out *uiout);

  97. extern int ui_out_test_flags (struct ui_out *uiout, int mask);

  98. extern int ui_out_query_field (struct ui_out *uiout, int colno,
  99.                                int *width, int *alignment, char **col_name);

  100. /* HACK: Code in GDB is currently checking to see the type of ui_out
  101.    builder when determining which output to produce.  This function is
  102.    a hack to encapsulate that test.  Once GDB manages to separate the
  103.    CLI/MI from the core of GDB the problem should just go away ....  */

  104. extern int ui_out_is_mi_like_p (struct ui_out *uiout);

  105. /* From here on we have things that are only needed by implementation
  106.    routines and main.c.   We should pehaps have a separate file for that,
  107.    like a  ui-out-impl.h  file.  */

  108. /* User Interface Output Implementation Function Table */

  109. /* Type definition of all implementation functions.  */

  110. typedef void (table_begin_ftype) (struct ui_out * uiout,
  111.                                   int nbrofcols, int nr_rows,
  112.                                   const char *tblid);
  113. typedef void (table_body_ftype) (struct ui_out * uiout);
  114. typedef void (table_end_ftype) (struct ui_out * uiout);
  115. typedef void (table_header_ftype) (struct ui_out * uiout, int width,
  116.                                    enum ui_align align, const char *col_name,
  117.                                    const char *colhdr);
  118. /* Note: level 0 is the top-level so LEVEL is always greater than
  119.    zero.  */
  120. typedef void (ui_out_begin_ftype) (struct ui_out *uiout,
  121.                                    enum ui_out_type type,
  122.                                    int level, const char *id);
  123. typedef void (ui_out_end_ftype) (struct ui_out *uiout,
  124.                                  enum ui_out_type type,
  125.                                  int level);
  126. typedef void (field_int_ftype) (struct ui_out * uiout, int fldno, int width,
  127.                                 enum ui_align align,
  128.                                 const char *fldname, int value);
  129. typedef void (field_skip_ftype) (struct ui_out * uiout, int fldno, int width,
  130.                                  enum ui_align align,
  131.                                  const char *fldname);
  132. typedef void (field_string_ftype) (struct ui_out * uiout, int fldno, int width,
  133.                                    enum ui_align align,
  134.                                    const char *fldname,
  135.                                    const char *string);
  136. typedef void (field_fmt_ftype) (struct ui_out * uiout, int fldno, int width,
  137.                                 enum ui_align align,
  138.                                 const char *fldname,
  139.                                 const char *format,
  140.                                 va_list args) ATTRIBUTE_FPTR_PRINTF(6,0);
  141. typedef void (spaces_ftype) (struct ui_out * uiout, int numspaces);
  142. typedef void (text_ftype) (struct ui_out * uiout,
  143.                            const char *string);
  144. typedef void (message_ftype) (struct ui_out * uiout, int verbosity,
  145.                               const char *format, va_list args)
  146.      ATTRIBUTE_FPTR_PRINTF(3,0);
  147. typedef void (wrap_hint_ftype) (struct ui_out * uiout, char *identstring);
  148. typedef void (flush_ftype) (struct ui_out * uiout);
  149. typedef int (redirect_ftype) (struct ui_out * uiout,
  150.                               struct ui_file * outstream);
  151. typedef void (data_destroy_ftype) (struct ui_out *uiout);

  152. /* ui-out-impl */

  153. /* IMPORTANT: If you change this structure, make sure to change the default
  154.    initialization in ui-out.c.  */

  155. struct ui_out_impl
  156.   {
  157.     table_begin_ftype *table_begin;
  158.     table_body_ftype *table_body;
  159.     table_end_ftype *table_end;
  160.     table_header_ftype *table_header;
  161.     ui_out_begin_ftype *begin;
  162.     ui_out_end_ftype *end;
  163.     field_int_ftype *field_int;
  164.     field_skip_ftype *field_skip;
  165.     field_string_ftype *field_string;
  166.     field_fmt_ftype *field_fmt;
  167.     spaces_ftype *spaces;
  168.     text_ftype *text;
  169.     message_ftype *message;
  170.     wrap_hint_ftype *wrap_hint;
  171.     flush_ftype *flush;
  172.     redirect_ftype *redirect;
  173.     data_destroy_ftype *data_destroy;
  174.     int is_mi_like_p;
  175.   };

  176. extern void *ui_out_data (struct ui_out *uiout);

  177. extern void uo_field_string (struct ui_out *uiout, int fldno, int width,
  178.                              enum ui_align align, const char *fldname,
  179.                              const char *string);

  180. /* Create a ui_out object */

  181. extern struct ui_out *ui_out_new (const struct ui_out_impl *impl,
  182.                                   void *data,
  183.                                   int flags);

  184. /* Destroy a ui_out object.  */

  185. extern void ui_out_destroy (struct ui_out *uiout);

  186. /* Redirect the ouptut of a ui_out object temporarily.  */

  187. extern int ui_out_redirect (struct ui_out *uiout, struct ui_file *outstream);

  188. #endif /* UI_OUT_H */