Class: ASMREPL::MacOS::ThreadState
- Inherits:
-
Object
- Object
- ASMREPL::MacOS::ThreadState
- Defined in:
- lib/asmrepl/macos.rb
Constant Summary collapse
- FLAGS =
[ ['CF', 'Carry Flag'], [nil, 'Reserved'], ['PF', 'Parity Flag'], [nil, 'Reserved'], ['AF', 'Adjust Flag'], [nil, 'Reserved'], ['ZF', 'Zero Flag'], ['SF', 'Sign Flag'], ['TF', 'Trap Flag'], ['IF', 'Interrupt Enable Flag'], ['DF', 'Direction Flag'], ['OF', 'Overflow Flag'], ['IOPL_H', 'I/O privilege level High bit'], ['IOPL_L', 'I/O privilege level Low bit'], ['NT', 'Nested Task Flag'], [nil, 'Reserved'], ]
Instance Attribute Summary collapse
-
#to_ptr ⇒ Object
readonly
Returns the value of attribute to_ptr.
Class Method Summary collapse
Instance Method Summary collapse
- #[](name) ⇒ Object
- #flags ⇒ Object
-
#initialize(buffer) ⇒ ThreadState
constructor
A new instance of ThreadState.
- #to_s ⇒ Object
Constructor Details
#initialize(buffer) ⇒ ThreadState
Returns a new instance of ThreadState.
98 99 100 |
# File 'lib/asmrepl/macos.rb', line 98 def initialize buffer @to_ptr = buffer end |
Instance Attribute Details
#to_ptr ⇒ Object (readonly)
Returns the value of attribute to_ptr.
96 97 98 |
# File 'lib/asmrepl/macos.rb', line 96 def to_ptr @to_ptr end |
Class Method Details
.malloc ⇒ Object
92 93 94 |
# File 'lib/asmrepl/macos.rb', line 92 def self.malloc new Fiddle::Pointer.malloc sizeof end |
Instance Method Details
#[](name) ⇒ Object
86 87 88 89 90 |
# File 'lib/asmrepl/macos.rb', line 86 def [] name idx = fields.index(name) return unless idx to_ptr[Fiddle::SIZEOF_INT64_T * idx, Fiddle::SIZEOF_INT64_T].unpack1("l!") end |
#flags ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/asmrepl/macos.rb', line 141 def flags flags = rflags f = [] FLAGS.each do |abbrv, _| if abbrv && flags & 1 == 1 f << abbrv end flags >>= 1 end f end |
#to_s ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/asmrepl/macos.rb', line 106 def to_s buf = "" fields.first(8).zip(fields.drop(8).first(8)).each do |l, r| buf << "#{l.ljust(3)} #{sprintf("%#018x", send(l))}" buf << " " buf << "#{r.ljust(3)} #{sprintf("%#018x", send(r))}\n" end buf << "\n" fields.drop(16).each do |reg| buf << "#{reg.ljust(6)} #{sprintf("%#018x", send(reg))}\n" end buf end |