Sha256: 33c1cd222890599627be9b61d91839c66a11f283423f6a3a0b5f0e8ddebdff59

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module RubyMemcheck
  class Frame
    attr_reader :configuration, :loaded_binaries, :fn, :obj, :file, :line

    def initialize(configuration, loaded_binaries, frame_xml)
      @configuration = configuration
      @loaded_binaries = loaded_binaries

      @fn = frame_xml.at_xpath("fn")&.content
      @obj = frame_xml.at_xpath("obj")&.content
      # file and line may not be available
      @file = frame_xml.at_xpath("file")&.content
      @line = frame_xml.at_xpath("line")&.content
    end

    def in_ruby?
      return false unless obj

      obj == configuration.ruby ||
        # Hack to fix Ruby built with --enabled-shared
        File.basename(obj) == "libruby.so.#{RUBY_VERSION}"
    end

    def in_binary?
      return false unless obj

      loaded_binaries.include?(obj)
    end

    def binary_init_func?
      return false unless in_binary?

      binary_name = File.basename(obj, ".*")
      fn == "Init_#{binary_name}"
    end

    def to_s
      if file
        "#{fn} (#{file}:#{line})"
      elsif fn
        "#{fn} (at #{obj})"
      else
        "<unknown stack frame>"
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby_memcheck-3.0.1 lib/ruby_memcheck/frame.rb
ruby_memcheck-3.0.0 lib/ruby_memcheck/frame.rb
ruby_memcheck-2.3.0 lib/ruby_memcheck/frame.rb
ruby_memcheck-2.2.1 lib/ruby_memcheck/frame.rb
ruby_memcheck-2.2.0 lib/ruby_memcheck/frame.rb
ruby_memcheck-2.1.2 lib/ruby_memcheck/frame.rb
ruby_memcheck-2.1.1 lib/ruby_memcheck/frame.rb
ruby_memcheck-2.1.0 lib/ruby_memcheck/frame.rb
ruby_memcheck-2.0.1 lib/ruby_memcheck/frame.rb
ruby_memcheck-2.0.0 lib/ruby_memcheck/frame.rb