Add the "set style source" command
This adds "set style source" (and "show style source") commands. This gives the user control over whether source code is highlighted. gdb/ChangeLog 2019-03-14 Tom Tromey <tromey@adacore.com> * NEWS: Add item for "style sources" commands. * source-cache.c (source_cache::get_source_lines): Check source_styling. * cli/cli-style.c (source_styling): New global. (_initialize_cli_style): Add "style sources" commands. (show_style_sources): New function. * cli/cli-style.h (source_styling): Declare. gdb/doc/ChangeLog 2019-03-14 Tom Tromey <tromey@adacore.com> * gdb.texinfo (Output Styling): Document "set style source" and "show style source". gdb/testsuite/ChangeLog 2019-03-14 Tom Tromey <tromey@adacore.com> * gdb.base/style.exp: Add "set style sources" test.
This commit is contained in:
parent
6f11e6824e
commit
d085f98901
|
@ -1,3 +1,13 @@
|
||||||
|
2019-03-14 Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
|
* NEWS: Add item for "style sources" commands.
|
||||||
|
* source-cache.c (source_cache::get_source_lines): Check
|
||||||
|
source_styling.
|
||||||
|
* cli/cli-style.c (source_styling): New global.
|
||||||
|
(_initialize_cli_style): Add "style sources" commands.
|
||||||
|
(show_style_sources): New function.
|
||||||
|
* cli/cli-style.h (source_styling): Declare.
|
||||||
|
|
||||||
2019-03-14 Pedro Alves <palves@redhat.com>
|
2019-03-14 Pedro Alves <palves@redhat.com>
|
||||||
Tom Tromey <tromey@adacore.com>
|
Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
|
|
6
gdb/NEWS
6
gdb/NEWS
|
@ -140,6 +140,12 @@ show style enabled
|
||||||
Enable or disable terminal styling. Styling is enabled by default
|
Enable or disable terminal styling. Styling is enabled by default
|
||||||
on most hosts, but disabled by default when in batch mode.
|
on most hosts, but disabled by default when in batch mode.
|
||||||
|
|
||||||
|
set style sources [on|off]
|
||||||
|
show style sources
|
||||||
|
Enable or disable source code styling. Source code styling is
|
||||||
|
enabled by default, but only takes effect if styling in general is
|
||||||
|
enabled, and if GDB was linked with GNU Source Highlight.
|
||||||
|
|
||||||
set style filename foreground COLOR
|
set style filename foreground COLOR
|
||||||
set style filename background COLOR
|
set style filename background COLOR
|
||||||
set style filename intensity VALUE
|
set style filename intensity VALUE
|
||||||
|
|
|
@ -31,6 +31,11 @@ int cli_styling = 0;
|
||||||
int cli_styling = 1;
|
int cli_styling = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* True if source styling is enabled. Note that this is only
|
||||||
|
consulted when cli_styling is true. */
|
||||||
|
|
||||||
|
int source_styling = 1;
|
||||||
|
|
||||||
/* Name of colors; must correspond to ui_file_style::basic_color. */
|
/* Name of colors; must correspond to ui_file_style::basic_color. */
|
||||||
static const char * const cli_colors[] = {
|
static const char * const cli_colors[] = {
|
||||||
"none",
|
"none",
|
||||||
|
@ -230,6 +235,16 @@ show_style_enabled (struct ui_file *file, int from_tty,
|
||||||
fprintf_filtered (file, _("CLI output styling is disabled.\n"));
|
fprintf_filtered (file, _("CLI output styling is disabled.\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
show_style_sources (struct ui_file *file, int from_tty,
|
||||||
|
struct cmd_list_element *c, const char *value)
|
||||||
|
{
|
||||||
|
if (source_styling)
|
||||||
|
fprintf_filtered (file, _("Source code styling is enabled.\n"));
|
||||||
|
else
|
||||||
|
fprintf_filtered (file, _("Source code styling is disabled.\n"));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_initialize_cli_style ()
|
_initialize_cli_style ()
|
||||||
{
|
{
|
||||||
|
@ -249,6 +264,20 @@ If enabled, output to the terminal is styled."),
|
||||||
set_style_enabled, show_style_enabled,
|
set_style_enabled, show_style_enabled,
|
||||||
&style_set_list, &style_show_list);
|
&style_set_list, &style_show_list);
|
||||||
|
|
||||||
|
add_setshow_boolean_cmd ("sources", no_class, &source_styling, _("\
|
||||||
|
Set whether source code styling is enabled."), _("\
|
||||||
|
Show whether source code styling is enabled."), _("\
|
||||||
|
If enabled, source code is styled.\n"
|
||||||
|
#ifdef HAVE_SOURCE_HIGHLIGHT
|
||||||
|
"Note that source styling only works if styling in general is enabled,\n\
|
||||||
|
see \"show style enabled\"."
|
||||||
|
#else
|
||||||
|
"Source highlighting is disabled in this installation of gdb, because\n\
|
||||||
|
it was not linked against GNU Source Highlight."
|
||||||
|
#endif
|
||||||
|
), set_style_enabled, show_style_sources,
|
||||||
|
&style_set_list, &style_show_list);
|
||||||
|
|
||||||
#define STYLE_ADD_SETSHOW_COMMANDS(STYLE, NAME, PREFIX_DOC) \
|
#define STYLE_ADD_SETSHOW_COMMANDS(STYLE, NAME, PREFIX_DOC) \
|
||||||
STYLE.add_setshow_commands (NAME, no_class, PREFIX_DOC, \
|
STYLE.add_setshow_commands (NAME, no_class, PREFIX_DOC, \
|
||||||
&style_set_list, \
|
&style_set_list, \
|
||||||
|
|
|
@ -93,6 +93,9 @@ extern cli_style_option variable_name_style;
|
||||||
/* The address style. */
|
/* The address style. */
|
||||||
extern cli_style_option address_style;
|
extern cli_style_option address_style;
|
||||||
|
|
||||||
|
/* True if source styling is enabled. */
|
||||||
|
extern int source_styling;
|
||||||
|
|
||||||
/* True if styling is enabled. */
|
/* True if styling is enabled. */
|
||||||
extern int cli_styling;
|
extern int cli_styling;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2019-03-14 Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
|
* gdb.texinfo (Output Styling): Document "set style source" and
|
||||||
|
"show style source".
|
||||||
|
|
||||||
2019-03-13 Simon Marchi <simon.marchi@ericsson.com>
|
2019-03-13 Simon Marchi <simon.marchi@ericsson.com>
|
||||||
|
|
||||||
* gdb.texinfo (Mode Options): Mention mi3.
|
* gdb.texinfo (Mode Options): Mention mi3.
|
||||||
|
|
|
@ -24525,6 +24525,16 @@ most hosts defaulting to @samp{on}.
|
||||||
|
|
||||||
@item show style enabled
|
@item show style enabled
|
||||||
Show the current state of styling.
|
Show the current state of styling.
|
||||||
|
|
||||||
|
@item set style sources @samp{on|off}
|
||||||
|
Enable or disable source code styling. This affects whether source
|
||||||
|
code, such as the output of the @code{list} command, is styled. Note
|
||||||
|
that source styling only works if styling in general is enabled, and
|
||||||
|
if @value{GDBN} was linked with the GNU Source Highlight library. The
|
||||||
|
default is @samp{on}.
|
||||||
|
|
||||||
|
@item show style sources
|
||||||
|
Show the current state of source code styling.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
Subcommands of @code{set style} control specific forms of styling.
|
Subcommands of @code{set style} control specific forms of styling.
|
||||||
|
|
|
@ -180,7 +180,7 @@ source_cache::get_source_lines (struct symtab *s, int first_line,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef HAVE_SOURCE_HIGHLIGHT
|
#ifdef HAVE_SOURCE_HIGHLIGHT
|
||||||
if (can_emit_style_escape (gdb_stdout))
|
if (source_styling && can_emit_style_escape (gdb_stdout))
|
||||||
{
|
{
|
||||||
const char *fullname = symtab_to_fullname (s);
|
const char *fullname = symtab_to_fullname (s);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2019-03-14 Tom Tromey <tromey@adacore.com>
|
||||||
|
|
||||||
|
* gdb.base/style.exp: Add "set style sources" test.
|
||||||
|
|
||||||
2019-03-13 Simon Marchi <simon.marchi@ericsson.com>
|
2019-03-13 Simon Marchi <simon.marchi@ericsson.com>
|
||||||
|
|
||||||
* mi-breakpoint-location-ena-dis.exp: Rename to ...
|
* mi-breakpoint-location-ena-dis.exp: Rename to ...
|
||||||
|
|
|
@ -50,6 +50,12 @@ save_vars { env(TERM) } {
|
||||||
"$main_expr.*$arg_expr.*$arg_expr.*$file_expr.*"
|
"$main_expr.*$arg_expr.*$arg_expr.*$file_expr.*"
|
||||||
gdb_test "info breakpoints" "$main_expr at $file_expr.*"
|
gdb_test "info breakpoints" "$main_expr at $file_expr.*"
|
||||||
|
|
||||||
|
gdb_test_no_output "set style sources off"
|
||||||
|
gdb_test "frame" \
|
||||||
|
"\r\n\[^\033\]*break here.*" \
|
||||||
|
"frame without styling"
|
||||||
|
gdb_test_no_output "set style sources on"
|
||||||
|
|
||||||
gdb_test "break main" "file $base_file_expr.*"
|
gdb_test "break main" "file $base_file_expr.*"
|
||||||
|
|
||||||
gdb_test "print &main" " = .* \033\\\[34m$hex\033\\\[m <$main_expr>"
|
gdb_test "print &main" " = .* \033\\\[34m$hex\033\\\[m <$main_expr>"
|
||||||
|
|
Loading…
Reference in New Issue