[3/5] Fix weird quoting in stap-probe.c

Message ID 20260822-no-backquotes-in-strings-v1-3-0b035ad036a3@tromey.com
State New
Headers
Series Remove `...' and related forms of quoting from gdb |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom Tromey Aug. 22, 2026, 8:30 p.m. UTC
  I found some code in stap-probe.c that split the quoting in a strange
way:

		warning (_("unrecognized bitness %s%c' for probe `%s'"),
			 got_minus ? "`-" : "`", *cur,

Here the leading ` is not part of the format string.  I found this odd
and so I split this fix out into its own patch.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34044
---
 gdb/stap-probe.c                                      | 4 ++--
 gdb/testsuite/gdb.arch/amd64-stap-optional-prefix.exp | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
  

Comments

Eli Zaretskii Aug. 23, 2026, 4:31 a.m. UTC | #1
> From: Tom Tromey <tom@tromey.com>
> Date: Sat, 22 Aug 2026 14:30:05 -0600
> Cc: Tom Tromey <tom@tromey.com>
> 
> I found some code in stap-probe.c that split the quoting in a strange
> way:
> 
> 		warning (_("unrecognized bitness %s%c' for probe `%s'"),
> 			 got_minus ? "`-" : "`", *cur,
> 
> Here the leading ` is not part of the format string.  I found this odd
> and so I split this fix out into its own patch.

This changes the quoting style of "-7" and the like.  As the test
suite shows, it was previously quoted as `-7'.  Is there a good reason
for this change?  I'm not sure I understand what is weird about this
quoting or ` not being part of the format string.  Is this just a
style-preference thing?
  
Tom de Vries Aug. 24, 2026, 6:09 p.m. UTC | #2
On 8/23/26 6:31 AM, Eli Zaretskii wrote:
>> From: Tom Tromey <tom@tromey.com>
>> Date: Sat, 22 Aug 2026 14:30:05 -0600
>> Cc: Tom Tromey <tom@tromey.com>
>>
>> I found some code in stap-probe.c that split the quoting in a strange
>> way:
>>
>> 		warning (_("unrecognized bitness %s%c' for probe `%s'"),
>> 			 got_minus ? "`-" : "`", *cur,
>>
>> Here the leading ` is not part of the format string.  I found this odd
>> and so I split this fix out into its own patch.
> 
> This changes the quoting style of "-7" and the like.  As the test
> suite shows, it was previously quoted as `-7'.  Is there a good reason
> for this change? 

I googled this a bit, and came across ( 
https://www.gnu.org/prep/standards/html_node/Quote-Characters.html#Quote-Characters 
):
...
Although GNU programs traditionally used 0x60 (‘`’) for opening and 0x27 
(‘'’) for closing quotes, nowadays quotes ‘`like this'’ are typically 
rendered asymmetrically, so quoting ‘"like this"’ or ‘'like this'’ 
typically looks better.
...

> I'm not sure I understand what is weird about this
> quoting or ` not being part of the format string.  Is this just a
> style-preference thing?

If we'd leave the quoting style unchanged, I would have preferred:
...
warning (_("unrecognized bitness `%s%c' for probe `%s'"),
  	 got_minus ? "-" : "", *cur,
...
which I find easier to read.

Thanks,
- Tom
  
Tom Tromey Sept. 3, 2026, 4:04 p.m. UTC | #3
>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

>> warning (_("unrecognized bitness %s%c' for probe `%s'"),
>> got_minus ? "`-" : "`", *cur,
>> 
>> Here the leading ` is not part of the format string.  I found this odd
>> and so I split this fix out into its own patch.

Eli> This changes the quoting style of "-7" and the like.  As the test
Eli> suite shows, it was previously quoted as `-7'.  Is there a good reason
Eli> for this change?  I'm not sure I understand what is weird about this
Eli> quoting or ` not being part of the format string.  Is this just a
Eli> style-preference thing?

There are two parts to this particular patch.

First, putting the opening quote into an argument string, rather than in
the format string, is a weird choice, IMO.

Second, I am slowly changing gdb to standardize on "..." quoting.
Removing `...' quoting is the first part of this.

Tom
  

Patch

diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index 986ff38c586..654a2f7ca45 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -1304,8 +1304,8 @@  stap_probe::parse_arguments (struct gdbarch *gdbarch)
 	      {
 		/* We have an error, because we don't expect anything
 		   except 1, 2, 4 and 8.  */
-		warning (_("unrecognized bitness %s%c' for probe `%s'"),
-			 got_minus ? "`-" : "`", *cur,
+		warning (_("unrecognized bitness \"%s%c\" for probe \"%s\""),
+			 got_minus ? "-" : "", *cur,
 			 this->get_name ().c_str ());
 		return;
 	      }
diff --git a/gdb/testsuite/gdb.arch/amd64-stap-optional-prefix.exp b/gdb/testsuite/gdb.arch/amd64-stap-optional-prefix.exp
index 9cd7dec166c..8f26e3fe9bf 100644
--- a/gdb/testsuite/gdb.arch/amd64-stap-optional-prefix.exp
+++ b/gdb/testsuite/gdb.arch/amd64-stap-optional-prefix.exp
@@ -79,7 +79,7 @@  foreach probe_name $normal_probes_names \
 
 with_test_prefix "fail_probe" {
     goto_probe "fail_probe"
-    gdb_test "print \$_probe_arg0" "warning: unrecognized bitness `-7' for probe `fail_probe'\r\nInvalid probe argument 0 -- probe has 0 arguments available"
+    gdb_test "print \$_probe_arg0" "warning: unrecognized bitness \"-7\" for probe \"fail_probe\"\r\nInvalid probe argument 0 -- probe has 0 arguments available"
 }
 
 with_test_prefix "fail2_probe" {