Bug 1362437

Summary: Compile Ruby with SystemTap
Product: Red Hat Software Collections Reporter: Lukas Zapletal <lzap>
Component: rh-ruby22Assignee: Pavel Valena <pvalena>
Status: CLOSED NOTABUG QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: hhorak, lzap, pvalena, vondruch
Target Milestone: alpha   
Target Release: 2.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-09-05 08:20:29 EDT Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Lukas Zapletal 2016-08-02 04:04:24 EDT
For Satellite performance debugging, we would like to have the possibility to hook on ruby markers, but it's not possible:

[root@fseven ~]# cat rubystack.stp 
#!/usr/bin/stap·

global fn_calls;

probe ruby.cmethod.entry
{
        fn_calls[classname, methodname] <<< 1;
}

probe end {
        foreach ([classname, methodname] in fn_calls- limit 30) {
                printf("%dx %s.%s\n",
                                @count(fn_calls[classname, methodname]),
                                classname, methodname);
        }

        delete fn_calls;
}

# SCL RUBY

[root@fseven ~]# stap rubystack.stp -c "scl enable rh-ruby22 \"ruby factorial.rb 5\""
120

# SYSTEM RUBY (working ok)

[root@fseven ~]# stap rubystack.stp -c "ruby factorial.rb 5"
120
2823x Module.===
1728x BasicObject.==
1728x Kernel.===
997x Symbol.to_s
980x Kernel.initialize_dup
979x Kernel.dup
960x Kernel.instance_variable_set
683x Hash.[]=
676x String.to_s
499x String.initialize_copy
445x Class.new
386x String.gsub
384x Array.initialize_copy
327x Kernel.class
320x Module.method_added
315x Array.each
286x Array.flatten
260x File.file?
242x #<Class:0x0000000213ad88>.core#define_method
236x String.<=>
220x String.to_i
204x Enumerable.any?
179x String.strip
179x File.join
177x Regexp.=~
164x Kernel.respond_to?
164x Kernel.untaint
156x String.=~
149x Array.last
146x Array.map!

Thanks!
Comment 1 Pavel Valena 2016-08-11 08:25:32 EDT
I will look into it.
Comment 2 Pavel Valena 2016-08-26 13:29:40 EDT
Hi,

I took your exact .stp file and I got correct SystemTap output without any issue.

In your case it is caused by invalid commands order. Running `scl enable ...` command, shell environment and paths are changed, which interferes with SystemTap.

# rpm -q rh-ruby22-ruby
rh-ruby22-ruby-2.2.2-15.el7.x86_64

# scl enable rh-ruby22 -- stap rubystack.stp -c "ruby factorial.rb 5"
5 => 120
377x Module.method_added
317x String.gsub
269x #<Class:0x00000001df3170>.core#define_method
228x Kernel.initialize_dup
228x String.initialize_copy
228x Kernel.dup
164x BasicObject.singleton_method_added
139x #<Class:0x00000001df3170>.core#define_singleton_method
93x String.[]
92x Module.===
84x Kernel.===
74x BasicObject.==
71x String.<=>
69x String.replace
61x Class.inherited
41x IO.set_encoding
33x Module.attr_reader
30x Symbol.to_s
26x Kernel.require
23x Module.attr_accessor
20x Kernel.nil?
20x BasicObject.!=
18x String.=~
17x Module.private
17x Kernel.!~
16x Module.autoload
16x #<Class:0x00000001df3170>.core#set_method_alias
14x Class.new
13x Array.==
10x File.join

[rh-ruby22 ~]# ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]

Please confirm that it works with commands in correct order.
Comment 3 Vít Ondruch 2016-09-05 08:20:29 EDT
I agree with Pavel's assessment => Closing this as a NOTABUG. Feel free to reopen in case we are wrong.
Comment 4 Lukas Zapletal 2016-09-06 09:37:44 EDT
Thanks Pavel, I haven't noticed this.