Patchwork New ARI warning Wed Oct 2 01:56:22 UTC 2019

login
register
mail settings
Submitter Tom Tromey
Date Oct. 2, 2019, 5:45 p.m.
Message ID <87k19nt51q.fsf@tromey.com>
Download mbox | patch
Permalink /patch/34794/
State New
Headers show

Comments

Tom Tromey - Oct. 2, 2019, 5:45 p.m.
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> On 2019-10-02 1:35 p.m., Tom Tromey wrote:
>> I believe that in most regexp syntax, a "]" doesn't need to be quoted in
>> a character class, provided it is either the first character (like
>> "[]...]") or comes immediately after the "^" (like "[^]...]").
>> 
>> The gawk manual mentions this, though it does also recommend using
>> backslash, so maybe I should just do that.
>> 
>> (info "(gawk) Bracket Expressions")
>> 
>> To include one of the characters '\', ']', '-', or '^' in a bracket
>> expression, put a '\' in front of it.  For example:
>> 
>> [d\]]
>> 
>> matches either 'd' or ']'.  Additionally, if you place ']' right after
>> the opening '[', the closing bracket is treated as one of the characters
>> to be matched.

Simon> Well, as  long as the regex does what it is meant to do, I am fine with it.

Simon> I just thought that it would be nice to have a small comment that explains
Simon> what it does, prevent using %p to print raw pointers, but allow the gdb
Simon> extensions.

I went ahead and made both changes.

Tom

commit ab3347cd98e02bb676e85279bc64684b48f4c609
Author: Tom Tromey <tromey@adacore.com>
Date:   Wed Oct 2 10:13:33 2019 -0600

    Let ARI allow gdb %p printf extensions
    
    As pointed out by Simon, this changes ARI to allow the gdb-specific %p
    printf extensions.
    
    gdb/ChangeLog
    2019-10-02  Tom Tromey  <tromey@adacore.com>
    
            * contrib/ari/gdb_ari.sh (%p): Allow gdb-specific %p extensions.
Tom Tromey - Oct. 8, 2019, 5:15 p.m.
>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:

Simon> Well, as  long as the regex does what it is meant to do, I am fine with it.

Simon> I just thought that it would be nice to have a small comment that explains
Simon> what it does, prevent using %p to print raw pointers, but allow the gdb
Simon> extensions.

Tom> I went ahead and made both changes.

I'm checking this in now.

Tom

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index cb450e28730..e79612696e6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@ 
+2019-10-02  Tom Tromey  <tromey@adacore.com>
+
+	* contrib/ari/gdb_ari.sh (%p): Allow gdb-specific %p extensions.
+
 2019-10-02  Tom Tromey  <tromey@adacore.com>
 
 	* NEWS: Add $_ada_exception entry.
diff --git a/gdb/contrib/ari/gdb_ari.sh b/gdb/contrib/ari/gdb_ari.sh
index 4bd434c8fec..7202563f7a3 100755
--- a/gdb/contrib/ari/gdb_ari.sh
+++ b/gdb/contrib/ari/gdb_ari.sh
@@ -353,7 +353,8 @@  Do not use printf(\"%p\"), instead use printf(\"%s\",paddr()) to dump a \
 target address, or host_address_to_string() for a host address"
     category["%p"] = ari_code
 }
-/%p/ && !/%prec/ {
+# Allow gdb %p extensions, but not other uses of %p.
+/%p[^[\]sF]/ && !/%prec/ {
     fail("%p")
 }