From bd012b0f9f2f8779323427933712f59c8a17eb7e Mon Sep 17 00:00:00 2001 From: symwell <111290954+symwell@users.noreply.github.com> Date: Wed, 17 Aug 2022 11:22:15 -0400 Subject: [PATCH] Doing config.lookup_package check first returns early in 98.7% of cases in sample_app_6th_ed. --- lib/appmap/hook.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/appmap/hook.rb b/lib/appmap/hook.rb index 499c5011..b57fbc9b 100644 --- a/lib/appmap/hook.rb +++ b/lib/appmap/hook.rb @@ -183,12 +183,6 @@ def trace_end(trace_point) hook = lambda do |hook_cls| lambda do |method_id| - # Don't try and trace the AppMap methods or there will be - # a stack overflow in the defined hook method. - next if %w[Marshal AppMap ActiveSupport].member?((hook_cls&.name || '').split('::')[0]) - - next if method_id == :call - method = \ begin hook_cls.instance_method(method_id) @@ -197,6 +191,16 @@ def trace_end(trace_point) next end + package = config.lookup_package(hook_cls, method) + # doing this check first returned early in 98.7% of cases in sample_app_6th_ed + next unless package + + # Don't try and trace the AppMap methods or there will be + # a stack overflow in the defined hook method. + next if %w[Marshal AppMap ActiveSupport].member?((hook_cls&.name || '').split('::')[0]) + + next if method_id == :call + next if self.class.already_hooked?(method) warn "AppMap: Examining #{hook_cls} #{method.name}" if LOG @@ -206,9 +210,6 @@ def trace_end(trace_point) # TODO: Figure out how to tell the difference? next unless disasm - package = config.lookup_package(hook_cls, method) - next unless package - package.handler_class.new(package, hook_cls, method).activate end end