Skip to content

mallocng ¤

Commands that help with debugging musl's allocator, mallocng.

Functions:

Attributes:

search_on_fail module-attribute ¤

search_on_fail = add_param(
    "ng-search-on-fail",
    True,
    "let the ng-slot* commands search the heap if necessary",
    help_docstring="\nFor freed, avail(able) and corrupted slots, it may be\nimpossible to recover the start of the group and meta.\n\nWhen this option is set to True, the ng-slotu and ng-slots\ncommands will search the heap to try to find the correct meta/group.\n    ",
    param_class=PARAM_BOOLEAN,
    scope=heap,
)

state_alloc_color module-attribute ¤

state_alloc_color = BLUE

state_alloc_color_alt module-attribute ¤

state_alloc_color_alt = CYAN

state_freed_color module-attribute ¤

state_freed_color = RED

state_freed_color_alt module-attribute ¤

state_freed_color_alt = LIGHT_RED

state_avail_color module-attribute ¤

state_avail_color = GRAY

state_avail_color_alt module-attribute ¤

state_avail_color_alt = LIGHT_GRAY

VALID_CHARS module-attribute ¤

VALID_CHARS = list(map(ord, set(printable) - set('\t\r\n\x0c\x0b')))

vis_cyclic_offset_color module-attribute ¤

vis_cyclic_offset_color = YELLOW

vis_offset_color module-attribute ¤

vis_offset_color = LIGHT_YELLOW

vis_cycled_mark_color module-attribute ¤

vis_cycled_mark_color = PURPLE

vis_pn3_reserved_color module-attribute ¤

vis_pn3_reserved_color = LIGHT_CYAN

vis_big_offset_check_color module-attribute ¤

vis_big_offset_check_color = BLACK

vis_ftr_reserved_color module-attribute ¤

vis_ftr_reserved_color = GREEN

default_vis_count module-attribute ¤

default_vis_count = add_param(
    "ng-vis-count",
    10,
    "default count for ng-vis",
    param_class=PARAM_UINTEGER,
    scope=heap,
)

parser module-attribute ¤

parser = ArgumentParser(
    description="\nDump the mallocng heap.\n\nMay produce lots of output.\n    "
)

get_slot_color ¤

get_slot_color(state: SlotState, last_color: str = '') -> str

get_colored_slot_state ¤

get_colored_slot_state(ss: SlotState) -> str

get_colored_slot_state_short ¤

get_colored_slot_state_short(ss: SlotState) -> str

dump_group ¤

dump_group(group: Group) -> str

dump_meta ¤

dump_meta(meta: Meta, focus_slot: int | None = None) -> str

Parameters:

  • meta (Meta) –

    the meta to dump

  • focus_slot (int | None, default: None ) –

    the index of the slot to highlight in the slot statuses list

dump_grouped_slot ¤

dump_grouped_slot(gslot: GroupedSlot, all: bool) -> str

dump_slot ¤

dump_slot(
    slot: Slot, all: bool, successful_preload: bool, will_dump_gslot: bool
) -> str

smart_dump_slot ¤

smart_dump_slot(slot: Slot, all: bool, gslot: GroupedSlot | None = None) -> str

dump_meta_area ¤

dump_meta_area(meta_area: MetaArea, coming_from_dump: bool = False) -> str

dump_malloc_context ¤

dump_malloc_context(ctx: MallocContext) -> str

mallocng_slot_user ¤

mallocng_slot_user(address: int, all: bool) -> None

mallocng_slot_start ¤

mallocng_slot_start(address: int, all: bool) -> None

mallocng_meta ¤

mallocng_meta(address: int) -> None

mallocng_group ¤

mallocng_group(address: int, index: int | None = None) -> None

mallocng_meta_area ¤

mallocng_meta_area(address: int, index: int | None = None) -> None

mallocng_malloc_context ¤

mallocng_malloc_context(address: int | None = None) -> None

mallocng_find ¤

mallocng_find(
    address: int,
    all: bool = False,
    metadata: bool = False,
    shallow: bool = False,
) -> None

bin_ascii ¤

bin_ascii(bs: bytearray)

colorize_pointer ¤

colorize_pointer(
    address: int, ptrvalue: int, state: SlotState, slot: Slot
) -> str

colorize_start_header_line ¤

colorize_start_header_line(shline: str, state: SlotState, slot: Slot) -> str

line_decoration ¤

line_decoration(addr: int, slot_state: SlotState, slot: Slot) -> str

Maybe append extra clarification to a line.

Currently only appends to p headers.

mallocng_visualize_slots ¤

mallocng_visualize_slots(address: int, count: int = default_vis_count)

mallocng_dump ¤

mallocng_dump(meta_area: int | None = None) -> None

mallocng_explain ¤

mallocng_explain() -> None