aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-02-07 06:23:40 -0700
committerTom Tromey <tom@tromey.com>2019-02-17 08:35:14 -0700
commita008792038c2510800db466897c4bb6305d20042 (patch)
treea317ce9b81aa7874e144c6d08472a8344237b7d6 /gdb/testsuite/gdb.base
parent75ba10dc558a450c7dbcdc24f816f6709f2b29f7 (diff)
downloadgdb-a008792038c2510800db466897c4bb6305d20042.zip
gdb-a008792038c2510800db466897c4bb6305d20042.tar.gz
gdb-a008792038c2510800db466897c4bb6305d20042.tar.bz2
Fix pager bugs with style output
I believe this fixes all the pager output problems with styling that Philippe pointed out, plus at least one more. The patch is somewhat hard to reason about, so you may wish to give it a try. Even writing the tests was hard. This removes the style caching, because it was difficult to keep the style cache correct in all cases. Since this would cause more style escapes to be emitted, instead it changes fputs_styled to try to avoid unnecessary changes. Another bug was that the wrap buffer was not flushed in the case where wrap_column==0. In the old (pre-patch series) code, characters were directly emitted in this case; so flushing the wrap buffer here restores this behavior. On error the wrap buffer must be emptied. Otherwise, interrupting output can leave characters in the buffer that will be emitted later. As discussed on gdb-patches, this fixes the ada-lang.c problem where filtered and unfiltered printing were mixed. Now user_select_syms uses filtered printing, which is what its callees were already doing. Finally, it was possible for source line highlighting to be garbled (and invalid escape sequences emitted) if the pager was invoked at the wrong spot. To fix this, the patch arranges for source line escapes to always be emitted as a unit. gdb/ChangeLog 2019-02-17 Tom Tromey <tom@tromey.com> * ada-lang.c (user_select_syms): Use filtered printing. * utils.c (wrap_style): New global. (desired_style): Remove. (emit_style_escape): Add stream parameter. (set_output_style, reset_terminal_style, prompt_for_continue): Update. (flush_wrap_buffer): Only flush gdb_stdout. (wrap_here): Set wrap_style. (fputs_maybe_filtered): Clear the wrap buffer on exception. Don't treat escape sequences as a character. Change when wrap buffer is flushed. (fputs_styled): Do not set the output style when the default is requested. * ui-style.h (struct ui_file_style) <is_default>: New method. * source.c (print_source_lines_base): Emit escape sequences in one piece. gdb/testsuite/ChangeLog 2019-02-17 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Add line-wrapping tests. * gdb.base/page.exp: Add test for quitting during pagination.
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r--gdb/testsuite/gdb.base/page.exp14
-rw-r--r--gdb/testsuite/gdb.base/style.exp18
2 files changed, 32 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/page.exp b/gdb/testsuite/gdb.base/page.exp
index 7461591..10ebf0d 100644
--- a/gdb/testsuite/gdb.base/page.exp
+++ b/gdb/testsuite/gdb.base/page.exp
@@ -80,6 +80,20 @@ gdb_expect_list "paged count remainder" "${gdb_prompt} " {
11
}
+set fours [string repeat 4 40]
+set str "1\\n2\\n3\\n$fours\\n5\\n"
+
+# Avoid some confusing output from readline.
+gdb_test_no_output "set editing off"
+
+gdb_test_no_output "set width 30"
+send_gdb "printf \"$str\"\n"
+gdb_expect_list "paged count for interrupt" \
+ ".*$pagination_prompt" \
+ [list 1\r\n 2\r\n 3\r\n 444444444444444444444444444444]
+
+gdb_test "q" "Quit" "quit while paging"
+
gdb_exit
return 0
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index 78d04b0..010d959 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -45,6 +45,24 @@ save_vars { env(TERM) } {
gdb_test "print &main" " = .* \033\\\[34m$hex\033\\\[m <$main_expr>"
+ # Regression test for a bug where line-wrapping would occur at the
+ # wrong spot with styling. There were different bugs at different
+ # widths, so try two.
+ foreach width {20 30} {
+ gdb_test_no_output "set width $width"
+ # There was also a bug where the styling could be wrong in the
+ # line listing; this is why the words from the source code are
+ # spelled out in the final result line of the test.
+ gdb_test "frame" \
+ [multi_line \
+ "#0 *$main_expr.*$arg_expr.*" \
+ ".*$arg_expr.*" \
+ ".* at .*$file_expr.*" \
+ "\[0-9\]+.*return.* break here .*"
+ ] \
+ "frame when width=$width"
+ }
+
gdb_exit
gdb_spawn