From 6506371f0671dd5ca11127fee4db8d8d7fec157f Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 8 Feb 2019 01:28:53 -0700 Subject: [PATCH] Add styling to macro commands This adds filename styling to "info macro". gdb/ChangeLog 2019-02-17 Tom Tromey * macrocmd.c (show_pp_source_pos): Style the file names. gdb/testsuite/ChangeLog 2019-02-17 Tom Tromey * gdb.base/style.exp: Use -g3 to compile when possible. Add test for macro styling. * gdb.base/style.c (SOME_MACRO): New macro. --- gdb/ChangeLog | 4 ++++ gdb/macrocmd.c | 9 ++++++--- gdb/testsuite/ChangeLog | 6 ++++++ gdb/testsuite/gdb.base/style.c | 2 ++ gdb/testsuite/gdb.base/style.exp | 16 +++++++++++++++- 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b9af73f371c..882546a814b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2019-02-17 Tom Tromey + + * macrocmd.c (show_pp_source_pos): Style the file names. + 2019-02-17 Tom Tromey PR tui/24197: diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c index beb9b78b344..3313e65f929 100644 --- a/gdb/macrocmd.c +++ b/gdb/macrocmd.c @@ -22,6 +22,7 @@ #include "macrotab.h" #include "macroexp.h" #include "macroscope.h" +#include "cli/cli-style.h" #include "cli/cli-utils.h" #include "command.h" #include "gdbcmd.h" @@ -121,14 +122,16 @@ show_pp_source_pos (struct ui_file *stream, char *fullname; fullname = macro_source_fullname (file); - fprintf_filtered (stream, "%s:%d\n", fullname, line); + fputs_styled (fullname, file_name_style.style (), stream); + fprintf_filtered (stream, ":%d\n", line); xfree (fullname); while (file->included_by) { fullname = macro_source_fullname (file->included_by); - fprintf_filtered (gdb_stdout, " included at %s:%d\n", fullname, - file->included_at_line); + fputs_filtered (_(" included at "), stream); + fputs_styled (fullname, file_name_style.style (), stream); + fprintf_filtered (stream, ":%d\n", file->included_at_line); xfree (fullname); file = file->included_by; } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 88c6a6c2acf..f50f1e3aca4 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-02-17 Tom Tromey + + * gdb.base/style.exp: Use -g3 to compile when possible. Add test + for macro styling. + * gdb.base/style.c (SOME_MACRO): New macro. + 2019-02-17 Tom Tromey * gdb.base/style.exp: Add line-wrapping tests. diff --git a/gdb/testsuite/gdb.base/style.c b/gdb/testsuite/gdb.base/style.c index 53f65960374..a44936ed731 100644 --- a/gdb/testsuite/gdb.base/style.c +++ b/gdb/testsuite/gdb.base/style.c @@ -13,6 +13,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#define SOME_MACRO 23 + int main (int argc, char **argv) { diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index 010d9592f34..2778001fed5 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -21,7 +21,16 @@ save_vars { env(TERM) } { # We need an ANSI-capable terminal to get the output. setenv TERM ansi - if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} { + set test_macros 0 + set options debug + get_compiler_info + if { [test_compiler_info "gcc-*"] || [test_compiler_info "clang-*"] } { + lappend options additional_flags=-g3 + set test_macros 1 + } + + if {[prepare_for_testing "failed to prepare" $testfile $srcfile \ + $options]} { return -1 } @@ -63,6 +72,11 @@ save_vars { env(TERM) } { "frame when width=$width" } + if {$test_macros} { + gdb_test "info macro SOME_MACRO" \ + "Defined at $base_file_expr:16\r\n#define SOME_MACRO 23" + } + gdb_exit gdb_spawn -- 2.30.2