node/lib/metasm/metasm/gui/debug.rb
# update the data window, or dump data to console if len given
update the data window, or dump data to console if len given
update the data window or dump data to console if len given
def cmd_dd(addr, dlen=nil, len=nil)
		if addr.kind_of? String
			s = addr.strip
			addr = solve_expr!(s) || @parent_widget.mem.curaddr
			if not s.empty?
				s = s[1..-1] if s[0] == ?,
				len ||= solve_expr(s)
			end
		end
		if len
			while len > 0
				data = @dbg.memory[addr, [len, 16].min]
				le = (@dbg.cpu.endianness == :little)
				data = '' if @dbg.memory.page_invalid?(addr)
				case dlen
				when nil; add_log "#{Expression[addr]}  #{data.unpack('C*').map { |c| '%02X' % c }.join(' ').ljust(2*16+15)}  #{data.tr("^\x20-\x7e", '.')}"
				when 1;   add_log "#{Expression[addr]}  #{data.unpack('C*').map { |c| '%02X' % c }.join(' ')}"
				when 2;   add_log "#{Expression[addr]}  #{data.unpack(le ? 'v*' : 'n*').map { |c| '%04X' % c }.join(' ')}"
				when 4;   add_log "#{Expression[addr]}  #{data.unpack(le ? 'V*' : 'N*').map { |c| '%08X' % c }.join(' ')}"
				when 8;   add_log "#{Expression[addr]}  #{data.unpack('Q*').map { |c| '%016X' % c }.join(' ')}"
				end
				addr += 16
				len -= 16
			end
		else
			if dlen
				@parent_widget.mem.view(:hex).data_size = dlen
				@parent_widget.mem.view(:hex).resized
				@parent_widget.mem.showview(:hex)
			end
			@parent_widget.mem.focus_addr(solve_expr(addr))
			@parent_widget.mem.gui_update
		end
	end
def cmd_dd ( addr , dlen = nil , len = nil ) if addr . kind_of? String s = addr . strip addr = solve_expr! ( s ) || @parent_widget . mem . curaddr if not s . empty? s = s [ 1 .. - 1 ] if s [ 0 ] == ?, len ||= solve_expr ( s ) end end if len while len > 0 data = @dbg . memory [ addr , [ len , 16 ] . min ] le = ( @dbg . cpu . endianness == :little ) data = '' if @dbg . memory . page_invalid? ( addr ) case dlen when nil ; add_log "#{Expression[addr]}  #{data.unpack('C*').map { |c| '%02X' % c }.join(' ').ljust(2*16+15)}  #{data.tr("^\x20-\x7e", '.')}" when 1 ; add_log "#{Expression[addr]}  #{data.unpack('C*').map { |c| '%02X' % c }.join(' ')}" when 2 ; add_log "#{Expression[addr]}  #{data.unpack(le ? 'v*' : 'n*').map { |c| '%04X' % c }.join(' ')}" when 4 ; add_log "#{Expression[addr]}  #{data.unpack(le ? 'V*' : 'N*').map { |c| '%08X' % c }.join(' ')}" when 8 ; add_log "#{Expression[addr]}  #{data.unpack('Q*').map { |c| '%016X' % c }.join(' ')}" end addr += 16 len -= 16 end else if dlen @parent_widget . mem . view ( :hex ) . data_size = dlen @parent_widget . mem . view ( :hex ) . resized @parent_widget . mem . showview ( :hex ) end @parent_widget . mem . focus_addr ( solve_expr ( addr ) ) @parent_widget . mem . gui_update end end
update the data window, or dump data to console if len given
update the data window or dump data to console if len given
addr
dlen
len