This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug translator/19926] New: macro arguments can't be passed to embedded C code


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]