From: Tom Tromey Date: Thu, 11 Dec 2025 15:10:51 +0000 (-0700) Subject: Add variable styling to "finish" output X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d05a2adc28602f5af4c4d70934b14c67f0109fe;p=thirdparty%2Fbinutils-gdb.git Add variable styling to "finish" output "finish" will print a line like: Value returned is $1 = 0 Here, the "$1" is not styled, but in other places, history variables are styled using the "variable" style. This patch corrects the oversight. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33714 --- diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 875bbe1ee69..f4d9bbd7ac9 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1616,8 +1616,8 @@ print_return_value_1 (struct ui_out *uiout, struct return_value_info *rv) { /* Print it. */ uiout->text ("Value returned is "); - uiout->field_fmt ("gdb-result-var", "$%d", - rv->value_history_index); + uiout->field_fmt ("gdb-result-var", variable_name_style.style (), + "$%d", rv->value_history_index); uiout->text (" = "); if (finish_print) diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index eff13fa864c..b4adb8e2516 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -1033,6 +1033,20 @@ proc test_pagination_continue_styling { } { } } +# Test the styling of "finish". +proc test_finish_styling {} { + with_ansi_styling_terminal { + clean_restart $::testfile + } + + gdb_test "break some_called_function" "Breakpoint $::decimal at .*" + if {![runto some_called_function]} { + return + } + + gdb_test "finish" "Value returned is [style \\\$$::decimal variable] = 0" +} + # Check to see if the Python styling of disassembler output is # expected or not, this styling requires Python support in GDB, and # the Python pygments module to be available. @@ -1078,3 +1092,4 @@ test_enable_styling_warning test_pagination_cmd_after_quit_styling test_pagination_prompt_styling test_pagination_continue_styling +test_finish_styling