public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [Bug tapsets/20136] New: Use the @const() operator across the tapset scripts.
@ 2016-05-24  9:43 mcermak at redhat dot com
  2016-05-24  9:45 ` [Bug tapsets/20136] " mcermak at redhat dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: mcermak at redhat dot com @ 2016-05-24  9:43 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=20136

            Bug ID: 20136
           Summary: Use the @const() operator across the tapset scripts.
           Product: systemtap
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: tapsets
          Assignee: systemtap at sourceware dot org
          Reporter: mcermak at redhat dot com
  Target Milestone: ---

PR19926 adds a new @const() operator to the translator.  Attached patch is a
kick-off attempt to use @const() across the tapset scripts where possible. 
It's rather large.  It went through one round of testing and fixing on my side
and now seems to test fine.  In some cases it changes/extends the original
annotations, but hopefully in a reasonable way.

There might be more opportunities to use @const() in the tapset scripts. 
Notably I've been looking at bodies of stp_pid(), tz_gmtoff(), and tz_name()
(which is a /* string */).  I've been rather conservative.

However, I see one problem: The attached patch doesn't have one particular
update that I'd like to do, but can't:  In tapset/macros.stpm, there is a
MAXSTRINGLEN macro. It looks like a promising candidate for an update similar
to this:

=======
diff --git a/tapset/macros.stpm b/tapset/macros.stpm                            
index fc86cff..6f8cfec 100644                                                   
--- a/tapset/macros.stpm                                                        
+++ b/tapset/macros.stpm                                                        
@@ -1,7 +1,7 @@                                                                 
 // Return MAXSTRINGLEN                                                         
 @define MAXSTRINGLEN                                                           
 %(                                                                             
-       %{ /* pure */ /* unprivileged */ MAXSTRINGLEN %}                        
+       @const("MAXSTRINGLEN")                                                  
 %)                                                                             

 @define __compat_task
=======

But such update makes semok/autocast07.stp unhappy:

=======
#  stap -vv -p2 semok/autocast07.stp
[ ... stuff deleted ... ]
semantic error: while processing function user_string
   thrown from: ../src/elaborate.cxx:5412
semantic error: unexpected @const: operator '@const' at
/usr/local/share/systemtap/tapset/macros.stpm:4:2
   thrown from: ../src/elaborate.cxx:5985
        source:         @const("MAXSTRINGLEN")
                        ^
        in expansion of macro: operator '@MAXSTRINGLEN' at
/usr/local/share/systemtap/tapset/uconversions.stp:44:2
        source:         return user_string_n(addr, @MAXSTRINGLEN)
                                                   ^
=======

(Notes for myself: The above exception gets initially thrown from
typeresolution_info::visit_const_op(), elaborate.cxx:5983.  Disabling this
check causes 'unresolved type : operator '@const'.)

I am not sure whether the above update to macros.stpm is something the
translator should support or not.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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

* [Bug tapsets/20136] Use the @const() operator across the tapset scripts.
  2016-05-24  9:43 [Bug tapsets/20136] New: Use the @const() operator across the tapset scripts mcermak at redhat dot com
@ 2016-05-24  9:45 ` mcermak at redhat dot com
  2016-05-24 11:30 ` mcermak at redhat dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mcermak at redhat dot com @ 2016-05-24  9:45 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=20136

--- Comment #1 from Martin Cermak <mcermak at redhat dot com> ---
Created attachment 9284
  --> https://sourceware.org/bugzilla/attachment.cgi?id=9284&action=edit
proposed patch

-- 
You are receiving this mail because:
You are the assignee for the bug.

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

* [Bug tapsets/20136] Use the @const() operator across the tapset scripts.
  2016-05-24  9:43 [Bug tapsets/20136] New: Use the @const() operator across the tapset scripts mcermak at redhat dot com
  2016-05-24  9:45 ` [Bug tapsets/20136] " mcermak at redhat dot com
@ 2016-05-24 11:30 ` mcermak at redhat dot com
  2016-05-24 18:35 ` fche at redhat dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mcermak at redhat dot com @ 2016-05-24 11:30 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=20136

--- Comment #2 from Martin Cermak <mcermak at redhat dot com> ---
(In reply to Martin Cermak from comment #0)
> =======                                                                          
> diff --git a/tapset/macros.stpm b/tapset/macros.stpm                             
> index fc86cff..6f8cfec 100644                                                    
> --- a/tapset/macros.stpm                                                         
> +++ b/tapset/macros.stpm                                                         
> @@ -1,7 +1,7 @@                                                                  
>  // Return MAXSTRINGLEN                                                          
>  @define MAXSTRINGLEN                                                            
>  %(                                                                              
> -       %{ /* pure */ /* unprivileged */ MAXSTRINGLEN %}                         
> +       @const("MAXSTRINGLEN")                                                   
>  %)                                                                              
>                                                                                  
>  @define __compat_task                                                           
> =======
> 
> But such update makes semok/autocast07.stp unhappy

The key thing appears to be the pretty printer included in autocast07.stp:

=======
# stap -p4 -e 'probe oneshot{ sun = & @cast(0, "sockaddr_un", "<sys/un.h>")
println(sun->sun_path) }' 
/root/.systemtap/cache/92/stap_920b3af0d4444bef6872b0b5f686f9db_2347.ko
# stap -p4 -e 'probe oneshot{ sun = & @cast(0, "sockaddr_un", "<sys/un.h>")
println(sun->sun_path$) }' 
semantic error: while processing function user_string

