Bug 5956 - Usage of "NULL" in systemtap script throws non-apparent error messages
Summary: Usage of "NULL" in systemtap script throws non-apparent error messages
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-18 12:08 UTC by Srinivasa DS
Modified: 2008-04-30 21:13 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Srinivasa DS 2008-03-18 12:08:10 UTC
Environment: 2.6.24 kernel, systemtap 20080315 snapshot and elfutils-0.130

If I use "NULL" in systemtap scripts, stap throws non-apparent error messages.
Systemtap user finds it difficult to understand these error messages. So there
is a need for more obvious/apparent error message for this situation.


=======================================================
[root@llm27lp1 obj]# cat b.stp
        global array

        probe syscall.write {
                if ($buf != NULL)
                array[pid()]++;
        }
        ....................
        .....................
======================================
Pass 3: translated to C into
"/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c" in 0usr/0sys/2real ms.
Running make -C "/lib/modules/2.6.24/build" M="/tmp/stapAyIw1G" modules >/dev/null
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c:92: error: expected
identifier or '(' before 'void'
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c:92: error: expected
')' before numeric constant
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c:93: error: expected
';' before 'union'
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c: In function
'probe_1109':
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c:237: error: expected
identifier before '(' token
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c:259: error: expected
identifier before '(' token
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c:268: error: 'struct
probe_1109_locals' has no member named '__tmp0'
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c:273: error: 'struct
probe_1109_locals' has no member named '__tmp2'
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c:273: error: 'struct
probe_1109_locals' has no member named '__tmp0'
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c:274: error: 'struct
probe_1109_locals' has no member named '__tmp3'
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c:274: error: 'struct
probe_1109_locals' has no member named '__tmp2'
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c:275: error: 'struct
probe_1109_locals' has no member named '__tmp2'
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c:276: error: 'struct
probe_1109_locals' has no member named '__tmp0'
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c:276: error: 'struct
probe_1109_locals' has no member named '__tmp2'
/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.c:277: error: 'struct
probe_1109_locals' has no member named '__tmp3'
make[1]: *** [/tmp/stapAyIw1G/stap_7513fe211e17b3d61924ad9133f1d1e1_857.o] Error 1
make: *** [_module_/tmp/stapAyIw1G] Error 2
==================================================
Comment 1 Frank Ch. Eigler 2008-03-18 13:08:03 UTC
The NULL name is being treated as an implicitly declared systemtap local,
and is copied into the generated C code's context structure.  These names
should be prefixed with something too, just like the globals already are
(s_VAR).  See translate.cxx: var::value() and c_varname().
Comment 2 Frank Ch. Eigler 2008-03-20 19:35:56 UTC
Rather than tweak the local variable naming widget, which has the potential
of changing the embedded-c function API, I committed a patch that defines
a NULL systemtap-level global.  This works because globals do have a C-level
name prefixing to avoid conflict with kernel globals/macros.
Comment 3 Frank Ch. Eigler 2008-04-30 21:13:17 UTC
patch committed