diff options
author | Tom Tromey <tom@tromey.com> | 2024-09-14 15:07:17 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2024-09-30 13:23:35 -0600 |
commit | 887ae0cf2be5cb10d68b14f16df8faf666f4e43b (patch) | |
tree | f7c92c61df329414d9e57a31c9f034750992e7ec /gdb/source.c | |
parent | 7ecf0250f7f0868f3b828ffadd47d0e5f2dbd875 (diff) | |
download | gdb-887ae0cf2be5cb10d68b14f16df8faf666f4e43b.zip gdb-887ae0cf2be5cb10d68b14f16df8faf666f4e43b.tar.gz gdb-887ae0cf2be5cb10d68b14f16df8faf666f4e43b.tar.bz2 |
Add line-number styling
This patch adds separate styling for line numbers. That is, whenever
gdb prints a source line number, it uses this style.
v2 includes a change to ensure that %ps works in query.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-by: Keith Seitz <keiths@redhat.com>
Diffstat (limited to 'gdb/source.c')
-rw-r--r-- | gdb/source.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/gdb/source.c b/gdb/source.c index b9122c4..61ed088 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1345,7 +1345,7 @@ print_source_lines_base (struct symtab *s, int line, int stopline, fields. ui_source_list is set only for CLI, not for TUI. */ - uiout->field_signed ("line", line); + uiout->field_signed ("line", line, line_number_style.style ()); uiout->text ("\tin "); uiout->field_string ("file", symtab_to_filename_for_display (s), @@ -1389,8 +1389,10 @@ print_source_lines_base (struct symtab *s, int line, int stopline, uiout->text (symtab_to_filename_for_display (s)); uiout->text (":"); } - xsnprintf (buf, sizeof (buf), "%d\t", new_lineno++); - uiout->text (buf); + + uiout->message ("%ps\t", styled_string (line_number_style.style (), + pulongest (new_lineno))); + ++new_lineno; while (*iter != '\0') { @@ -1551,8 +1553,9 @@ info_line_command (const char *arg, int from_tty) if (start_pc == end_pc) { - gdb_printf ("Line %d of \"%s\"", - sal.line, + gdb_printf ("Line %ps of \"%s\"", + styled_string (line_number_style.style (), + pulongest (sal.line)), symtab_to_filename_for_display (sal.symtab)); gdb_stdout->wrap_here (2); gdb_printf (" is at address "); @@ -1562,8 +1565,9 @@ info_line_command (const char *arg, int from_tty) } else { - gdb_printf ("Line %d of \"%s\"", - sal.line, + gdb_printf ("Line %ps of \"%s\"", + styled_string (line_number_style.style (), + pulongest (sal.line)), symtab_to_filename_for_display (sal.symtab)); gdb_stdout->wrap_here (2); gdb_printf (" starts at address "); @@ -1589,8 +1593,10 @@ info_line_command (const char *arg, int from_tty) /* Is there any case in which we get here, and have an address which the user would want to see? If we have debugging symbols and no line numbers? */ - gdb_printf (_("Line number %d is out of range for \"%s\".\n"), - sal.line, symtab_to_filename_for_display (sal.symtab)); + gdb_printf (_("Line number %ps is out of range for \"%s\".\n"), + styled_string (line_number_style.style (), + pulongest (sal.line)), + symtab_to_filename_for_display (sal.symtab)); } } |