semantic error: unexpected @const: operator '@const' at
/usr/local/share/systemtap/tapset/macros.stpm:4:2
        source:         @const("MAXSTRINGLEN") 
                        ^
        in expansion of macro: operator '@MAXSTRINGLEN' at
/usr/local/share/systemtap/tapset/uconversions.stp:44:29
        source:         return user_string_n(addr, @MAXSTRINGLEN)
                                                   ^

Pass 2: analysis failed.  [man error::pass2]
#
=======

Hmm, pretty surprising relationship between the pretty printer and seemingly
unrelated @const() operator!

-- 
You are receiving this mail because:
You are the assignee for the bug.

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

* [Bug tapsets/20136] Use the @const() operator across the tapset scripts.
  2016-05-24  9:43 [Bug tapsets/20136] New: Use the @const() operator across the tapset scripts mcermak at redhat dot com
  2016-05-24  9:45 ` [Bug tapsets/20136] " mcermak at redhat dot com
  2016-05-24 11:30 ` mcermak at redhat dot com
@ 2016-05-24 18:35 ` fche at redhat dot com
  2016-05-26  9:16 ` mcermak at redhat dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: fche at redhat dot com @ 2016-05-24 18:35 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=20136

Frank Ch. Eigler <fche at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fche at redhat dot com

--- Comment #3 from Frank Ch. Eigler <fche at redhat dot com> ---
I wonder if this weird phenomenon could be corrected by a simplification of the
way @const() is implemented.  What if it were purely a parse-time syntax, that
the parser itself expanded to an embedded_expr %{ ... %} business?  So the
staptree.* stuff wouldn't need a const_op machinery at all; your test case
would just work (tm) since post-pass-1, the elaboration code can't even see
@const.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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

* [Bug tapsets/20136] Use the @const() operator across the tapset scripts.
  2016-05-24  9:43 [Bug tapsets/20136] New: Use the @const() operator across the tapset scripts mcermak at redhat dot com
                   ` (2 preceding siblings ...)
  2016-05-24 18:35 ` fche at redhat dot com
@ 2016-05-26  9:16 ` mcermak at redhat dot com
  2016-05-27 19:36 ` mcermak at redhat dot com
  2016-05-27 19:49 ` mcermak at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: mcermak at redhat dot com @ 2016-05-26  9:16 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=20136

--- Comment #4 from Martin Cermak <mcermak at redhat dot com> ---
Created attachment 9287
  --> https://sourceware.org/bugzilla/attachment.cgi?id=9287&action=edit
proposed patch

Attached simple patch helps in case the constant isn't being used inside of a
macro. It's implemented very similarly to how macros parsing is implemented,
and macros can't be nested.  But it's very handy to be able to do something
like this:

@__syscall_compat_gate(@const("__NR_open"), @const("__NR_compat_open"))

So I think, if we want to go this "parser-only" way, we'll need to process
constants separately before processing macros.

Note that the problem of the previous implementation was of a corner case
nature I think. Whole the testsuite passed with it except of the mentioned
pretty-printer case.

Having said all that, I am wondering which of the two approaches is the right
one.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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

* [Bug tapsets/20136] Use the @const() operator across the tapset scripts.
  2016-05-24  9:43 [Bug tapsets/20136] New: Use the @const() operator across the tapset scripts mcermak at redhat dot com
                   ` (3 preceding siblings ...)
  2016-05-26  9:16 ` mcermak at redhat dot com
@ 2016-05-27 19:36 ` mcermak at redhat dot com
  2016-05-27 19:49 ` mcermak at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: mcermak at redhat dot com @ 2016-05-27 19:36 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=20136

--- Comment #5 from Martin Cermak <mcermak at redhat dot com> ---
Created attachment 9291
  --> https://sourceware.org/bugzilla/attachment.cgi?id=9291&action=edit
proposed patch

With update PR19926#c10, attached patch tests fine and also includes the
MAXSTRINGLEN bit.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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

* [Bug tapsets/20136] Use the @const() operator across the tapset scripts.
  2016-05-24  9:43 [Bug tapsets/20136] New: Use the @const() operator across the tapset scripts mcermak at redhat dot com
                   ` (4 preceding siblings ...)
  2016-05-27 19:36 ` mcermak at redhat dot com
@ 2016-05-27 19:49 ` mcermak at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: mcermak at redhat dot com @ 2016-05-27 19:49 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=20136

Martin Cermak <mcermak at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Martin Cermak <mcermak at redhat dot com> ---
Fixed in commit efbffd6edcc6805e806786f116dc6c3192667002

-- 
You are receiving this mail because:
You are the assignee for the bug.

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

end of thread, other threads:[~2016-05-27 19:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-24  9:43 [Bug tapsets/20136] New: Use the @const() operator across the tapset scripts mcermak at redhat dot com
2016-05-24  9:45 ` [Bug tapsets/20136] " mcermak at redhat dot com
2016-05-24 11:30 ` mcermak at redhat dot com
2016-05-24 18:35 ` fche at redhat dot com
2016-05-26  9:16 ` mcermak at redhat dot com
2016-05-27 19:36 ` mcermak at redhat dot com
2016-05-27 19:49 ` mcermak at redhat dot com

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 read-only IMAP folder(s) and NNTP newsgroup(s).