Sha256: 6b7186dd7533b83d182cc8e46dbcdae8ae3a7bbcff23e3451d46f1af26c0f00a

Contents?: true

Size: 938 Bytes

Versions: 8

Compression:

Stored size: 938 Bytes

Contents

# frozen_string_literal: true

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

    def initialize(configuration, frame_xml)
      @configuration = configuration
      @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?
      obj == configuration.ruby ||
        # Hack to fix Ruby built with --enabled-shared
        File.basename(obj) == "libruby.so.#{RUBY_VERSION}"
    end

    def in_binary?
      if obj
        File.basename(obj, ".*") == configuration.binary_name
      else
        false
      end
    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

8 entries across 8 versions & 1 rubygems

Version Path
ruby_memcheck-1.2.0 lib/ruby_memcheck/frame.rb
ruby_memcheck-1.1.2 lib/ruby_memcheck/frame.rb
ruby_memcheck-1.1.1 lib/ruby_memcheck/frame.rb
ruby_memcheck-1.1.0 lib/ruby_memcheck/frame.rb
ruby_memcheck-1.0.3 lib/ruby_memcheck/frame.rb
ruby_memcheck-1.0.2 lib/ruby_memcheck/frame.rb
ruby_memcheck-1.0.1 lib/ruby_memcheck/frame.rb
ruby_memcheck-1.0.0 lib/ruby_memcheck/frame.rb