10
10
import re
11
11
import csv
12
12
import json
13
- import math
14
13
from argparse import ArgumentParser
15
14
from copy import deepcopy
16
15
from prettytable import PrettyTable
17
- from tools .arm_pack_manager import Cache
18
16
19
17
from .utils import (argparse_filestring_type , argparse_lowercase_hyphen_type ,
20
18
argparse_uppercase_type )
@@ -509,7 +507,7 @@ def reduce_depth(self, depth):
509
507
510
508
export_formats = ["json" , "csv-ci" , "table" ]
511
509
512
- def generate_output (self , export_format , depth , file_output = None , * args ):
510
+ def generate_output (self , export_format , depth , file_output = None ):
513
511
""" Generates summary of memory map data
514
512
515
513
Positional arguments:
@@ -534,9 +532,8 @@ def generate_output(self, export_format, depth, file_output=None, *args):
534
532
535
533
to_call = {'json' : self .generate_json ,
536
534
'csv-ci' : self .generate_csv ,
537
- 'table' : self .generate_table ,
538
- 'bars' : self .generate_bars }[export_format ]
539
- output = to_call (file_desc , * args )
535
+ 'table' : self .generate_table }[export_format ]
536
+ output = to_call (file_desc )
540
537
541
538
if file_desc is not stdout :
542
539
file_desc .close ()
@@ -620,71 +617,6 @@ def generate_table(self, file_desc):
620
617
621
618
return output
622
619
623
- def generate_bars (self , file_desc , device_name = None ):
624
- """ Generates nice looking bars that represent the memory consumption
625
-
626
- Returns: string containing nice looking bars
627
- """
628
-
629
- # TODO add tty detection, and width detection probably
630
- WIDTH = 72
631
- try :
632
- # NOTE this only works on linux
633
- import sys , fcntl , termios , struct
634
- height , width , _ , _ = struct .unpack ('HHHH' ,
635
- fcntl .ioctl (sys .stdout .fileno (), termios .TIOCGWINSZ ,
636
- struct .pack ('HHHH' , 0 , 0 , 0 , 0 )))
637
- WIDTH = min (width , WIDTH )
638
- except Exception :
639
- pass
640
-
641
- text = self .subtotal ['.text' ]
642
- data = self .subtotal ['.data' ]
643
- bss = self .subtotal ['.bss' ]
644
- rom_used = self .mem_summary ['total_flash' ]
645
- ram_used = self .mem_summary ['static_ram' ]
646
-
647
- # No device_name = no cmsis-pack = we don't know the memory layout
648
- if device_name is not None :
649
- try :
650
- cache = Cache (False , False )
651
- cmsis_part = cache .index [device_name ]
652
- rom_avail = int (cmsis_part ['memory' ]['IROM1' ]['size' ], 0 )
653
- ram_avail = int (cmsis_part ['memory' ]['IRAM1' ]['size' ], 0 )
654
- except KeyError :
655
- # If we don't have the expected regions, fall back to no device_name
656
- device_name = None
657
-
658
- PREFIXES = ['' , 'K' , 'M' , 'G' , 'T' , 'P' , 'E' ]
659
- def unit (n , u = 'B' , p = 3 ):
660
- if n == 0 :
661
- return '0' + u
662
-
663
- scale = math .floor (math .log (n , 1024 ))
664
- return '{1:.{0}g}{2}{3}' .format (p , n / (1024 ** scale ), PREFIXES [int (scale )], u )
665
-
666
- usage = "Text {} Data {} BSS {}" .format (unit (text ), unit (data ), unit (bss ))
667
- avail = "ROM {} RAM {}" .format (unit (rom_used ), unit (ram_used ))
668
- output = ["{0} {1:>{2}}" .format (usage , avail ,
669
- abs (WIDTH - len (usage )- 1 ) if device_name is not None else 0 )]
670
-
671
- if device_name is not None :
672
- for region , avail , uses in [
673
- ('ROM' , rom_avail , [('|' , text ), ('|' , data )]),
674
- ('RAM' , ram_avail , [('|' , bss ), ('|' , data )])]:
675
- barwidth = WIDTH - 17 - len (region )
676
-
677
- used = sum (use for c , use in uses )
678
- bars = [(c , (barwidth * use ) // avail ) for c , use in uses ]
679
- bars .append ((' ' , barwidth - sum (width for c , width in bars )))
680
- bars = '' .join (c * width for c , width in bars )
681
-
682
- output .append ("{0} [{2:<{1}}] {3:>13}" .format (
683
- region , barwidth , bars ,
684
- "{}/{}" .format (unit (used ), unit (avail ))))
685
-
686
- return '\n ' .join (output )
687
-
688
620
toolchains = ["ARM" , "ARM_STD" , "ARM_MICRO" , "GCC_ARM" , "GCC_CR" , "IAR" ]
689
621
690
622
def compute_report (self ):
0 commit comments