lib/rubyrun/rubyrun_instrumentor__.rb in rubyrun-0.9.8 vs lib/rubyrun/rubyrun_instrumentor__.rb in rubyrun-0.9.9

- old
+ new

@@ -66,33 +66,34 @@ # 5. Exclude inherited instances, private, protected, and singleton methods. # The way this works is that if m is one of these non-inherited instance # methods or singleton methods then it should NOT be excluded. Otherwise # it is assumed it is an inherited one and hence excluded. def is_non_negotiably_excluded?(type, klass, id) - return true if is_in?(RUBYRUN_FIREWALL_HASH, klass, id) + return true if is_in?(RUBYRUN_FIREWALL_HASH, klass, id) return true if id.id2name[-1,1] == '=' if id.id2name[0, RUBYRUN_PREFIX_LENGTH] == RUBYRUN_PREFIX $rubyrun_prev_method = id.id2name return true end if ($rubyrun_prev_method ||="").include?(id.id2name) $rubyrun_prev_method = nil return true - end + end + m_name = return_mid(id) if type == 'i' klass.instance_methods(false).each {|m| - return false if m == id.id2name + return false if m == m_name } klass.private_instance_methods(false).each {|m| - return false if m == id.id2name + return false if m == m_name } klass.protected_instance_methods(false).each {|m| - return false if m == id.id2name + return false if m == m_name } else klass.singleton_methods.each {|m| - return false if m == id.id2name + return false if m == m_name } end true end @@ -144,30 +145,33 @@ eval <<-BODY1 def #{mid.id2name} (*args, &blk) RubyRunInstrumentor__.collect_method_data(self, #{klass}, '#{mid}', *args) {self.send("#{alias_name}", *args, &blk)} end BODY1 - if klass.private_instance_methods(false).include?(alias_name) + m_name = return_mid(alias_name) + if klass.private_instance_methods(false).include?(m_name) private mid - elsif klass.protected_instance_methods(false).include?(alias_name) + elsif klass.protected_instance_methods(false).include?(m_name) protected mid end } end # Same as insert_code_to_instance_method def insert_code_to_singleton_method(klass, mid) + klass_name = return_class_name(klass) (class << klass; self; end).class_eval { alias_name = "#{RubyRunGlobals::RUBYRUN_PREFIX}_#{rand.to_s.split('.')[1]}_#{mid.id2name}" alias_method alias_name, mid.id2name eval <<-BODY2 def #{mid.id2name} (*args, &blk) - RubyRunInstrumentor__.collect_method_data(self, #{klass}, '#{mid}', *args) {self.send("#{alias_name}", *args, &blk)} + RubyRunInstrumentor__.collect_method_data(self, #{klass_name}, '#{mid}', *args) {self.send("#{alias_name}", *args, &blk)} end BODY2 - if self.private_instance_methods(false).include?(alias_name) + m_name = return_mid(alias_name) + if self.private_instance_methods(false).include?(m_name) private mid - elsif self.protected_instance_methods(false).include?(alias_name) + elsif self.protected_instance_methods(false).include?(m_name) protected mid end } end \ No newline at end of file