From: Simon Marchi <simon.marchi@polymtl.ca>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA v2 01/24] Introduce and use ui_out_emit_table
Date: Sat, 29 Jul 2017 23:10:00 -0000 [thread overview]
Message-ID: <c3e56fed15a53e5eddb25d1d26a5c1c7@polymtl.ca> (raw)
In-Reply-To: <20170725172107.9799-2-tom@tromey.com>
Hi Tom,
Just some formatting comments, I think it's fine to push with those
fixed.
> @@ -6851,48 +6850,43 @@ breakpoint_1 (char *args, int allflag,
> }
> }
>
> - if (opts.addressprint)
> - bkpttbl_chain
> - = make_cleanup_ui_out_table_begin_end (uiout, 6,
> - nr_printable_breakpoints,
> - "BreakpointTable");
> - else
> - bkpttbl_chain
> - = make_cleanup_ui_out_table_begin_end (uiout, 5,
> - nr_printable_breakpoints,
> - "BreakpointTable");
> -
> - if (nr_printable_breakpoints > 0)
> - annotate_breakpoints_headers ();
> - if (nr_printable_breakpoints > 0)
> - annotate_field (0);
> - uiout->table_header (7, ui_left, "number", "Num"); /* 1 */
> - if (nr_printable_breakpoints > 0)
> - annotate_field (1);
> - uiout->table_header (print_type_col_width, ui_left, "type", "Type");
> /* 2 */
> - if (nr_printable_breakpoints > 0)
> - annotate_field (2);
> - uiout->table_header (4, ui_left, "disp", "Disp"); /* 3 */
> - if (nr_printable_breakpoints > 0)
> - annotate_field (3);
> - uiout->table_header (3, ui_left, "enabled", "Enb"); /* 4 */
> - if (opts.addressprint)
> - {
> - if (nr_printable_breakpoints > 0)
> - annotate_field (4);
> - if (print_address_bits <= 32)
> - uiout->table_header (10, ui_left, "addr", "Address"); /* 5 */
> - else
> - uiout->table_header (18, ui_left, "addr", "Address"); /* 5 */
> - }
> - if (nr_printable_breakpoints > 0)
> - annotate_field (5);
> - uiout->table_header (40, ui_noalign, "what", "What"); /* 6 */
> - uiout->table_body ();
> - if (nr_printable_breakpoints > 0)
> - annotate_breakpoints_table ();
> + {
> + ui_out_emit_table table_emitter (uiout,
> + opts.addressprint ? 6 : 5,
> + nr_printable_breakpoints,
> + "BreakpointTable");
> +
> + if (nr_printable_breakpoints > 0)
> + annotate_breakpoints_headers ();
> + if (nr_printable_breakpoints > 0)
> + annotate_field (0);
> + uiout->table_header (7, ui_left, "number", "Num"); /* 1 */
> + if (nr_printable_breakpoints > 0)
> + annotate_field (1);
> + uiout->table_header (print_type_col_width, ui_left, "type",
> "Type"); /* 2 */
> + if (nr_printable_breakpoints > 0)
> + annotate_field (2);
> + uiout->table_header (4, ui_left, "disp", "Disp"); /* 3 */
> + if (nr_printable_breakpoints > 0)
> + annotate_field (3);
> + uiout->table_header (3, ui_left, "enabled", "Enb"); /* 4 */
> + if (opts.addressprint)
> + {
> + if (nr_printable_breakpoints > 0)
> + annotate_field (4);
> + if (print_address_bits <= 32)
> + uiout->table_header (10, ui_left, "addr", "Address"); /* 5 */
> + else
> + uiout->table_header (18, ui_left, "addr", "Address"); /* 5 */
> + }
> + if (nr_printable_breakpoints > 0)
> + annotate_field (5);
> + uiout->table_header (40, ui_noalign, "what", "What"); /* 6 */
> + uiout->table_body ();
> + if (nr_printable_breakpoints > 0)
> + annotate_breakpoints_table ();
>
> - ALL_BREAKPOINTS (b)
> + ALL_BREAKPOINTS (b)
Shouldn't the scope just under this be indented as well?
> @@ -1075,19 +1074,18 @@ info_sharedlibrary_command (char *pattern, int
> from_tty)
> }
> }
>
> - table_cleanup =
> - make_cleanup_ui_out_table_begin_end (uiout, 4, nr_libs,
> - "SharedLibraryTable");
> + {
> + ui_out_emit_table table_emitter (uiout, 4, nr_libs,
> "SharedLibraryTable");
>
> - /* The "- 1" is because ui_out adds one space between columns. */
> - uiout->table_header (addr_width - 1, ui_left, "from", "From");
> - uiout->table_header (addr_width - 1, ui_left, "to", "To");
> - uiout->table_header (12 - 1, ui_left, "syms-read", "Syms Read");
> - uiout->table_header (0, ui_noalign, "name", "Shared Object
> Library");
> + /* The "- 1" is because ui_out adds one space between columns. */
> + uiout->table_header (addr_width - 1, ui_left, "from", "From");
> + uiout->table_header (addr_width - 1, ui_left, "to", "To");
> + uiout->table_header (12 - 1, ui_left, "syms-read", "Syms Read");
> + uiout->table_header (0, ui_noalign, "name", "Shared Object
> Library");
>
> - uiout->table_body ();
> + uiout->table_body ();
>
> - ALL_SO_LIBS (so)
> + ALL_SO_LIBS (so)
I think the scope below should be indented as well.
> {
> if (! so->so_name[0])
> continue;
> @@ -1121,8 +1119,7 @@ info_sharedlibrary_command (char *pattern, int
> from_tty)
>
> uiout->text ("\n");
> }
> -
> - do_cleanups (table_cleanup);
> + }
>
> if (nr_libs == 0)
> {
> diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
> index 4f2bac5..6721e22 100644
> --- a/gdb/tracepoint.c
> +++ b/gdb/tracepoint.c
> @@ -482,7 +482,6 @@ tvariables_info_1 (void)
> struct trace_state_variable *tsv;
> int ix;
> int count = 0;
> - struct cleanup *back_to;
> struct ui_out *uiout = current_uiout;
>
> if (VEC_length (tsv_s, tvariables) == 0 && !uiout->is_mi_like_p ())
> @@ -496,8 +495,7 @@ tvariables_info_1 (void)
> tsv->value_known = target_get_trace_state_variable_value
> (tsv->number,
> &(tsv->value));
>
> - back_to = make_cleanup_ui_out_table_begin_end (uiout, 3,
> - count,
> "trace-variables");
> + ui_out_emit_table table_emitter (uiout, 3, count,
> "trace-variables");
> uiout->table_header (15, ui_left, "name", "Name");
> uiout->table_header (11, ui_left, "initial", "Initial");
> uiout->table_header (11, ui_left, "current", "Current");
> @@ -531,8 +529,6 @@ tvariables_info_1 (void)
> uiout->field_string ("current", c);
> uiout->text ("\n");
> }
> -
> - do_cleanups (back_to);
> }
>
> /* List all the trace state variables. */
> @@ -3952,9 +3948,8 @@ info_static_tracepoint_markers_command (char
> *arg, int from_tty)
> don't work without in-process agent, so we don't bother users to
> type
> `set agent on' when to use static tracepoint. */
>
> - old_chain
> - = make_cleanup_ui_out_table_begin_end (uiout, 5, -1,
> - "StaticTracepointMarkersTable");
> + ui_out_emit_table table_emitter (uiout, 5, -1,
> + "StaticTracepointMarkersTable");
>
> uiout->table_header (7, ui_left, "counter", "Cnt");
>
> @@ -3970,7 +3965,7 @@ info_static_tracepoint_markers_command (char
> *arg, int from_tty)
> uiout->table_body ();
>
> markers = target_static_tracepoint_markers_by_strid (NULL);
> - make_cleanup (VEC_cleanup (static_tracepoint_marker_p), &markers);
> + old_chain = make_cleanup (VEC_cleanup (static_tracepoint_marker_p),
> &markers);
>
> for (i = 0;
> VEC_iterate (static_tracepoint_marker_p,
> diff --git a/gdb/ui-out.h b/gdb/ui-out.h
> index 9278cab..2293f26 100644
> --- a/gdb/ui-out.h
> +++ b/gdb/ui-out.h
> @@ -220,4 +220,31 @@ private:
> typedef ui_out_emit_type<ui_out_type_tuple> ui_out_emit_tuple;
> typedef ui_out_emit_type<ui_out_type_list> ui_out_emit_list;
>
> +/* This is similar to make_cleanup_ui_out_table_begin_end, but written
> + as an RAII class. */
> +class ui_out_emit_table
> +{
> +public:
> +
> + ui_out_emit_table (struct ui_out *uiout, int nr_cols, int nr_rows,
> + const char *tblid)
> +
Spurious empty line?
> + : m_uiout (uiout)
> + {
> + m_uiout->table_begin (nr_cols, nr_rows, tblid);
> + }
> +
> + ~ui_out_emit_table ()
> + {
> + m_uiout->table_end ();
> + }
> +
> + ui_out_emit_table (const ui_out_emit_table &) = delete;
> + ui_out_emit_table &operator= (const ui_out_emit_table &) = delete;
> +
> +private:
> +
> + struct ui_out *m_uiout;
> +};
> +
> #endif /* UI_OUT_H */
Thanks,
Simon
next prev parent reply other threads:[~2017-07-29 23:10 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-25 17:24 [RFA v2 00/24] More miscellaneous C++-ification Tom Tromey
2017-07-25 17:21 ` [RFA v2 18/24] Use a scoped_restore for command_nest_depth Tom Tromey
2017-07-25 17:21 ` [RFA v2 19/24] Replace do_restore_instream_cleanup with scoped_restore Tom Tromey
2017-07-25 17:21 ` [RFA v2 23/24] Use gdb_argv in Python Tom Tromey
2017-07-31 20:26 ` Simon Marchi
2017-07-25 17:21 ` [RFA v2 22/24] Introduce gdb_argv, a class wrapper for buildargv Tom Tromey
2017-07-31 20:22 ` Simon Marchi
2017-07-25 17:22 ` [RFA v2 05/24] Use gdb_file_up in source.c Tom Tromey
2017-07-30 18:59 ` Simon Marchi
2017-07-25 17:22 ` [RFA v2 12/24] More uses of scoped_restore Tom Tromey
2017-07-25 17:22 ` [RFA v2 16/24] Remove in_user_command Tom Tromey
2017-07-25 17:24 ` [RFA v2 06/24] Change open_terminal_stream to return a gdb_file_up Tom Tromey
2017-07-30 19:04 ` Simon Marchi
2017-07-25 17:24 ` [RFA v2 08/24] Remove an unlink cleanup Tom Tromey
2017-07-31 18:47 ` Simon Marchi
2017-07-25 17:24 ` [RFA v2 09/24] Remove close cleanup Tom Tromey
2017-07-31 19:09 ` Simon Marchi
2017-07-25 17:24 ` [RFA v2 24/24] Remove make_cleanup_freeargv and gdb_buildargv Tom Tromey
2017-07-31 20:26 ` Simon Marchi
2017-07-25 17:25 ` [RFA v2 10/24] Remove make_cleanup_restore_current_language Tom Tromey
2017-07-31 19:21 ` Simon Marchi
2017-07-31 22:17 ` Tom Tromey
2017-08-01 8:44 ` Simon Marchi
2017-07-25 17:26 ` [RFA v2 07/24] Remove make_cleanup_fclose Tom Tromey
2017-07-30 19:05 ` Simon Marchi
2017-07-25 17:26 ` [RFA v2 21/24] Remove a cleanup in Python Tom Tromey
2017-07-25 17:26 ` [RFA v2 04/24] Use gdb_file_up in fbsd-nat.c Tom Tromey
2017-07-29 23:56 ` Simon Marchi
2017-07-25 17:26 ` [RFA v2 02/24] Introduce and use gdb_file_up Tom Tromey
2017-07-29 23:40 ` Simon Marchi
2017-07-30 16:25 ` Tom Tromey
2017-07-30 18:31 ` Simon Marchi
2017-07-25 17:26 ` [RFA v2 01/24] Introduce and use ui_out_emit_table Tom Tromey
2017-07-29 23:10 ` Simon Marchi [this message]
2017-07-30 16:23 ` Tom Tromey
2017-07-30 18:29 ` Simon Marchi
2017-07-31 22:12 ` Tom Tromey
2017-07-25 17:27 ` [RFA v2 14/24] Use unique_xmalloc_ptr in jit.c Tom Tromey
2017-07-31 19:25 ` Simon Marchi
2017-07-25 17:27 ` [RFA v2 13/24] Replace tui_restore_gdbout with scoped_restore Tom Tromey
2017-07-25 17:27 ` [RFA v2 15/24] Use containers to avoid cleanups Tom Tromey
2017-07-31 19:42 ` Simon Marchi
2017-07-25 17:27 ` [RFA v2 03/24] Change return type of find_and_open_script Tom Tromey
2017-07-29 23:54 ` Simon Marchi
2017-07-30 16:27 ` Tom Tromey
2017-07-25 17:51 ` [RFA v2 20/24] Avoid some manual memory management in Python Tom Tromey
2017-07-25 18:02 ` [RFA v2 17/24] Remove user_call_depth Tom Tromey
2017-07-31 19:46 ` Simon Marchi
2017-07-25 18:04 ` [RFA v2 11/24] Remove make_cleanup_free_so Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c3e56fed15a53e5eddb25d1d26a5c1c7@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).