Add limit flag for heap commands which overrides heap-dereference-limit
Useful especially when one wants to see more (or less) chunks printed for one run of the command.
As mentioned here: https://github.com/pwndbg/pwndbg/issues/2376#issuecomment-2296825757
EDIT: Eh, obviously "limit flags" are not there, but some limits are passed via heap-dereference-limit. Sorry for my confusion below.
I believe such limit flags are already there:
dc@dc:~/pwndbg$ rg heap_chain_limit
pwndbg/gdblib/heap/__init__.py
51:heap_chain_limit = add_heap_param(
pwndbg/gdblib/heap/ptmalloc.py
776: limit=pwndbg.gdblib.heap.heap_chain_limit,
1260: limit=pwndbg.gdblib.heap.heap_chain_limit,
1367: chain_size = int(pwndbg.gdblib.heap.heap_chain_limit)
pwndbg/commands/heap.py
30:from pwndbg.gdblib.heap import heap_chain_limit
105: chain_fd[0], limit=heap_chain_limit, offset=offset, safe_linking=safe_lnk
Hmm, the format_bin function does pwndbg.chain.format(..., limit=heap_chain_limit, ...) -- does heap_chain_limit refer to a parameter here, or its copy? I wonder if one does set heap-dereference-limit 100 will this value be properly resolved here?
Update: Yes. I confirmed that this value is resolved properly and an updated value is used.
So the limitation of dereferencing is used properly when displaying various bins and linked lists.
Now, yeah, the bins (and maybe some other?) command does not have a --limit flag.
Alternatively to adding such flag, we could extend the help string to inform about heap-dereference-limit parameter.
@k4lizen is this still valid and needed? maybe we implemented it somehow? shall we close it?
Hm, where did the original issue go? It had some relevant info :(
It is valid and unimplemented though probably not too important a feature