Jianliang Shen | abf0041 | 2021-11-12 10:58:52 +0800 | [diff] [blame^] | 1 | ###################### |
| 2 | Code size analyze tool |
| 3 | ###################### |
| 4 | |
| 5 | .. contents:: Table of Contents |
| 6 | |
| 7 | These are scripts to dump ARMCLANG complie map file detail information and get |
| 8 | the 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 | *************** |
| 18 | Install sqlite3 |
| 19 | *************** |
| 20 | |
| 21 | Linux |
| 22 | ===== |
| 23 | Install 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 | ***** |
| 32 | Usage |
| 33 | ***** |
| 34 | |
| 35 | The 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 | |
| 43 | It is required to input map file path for the script before show the UI. While |
| 44 | input the map file, compiler information such as ``--gnuarm`` or ``--armcc`` |
| 45 | is required. |
| 46 | |
| 47 | keys |
| 48 | ==== |
| 49 | |
| 50 | The script ui.py supplies a menu to choose what developers may be interested. |
| 51 | There 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 | |
| 60 | Search |
| 61 | ====== |
| 62 | |
| 63 | In ``Function detail`` and ``library detail`` pages, developers can search for |
| 64 | specific target with key word of target name. Press ``:`` to start search and |
| 65 | enter the name in the last line of window. All the targets with key word will |
| 66 | be given. |
| 67 | |
| 68 | You 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 | |
| 73 | All the features provided by UI can be used in command line too. Enter ``-h`` to |
| 74 | get the help information and choose the option to use. |
| 75 | |
| 76 | Save |
| 77 | ==== |
| 78 | |
| 79 | In any page, press ``s`` or ``S`` to start enter output file name to save the |
| 80 | content of this page. |
| 81 | |
| 82 | Diff |
| 83 | ==== |
| 84 | |
| 85 | Use ``code_size_diff.py`` to diff two diffrent build results with same compiler. |
| 86 | Firstly, use ``code_size_analyze.py`` to prepare two different databases. For |
| 87 | example: |
| 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 | |
| 99 | Then 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 | |
| 111 | The summary information change will be printed. Enter ``-h`` to get more usages |
| 112 | of diff tool. |
| 113 | |
| 114 | -------------- |
| 115 | |
| 116 | *Copyright (c) 2021, Arm Limited. All rights reserved.* |