Fix heap_config

This commit is contained in:
Gulshan Singh 2022-10-19 14:54:37 -07:00
parent 78065e8ba9
commit 4be16dcd5d
2 changed files with 5 additions and 22 deletions

View File

@ -12,9 +12,7 @@ import pwndbg.glibc
import pwndbg.lib.heap.helpers
from pwndbg.color import generateColorFunction
from pwndbg.color import message
from pwndbg.commands.config import extend_value_with_default
from pwndbg.commands.config import get_config_parameters
from pwndbg.commands.config import print_row
from pwndbg.commands.config import display_config
from pwndbg.heap.ptmalloc import Chunk
@ -1250,26 +1248,8 @@ parser.add_argument(
@pwndbg.commands.ArgparsedCommand(parser)
def heap_config(filter_pattern):
values = get_config_parameters("heap", filter_pattern)
display_config(filter_pattern, "heap")
if not values:
print(message.hint('No config parameter found with filter "{}"'.format(filter_pattern)))
return
longest_optname = max(map(len, [v.optname for v in values]))
longest_value = max(
map(len, [extend_value_with_default(repr(v.value), repr(v.default)) for v in values])
)
header = print_row("Name", "Value", "Def", "Documentation", longest_optname, longest_value)
print("-" * (len(header)))
for v in sorted(values):
print_row(
v.optname, repr(v.value), repr(v.default), v.docstring, longest_optname, longest_value
)
print(message.hint("You can set config variable with `set <config-var> <value>`"))
print(
message.hint(
"Some config(e.g. main_arena) will only working when resolve-heap-via-heuristic is `True`"

View File

@ -8,3 +8,6 @@ def test_config():
gdb.execute("set banner-separator #")
# \u2500 is ─
assert "'#' ('\u2500')" in gdb.execute("theme", to_string=True)
gdb.execute("set global-max-fast 0x80")
assert "'0x80' ('0')" in gdb.execute("heap_config", to_string=True)