This patch adds separate styling for line numbers. That is, whenever
gdb prints a source line number, it uses this style.
v2 includes a change to ensure that %ps works in query.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-by: Keith Seitz <keiths@redhat.com>
Now that defs.h, server.h and common-defs.h are included via the
`-include` option, it is no longer necessary for source files to include
them. Remove all the inclusions of these files I could find. Update
the generation scripts where relevant.
Change-Id: Ia026cff269c1b7ae7386dd3619bc9bb6a5332837
Approved-By: Pedro Alves <pedro@palves.net>
Introduce new ui_file buffering_file to temporarily collect output
written to gdb_std* output streams during print_thread, print_frame_info
and print_stop_event.
This ensures that output during these functions is not interrupted
by debuginfod progress messages.
With the addition of deferred debuginfo downloading it is possible
for download progress messages to print during these events.
Without any intervention we can end up with poorly formatted output:
(gdb) backtrace
[...]
#8 0x00007fbe8af7d7cf in pygi_invoke_c_callable (Downloading separate debug info for /lib64/libpython3.11.so.1.0
function_cache=0x561221b224d0, state=<optimized out>...
To fix this we buffer writes to gdb_std* output streams while allowing
debuginfod progress messages to skip the buffers and print to the
underlying output streams immediately. Buffered output is then written
to the output streams. This ensures that progress messages print first,
followed by uninterrupted frame/thread/stop info:
(gdb) backtrace
[...]
Downloading separate debug info for /lib64/libpython3.11.so.1.0
#8 0x00007fbe8af7d7cf in pygi_invoke_c_callable (function_cache=0x561221b224d0, state=<optimized out>...
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is the result of the following actions:
- Running gdb/copyright.py to update all of the copyright headers to
include 2024,
- Manually updating a few files the copyright.py script told me to
update, these files had copyright headers embedded within the
file,
- Regenerating gdbsupport/Makefile.in to refresh it's copyright
date,
- Using grep to find other files that still mentioned 2023. If
these files were updated last year from 2022 to 2023 then I've
updated them this year to 2024.
I'm sure I've probably missed some dates. Feel free to fix them up as
you spot them.
common-defs.h has a few defines that I suspect were used during the
transition to C++. These aren't needed any more, so remove them.
Tested by rebuilding.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
clear_current_line overwrites the current line with chars_per_line
blank spaces. Printing the final space triggers a condition in
pager_file::puts that causes lines_printed to be incremented. If
lines_printed becomes greater than or equal to lines_allowed, the
pagination prompt will appear if enabled.
In this case the prompt is unnecessary since after printing the final
space clear_current_line immediately moves the cursor to the beginning
of the line with '\r'. A new line isn't actually started, so the prompt
ends up being spurious.
Additionally it's possible for gdb to crash during this pagination prompt.
Answering the prompt with 'q' throws an exception intended to bring gdb
back to the main event loop. But since commit 0fea10f327,
clear_current_line may be called under the progress_update destructor.
The exception will try to propagate through the destructor, causing an abort.
To fix this, pagination is disabled for the duration for clear_current_line.
clear_current_line is also renamed to clear_progress_notify to help
indicate that it is a special purpose function intended for use with
do_progress_notify.
Acked-by: Eli Zaretskii <eliz@gnu.org>
I'd like to move some things so they become methods on struct ui. But
first, I think that struct ui and the related things are big enough to
deserve their own file, instead of being scattered through top.{c,h} and
event-top.c.
Change-Id: I15594269ace61fd76ef80a7b58f51ff3ab6979bc
This commit is the result of running the gdb/copyright.py script,
which automated the update of the copyright year range for all
source files managed by the GDB project to be updated to include
year 2023.
If the download size is known, a progress bar is displayed along with
the percentage of completion and the total download size.
Downloading separate debug info for /lib/libxyz.so
[############ ] 25% (10.01 M)
If the download size is not known, a progress indicator is displayed
with a ticker ("###") that moves across the screen at a rate of 1 tick
every 0.5 seconds.
Downloading separate debug info for /lib/libxyz.so
[ ### ]
If the output stream is not a tty, batch mode is enabled, the screen is
too narrow or width has been set to 'unlimited', then only a static
description of the download is printed. No bar or ticker is displayed.
Downloading separate debug info for /lib/libxyz.so...
In any case, if the size of the download is known at the time the
description is printed then it will be included in the description.
Downloading 10.01 MB separate debug info for /lib/libxyz.so...
There is no longer any need for ui_out_flag::unfiltered_output --
nothing ever sets this flag. This used to be needed to make the
_unfiltered output work, but now only printf_unfiltered can be used,
and it uses the puts_unfiltered method. This patch removes the flag
and the dead code.
Now that filtered and unfiltered output can be treated identically, we
can unify the printf family of functions. This is done under the name
"gdb_printf". Most of this patch was written by script.
Now that filtered and unfiltered output can be treated identically, we
can unify the putc family of functions. This is done under the name
"gdb_putc". Most of this patch was written by script.
Now that filtered and unfiltered output can be treated identically, we
can unify the puts family of functions. This is done under the name
"gdb_puts". Most of this patch was written by script.
Right now, wrap_here is a global function. In the long run, we'd like
output streams to be relatively self-contained objects, and having a
global function like this is counter to that goal. Also, existing
code freely mixes writes to some parameterized stream with calls to
wrap_here -- but wrap_here only really affects gdb_stdout, so this is
also incoherent.
This step is a patch toward making wrap_here more sane. It adds a
wrap_here method to ui_file and changes ui_out implementations to use
it.
I think it only really makes sense to call wrap_here with an argument
consisting solely of spaces. Given this, it seemed better to me that
the argument be an int, rather than a string. This patch is the
result. Much of it was written by a script.
This commit brings all the changes made by running gdb/copyright.py
as per GDB's Start of New Year Procedure.
For the avoidance of doubt, all changes in this commits were
performed by the script.
This removes the print_spaces helper function, in favor of using the
"*%s" idiom that's already used in many places in gdb. One spot (in
symmisc.c) is changed to use print_spaces_filtered, because the rest
of that function is using filtered output. (This highlights one way
that the printf idiom is better -- this error is harder to make when
using that.)
Regression tested on x86-64 Fedora 34.
This commits the result of running gdb/copyright.py as per our Start
of New Year procedure...
gdb/ChangeLog
Update copyright year range in copyright header of all GDB files.
Prints progress like:
Downloading 4.89 MB separate debug info for /usr/lib64/libgcrypt.so.20.
Downloading 1.10 MB separate debug info for /usr/lib64/liblzma.so.5.
Downloading 1.31 MB separate debug info for /usr/lib64/liblz4.so.1.
Downloading 0.96 MB separate debug info for /usr/lib64/libsmime3.so.
[### ]
Tested on x86_64-linux.
ChangeLog:
2020-12-16 Martin Liska <mliska@suse.cz>
Tom de Vries <tdevries@suse.de>
* gdb/debuginfod-support.c (struct user_data): Remove has_printed
field. Add meter field.
(progressfn): Print progress using meter.
This introduces a new "metadata" style and changes many places in gdb
to use it. The idea here is to let the user distinguish gdb output
from output that (conceptually at least) comes directly from the
inferior. The newly-styled category includes text that gdb
traditionally surrounds in "<...>", like "<unavailable>".
I only added a single test for this. In many cases this output is
difficult to test. Also, while developing this errors in the
implementation of the new printf formats showed up as regressions.
gdb/ChangeLog
2019-10-01 Tom Tromey <tom@tromey.com>
* p-lang.c (pascal_printstr): Use metadata style.
* value.c (show_convenience): Use metadata style.
* valprint.c (valprint_check_validity, val_print_optimized_out)
(val_print_not_saved, val_print_unavailable)
(val_print_invalid_address, generic_val_print, val_print)
(value_check_printable, val_print_array_elements): Use metadata
style.
* ui-out.h (class ui_out) <field_fmt>: New overload.
<do_field_fmt>: Add style parameter.
* ui-out.c (ui_out::field_fmt): New overload.
* typeprint.c (type_print_unknown_return_type)
(val_print_not_allocated, val_print_not_associated): Use metadata
style.
* tui/tui-out.h (class tui_ui_out) <do_field_fmt>: Add style
parameter.
* tui/tui-out.c (tui_ui_out::do_field_fmt): Update.
* tracepoint.c (tvariables_info_1): Use metadata style.
* stack.c (print_frame_arg, print_frame_info, print_frame)
(info_frame_command_core): Use metadata style.
* skip.c (info_skip_command): Use metadata style.
* rust-lang.c (rust_print_enum): Use metadata style.
* python/py-prettyprint.c (print_stack_unless_memory_error): Use
metadata style.
* python/py-framefilter.c (py_print_single_arg): Use metadata
style.
* printcmd.c (do_one_display, print_variable_and_value): Use
metadata style.
* p-valprint.c (pascal_val_print)
(pascal_object_print_value_fields): Use metadata style.
* p-typeprint.c (pascal_type_print_base): Use metadata style.
* mi/mi-out.h (class mi_ui_out) <do_field_fmt>: Add style
parameter.
* mi/mi-out.c (mi_ui_out::do_field_fmt): Update.
* m2-valprint.c (m2_print_long_set): Use metadata style.
* m2-typeprint.c (m2_print_type): Use metadata style.
* infcmd.c (print_return_value_1): Use metadata style.
* gnu-v3-abi.c (print_one_vtable): Use metadata style.
* f-valprint.c (info_common_command_for_block): Use metadata
style.
* f-typeprint.c (f_type_print_base): Use metadata style.
* expprint.c (print_subexp_standard): Use metadata style.
* cp-valprint.c (cp_print_value_fields): Use metadata style.
* cli/cli-style.h (class cli_style_option): Add constructor.
(metadata_style): Declare.
* cli/cli-style.c (metadata_style): New global.
(_initialize_cli_style): Register metadata style.
* cli-out.h (class cli_ui_out) <do_field_fmt>: Add style
parameter.
* cli-out.c (cli_ui_out::do_field_fmt): Update.
* c-typeprint.c (c_type_print_base_struct_union)
(c_type_print_base_1): Use metadata style.
* breakpoint.c (watchpoint_value_print)
(print_one_breakpoint_location): Use metadata style.
* break-catch-syscall.c (print_one_catch_syscall): Use metadata
style.
* break-catch-sig.c (signal_catchpoint_print_one): Use metadata
style.
* ada-valprint.c (val_print_packed_array_elements, printstr)
(print_field_values, ada_val_print_ref, ada_val_print): Use
metadata style.
* ada-typeprint.c (print_array_type, ada_print_type): Use metadata
style.
* ada-tasks.c (print_ada_task_info, info_task): Use metadata
style.
* ada-lang.c (user_select_syms): Use metadata style.
gdb/testsuite/ChangeLog
2019-10-01 Tom Tromey <tom@tromey.com>
* lib/gdb-utils.exp (style): Handle "metadata" argument.
* gdb.base/style.exp: Add metadata style test.
This introduces a few gdb-specific %p format suffixes. This is useful
for emitting gdb-specific output in an ergonomic way. It also yields
code that is more i18n-friendly.
The comment before ui_out::message explains the details.
Note that the tests had to change a little. When using one of the gdb
printf functions with styling, there can be spurious style changes
emitted to the output. This did not seem worthwhile to fix, as the
low-level output functions are rather spaghetti-ish already, and I
didn't want to make them even worse.
This change also necessitated adding support for "*" as precision and
width in format_pieces. These are used in various spots in gdb, and
it seemed better to me to implement them than to remove the uses.
gdb/ChangeLog
2019-10-01 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* unittests/format_pieces-selftests.c: Add gdb_format parameter.
(test_gdb_formats): New function.
(run_tests): Call it.
(test_format_specifier): Update.
* utils.h (fputs_filtered): Update comment.
(vfprintf_styled, vfprintf_styled_no_gdbfmt)
(fputs_styled_unfiltered): Declare.
* utils.c (fputs_styled_unfiltered): New function.
(vfprintf_maybe_filtered): Add gdbfmt parameter.
(vfprintf_filtered): Update.
(vfprintf_unfiltered, vprintf_filtered): Update.
(vfprintf_styled, vfprintf_styled_no_gdbfmt): New functions.
* ui-out.h (enum ui_out_flag) <unfiltered_output,
disallow_ui_out_field>: New constants.
(enum class field_kind): New.
(struct base_field_s, struct signed_field_s): New.
(signed_field): New function.
(struct string_field_s): New.
(string_field): New function.
(struct styled_string_s): New.
(styled_string): New function.
(class ui_out) <message>: Add comment.
<vmessage, call_do_message>: New methods.
<do_message>: Add style parameter.
* ui-out.c (ui_out::call_do_message, ui_out::vmessage): New
methods.
(ui_out::message): Rewrite.
* mi/mi-out.h (class mi_ui_out) <do_message>: Add style
parameter.
* mi/mi-out.c (mi_ui_out::do_message): Add style parameter.
* gdbsupport/format.h (class format_pieces) <format_pieces>: Add
gdb_extensions parameter.
(class format_piece): Add parameter to constructor.
(n_int_args): New field.
* gdbsupport/format.c (format_pieces::format_pieces): Add
gdb_extensions parameter. Handle '*'.
* cli-out.h (class cli_ui_out) <do_message>: Add style parameter.
* cli-out.c (cli_ui_out::do_message): Add style parameter. Call
vfprintf_styled_no_gdbfmt.
(cli_ui_out::do_field_string, cli_ui_out::do_spaces)
(cli_ui_out::do_text, cli_ui_out::field_separator): Allow
unfiltered output.
* ui-style.h (struct ui_file_style) <ptr>: New method.
gdb/testsuite/ChangeLog
2019-10-01 Tom Tromey <tom@tromey.com>
* gdb.base/style.exp: Update tests.
This adds more styling to the disassemble command. In particular,
addresses and function names in the disassembly are now styled.
This required fixing a small latent bug in set_output_style. This
function always passed NULL to emit_style_escape; but when writing to
a file other than gdb_stdout, it should emit the style escape
directly. (FWIW this is another argument for better integrating the
pager with ui_file and getting rid of this entire layer.)
gdb/ChangeLog
2019-08-06 Tom Tromey <tom@tromey.com>
* utils.c (set_output_style): Sometimes pass stream to
emit_style_escape.
* ui-out.h (class ui_out) <can_emit_style_escape>: Declare.
* record-btrace.c (btrace_insn_history): Update.
* mi/mi-out.h (class mi_ui_out) <can_emit_style_escape>: New
method.
* disasm.h (gdb_pretty_print_disassembler): Add uiout parameter.
Update initializers.
<m_uiout>: New field.
<m_di>: Move lower.
* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn):
Remove "uiout" parameter.
(dump_insns): Update.
* cli-out.h (class cli_ui_out) <can_emit_style_escape>: Declare.
* cli-out.c (cli_ui_out::can_emit_style_escape): New method.
gdb/testsuite/ChangeLog
2019-08-06 Tom Tromey <tom@tromey.com>
* gdb.base/style.exp: Add disassemble test.
* gdb.base/style.c (some_called_function): New function.
(main): Use it.
This adds field_unsigned and changes various places using field_fmt
with "%u" to use this instead. This also replaces an existing
equivalent helper function in record-btrace.c.
2019-07-15 Tom Tromey <tromey@adacore.com>
* mi/mi-out.h (class mi_ui_out) <do_field_unsigned>: Declare.
* mi/mi-out.c (mi_ui_out::do_field_unsigned): New method.
* cli-out.h (class cli_ui_out) <do_field_unsigned>: Declare.
* cli-out.c (cli_ui_out::do_field_int): New method.
* ui-out.c (ui_out::field_unsigned): New method.
* symfile.c (generic_load): Use field_unsigned.
(print_transfer_performance): Likewise.
* record-btrace.c (ui_out_field_uint): Remove.
(btrace_call_history_insn_range, btrace_call_history): Use
field_unsigned.
* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn): Use
field_unsigned.
* ui-out.h (class ui_out) <field_unsigned>: New method.
<do_field_unsigned>: Likewise.
This commit applies all changes made after running the gdb/copyright.py
script.
Note that one file was flagged by the script, due to an invalid
copyright header
(gdb/unittests/basic_string_view/element_access/char/empty.cc).
As the file was copied from GCC's libstdc++-v3 testsuite, this commit
leaves this file untouched for the time being; a patch to fix the header
was sent to gcc-patches first.
gdb/ChangeLog:
Update copyright year range in all GDB files.
This adds style support for variable names. For the time being, this
is only done in backtraces, not in ptype or print; those places do not
use ui-out and so would need ad hoc changes.
This also adds styling to the names printed for local variables in
"backtrace full". This code does not use ui-out, so the styling is
done using the low-level API.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
* ui-out.h (enum class ui_out_style_kind) <VARIABLE>: New global.
* stack.c (print_frame_arg): Style name.
* printcmd.c (print_variable_and_value): Style variable name.
* cli/cli-style.h (variable_name_style): Declare.
* cli/cli-style.c (variable_name_style): New global.
(_initialize_cli_style): Update.
* cli-out.c (cli_ui_out::do_field_string): Update.
gdb/testsuite/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
* gdb.base/style.exp: Add test for variable names.
This adds some output styling to the CLI.
A style is currently a foreground color, a background color, and an
intensity (dim or bold). (This list could be expanded depending on
terminal capabilities.)
A style can be applied while printing. For ui-out, this is done by
passing the style constant as an argument. For low-level cases,
fprintf_styled and fputs_styled are provided.
Users can control the style via a number of new set/show commands. In
the interest of not typing many nearly-identical documentation
strings, I automated this. On the down side, this is not very
i18n-friendly.
I've chose some default colors to use. I think it would be good to
enable this by default, so that when users start the new gdb, they
will see the new feature.
Stylizing is done if TERM is set and is not "dumb". This could be
improved when the TUI is available by using the curses has_colors
call. That is, the lowest layer could call this without committing to
using curses everywhere; see my other patch for TUI colorizing.
I considered adding a new "set_style" method to ui_file. However,
because the implementation had to interact with the pager code, I
didn't take this approach. But, one idea might be to put the isatty
check there and then have it defer to the lower layers.
gdb/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
* utils.h (set_output_style, fprintf_styled)
(fputs_styled): Declare.
* utils.c (applied_style, desired_style): New globals.
(emit_style_escape, set_output_style): New function.
(prompt_for_continue): Emit style escapes.
(fputs_maybe_filtered): Likewise.
(fputs_styled, fprintf_styled): New functions.
* ui-out.h (enum class ui_out_style_kind): New.
(class ui_out) <field_string, field_stream, do_field_string>: Add
style parameter.
* ui-out.c (ui_out::field_stream, ui_out::field_string): Add style
parameter.
* tui/tui-out.h (class tui_ui_out) <do_field_string>: Add style
parameter.
* tui/tui-out.c (tui_ui_out::do_field_string): Add style
parameter.
(tui_ui_out::do_field_string): Update.
* tracepoint.c (print_one_static_tracepoint_marker): Style
output.
* stack.c (print_frame_info, print_frame): Style output.
* source.c (print_source_lines_base): Style output.
* skip.c (info_skip_command): Style output.
* record-btrace.c (btrace_call_history_src_line): Style output.
(btrace_call_history): Likewise.
* python/py-framefilter.c (py_print_frame): Style output.
* mi/mi-out.h (class mi_ui_out) <do_field_string>: Add style
parameter.
* mi/mi-out.c (mi_ui_out::do_table_header)
(mi_ui_out::do_field_int): Update.
(mi_ui_out::do_field_string): Update.
* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn):
Style output.
* cli/cli-style.h: New file.
* cli/cli-style.c: New file.
* cli-out.h (class cli_ui_out) <do_field_string>: Add style
parameter.
* cli-out.c (cli_ui_out::do_table_header)
(cli_ui_out::do_field_int, cli_ui_out::do_field_skip): Update.
(cli_ui_out::do_field_string): Add style parameter. Style the
output.
* breakpoint.c (print_breakpoint_location): Style output.
(update_static_tracepoint): Likewise.
* Makefile.in (SUBDIR_CLI_SRCS): Add cli-style.c.
(HFILES_NO_SRCDIR): Add cli-style.h.
gdb/testsuite/ChangeLog
2018-12-28 Tom Tromey <tom@tromey.com>
* gdb.base/style.exp: New file.
* gdb.base/style.c: New file.
This patch removes a FIXME comment from cli-out.c, now instead of
formatting integers into a fixed size buffer we build a std::string
and extract the formatted integer from that.
The old code using a fixed size buffer was probably fine (the integer
was not going to overflow it) and probably slightly more efficient
(avoids building a std::string) however, given we already have utility
code in GDB that will allow the 'FIXME' comment to be removed, it
seems like an easy improvement.
gdb/ChangeLog:
* cli-out.c (cli_ui_out::do_field_int): Use string_printf rather
than a fixed size buffer.
Currently the method 'cli_ui_out::do_field_fmt' has this comment:
/* This is the only field function that does not align. */
The reality is even slightly worse, the 'fmt' field type doesn't
respect either the field alignment or the field width. In at least
one place in GDB we attempt to work around this lack of respect for
field width by adding additional padding manually. But, as is often
the case, this is leading to knock on problems.
Conside the output for 'info breakpoints' when a breakpoint has
multiple locations. This example is taken from the testsuite, from
test gdb.opt/inline-break.exp:
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
1.1 y 0x00000000004004ae in func4b at /src/gdb/testsuite/gdb.opt/inline-break.c:64
1.2 y 0x0000000000400682 in func4b at /src/gdb/testsuite/gdb.opt/inline-break.c:64
The miss-alignment of the fields shown here is exactly as GDB
currently produces.
With this patch 'fmt' style fields are now first written into a
temporary buffer, and then written out as a 'string' field. The
result is that the field width, and alignment should now be respected.
With this patch in place the output from GDB now looks like this:
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
1.1 y 0x00000000004004ae in func4b at /src/gdb/testsuite/gdb.opt/inline-break.c:64
1.2 y 0x0000000000400682 in func4b at /src/gdb/testsuite/gdb.opt/inline-break.c:64
This patch has been tested on x86-64/Linux with no regressions,
however, the testsuite doesn't always spot broken output formatting or
alignment. I have also audited all uses of 'fmt' fields that I could
find, and I don't think there are any other places that specifically
try to work around the lack of width/alignment, however, I could have
missed something.
gdb/ChangeLog:
* breakpoint.c (print_one_breakpoint_location): Reduce whitespace,
and remove insertion of extra spaces in GDB's output.
* cli-out.c (cli_ui_out::do_field_fmt): Update header comment.
Layout field into a temporary buffer, and then output it as a
string field.
gdb/testsuite/ChangeLog:
* gdb.opt/inline-break.exp: Add test that info breakpoint output
is correctly aligned.
I noticed that cli_ui_out::out_field_fmt is only used by a single
caller, and it can easily be replaced by fputs_filtered. So, this
patch removes it.
ChangeLog
2018-04-24 Tom Tromey <tom@tromey.com>
* cli-out.c (cli_ui_out::out_field_fmt): Remove.
(cli_ui_out::do_field_string): Use fputs_filtered.
* cli-out.h (class cli_ui_out) <out_field_fmt>: Remove.
All implementations of redirect/do_redirect in the ui_out subsystem
always return 0 (success). We can therefore clean it up and make them
return void.
gdb/ChangeLog:
* cli-out.c (cli_ui_out::do_redirect): Change return type to
void.
* cli-out.h (cli_ui_out::do_redirect): Likewise.
* mi/mi-out.c (mi_ui_out::do_redirect): Likewise.
* mi/mi-out.h (mi_ui_out::do_redirect): Likewise.
* ui-out.c (ui_out::redirect): Likewise.
* ui-out.h (ui_out::redirect, ui_out::do_redirect): Likewise.
* cli/cli-logging.c (set_logging_redirect): Update call site of
ui_out::redirect.
(handle_redirections): Likewise.
* scm-ports.c (ioscm_with_output_to_port_worker): Likewise.
* top.c (execute_command_to_string): Likewise.
* utils.c (do_ui_out_redirect_pop): Likewise.
This applies the second part of GDB's End of Year Procedure, which
updates the copyright year range in all of GDB's files.
gdb/ChangeLog:
Update copyright year range in all GDB files.
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.
Use a standard vector instead of the home-made version. I used a vector
of plain pointers, because the cli_ui_out_data object doesn't own the
streams objects (i.e. they shouldn't be deleted when the vector is
deleted).
gdb/ChangeLog:
* cli-out.h (cli_ui_out_data) <streams>: Change type to
std::vector.
* cli-out.c: Remove vec.h include.
(cli_uiout_dtor): Update.
(cli_field_fmt): Update.
(cli_spaces): Update.
(cli_text): Update.
(cli_message): Update.
(cli_flush): Update.
(cli_redirect): Update.
(out_field_fmt): Update.
(field_separator): Update.
(cli_out_data_ctor): Update.
(cli_out_new): Update.
(cli_out_set_stream): Update.
The following patches introduce C++ vectors and strings as fields of the
various ui_out structures. We therefore need to use new/delete so that
their contructor/destructor is called. I find it simpler to change all
the allocations in a separate preliminary patch, rather than in each
individual patch.
gdb/ChangeLog:
* cli-out.c (cli_uiout_dtor): Use delete instead of xfree.
(cli_out_new): Use new instead of XNEW.
* mi/mi-out.c (mi_out_data_dtor): Use delete instead of xfree.
(mi_out_new): Use new instead of XNEW.
* tui/tui-out.c (tui_out_new): Likewise.
* ui-out.c (push_level): Likewise.
(pop_level): Use delete instead of xfree.
(clear_header_list): Use delete instead of xfree.
(append_header_to_list): Use new instead of XNEW.
(ui_out_new): Likewise.