'Verify ROP gadget code from start to end with max number of instructions
Args:
- start: start address (Int)
- end: end addres (Int)
- depth: number of instructions (Int)
Returns:
- list of valid gadgets (address(Int), asmcode(String))'

def _verify_rop_gadget(self, start, end, depth=5):

    result = []
    valid = 0
    out = self.execute_redirect(('disassemble    0x%x,    0x%x' % (start, (end + 1))))
    if (not out):
        return []
    code = out.splitlines()[1:(-1)]
    for line in code:
        if ('bad' in line):
            return []
        (addr, code) = line.strip().split(':', 1)
        addr = to_int(addr.split()[0])
        result += [(addr, '    '.join(code.strip().split()))]
        if ('ret' in code):
            return result
        if (len(result) > depth):
            break
    return []
