require "twib/interface.rb" require "twib/switch/debug.rb" module Twib module Interfaces # Debug interface bound to a specific process. class ITwibDebugger < Interface # @api private module Command QUERY_MEMORY = 10 READ_MEMORY = 11 WRITE_MEMORY = 12 LIST_THREADS = 13 GET_DEBUG_EVENT = 14 GET_THREAD_CONTEXT = 15 BREAK_PROCESS = 16 CONTINUE_DEBUG_EVENT = 17 SET_THREAD_CONTEXT = 18 GET_NSO_INFOS = 19 WAIT_EVENT = 20 end # Queries process segment information at the given address. # # debug.query_memory(0) # # => {:base=>0, :size=>62308483072, :memory_type=>0, # # :memory_attribute=>0, :permission=>0, # # :device_ref_count=>0, :ipc_ref_count=>0} # # @param addr [Integer] Address to query # @return [Hash] def query_memory(addr) Hash[ [:base, :size, :memory_type, :memory_attribute, :permission, :device_ref_count, :ipc_ref_count].zip( send(Command::QUERY_MEMORY, [addr].pack("Q<")).wait_ok.payload.unpack("Q] def get_nso_infos response = send(Command::GET_NSO_INFOS).wait_ok.payload count = response.unpack("Q<")[0] count.times.map do |i| Hash[ [:base, :size, :build_id].zip(response[8 + 0x30 * i, 0x30].unpack("Q