()
For each running thread, updates the known address range
    for its stack.
For each running thread, updates the known address range
    for its stack.
For each running thread updates the known address range for its stack .
def update():
    """
    For each running thread, updates the known address range
    for its stack.
    """
    curr_thread = gdb.selected_thread()
    try:
        for thread in gdb.selected_inferior().threads():
            thread.switch()
            sp = pwndbg.regs.sp

            # Skip if sp is None or 0
            # (it might be 0 if we debug a qemu kernel)
            if not sp:
                continue

            sp_low = sp & ~(0xfff)
            sp_low -= 0x1000

            # If we don't already know about this thread, create
            # a new Page mapping for it.
            page = stacks.get(thread.ptid, None)
            if page is None:
                start = sp_low
                stop  = find_upper_stack_boundary(sp)
                page  = pwndbg.memory.Page(start, stop-start, 6 if not is_executable() else 7, 0, '[stack]')
                stacks[thread.ptid] = page
                continue
            elif page.objfile is None:
                pid, tid, _ = thread.ptid
                if pid == tid:
                    page.objfile = '[stack]'
                else:
                    page.objfile = '[stack:%i]' % tid

            # If we *DO* already know about this thread, just
            # update the lower boundary if it got any lower.
            low = min(page.vaddr, sp_low)
            if low != page.vaddr:
                page.memsz  += (page.vaddr - low)
                page.vaddr   = low
    finally:
        if curr_thread:
            curr_thread.switch()
def update ( ) : curr_thread = gdb . selected_thread ( ) try : for thread in gdb . selected_inferior ( ) . threads ( ) : thread . switch ( ) sp = pwndbg . regs . sp # Skip if sp is None or 0 # (it might be 0 if we debug a qemu kernel) if not sp : continue sp_low = sp & ~ ( 0xfff ) sp_low -= 0x1000 # If we don't already know about this thread, create # a new Page mapping for it. page = stacks . get ( thread . ptid , None ) if page is None : start = sp_low stop = find_upper_stack_boundary ( sp ) page = pwndbg . memory . Page ( start , stop - start , 6 if not is_executable ( ) else 7 , 0 , '[stack]' ) stacks [ thread . ptid ] = page continue elif page . objfile is None : pid , tid , _ = thread . ptid if pid == tid : page . objfile = '[stack]' else : page . objfile = '[stack:%i]' % tid # If we *DO* already know about this thread, just # update the lower boundary if it got any lower. low = min ( page . vaddr , sp_low ) if low != page . vaddr : page . memsz += ( page . vaddr - low ) page . vaddr = low finally : if curr_thread : curr_thread . switch ( )