HBehrens / puncover

Analyses C/C++ build output for code size, static variables, and stack usage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stack usage not displayed correctly due to basefile not being parsed in files with extension .su

vChavezB opened this issue · comments

I was testing the stack usage feature of puncover but found out there is a bug in the code.

I enabled stack usage in the GCC compiler (-fstack-usage) but I was not getting any info on the puncover website. After debugging I noticed that the function parse_stack_usage_line does not parse correctly the so-called base_file_name

This is important because when you are adding the stack usage it compares the base_file_name that was added previously when looking for symbols... i.e., with arm-none-eabi-nm -Sl YOUR_ELF_FILE.elf. Specifically here

sym[BASE_FILE] = os.path.basename(file)

Therefore parse_stack_usage_line should also extract the base file name.

My suggestion:

  def parse_stack_usage_line(self, line):
       match = self.parse_stack_usage_line_pattern.match(line)
       if not match:
           return False

       file_name = match.group(1)
       base_file_name = os.path.basename(file_name)
       line = int(match.group(3))
       symbol_name = match.group(5)
       stack_size = int(match.group(6))
       stack_qualifier = match.group(7)

       return self.add_stack_usage(base_file_name, line, symbol_name, stack_size, stack_qualifier)