41
41
# pandas
42
42
# plotly
43
43
44
+ import fnmatch
44
45
import logging
45
46
import re
46
47
import subprocess
@@ -718,14 +719,18 @@ def symbols_from_nm(elf_file: str) -> list[Symbol]:
718
719
return symbols
719
720
720
721
721
- def fetch_symbols (elf_file : str , fetch : FetchStyle ) -> Tuple [list [Symbol ], str ]:
722
+ def fetch_symbols (elf_file : str , fetch : FetchStyle , glob_filter : Optional [ str ] ) -> Tuple [list [Symbol ], str ]:
722
723
"""Returns the sumbol list and the separator used to split symbols
723
724
"""
724
725
match fetch :
725
726
case FetchStyle .NM :
726
- return symbols_from_nm (elf_file ), "::"
727
+ symbols , separator = symbols_from_nm (elf_file ), "::"
727
728
case FetchStyle .OBJDUMP :
728
- return symbols_from_objdump (elf_file ), '/'
729
+ symbols , separator = symbols_from_objdump (elf_file ), '/'
730
+ if glob_filter is not None :
731
+ symbols = [s for s in symbols if fnmatch .fnmatch (s .name , glob_filter )]
732
+
733
+ return symbols , separator
729
734
730
735
731
736
def list_id (tree_path : list [str ]) -> str :
@@ -833,6 +838,11 @@ def compute_symbol_diff(orig: list[Symbol], base: list[Symbol]) -> list[Symbol]:
833
838
default = None ,
834
839
help = "Zoom in the graph to ONLY the specified path as root (e.g. ::chip::app)" ,
835
840
)
841
+ @click .option (
842
+ "--glob-filter" ,
843
+ default = None ,
844
+ help = "Glob filter by name" ,
845
+ )
836
846
@click .option (
837
847
"--strip" ,
838
848
default = None ,
@@ -855,15 +865,16 @@ def main(
855
865
zoom : Optional [str ],
856
866
strip : Optional [str ],
857
867
diff : Optional [str ],
868
+ glob_filter : Optional [str ],
858
869
):
859
870
log_fmt = "%(asctime)s %(levelname)-7s %(message)s"
860
871
coloredlogs .install (level = __LOG_LEVELS__ [log_level ], fmt = log_fmt )
861
872
862
- symbols , separator = fetch_symbols (elf_file , __FETCH_STYLES__ [fetch_via ])
873
+ symbols , separator = fetch_symbols (elf_file , __FETCH_STYLES__ [fetch_via ], glob_filter )
863
874
title = elf_file
864
875
865
876
if diff :
866
- diff_symbols , _ = fetch_symbols (diff , __FETCH_STYLES__ [fetch_via ])
877
+ diff_symbols , _ = fetch_symbols (diff , __FETCH_STYLES__ [fetch_via ], glob_filter )
867
878
symbols = compute_symbol_diff (symbols , diff_symbols )
868
879
title = f"{ elf_file } COMPARED TO { diff } "
869
880
0 commit comments