mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Minor changes to disasm output. Fix GCC warning.
This commit is contained in:
parent
25234f8a1c
commit
8a61e848c0
2 changed files with 8 additions and 3 deletions
9
ujit.rb
9
ujit.rb
|
@ -1,5 +1,9 @@
|
||||||
module UJIT
|
module UJIT
|
||||||
def self.disasm(iseq)
|
def self.disasm(iseq)
|
||||||
|
if iseq.is_a? Method
|
||||||
|
iseq = RubyVM::InstructionSequence.of(iseq)
|
||||||
|
end
|
||||||
|
|
||||||
blocks = UJIT.blocks_for(iseq)
|
blocks = UJIT.blocks_for(iseq)
|
||||||
return if blocks.empty?
|
return if blocks.empty?
|
||||||
|
|
||||||
|
@ -10,13 +14,14 @@ module UJIT
|
||||||
str << iseq.disasm
|
str << iseq.disasm
|
||||||
str << "\n"
|
str << "\n"
|
||||||
|
|
||||||
|
# Sort the blocks by increasing addresses
|
||||||
blocks.sort_by(&:address).reverse.each do |block|
|
blocks.sort_by(&:address).reverse.each do |block|
|
||||||
str << "== ISEQ RANGE: #{block.iseq_start_index} -> #{block.iseq_end_index} ".ljust(80, "=")
|
str << "== ISEQ RANGE: [#{block.iseq_start_index},#{block.iseq_end_index}[ ".ljust(80, "=")
|
||||||
str << "\n"
|
str << "\n"
|
||||||
|
|
||||||
cs.disasm(block.code, 0).each do |i|
|
cs.disasm(block.code, 0).each do |i|
|
||||||
str << sprintf(
|
str << sprintf(
|
||||||
"\t0x%<address>x:\t%<instruction>s\t%<details>s\n",
|
"\t%<address>04X:\t%<instruction>s\t%<details>s\n",
|
||||||
address: i.address,
|
address: i.address,
|
||||||
instruction: i.mnemonic,
|
instruction: i.mnemonic,
|
||||||
details: i.op_str
|
details: i.op_str
|
||||||
|
|
Loading…
Add table
Reference in a new issue