Class: Ragweed::Wraposx::ThreadInfo::Basic

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

Overview

struct thread_basic_info

time_value_t     user_time;
time_value_t   system_time;
integer_t        cpu_usage;
policy_t            policy;
integer_t        run_state;
integer_t            flags;
integer_t    suspend_count;
integer_t       sleep_time;

;

Defined Under Namespace

Modules: Flags

Constant Summary collapse

FLAVOR =
Ragweed::Wraposx::ThreadInfo::BASIC_INFO

Instance Method Summary collapse

Methods included from FFIStructInclude

#method_missing, #methods, #respond_to?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ragweed::FFIStructInclude

Instance Method Details

#dump(&block) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ragweed/wraposx/thread_info.rb', line 52

def dump(&block)
  maybe_hex = lambda {|a| begin; "\n" + (" " * 9) + block.call(a, 16).hexdump(true)[10..-2]; rescue; ""; end }
  maybe_dis = lambda {|a| begin; "\n" + block.call(a, 16).distorm.map {|i| "         " + i.mnem}.join("\n"); rescue; ""; end }

  string =<<EOM
  -----------------------------------------------------------------------
  INFO:
  user_time:     #{self.user_time.to_s.rjust(8, "0")} #{maybe_hex.call(self.user_time)}
  system_time:   #{self.system_time.to_s.rjust(8, "0")} #{maybe_hex.call(self.system_time)}
  cpu_usage:     #{self.cpu_usage.to_s.rjust(8, "0")} #{maybe_hex.call(self.cpu_usage)}
  policy:        #{self.policy.to_s.rjust(8, "0")} #{maybe_hex.call(self.policy)}
  run_state:     #{self.run_state.to_s.rjust(8, "0")} #{maybe_hex.call(self.run_state)}
  suspend_count: #{self.suspend_count.to_s.rjust(8, "0")} #{maybe_hex.call(self.suspend_count)}
  sleep_time:    #{self.sleep_time.to_s.rjust(8, "0")} #{maybe_hex.call(self.sleep_time)}
  flags:         #{self.flags.to_s(2).rjust(32, "0")} #{Flags.flag_dump(self.flags)}
EOM
end