blob: 31957bb021b650250a49cc0f178515b83ba09c60 [file] [log] [blame]
Jianliang Shenabf00412021-11-12 10:58:52 +08001######################
2Code size analyze tool
3######################
4
5.. contents:: Table of Contents
6
7These are scripts to dump ARMCLANG complie map file detail information and get
8the change between two different build results. The features are:
9
10* Get a database to implement data tables from ARMCLANG or GNUARM map file.
11* Supply an UI for developers to scan sorted information of sections, libraries,
12 object files, functions and data. It can help analyze the biggest or smallest
13 targets in certain image. It can also help search functions or data to locate
14 their address and detail information.
15* Diff two databases to see the code size increasement or decreasement.
16
17***************
18Install sqlite3
19***************
20
21Linux
22=====
23Install sqlite3 for python.
24
25.. code-block:: bash
26
27 sudo apt-get install python3-dev libmysqlclient-dev
28 pip install mysqlclient
29
30
31*****
32Usage
33*****
34
35The command is:
36
37.. code-block:: bash
38
39 python3 code_size_analyze.py -i <map file path> --gnuarm
40 python3 code_size_analyze.py -i <map file path> --armcc
41 python3 code_size_analyze.py --ui
42
43It is required to input map file path for the script before show the UI. While
44input the map file, compiler information such as ``--gnuarm`` or ``--armcc``
45is required.
46
47keys
48====
49
50The script ui.py supplies a menu to choose what developers may be interested.
51There are several keys to move cursor.
52
53* UP: Move UP, mouse scrolling up is same.
54* DOWN: Move down, mouse scrolling down is same.
55* RIGHT: Move right.
56* LEFT: Move left.
57* Enter: Move to next page if it can be unfolded.
58* ``Q`` or ``q``: Escape to previous page or close script if it in top menu.
59
60Search
61======
62
63In ``Function detail`` and ``library detail`` pages, developers can search for
64specific target with key word of target name. Press ``:`` to start search and
65enter the name in the last line of window. All the targets with key word will
66be given.
67
68You can also search or dump the target in command line without Ui, for example:
69.. code-block:: bash
70
71 python3 code_size_analyze.py --search_func <func_name>
72
73All the features provided by UI can be used in command line too. Enter ``-h`` to
74get the help information and choose the option to use.
75
76Save
77====
78
79In any page, press ``s`` or ``S`` to start enter output file name to save the
80content of this page.
81
82Diff
83====
84
85Use ``code_size_diff.py`` to diff two diffrent build results with same compiler.
86Firstly, use ``code_size_analyze.py`` to prepare two different databases. For
87example:
88
89.. code-block:: bash
90
91 cd <TF-M workspace>
92 git checkout branch1
93 # Build with ARMCLANG
94 python3 code_size_analyze.py -i <map file 1> --armcc
95 mv data.db output/branch1.db
96
97 # Do the same steps to create branch2.db
98
99Then compare two database with the diff tool, the branch1 is base.
100
101.. code-block:: bash
102
103 python3 code_size_diff.py -i output/branch1.db output/branch2.db -a
104 Code size: +++ 48928 B 47.78 KB
105 RO data: +++ 29440 B 28.75 KB
106 RW data: --- 64 B 0.06 KB
107 ZI data: --- 500 B 0.49 KB
108 Flash size: +++ 78304 B 76.47 KB
109 RAM size: --- 564 B 0.55 KB
110
111The summary information change will be printed. Enter ``-h`` to get more usages
112of diff tool.
113
114--------------
115
116*Copyright (c) 2021, Arm Limited. All rights reserved.*