Sha256: af927d520bc7efcfea19704af98f31b6ef0fd6e295a6a75bf2177549e9c1df2b

Contents?: true

Size: 906 Bytes

Versions: 5

Compression:

Stored size: 906 Bytes

Contents

#
# Author: Waldemar Hummer (hummer@dsg.tuwien.ac.at)
#

require "toaster/state/transition_edge"
require "toaster/markup/markup_util"

include Toaster

module Toaster

  class PtraceUtil

    WORD_SIZE = 8

    def self.read_string(ptrace_target, addr)
      str = ""
      do_continue = true
      iter = 0
      while do_continue
        v = ptrace_target.text.peek(addr + (WORD_SIZE * iter))
        (0..7).each do |shift_bytes|
          shift = 8 * shift_bytes
          byte = (v >> shift) & 0xFF
          if byte == 0
            #puts "END OF STRING!!"
            do_continue = false
            break
          end
          str += byte.chr
        end
        iter += 1
      end
      return str
    end

    def self.get_filename_for_fd(pid, fd)
      path = "/proc/#{pid}/fd/#{fd}"
      begin
        return File.readlink(path)
      rescue
        return nil
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cloud-toaster-1.1.6 lib/toaster/state/ptrace_util.rb
cloud-toaster-1.1.5 lib/toaster/state/ptrace_util.rb
cloud-toaster-1.1.4 lib/toaster/state/ptrace_util.rb
cloud-toaster-1.1.3 lib/toaster/state/ptrace_util.rb
cloud-toaster-1.1.2 lib/toaster/state/ptrace_util.rb