def on_get_annotations(self, address, size, mouse_offs): ann = [] ip = get_ip_val() sp = get_sp_val() if ip is not None and sp is not None: ann.append((ip, Qt.red, "%X (IP)" % ip, Qt.red)) ann.append((sp, Qt.green, "%X (SP)" % sp, Qt.green)) return ann
def on_get_annotations(self, address, size, mouse_offs): annotations = [] sp = get_sp_val() ip = get_ip_val() fi = FrameInfo() if sp and ip: arrow = sp if self.sp_arrow else None frame_start_ea = fi.ea funcname = get_func_name(ip) annotations.append((None, None, "", None)) annotations.append((arrow, self.palette[4], "[Stack Pointer]", self.palette[1])) annotations.append((None, None, " address: 0x%x" % (sp), self.palette[3])) sp_boundaries = fi.get_element_boundaries(sp) if sp_boundaries and len(fi.members): start, end = sp_boundaries name, offs, msize, foffs = fi.members[start] annotations.append((None, None, " points to: %s" % (name), self.palette[3])) annotations.append((None, None, "", None)) annotations.append((None, None, "[Function]", self.palette[1])) annotations.append((None, None, " name: %s" % (funcname), self.palette[3])) annotations.append((None, None, " frame addr: 0x%x" % (frame_start_ea), self.palette[3])) if mouse_offs and len(fi.members): mouse_boundaries = fi.get_element_boundaries(address+mouse_offs) if mouse_boundaries: start, end = mouse_boundaries name, offs, msize, foffs = fi.members[start] # "dist" is the distance from current variable to # end of stack frame this is where a return address # may be stored depending on the CPU architecture dist = foffs-offs # address of frame member in memory var_addr = frame_start_ea+offs # add annotations annotations.append((None, None, "", None)) annotations.append((None, None, "[Frame Member]", self.palette[1])) annotations.append((None, None, " name: %s" % (name), self.palette[3])) annotations.append((None, None, " addr: 0x%x" % (var_addr), self.palette[3])) annotations.append((None, None, " offs: Frame+0x%x" % (offs), self.palette[3])) annotations.append((None, None, " size: 0x%x" % (msize), self.palette[3])) annotations.append((None, None, " distance: %s0x%x" % ("-" if dist < 0 else "", abs(dist)), self.palette[3])) annotations.append((None, None, " cursor: %s+0x%x" % (name, address + mouse_offs - (frame_start_ea+offs)), self.palette[3])) else: annotations.append((None, None, "Debugger inactive", self.palette[4])) return annotations
def _get_frame(self): result = False sp = get_sp_val() ip = get_ip_val() if ip and sp: f = get_func(ip) if f: frame = get_frame(f) if frame: self.framesize = get_struc_size(frame) n = frame.memqty frame_offs = f.frregs + f.frsize self.ea = sp - get_spd(f, ip) - frame_offs for i in xrange(n): m = frame.get_member(i) if m: lvar_name = get_member_name(m.id) lvar_ea = self.ea + m.soff lvar_size = m.eoff - m.soff self.members[lvar_ea] = (lvar_name, m.soff, lvar_size, frame_offs) result = True return result
def on_process_buffer(self, buffers, addr, total, mouse_offs): colors = [] goffs = 0 mouse_boundaries = None sp = get_sp_val() ip = get_ip_val() fi = FrameInfo() if mouse_offs is not None: mouse_boundaries = fi.get_element_boundaries(addr+mouse_offs) for mapped, buf in buffers: if mapped: i = 0 while i < len(buf): # highlight stack var pointed to by mouse if mouse_offs and mouse_boundaries: start, end = mouse_boundaries if addr + goffs + i in xrange(start, end): size = min(end - start, total-i) for j in xrange(size): colors.append((True, self.palette[3])) i += size continue # flash sp if sp is not None and self.hook.highlighted and sp == addr + goffs + i: size = get_item_size(sp) boundaries = fi.get_element_boundaries(sp) if boundaries: start, end = boundaries size = min(end - start, total-i) for j in xrange(size): colors.append((True, self.palette[4])) i += size continue # locals if goffs + addr + i in xrange(fi.ea, fi.ea + fi.framesize): size = 1 boundaries = fi.get_element_boundaries(goffs + addr + i) if boundaries: # if anything on the stackframe start, end = boundaries size = min(end - start, total-i) for j in xrange(size): colors.append((True, self.palette[2])) i += size continue else: #gap between locals colors.append((True, self.palette[1])) i += 1 continue # default bg color colors.append((True, self.palette[0])) i += 1 # unmapped, transparency else: for i in xrange(len(buf)): colors.append((False, None)) goffs += len(buf) return colors
def _request_update_viewer(self, sp=None): _sp = sp if sp else get_sp_val() if self.pw: self.pw.on_filter_request_update(_sp, center=True)