Marco Mayer / Mbed OS Queue
Embed: (wiki syntax)

« Back to documentation index

MemapParser Class Reference

MemapParser Class Reference

Public Member Functions

def __init__
def module_add
def module_replace
def check_new_section_gcc
def parse_object_name_gcc
def parse_section_gcc
def parse_map_file_gcc
def parse_object_name_armcc
def parse_section_armcc
def parse_object_name_iar
def parse_section_iar
def parse_map_file_armcc
def check_new_library_iar
def check_new_object_lib_iar
def parse_iar_command_line
def parse_map_file_iar
def reduce_depth
def generate_output
def generate_json
def generate_csv
def generate_table
def compute_report
def parse

Detailed Description

An object that represents parsed results, parses the memory map files,
and writes out different file types of memory results

Definition at line 35 of file memap.py.


Constructor & Destructor Documentation

def __init__ (   self )
General initialization

Definition at line 52 of file memap.py.


Member Function Documentation

def check_new_library_iar (   self,
  line 
)
Searches for libraries and returns name. Example:
m7M_tls.a: [43]

Definition at line 388 of file memap.py.

def check_new_object_lib_iar (   self,
  line 
)
Searches for objects within a library section and returns name. Example:
rt7M_tl.a: [44]
    ABImemclr4.o                 6
    ABImemcpy_unaligned.o      118
    ABImemset48.o               50
    I64DivMod.o                238
    I64DivZer.o                  2

Definition at line 403 of file memap.py.

def check_new_section_gcc (   self,
  line 
)
Check whether a new section in a map file has been detected (only
applies to gcc)

Positional arguments:
line - the line to check for a new section

Definition at line 113 of file memap.py.

def compute_report (   self )
Generates summary of memory usage for main areas

Definition at line 623 of file memap.py.

def generate_csv (   self,
  file_desc 
)
Generate a CSV file from a memoy map

Positional arguments:
file_desc - the file to write out the final report to

Definition at line 553 of file memap.py.

def generate_json (   self,
  file_desc 
)
Generate a json file from a memory map

Positional arguments:
file_desc - the file to write out the final report to

Definition at line 542 of file memap.py.

def generate_output (   self,
  export_format,
  depth,
  file_output = None 
)
Generates summary of memory map data

Positional arguments:
export_format - the format to dump

Keyword arguments:
file_desc - descriptor (either stdout or file)
depth - directory depth on report

Returns: generated string for the 'table' format, otherwise None

Definition at line 507 of file memap.py.

def generate_table (   self,
  file_desc 
)
Generate a table from a memoy map

Returns: string of the generated table

Definition at line 580 of file memap.py.

def module_add (   self,
  object_name,
  size,
  section 
)
Adds a module / section to the list

Positional arguments:
object_name - name of the entry to add
size - the size of the module being added
section - the section the module contributes to

Definition at line 79 of file memap.py.

def module_replace (   self,
  old_object,
  new_object 
)
Replaces an object name with a new one

Definition at line 106 of file memap.py.

def parse (   self,
  mapfile,
  toolchain 
)
Parse and decode map file depending on the toolchain

Positional arguments:
mapfile - the file name of the memory map file
toolchain - the toolchain used to create the file

Definition at line 652 of file memap.py.

def parse_iar_command_line (   self,
  lines 
)
Parse the files passed on the command line to the iar linker

Positional arguments:
lines -- an iterator over the lines within a file

Definition at line 422 of file memap.py.

def parse_map_file_armcc (   self,
  file_desc 
)
Main logic to decode armc5 map files

Positional arguments:
file_desc - a file like object to parse as an armc5 map file

Definition at line 356 of file memap.py.

def parse_map_file_gcc (   self,
  file_desc 
)
Main logic to decode gcc map files

Positional arguments:
file_desc - a stream object to parse as a gcc map file

Definition at line 191 of file memap.py.

def parse_map_file_iar (   self,
  file_desc 
)
Main logic to decode IAR map files

Positional arguments:
file_desc - a file like object to parse as an IAR map file

Definition at line 441 of file memap.py.

def parse_object_name_armcc (   self,
  line 
)
Parse object file

Positional arguments:
line - the line containing the object or library

Definition at line 230 of file memap.py.

def parse_object_name_gcc (   self,
  line 
)
Parse a path to object file

Positional arguments:
txt - the path to parse the object and module name from

Definition at line 132 of file memap.py.

def parse_object_name_iar (   self,
  object_name 
)
Parse object file

Positional arguments:
line - the line containing the object or library

Definition at line 290 of file memap.py.

def parse_section_armcc (   self,
  line 
)
Parse data from an armcc map file

Examples of armcc map file:
    Base_Addr    Size         Type   Attr      Idx    E Section Name        Object
    0x00000000   0x00000400   Data   RO        11222    RESET               startup_MK64F12.o
    0x00000410   0x00000008   Code   RO        49364  * !!!main             c_w.l(__main.o)

Positional arguments:
line - the line to parse the section data from

Definition at line 252 of file memap.py.

def parse_section_gcc (   self,
  line 
)
Parse data from a section of gcc map file

examples:
        0x00004308       0x7c ./BUILD/K64F/GCC_ARM/mbed-os/hal/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/spi_api.o
 .text          0x00000608      0x198 ./BUILD/K64F/GCC_ARM/mbed-os/core/mbed-rtos/rtx/TARGET_CORTEX_M/TARGET_RTOS_M4_M7/TOOLCHAIN_GCC/HAL_CM4.o

Positional arguments:
line - the line to parse a section from

Definition at line 165 of file memap.py.

def parse_section_iar (   self,
  line 
)
Parse data from an IAR map file

Examples of IAR map file:
 Section             Kind        Address     Size  Object
 .intvec             ro code  0x00000000    0x198  startup_MK64F12.o [15]
 .rodata             const    0x00000198      0x0  zero_init3.o [133]
 .iar.init_table     const    0x00008384     0x2c  - Linker created -
 Initializer bytes   const    0x00000198     0xb2  <for P3 s0>
 .data               inited   0x20000000     0xd4  driverAtmelRFInterface.o [70]
 .bss                zero     0x20000598    0x318  RTX_Conf_CM.o [4]
 .iar.dynexit        uninit   0x20001448    0x204  <Block tail>
   HEAP              uninit   0x20001650  0x10000  <Block tail>

Positional_arguments:
line - the line to parse section data from

Definition at line 307 of file memap.py.

def reduce_depth (   self,
  depth 
)
populates the short_modules attribute with a truncated module list

(1) depth = 1:
main.o
mbed-os

(2) depth = 2:
main.o
mbed-os/test.o
mbed-os/drivers

Definition at line 476 of file memap.py.