Bug 18942 - any script will include all the globals from tapset/argv.stp
Summary: any script will include all the globals from tapset/argv.stp
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: tapsets (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-09 15:40 UTC by David Smith
Modified: 2015-09-09 15:49 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 David Smith 2015-09-09 15:40:16 UTC
This is on RHEL7, but most likely happen everywhere:

====
# stap -vp4 -e 'probe syscall.read { printf("%s, %s\n", name, argstr) }'
Pass 1: parsed user script and 113 library script(s) using 214560virt/32056res/2944shr/29492data kb, in 670usr/30sys/707real ms.
Pass 2: analyzed script: 2 probe(s), 5 function(s), 94 embed(s), 33 global(s) using 250360virt/68808res/3864shr/65292data kb, in 1200usr/140sys/1339real ms.
Pass 3: translated to C into "/tmp/stapYRq5dD/stap_ec359b719647ca1ded86300ca3d447f0_56028_src.c" using 250360virt/69188res/4244shr/65292data kb, in 30usr/80sys/111real ms.
/home/dsmith/.systemtap/cache/ec/stap_ec359b719647ca1ded86300ca3d447f0_56028.ko
Pass 4: compiled C into "stap_ec359b719647ca1ded86300ca3d447f0_56028.ko" in 11730usr/2230sys/13771real ms.
====

Notice the "Pass 2" line reports the use of 33 globals. Looking at the pass 2 output, here are the global variables it is compiling in:

====
# globals
argv[32]:string [long]
argv_1:string
argv_2:string
argv_3:string
argv_4:string
argv_5:string
argv_6:string
argv_7:string
argv_8:string
argv_9:string
argv_10:string
argv_11:string
argv_12:string
argv_13:string
argv_14:string
argv_15:string
argv_16:string
argv_17:string
argv_18:string
argv_19:string
argv_20:string
argv_21:string
argv_22:string
argv_23:string
argv_24:string
argv_25:string
argv_26:string
argv_27:string
argv_28:string
argv_29:string
argv_30:string
argv_31:string
argv_32:string
====

Since these global variables aren't actually used, they should not be included in the module.
Comment 1 David Smith 2015-09-09 15:49:35 UTC
Josh Stone helped me realize that __count_envp() and __count_compat_envp() tapset functions from tapset/linux/aux_syscalls.stp have a local variable called 'argc'. The translator can't tell the difference between this local and the global, so it pulled the global in.

With the variable names changed in tapset/linux/aux_syscalls.stp, no globals get pulled into that test script.

Fixed in commit 36aa918. With this change, that same script uses no global variables:

====
# stap -vp4 -e 'probe syscall.read { printf("%s, %s\n", name, argstr) }'
Pass 1: parsed user script and 113 library script(s) using 214560virt/32056res/2944shr/29492data kb, in 640usr/30sys/673real ms.
Pass 2: analyzed script: 1 probe(s), 5 function(s), 94 embed(s), 0 global(s) using 250356virt/68776res/3860shr/65288data kb, in 1130usr/160sys/1290real ms.
Pass 3: translated to C into "/tmp/stapBPUP2p/stap_80a9d5c9c352558521b5742a83e36296_54572_src.c" using 250356virt/69128res/4212shr/65288data kb, in 20usr/80sys/106real ms.
/home/dsmith/.systemtap/cache/80/stap_80a9d5c9c352558521b5742a83e36296_54572.ko
Pass 4: compiled C into "stap_80a9d5c9c352558521b5742a83e36296_54572.ko" in 11250usr/2030sys/13082real ms.
====