Add styling to macro commands
authorTom Tromey <tom@tromey.com>
Fri, 8 Feb 2019 08:28:53 +0000 (01:28 -0700)
committerTom Tromey <tom@tromey.com>
Sun, 17 Feb 2019 23:28:38 +0000 (16:28 -0700)
This adds filename styling to "info macro".

gdb/ChangeLog
2019-02-17  Tom Tromey  <tom@tromey.com>

* macrocmd.c (show_pp_source_pos): Style the file names.

gdb/testsuite/ChangeLog
2019-02-17  Tom Tromey  <tom@tromey.com>

* 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
gdb/macrocmd.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/style.c
gdb/testsuite/gdb.base/style.exp

index b9af73f371c69d437df1f18edb9ef789ce702e0a..882546a814bb49714415e5c5de44d77b4d793f4f 100644 (file)
@@ -1,3 +1,7 @@
+2019-02-17  Tom Tromey  <tom@tromey.com>
+
+       * macrocmd.c (show_pp_source_pos): Style the file names.
+
 2019-02-17  Tom Tromey  <tom@tromey.com>
 
        PR tui/24197:
index beb9b78b3441ebd044900a0cd30cee321597a328..3313e65f929c643d83cf5320dbdc00bc115b9016 100644 (file)
@@ -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;
     }
index 88c6a6c2acfc68b5c4c768f237c6dff6db9b72d6..f50f1e3aca49306a4bb246ebb040237515ff16bd 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-17  Tom Tromey  <tom@tromey.com>
+
+       * 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  <tom@tromey.com>
 
        * gdb.base/style.exp: Add line-wrapping tests.
index 53f659603742b026565ddb943cfa91f9d9345b6f..a44936ed731946bad4787bb83ed78e74b6b70bbd 100644 (file)
@@ -13,6 +13,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#define SOME_MACRO 23
+
 int
 main (int argc, char **argv)
 {
index 010d9592f343aff56656f074e70ea7a50b74afaa..2778001fed5b19eb905f21610c6e1f1a705623f4 100644 (file)
@@ -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
 
This page took 0.034981 seconds and 4 git commands to generate.