Skip to content

Commit 6506371

Browse files
committed
Add styling to macro commands
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.
1 parent 0c820d6 commit 6506371

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

gdb/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2019-02-17 Tom Tromey <tom@tromey.com>
2+
3+
* macrocmd.c (show_pp_source_pos): Style the file names.
4+
15
2019-02-17 Tom Tromey <tom@tromey.com>
26

37
PR tui/24197:

gdb/macrocmd.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "macrotab.h"
2323
#include "macroexp.h"
2424
#include "macroscope.h"
25+
#include "cli/cli-style.h"
2526
#include "cli/cli-utils.h"
2627
#include "command.h"
2728
#include "gdbcmd.h"
@@ -121,14 +122,16 @@ show_pp_source_pos (struct ui_file *stream,
121122
char *fullname;
122123

123124
fullname = macro_source_fullname (file);
124-
fprintf_filtered (stream, "%s:%d\n", fullname, line);
125+
fputs_styled (fullname, file_name_style.style (), stream);
126+
fprintf_filtered (stream, ":%d\n", line);
125127
xfree (fullname);
126128

127129
while (file->included_by)
128130
{
129131
fullname = macro_source_fullname (file->included_by);
130-
fprintf_filtered (gdb_stdout, " included at %s:%d\n", fullname,
131-
file->included_at_line);
132+
fputs_filtered (_(" included at "), stream);
133+
fputs_styled (fullname, file_name_style.style (), stream);
134+
fprintf_filtered (stream, ":%d\n", file->included_at_line);
132135
xfree (fullname);
133136
file = file->included_by;
134137
}

gdb/testsuite/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2019-02-17 Tom Tromey <tom@tromey.com>
2+
3+
* gdb.base/style.exp: Use -g3 to compile when possible. Add test
4+
for macro styling.
5+
* gdb.base/style.c (SOME_MACRO): New macro.
6+
17
2019-02-17 Tom Tromey <tom@tromey.com>
28

39
* gdb.base/style.exp: Add line-wrapping tests.

gdb/testsuite/gdb.base/style.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
You should have received a copy of the GNU General Public License
1414
along with this program. If not, see <http://www.gnu.org/licenses/>. */
1515

16+
#define SOME_MACRO 23
17+
1618
int
1719
main (int argc, char **argv)
1820
{

gdb/testsuite/gdb.base/style.exp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ save_vars { env(TERM) } {
2121
# We need an ANSI-capable terminal to get the output.
2222
setenv TERM ansi
2323

24-
if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
24+
set test_macros 0
25+
set options debug
26+
get_compiler_info
27+
if { [test_compiler_info "gcc-*"] || [test_compiler_info "clang-*"] } {
28+
lappend options additional_flags=-g3
29+
set test_macros 1
30+
}
31+
32+
if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
33+
$options]} {
2534
return -1
2635
}
2736

@@ -63,6 +72,11 @@ save_vars { env(TERM) } {
6372
"frame when width=$width"
6473
}
6574

75+
if {$test_macros} {
76+
gdb_test "info macro SOME_MACRO" \
77+
"Defined at $base_file_expr:16\r\n#define SOME_MACRO 23"
78+
}
79+
6680
gdb_exit
6781
gdb_spawn
6882

0 commit comments

Comments
 (0)