qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] simpletrace: correctly detect pointers to strings
@ 2016-10-31 13:25 Paolo Bonzini
  2016-10-31 13:36 ` Fam Zheng
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2016-10-31 13:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha

The visit_type_str tracepoint takes a char**, and the simpletrace backend
incorrectly treats that as a string.  The resulting compiler warning breaks
--enable-trace-backend=simple builds (including the mingw docker target).
Fix it by rejecting pointers to pointers to char; rewrite the detection
as a regular expression for simplicity.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/tracetool/backend/simple.py | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py
index 9885e83..9dae646 100644
--- a/scripts/tracetool/backend/simple.py
+++ b/scripts/tracetool/backend/simple.py
@@ -14,17 +14,15 @@ __email__      = "stefanha@linux.vnet.ibm.com"
 
 
 from tracetool import out
+import re
 
 
 PUBLIC = True
+STRTYPE_RE = re.compile(r'\s*(?:const )?char\s*\*(?!\s*\*)')
 
 
 def is_string(arg):
-    strtype = ('const char*', 'char*', 'const char *', 'char *')
-    if arg.lstrip().startswith(strtype):
-        return True
-    else:
-        return False
+    return not (STRTYPE_RE.match(arg) is None)
 
 
 def generate_h_begin(events, group):
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] simpletrace: correctly detect pointers to strings
  2016-10-31 13:25 [Qemu-devel] [PATCH] simpletrace: correctly detect pointers to strings Paolo Bonzini
@ 2016-10-31 13:36 ` Fam Zheng
  2016-11-02 14:23   ` Stefan Hajnoczi
  0 siblings, 1 reply; 3+ messages in thread
From: Fam Zheng @ 2016-10-31 13:36 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, stefanha

On Mon, 10/31 14:25, Paolo Bonzini wrote:
> The visit_type_str tracepoint takes a char**, and the simpletrace backend
> incorrectly treats that as a string.  The resulting compiler warning breaks
> --enable-trace-backend=simple builds (including the mingw docker target).
> Fix it by rejecting pointers to pointers to char; rewrite the detection
> as a regular expression for simplicity.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  scripts/tracetool/backend/simple.py | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py
> index 9885e83..9dae646 100644
> --- a/scripts/tracetool/backend/simple.py
> +++ b/scripts/tracetool/backend/simple.py
> @@ -14,17 +14,15 @@ __email__      = "stefanha@linux.vnet.ibm.com"
>  
>  
>  from tracetool import out
> +import re
>  
>  
>  PUBLIC = True
> +STRTYPE_RE = re.compile(r'\s*(?:const )?char\s*\*(?!\s*\*)')
>  
>  
>  def is_string(arg):
> -    strtype = ('const char*', 'char*', 'const char *', 'char *')
> -    if arg.lstrip().startswith(strtype):
> -        return True
> -    else:
> -        return False
> +    return not (STRTYPE_RE.match(arg) is None)
>  
>  
>  def generate_h_begin(events, group):
> -- 
> 1.8.3.1
> 
> 

There is already:

commit db4df20de86c6e8ecd6c9f042c029ffb9f9cddac
Author: Fam Zheng <famz@redhat.com>
Date:   Wed Oct 26 11:50:06 2016 +0800

    trace: Fix 'char **' compilation error in simple backend

    Currently, the generated function body will do "strlen(arg)" but the
    argument could be 'char **' or 'char * const *'. Avoid that by excluding
    such cases in is_string check.

    Reported by patchew's "make docker-test-mingw@fedora".

    Suggested-by: Eric Blake <eblake@redhat.com>
    Signed-off-by: Fam Zheng <famz@redhat.com>
    Reviewed-by: Eric Blake <eblake@redhat.com>
    Message-id: 1477453806-21097-1-git-send-email-famz@redhat.com
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] simpletrace: correctly detect pointers to strings
  2016-10-31 13:36 ` Fam Zheng
@ 2016-11-02 14:23   ` Stefan Hajnoczi
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2016-11-02 14:23 UTC (permalink / raw)
  To: Fam Zheng; +Cc: Paolo Bonzini, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2391 bytes --]

On Mon, Oct 31, 2016 at 09:36:01PM +0800, Fam Zheng wrote:
> On Mon, 10/31 14:25, Paolo Bonzini wrote:
> > The visit_type_str tracepoint takes a char**, and the simpletrace backend
> > incorrectly treats that as a string.  The resulting compiler warning breaks
> > --enable-trace-backend=simple builds (including the mingw docker target).
> > Fix it by rejecting pointers to pointers to char; rewrite the detection
> > as a regular expression for simplicity.
> > 
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > ---
> >  scripts/tracetool/backend/simple.py | 8 +++-----
> >  1 file changed, 3 insertions(+), 5 deletions(-)
> > 
> > diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py
> > index 9885e83..9dae646 100644
> > --- a/scripts/tracetool/backend/simple.py
> > +++ b/scripts/tracetool/backend/simple.py
> > @@ -14,17 +14,15 @@ __email__      = "stefanha@linux.vnet.ibm.com"
> >  
> >  
> >  from tracetool import out
> > +import re
> >  
> >  
> >  PUBLIC = True
> > +STRTYPE_RE = re.compile(r'\s*(?:const )?char\s*\*(?!\s*\*)')
> >  
> >  
> >  def is_string(arg):
> > -    strtype = ('const char*', 'char*', 'const char *', 'char *')
> > -    if arg.lstrip().startswith(strtype):
> > -        return True
> > -    else:
> > -        return False
> > +    return not (STRTYPE_RE.match(arg) is None)
> >  
> >  
> >  def generate_h_begin(events, group):
> > -- 
> > 1.8.3.1
> > 
> > 
> 
> There is already:
> 
> commit db4df20de86c6e8ecd6c9f042c029ffb9f9cddac
> Author: Fam Zheng <famz@redhat.com>
> Date:   Wed Oct 26 11:50:06 2016 +0800
> 
>     trace: Fix 'char **' compilation error in simple backend
> 
>     Currently, the generated function body will do "strlen(arg)" but the
>     argument could be 'char **' or 'char * const *'. Avoid that by excluding
>     such cases in is_string check.
> 
>     Reported by patchew's "make docker-test-mingw@fedora".
> 
>     Suggested-by: Eric Blake <eblake@redhat.com>
>     Signed-off-by: Fam Zheng <famz@redhat.com>
>     Reviewed-by: Eric Blake <eblake@redhat.com>
>     Message-id: 1477453806-21097-1-git-send-email-famz@redhat.com
>     Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Right, I'm going to skip Paolo's patch and have double-checked that
--enable-trace-backend=simple compiles cleanly.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-02 14:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-31 13:25 [Qemu-devel] [PATCH] simpletrace: correctly detect pointers to strings Paolo Bonzini
2016-10-31 13:36 ` Fam Zheng
2016-11-02 14:23   ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).