Bug 18598

Summary: stap_staticmarkers.stp tapset has no test case
Product: systemtap Reporter: David Smith <dsmith>
Component: tapsetsAssignee: Unassigned <systemtap>
Status: RESOLVED FIXED    
Severity: normal CC: jistone
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description David Smith 2015-06-25 15:23:42 UTC
While working on bug #18577 and going through the semantic errors that 'stap -vv -l **' produces, I noticed that I was getting errors from the stap_staticmarkers.stp tapset. This tapset provides probe aliases for markers built into stap and staprun.

Markers exist in stap:

====
# stap -l 'process("stap").mark("*")'
process("/usr/local/bin/stap").mark("benchmark")
process("/usr/local/bin/stap").mark("benchmark__end")
process("/usr/local/bin/stap").mark("benchmark__start")
process("/usr/local/bin/stap").mark("benchmark__thread__end")
process("/usr/local/bin/stap").mark("benchmark__thread__start")
process("/usr/local/bin/stap").mark("cache__add__module")
process("/usr/local/bin/stap").mark("cache__add__source")
process("/usr/local/bin/stap").mark("cache__clean")
process("/usr/local/bin/stap").mark("cache__get")
process("/usr/local/bin/stap").mark("client__end")
process("/usr/local/bin/stap").mark("client__start")
process("/usr/local/bin/stap").mark("pass0__end")
process("/usr/local/bin/stap").mark("pass0__start")
process("/usr/local/bin/stap").mark("pass1__end")
process("/usr/local/bin/stap").mark("pass1a__start")
process("/usr/local/bin/stap").mark("pass1b__start")
process("/usr/local/bin/stap").mark("pass2__end")
process("/usr/local/bin/stap").mark("pass2__start")
process("/usr/local/bin/stap").mark("pass3__end")
process("/usr/local/bin/stap").mark("pass3__start")
process("/usr/local/bin/stap").mark("pass4__end")
process("/usr/local/bin/stap").mark("pass4__start")
process("/usr/local/bin/stap").mark("pass5__end")
process("/usr/local/bin/stap").mark("pass5__start")
process("/usr/local/bin/stap").mark("pass6__end")
process("/usr/local/bin/stap").mark("pass6__start")
process("/usr/local/bin/stap").mark("stap_system__complete")
process("/usr/local/bin/stap").mark("stap_system__spawn")
process("/usr/local/bin/stap").mark("stap_system__start")
====

But, no markers can be found in staprun:

====
# stap -l 'process("staprun").mark("*")'
====

This is odd because several markers appear in the staprun source. Perhaps we've got a build problem.

Note that the stap_staticmarkers.stp needs a buildok test case so that this sort of problem would have been found sooner.
Comment 1 Josh Stone 2015-06-25 17:15:11 UTC
The more direct way to check existence is "readelf -n", and this is revealing:

$ readelf -n /usr/local/bin/staprun
readelf: Error: Input file '/usr/local/bin/staprun' is not readable.

That's because staprun has mode 4110 (suid|xusr|xgrp).  Nobody has read permission, which effectively means only root can read it.

Although you wrote a '#' before your commands, which usually indicates a root prompt... Is that so, or were you running as a user?

$ sudo readelf -n /usr/local/bin/staprun
[...]
Displaying notes found at file offset 0x0002ba98 with length 0x000001f4:
  Owner                 Data size       Description
  stapsdt              0x00000036       NT_STAPSDT (SystemTap probe descriptors)
    Provider: staprun
    Name: remove__module
    Location: 0x000000000040856e, Base: 0x0000000000427358, Semaphore: 0x0000000000000000
    Arguments: 8@%rbx
  stapsdt              0x00000036       NT_STAPSDT (SystemTap probe descriptors)
    Provider: staprun
    Name: insert__module
    Location: 0x000000000040aa18, Base: 0x0000000000427358, Semaphore: 0x0000000000000000
    Arguments: 8@%r12
[etc]
Comment 2 David Smith 2015-06-25 17:42:06 UTC
(In reply to Josh Stone from comment #1)
> The more direct way to check existence is "readelf -n", and this is
> revealing:
> 
> $ readelf -n /usr/local/bin/staprun
> readelf: Error: Input file '/usr/local/bin/staprun' is not readable.
> 
> That's because staprun has mode 4110 (suid|xusr|xgrp).  Nobody has read
> permission, which effectively means only root can read it.
> 
> Although you wrote a '#' before your commands, which usually indicates a
> root prompt... Is that so, or were you running as a user?

Ah, that was definitely it. With sudo:

====
# sudo stap -l 'process("staprun").mark("*")' 
process("/usr/bin/staprun").mark("insert__module")
process("/usr/bin/staprun").mark("remove__module")
process("/usr/bin/staprun").mark("send__ctlmsg")
process("/usr/bin/staprun").mark("stap_system__complete")
process("/usr/bin/staprun").mark("stap_system__spawn")
process("/usr/bin/staprun").mark("stap_system__start")
====

I'll still write a buildok test case for this tapset.
Comment 3 David Smith 2015-06-25 18:01:08 UTC
Test case added in commit f4943fb.