[docs]defhex_dump(self,start,size,word_size=4,words_per_row=4,endianness="Iend_BE",symbolic_char="?",unprintable_char=".",solve=False,extra_constraints=None,inspect=False,disable_actions=True,):""" Returns a hex dump as a string. The solver, if enabled, is called once for every byte potentially making this function very slow. It is meant to be used mainly as a "visualization" for debugging. Warning: May read and display more bytes than `size` due to rounding. Particularly, if size is less than, or not a multiple of word_size*words_per_line. :param start: starting address from which to print :param size: number of bytes to display :param word_size: number of bytes to group together as one space-delimited unit :param words_per_row: number of words to display per row of output :param endianness: endianness to use when displaying each word (ASCII representation is unchanged) :param symbolic_char: the character to display when a byte is symbolic and has multiple solutions :param unprintable_char: the character to display when a byte is not printable :param solve: whether or not to attempt to solve (warning: can be very slow) :param extra_constraints: extra constraints to pass to the solver is solve is True :param inspect: whether or not to trigger SimInspect breakpoints for the memory load :param disable_actions: whether or not to disable SimActions for the memory load :return: hex dump as a string """ifendianness=="Iend_BE":end=1else:end=-1ifextra_constraintsisNone:extra_constraints=[]# round up size so that chop() worksline_size=word_size*words_per_rowsize=sizeifsize%line_size==0elsesize+line_size-size%line_sizeraw_mem=super().load(start,size=size,inspect=inspect,disable_actions=disable_actions)i=startdump_str=""forlineinraw_mem.chop(line_size*self.state.arch.byte_width):dump="%x:"%igroup_str=""forwordinline.chop(word_size*self.state.arch.byte_width):word_bytes=""word_str=""forbyte_inword.chop(self.state.arch.byte_width)[::end]:byte_value=Noneifnotself.state.solver.symbolic(byte_)orsolve:try:byte_value=self.state.solver.eval_one(byte_,extra_constraints=extra_constraints)exceptSimValueError:passifbyte_valueisnotNone:word_bytes+="%02x"%byte_valueifchr(byte_value)instring.printable[:-5]:word_str+=chr(byte_value)else:word_str+=unprintable_charelse:word_bytes+=symbolic_char*2word_str+=symbolic_chardump+=" "+word_bytesgroup_str+=word_str[::end]# always print ASCII representation in little-endiandump+=" "+group_stri+=line_sizedump_str+=dump+"\n"returndump_str