def METHOD_NAME(self, address, size=4, perms="rw"):
    idx = None
    for i in range(4):
        if not self.hwdebug[i]:
            idx = i
            break
    if idx is None:
        raise Exception("ERROR: there...  are... 4... debug registers!")
    pbits = dbg_types.get(perms)
    if pbits is None:
        raise Exception("Unsupported watchpoint perms %s (x86 supports x,w,rw)" % perms)
    if pbits == dbg_execute and size != 1:
        raise Exception("Watchpoint for execute *must* be 1 byte long!")
    if size not in [1, 2, 4]:
        raise Exception("Unsupported watchpoint size %d (x86 supports 1,2,4)" % size)
    ctrl = 0
    self.hwdebug[idx] = address
    ctrl |= 1 << (2*idx)           # Enabled
    mask = ((size-1) << 2) + pbits  # perms and size
    ctrl |= (mask << (16 + (4 * idx)))
    # ctrl |= 0x100 # Local exact (ignored by p6+ for read)
    for tid in self.getThreads().keys():
        ctx = self.getRegisterContext(tid)
        ctrl_orig = ctx.getRegister(e_i386.REG_DEBUG7)
        # logger.debug("debug%d: %.8x debug7: %.8x" % (idx,address,ctrl|ctrl_orig))
        ctx.setRegister(e_i386.REG_DEBUG7, ctrl_orig | ctrl)
        ctx.setRegister(e_i386.REG_DEBUG0 + idx, address)
    return