* [Bug translator/19926] New: macro arguments can't be passed to embedded C code
@ 2016-04-08 16:21 dsmith at redhat dot com
2016-04-08 17:22 ` [Bug translator/19926] " fche at redhat dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: dsmith at redhat dot com @ 2016-04-08 16:21 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=19926
Bug ID: 19926
Summary: macro arguments can't be passed to embedded C code
Product: systemtap
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: translator
Assignee: systemtap at sourceware dot org
Reporter: dsmith at redhat dot com
Target Milestone: ---
Currently macros take arguments, but these arguments can't be passed down to an
embedded-C code section, like in the following:
====
@define constant(val)
%(
%{ /* pure */ /* unprivileged */ /* stable */ val %}
%)
probe begin
{
printf("val is %d\n", @constant(BITS_PER_LONG))
}
====
When you try to compile the above code, you get:
====
# stap -gv constant_macro.stp
Pass 1: parsed user script and 113 library scripts using
238844virt/37452res/7776shr/29736data kb, in 180usr/40sys/214real ms.
Pass 2: analyzed script: 1 probe, 0 functions, 0 embeds, 0 globals using
239636virt/38040res/7844shr/30528data kb, in 0usr/0sys/6real ms.
Pass 3: translated to C into
"/tmp/stapByR0yh/stap_76763d2fad5c70e1e248621ad6da6b55_989_src.c" using
239636virt/38040res/7844shr/30528data kb, in 0usr/0sys/1real ms.
/tmp/stapByR0yh/stap_76763d2fad5c70e1e248621ad6da6b55_989_src.c: In function
‘probe_2814’:
/tmp/stapByR0yh/stap_76763d2fad5c70e1e248621ad6da6b55_989_src.c:154:74: error:
‘val’ undeclared (first use in this function)
l->__tmp0 = (((int64_t) ( /* pure */ /* unprivileged */ /* stable */ val
)));
^~~
/tmp/stapByR0yh/stap_76763d2fad5c70e1e248621ad6da6b55_989_src.c:154:74: note:
each undeclared identifier is reported only once for each function it appears
in
scripts/Makefile.build:291: recipe for target
'/tmp/stapByR0yh/stap_76763d2fad5c70e1e248621ad6da6b55_989_src.o' failed
make[1]: *** [/tmp/stapByR0yh/stap_76763d2fad5c70e1e248621ad6da6b55_989_src.o]
Error 1
Makefile:1431: recipe for target '_module_/tmp/stapByR0yh' failed
make: *** [_module_/tmp/stapByR0yh] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compiled C into "stap_76763d2fad5c70e1e248621ad6da6b55_989.ko" in
14490usr/2760sys/17114real ms.
Pass 4: compilation failed. [man error::pass4]
====
Note that using 'STAP_ARG_val' gives similar compilation errors.
If this worked, something like the @constant() macro could be used all over the
tapset library files, making it much easier to specify constants properly.
Right now they are typically marked with 0-3 of the correct annotations.
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug translator/19926] macro arguments can't be passed to embedded C code
2016-04-08 16:21 [Bug translator/19926] New: macro arguments can't be passed to embedded C code dsmith at redhat dot com
@ 2016-04-08 17:22 ` fche at redhat dot com
2016-04-08 20:42 ` dsmith at redhat dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: fche at redhat dot com @ 2016-04-08 17:22 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=19926
Frank Ch. Eigler <fche at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |fche at redhat dot com
Resolution|--- |INVALID
--- Comment #1 from Frank Ch. Eigler <fche at redhat dot com> ---
This is intentional. The translator does not attempt to parse or process
embedded-C code, beyond /* pragmas */. We cannot practically undertake to
perform a C level syntax parse to paste in script level tokens.
Let's think of another way to express constants nicely.
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug translator/19926] macro arguments can't be passed to embedded C code
2016-04-08 16:21 [Bug translator/19926] New: macro arguments can't be passed to embedded C code dsmith at redhat dot com
2016-04-08 17:22 ` [Bug translator/19926] " fche at redhat dot com
@ 2016-04-08 20:42 ` dsmith at redhat dot com
2016-04-08 20:54 ` [Bug translator/19926] we need a better way to express constants in tapset code dsmith at redhat dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: dsmith at redhat dot com @ 2016-04-08 20:42 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=19926
--- Comment #2 from David Smith <dsmith at redhat dot com> ---
One (somewhat) hacky way to express constants more easily, would be to just
define a new annotation. In other words,
%{ /* constant */ FOO %}
could be the same thing as:
%{ /* pure */ /* unprivileged */ /* stable */ FOO %}
Another idea would be to be able to something like:
%{ /* pure-unprivileged-stable */ FOO %}
That last one is still a bit long, but better than 3 separate annotations.
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug translator/19926] we need a better way to express constants in tapset code
2016-04-08 16:21 [Bug translator/19926] New: macro arguments can't be passed to embedded C code dsmith at redhat dot com
2016-04-08 17:22 ` [Bug translator/19926] " fche at redhat dot com
2016-04-08 20:42 ` dsmith at redhat dot com
@ 2016-04-08 20:54 ` dsmith at redhat dot com
2016-04-08 20:59 ` dsmith at redhat dot com
2016-05-11 14:54 ` mcermak at redhat dot com
4 siblings, 0 replies; 6+ messages in thread
From: dsmith at redhat dot com @ 2016-04-08 20:54 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=19926
David Smith <dsmith at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |---
Summary|macro arguments can't be |we need a better way to
|passed to embedded C code |express constants in tapset
| |code
--- Comment #3 from David Smith <dsmith at redhat dot com> ---
We need a better way to express constants in tapset code. Currently, they
should look like:
%{ /* pure */ /* unprivileged */ /* stable */ CONSTANT_NAME %}
but the tapset code has has several variants of the above - some have no
annotations, some only have some of the needed annotations.
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug translator/19926] we need a better way to express constants in tapset code
2016-04-08 16:21 [Bug translator/19926] New: macro arguments can't be passed to embedded C code dsmith at redhat dot com
` (2 preceding siblings ...)
2016-04-08 20:54 ` [Bug translator/19926] we need a better way to express constants in tapset code dsmith at redhat dot com
@ 2016-04-08 20:59 ` dsmith at redhat dot com
2016-05-11 14:54 ` mcermak at redhat dot com
4 siblings, 0 replies; 6+ messages in thread
From: dsmith at redhat dot com @ 2016-04-08 20:59 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=19926
--- Comment #4 from David Smith <dsmith at redhat dot com> ---
While talking about this, Frank came up with another idea of using a
script-level syntax like @const("...") - kind of like @cast(). It could even
refer to a header file in which to find it, like @cast(). This new syntax would
just expand to the embedded-C %{ ... %}. So basically it would be a macro, but
implemented at the parser level with a @operator rather than the macro language
proper
But Josh noted that there is a lot more footwork for new syntax
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug translator/19926] we need a better way to express constants in tapset code
2016-04-08 16:21 [Bug translator/19926] New: macro arguments can't be passed to embedded C code dsmith at redhat dot com
` (3 preceding siblings ...)
2016-04-08 20:59 ` dsmith at redhat dot com
@ 2016-05-11 14:54 ` mcermak at redhat dot com
4 siblings, 0 replies; 6+ messages in thread
From: mcermak at redhat dot com @ 2016-05-11 14:54 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=19926
Martin Cermak <mcermak at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mcermak at redhat dot com
Assignee|systemtap at sourceware dot org |mcermak at redhat dot com
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-05-11 14:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-08 16:21 [Bug translator/19926] New: macro arguments can't be passed to embedded C code dsmith at redhat dot com
2016-04-08 17:22 ` [Bug translator/19926] " fche at redhat dot com
2016-04-08 20:42 ` dsmith at redhat dot com
2016-04-08 20:54 ` [Bug translator/19926] we need a better way to express constants in tapset code dsmith at redhat dot com
2016-04-08 20:59 ` dsmith at redhat dot com
2016-05-11 14:54 ` 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).