diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2016-12-01 16:05:17 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2016-12-01 16:05:17 -0500 |
commit | 33b2fac610fff1255a24763277a4bf77f1b59ef1 (patch) | |
tree | c08dc9784a1383b8d9fce71e923462aef9b5fdec /gdb/mi/mi-out.c | |
parent | 909c0aa5824080c287b390f82726cf5bfb7011e3 (diff) | |
download | gdb-33b2fac610fff1255a24763277a4bf77f1b59ef1.zip gdb-33b2fac610fff1255a24763277a4bf77f1b59ef1.tar.gz gdb-33b2fac610fff1255a24763277a4bf77f1b59ef1.tar.bz2 |
Simplify ui-out level code
Now that we use a vector to store the levels, we don't have to keep a
separate level field in ui_out to keep track of the current level. We
can efficiently derive it from the vector size. That causes a little
change in the meaning of the level, as in they are now 1-based instead
of 0-based (the initial level has the "id" 1 now), but it shouldn't
change anything in the behavior.
Additionally, push_level and pop_level don't really need to return the
new level, making them return void simplifies the code a bit.
Finally, the ui_out_begin/ui_out_end callbacks in the ui_out_impl
interface don't need to be passed the level, it's never actually used.
New in v2:
- Remove or update stale comments.
gdb/ChangeLog:
* ui-out.h (ui_out_begin_ftype): Remove level parameter.
(ui_out_end_ftype): Likewise.
* ui-out.c (struct ui_out) <level>: Replace field with a method
that dynamically computes the result.
(current_level): Get vector's back item instead of using
uiout->level.
(push_level): Make return type void.
(pop_level): Make return type void and update access to
ui_out::level.
(uo_begin): Remove level parameter.
(uo_end): Likewise.
(ui_out_table_begin): Update access to uiout::level.
(ui_out_begin): Don't read return value from push_level, call
uiout->level() instead, update call to uo_begin.
(ui_out_end): Don't read return value from pop_level, update
call to uo_end.
(verify_field): Update access to uiout->level.
(ui_out_new): Don't initialize ui_out::level, call push_level
to push the initial level instead of doing it by hand.
* cli-out.c (cli_begin): Remove level parameter.
(cli_end): Likewise.
* mi/mi-out.c (mi_begin): Likewise.
(mi_end): Likewise.
Diffstat (limited to 'gdb/mi/mi-out.c')
-rw-r--r-- | gdb/mi/mi-out.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c index 9a2cb83..b6d25d3 100644 --- a/gdb/mi/mi-out.c +++ b/gdb/mi/mi-out.c @@ -45,8 +45,8 @@ static void mi_table_header (struct ui_out *uiout, int width, const std::string &col_name, const std::string &col_hdr); static void mi_begin (struct ui_out *uiout, enum ui_out_type type, - int level, const char *id); -static void mi_end (struct ui_out *uiout, enum ui_out_type type, int level); + const char *id); +static void mi_end (struct ui_out *uiout, enum ui_out_type type); static void mi_field_int (struct ui_out *uiout, int fldno, int width, enum ui_align alig, const char *fldname, int value); static void mi_field_skip (struct ui_out *uiout, int fldno, int width, @@ -159,8 +159,7 @@ mi_table_header (struct ui_out *uiout, int width, enum ui_align alignment, /* Mark beginning of a list. */ void -mi_begin (struct ui_out *uiout, enum ui_out_type type, int level, - const char *id) +mi_begin (struct ui_out *uiout, enum ui_out_type type, const char *id) { mi_out_data *data = (mi_out_data *) ui_out_data (uiout); @@ -173,7 +172,7 @@ mi_begin (struct ui_out *uiout, enum ui_out_type type, int level, /* Mark end of a list. */ void -mi_end (struct ui_out *uiout, enum ui_out_type type, int level) +mi_end (struct ui_out *uiout, enum ui_out_type type) { mi_out_data *data = (mi_out_data *) ui_out_data (uiout); |