This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC 5/8] Style locations when setting a breakpoint
- From: Simon Marchi <simark at simark dot ca>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Sat, 6 Oct 2018 12:36:00 -0400
- Subject: Re: [RFC 5/8] Style locations when setting a breakpoint
- References: <20180906211303.11029-1-tom@tromey.com> <20180906211303.11029-6-tom@tromey.com>
On 2018-09-06 5:13 p.m., Tom Tromey wrote:
> say_where does not use ui-out, so function and file names printed by
> it were not styled. This patch changes say_where to use the low-level
> style code directly.
> ---
> gdb/breakpoint.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index 4e7dac51574..62824351ed6 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -68,6 +68,7 @@
> #include "format.h"
> #include "thread-fsm.h"
> #include "tid-parse.h"
> +#include "cli/cli-style.h"
>
> /* readline include files */
> #include "readline/readline.h"
> @@ -12203,9 +12204,14 @@ say_where (struct breakpoint *b)
> /* If there is a single location, we can print the location
> more nicely. */
> if (b->loc->next == NULL)
> - printf_filtered (": file %s, line %d.",
> - symtab_to_filename_for_display (b->loc->symtab),
> - b->loc->line_number);
> + {
> + puts_filtered (": file ");
> + set_output_style (gdb_stdout, file_name_style.style ());
> + puts_filtered (symtab_to_filename_for_display (b->loc->symtab));
> + set_output_style (gdb_stdout, ui_file_style ());
> + printf_filtered (", line %d.",
> + b->loc->line_number);
> + }
In general, I guess we'll want to use an RAII object that resets the output style,
in case the code between the two calls throws?
Simon