]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add variable styling to "finish" output
authorTom Tromey <tromey@adacore.com>
Thu, 11 Dec 2025 15:10:51 +0000 (08:10 -0700)
committerTom Tromey <tromey@adacore.com>
Mon, 5 Jan 2026 19:01:17 +0000 (12:01 -0700)
"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

gdb/infcmd.c
gdb/testsuite/gdb.base/style.exp

index 875bbe1ee692b040e395e4cc45091f70adbc621e..f4d9bbd7ac97eac68c9149f6a896219221442827 100644 (file)
@@ -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)
index eff13fa864cfafe34ef85e964af6964cb6099dbe..b4adb8e251645c47af1bdd69fd4da830973a4dca 100644 (file)
@@ -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