Class: Ragweed::Wraposx::ThreadContext::Debug

Inherits:
FFI::Struct
  • Object
show all
Includes:
FFIStructInclude
Defined in:
lib/ragweed/wraposx/thread_context.rb

Constant Summary collapse

FLAVOR =
12

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
# File 'lib/ragweed/wraposx/thread_context.rb', line 502

def method_missing meth, *args
  super unless self.respond_to? meth
  if meth.to_s =~ /=$/
    mth = meth.to_s.gsub(/=$/,'').intern
    if self.members.include? mth
      # don't proxy
      self.__send__(:[]=, mth, *args)
    elsif self[:dsh].members.include? meth
      self[:dsh].__send__(:[]=, mth, *args)
    else
      case self[:dsh][:flavor]
      when Ragweed::Wraposx::ThreadContext::X86_DEBUG_STATE32
        self[:uds][:ds32].__send__(:[]=, mth, *args)
      when Ragweed::Wraposx::ThreadContext::X86_DEBUG_STATE64
        self[:uds][:ds64].__send__(:[]=, mth, *args)
      end
    end
  else
    if self.members.include? meth
      # don't proxy
      self.__send__(:[], meth, *args)
    elsif self[:dsh].members.include? meth
      self[:dsh].__send__(:[], meth, *args)
    else
      case self[:dsh][:flavor]
      when Ragweed::Wraposx::ThreadContext::X86_DEBUG_STATE32
        self[:uds][:ds32].__send__(:[], meth, *args)
      when Ragweed::Wraposx::ThreadContext::X86_DEBUG_STATE64
        self[:uds][:ds64].__send__(:[], meth, *args)
      end
    end
  end
end

Instance Method Details

#headerObject



466
# File 'lib/ragweed/wraposx/thread_context.rb', line 466

def header; self[:dsh]; end

#is_32?Boolean

Returns:

  • (Boolean)


465
# File 'lib/ragweed/wraposx/thread_context.rb', line 465

def is_32?; !is_64?; end

#is_64?Boolean

Returns:

  • (Boolean)


464
# File 'lib/ragweed/wraposx/thread_context.rb', line 464

def is_64?; self[:dsh].is_64?; end

#methods(regular = true) ⇒ Object



473
474
475
476
477
478
479
480
481
482
483
484
485
# File 'lib/ragweed/wraposx/thread_context.rb', line 473

def methods regular=true
  ret = super + self.members.map{|x| [x.to_s, x.to_s + "="]}
  ret += self[:dsh].members.map{|x| [x.to_s, x.to_s + "="]}
  ret += case self[:dsh][:flavor]
  when Ragweed::Wraposx::ThreadContext::X86_DEBUG_STATE32
    self[:uds][:ds32].members.map{|x| [x.to_s, x.to_s + "="]}
  when Ragweed::Wraposx::ThreadContext::X86_DEBUG_STATE64
    self[:uds][:ds64].members.map{|x| [x.to_s, x.to_s + "="]}
  else
    []
  end
  ret.flatten
end

#respond_to?(meth, include_priv = false) ⇒ Boolean

Returns:

  • (Boolean)


536
537
538
539
# File 'lib/ragweed/wraposx/thread_context.rb', line 536

def respond_to? meth, include_priv=false
  mth = meth.to_s.gsub(/=$/,'') # may not be needed anymore
  self.methods.include? mth || super
end