'Display memory content at an address with smart dereferences
Usage:
MYNAME [linecount] (analyze at current $SP)
MYNAME address [linecount]'

def telescope(self, *arg):

    (address, count) = normalize_argv(arg, 2)
    if self._is_running():
        sp = peda.getreg('sp')
    else:
        sp = None
    if (count is None):
        count = 8
        if (address is None):
            address = sp
        elif (address < 4096):
            count = address
            address = sp
    if (not address):
        return
    step = peda.intsize()
    if (not peda.is_address(address)):
        for i in range(count):
            if (not peda.execute(('x/%sx    0x%x' % (('g' if (step == 8) else 'w'), (address + (i * step)))))):
                break
        return
    result = []
    for i in range(count):
        value = (address + (i * step))
        if peda.is_address(value):
            result += [peda.examine_mem_reference(value)]
        else:
            result += [None]
    idx = 0
    text = ''
    for chain in result:
        text += ('%04d|    ' % idx)
        text += format_reference_chain(chain)
        text += '\n'
        idx += step
    pager(text)
    return
