memtab.categorizer module

Category assignment module for memtab.

This module provides functionality to assign categories to symbols from various sources (nm, readelf, objdump, map files) in a consistent manner.

memtab.categorizer.assign_addr_to_region(addr, memory_regions)

Assign a memory region to an address based on its range.

Return type:

Optional[Region]

Args:

addr: The address to assign a region to. memory_regions: List of memory regions to check against.

Returns:

The matching memory region if found, otherwise None.

memtab.categorizer.assign_symbol_to_region(symbol, memory_regions)

Assign a memory region to a symbol based on its address.

Return type:

Optional[Region]

memtab.categorizer.assign_symbols_to_regions(symbols, regions)

Assign symbols to memory regions based on address ranges.

Return type:

None

Args:

symbols: List of symbols to assign regions to. regions: List of memory regions to match against.

memtab.categorizer.assign_symbols_to_sections(symbols, sections)

Assign symbols to sections based on address ranges.

Return type:

None

Args:

symbols: List of symbols to assign sections to. sections: List of sections to match against.

memtab.categorizer.categorize_symbol(symbol, categories, comp_dir=None)

Categorize a symbol based on its name and file path.

This function takes a symbol and attempts to categorize it based on the provided categories configuration.

Return type:

List[str]

Args:

symbol: The symbol to categorize. categories: A list of category dictionaries with names and patterns. comp_dir: The compilation directory, to help normalize paths.

Returns:

A list of category names that the symbol belongs to.

memtab.categorizer.normalize_symbol_file_path(file_path, comp_dir=None)

Normalize a symbol file path.

This function normalizes file paths from different sources to ensure consistent category assignment.

Return type:

str

Args:

file_path: The file path to normalize. comp_dir: The compilation directory to use as a reference.

Returns:

A normalized file path.