CN117008948A - Resource distribution statistical method in embedded development process - Google Patents

Resource distribution statistical method in embedded development process Download PDF

Info

Publication number
CN117008948A
CN117008948A CN202310919594.5A CN202310919594A CN117008948A CN 117008948 A CN117008948 A CN 117008948A CN 202310919594 A CN202310919594 A CN 202310919594A CN 117008948 A CN117008948 A CN 117008948A
Authority
CN
China
Prior art keywords
memory
file
map
content
map file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310919594.5A
Other languages
Chinese (zh)
Inventor
金思宇
薛青云
张卜
刘子郡
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Maxieye Automobile Technology Co ltd
Original Assignee
Shanghai Maxieye Automobile Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Maxieye Automobile Technology Co ltd filed Critical Shanghai Maxieye Automobile Technology Co ltd
Priority to CN202310919594.5A priority Critical patent/CN117008948A/en
Publication of CN117008948A publication Critical patent/CN117008948A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a resource distribution statistical method in an embedded development process, which comprises the following steps: the steps are as follows: after a user imports a map file of a corresponding platform, map analysis tool software calls a corresponding analysis function, analyzes the map file of a corresponding format through a re module of Python, and extracts required content; after the software tool extracts the content, the parsed content is displayed on the graphical interface through GUI programming of Qt. When the method is used, a user can automatically analyze the content of the map file by only importing the map file corresponding to the embedded development platform, can sort the memory occupation conditions of the files, the variables and the constants in different program segments in a descending order, and displays the sorted memory occupation conditions in an interface table, so that a developer can conveniently and quickly know the current program memory resource allocation condition.

Description

Resource distribution statistical method in embedded development process
Technical Field
The invention relates to the field of embedded development, in particular to a resource distribution statistical method in an embedded development process.
Background
In embedded programming, a map file is a file that describes the layout of program source code, data, functions, etc., in memory in text form. The map file is a file generated after a Linker (Linker) generates an executable file from a target file, and can be used for execution of an analysis program and generation of an optimized executable file. Map files typically contain the following important content:
1. memory layout including each file: the Map file will show the address range of each source file in the program and the location of each section in the file in memory.
2. Display function, variable, and macro defined location: map files can help us find which functions are placed in which locations in memory in the program, as well as global variables and macro-defined memory addresses.
3. And displaying the use condition of the memory: the map file can display the use conditions of different memory sections such as a data section, a stack section, a heap section and the like in the program, so that people can know the use conditions of the memory in the program and optimize the memory. By analyzing Map files, the memory use condition and execution condition of the program can be better known, the program is pertinently optimized, and the performance and stability of the program are improved.
However, the map file generated by the linker has extremely large content and is tens of thousands of lines in length, so that the map file is inconvenient to read, and a developer needs to take a long search time if the current program memory allocation needs to be adjusted.
This is a problem often encountered in the embedded development process, and therefore, it is necessary to provide a tool and a method for resolving map memory resource mapping files, aiming at the above-mentioned defects in the prior art.
Disclosure of Invention
The invention aims to provide a resource distribution statistical method in an embedded development process so as to solve the problems in the background technology.
In order to achieve the above purpose, the present invention provides the following technical solutions: a resource distribution statistical method in an embedded development process comprises the following steps:
s1: after a user imports a map file of a corresponding platform, map analysis tool software calls a corresponding analysis function, analyzes the map file of a corresponding format through a re module of Python, and extracts required content;
s2: after the software tool extracts the content, the parsed content is displayed on the graphical interface through GUI programming of Qt.
Preferably, the extracting content in S1 includes:
program segments such as text (machine instruction after program source code compilation), data segments, i.e., memory sizes of explicitly initialized non-0 global variables, bss zero initialization segments, etc.;
o/. Obj can relocate the memory size, the starting address, the ending address of the binary file and sort in descending order of the memory size in each program segment;
each o/. Obj can relocate the memory size, start address, end address of the memory cells within the binary file and be sorted in descending memory size order within each o/. Obj file.
Preferably, the map parsing tool software comprises a UI interface module and a parsing function module, wherein the UI interface module comprises a plurality of selection units, namely a map file platform unit, a unit memory ordering unit and an interface display unit, wherein the map file platform unit is selected to be associated with the parsing function module unit, a inflorescence task compiler, a rap cs+ compiler and an enzhps Code Warrior compiler are stored in the parsing function module, the map file platform unit is selected to be used for selecting the compiler, and the memory unit names and memory occupation are extracted based on the compiler, and the memory ordering unit is used for ordering.
Compared with the prior art, the invention has the beneficial effects that:
1. the invention provides a tool and a method for analyzing map memory resource mapping files, wherein a user can automatically analyze the content of the map memory resource mapping files by only importing the map files corresponding to an embedded development platform, and can sort the memory occupation conditions of files, variables and constants in different program segments in a descending order and display the memory occupation conditions in an interface table, so that a developer can conveniently and quickly know the current program memory resource allocation conditions.
2. According to the map memory resource mapping file of the specific platform imported by the user, the map text technology is adopted by the invention, so that the use condition of the memory resource can be resolved, the application platform is wide, the user operation is simple and convenient, and the display interface structure is clear. On the other hand, as the map file structure generated by the linker of each embedded platform is fixed, the three platforms supported at present can be permanently reused for the invention, and the corresponding analysis scheme can be permanently reused for the new platform after being determined.
Drawings
FIG. 1 is a diagram of a tool architecture of the present invention;
FIG. 2 is a diagram of an overview of content resolution in an embodiment of the invention;
FIG. 3 is a schematic diagram of a memory condition and a start and end address of a target file displayed after a certain program segment is expanded in an embodiment of the present invention;
FIG. 4 is a schematic diagram of a map file platform selection in an embodiment of the present invention;
FIG. 5 is a diagram illustrating the memory size of a program segment that is displayed after a file is imported according to an embodiment of the present invention;
FIG. 6 is a map file generated by an embedded program via an Infrax flight compiling platform according to an embodiment of the invention;
FIG. 7 is a diagram of reorganizing structured data after reading map files of a Ying Fei Ling compilation platform according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of an analytical function for reading a map file of a Ying Fei Ling compilation platform according to an embodiment of the present invention;
FIG. 9 shows the formatted data after the parsing is performed in the UI according to the embodiment of the present invention;
fig. 10 is a diagram of memory information displayed on a UI according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1-5, the present invention uses Python parsing map text technology, and parses map files generated by linker (inflorescence task compiler, risac+ compiler and enzhps Code Warrior compiler) of the above three platforms, wherein the specific implementation scheme is as follows:
s1: after a user imports a map file of a corresponding platform, the software calls a corresponding analysis function, analyzes the map file of a corresponding format through a re module of Python, and extracts required contents, wherein the contents comprise:
program segments, such as the memory size of text segments (machine instructions after program source code compilation), data segments (explicitly initializing global variables other than 0), bss zero initialization segments, etc.;
o/. Obj can relocate the memory size, the starting address, the ending address of the binary file and sort in descending order of the memory size in each program segment;
(3) Each o/. Obj can relocate the memory size, the starting address, the ending address of the memory unit in the binary file, and sort in descending order of memory size in each o/. Obj file;
s2: after the software tool extracts the content, the analysis content is displayed on a graphical interface through the GUI programming of the Qt.
The following describes in detail the process of reading map file, parsing data, and displaying data, taking the inflorescence platform as an example.
The first step: reading a file and analyzing data:
when the parsing function of a specific map file is written in the early stage, the composition mode of the content of the map file needs to be read. For the convenience of reader understanding, a map file generated by a simple-structure Infrax compiling platform is selected, and as shown in fig. 6, part of the content of the map file generated by an embedded program through the Infrax compiling platform is shown.
It can be observed that the first column is the o filename, the second column is the section block displayed in the structure of "block-filename-identifier", and the third column is the memory size occupied by this identifier. Since the map file of the platform has no start address and end address of the identifier, only the first three columns of content are used as required information, and then the file is read only in a text form, and the content is analyzed regularly. FIG. 7 is the parsed code of such map files under the InfraRed platform.
Firstly, a map file is opened in a text mode, and the map file generated by the Infrax platform is used for identifying a memory address map generated by a starting writing linker in a Link result mode, so that the needed content of the part is found in a regular matching mode.
In the second step, in this section, each line represents information of a memory unit (identifier) in the program, and the symbol dividing each line of the content in the text is "|and" - - - ", which is used as a flag to extract information line by line and store it in the array item.
And thirdly, the extracted line information is possibly divided into a plurality of lines according to the length of the characters, so that the line information is continuously extracted by line feed character segmentation. In the content divided by the line-feed character, the column information is further divided by the character "|", the column information is continuously extracted, the first three columns of each line are extracted, and the content with no meaning of the space segment is removed by the fakseSTR.
To this end, the useful block names, file names, identifier names and memory sizes are extracted row by row and column by column to continue the next step of assembling data.
And a second step of: the reorganized data is the desired formatted data:
in the first step, only the content expected in the map file is extracted, in order to facilitate the subsequent use on the interface, the data needs to be recombined into a form convenient for constructing the UI interface content, and in the code of fig. 8, the data extracted in the first step is recombined, so that the specific formatted data is finally obtained.
At the end of the first step, the obtained data_list is a ternary list composed of the first three columns in the Link results, and is unordered data directly extracted from the map file, so that the data_list needs to be reassembled into displayable formatted data according to a three-layer structure of a set program block-file-identifier.
First, the original data_list that was originally taken is traversed and classified by file name by constructing a dictionary with keys as file names whose values are the identifier name, memory size, and block type under this file name.
And secondly, the program blocks are required to be displayed on the UI interface as a first level, the data_list original data list is required to be traversed again, and a dictionary with a key as a program block name and a value as a dictionary with a file name as a key is established. When the dictionary is searched by the program block name, all dictionary information with the file name as a key under the program block can be extracted, and the dictionary with the file name as a key has the value of the binary list of the identifier name-memory size.
Thus, a tree-like storage structure is obtained, the data structure is "dictionary-list", the content is "program block name-file name- (identifier name-memory size)", and the memory size of each identifier at the bottom layer is known, so that the storage of the memory size of a certain file is omitted, and the file size is calculated while analyzing.
And a third step of: and displaying the memory resource conditions on the interface according to the memory size sequence:
the function shown in fig. 9 is to unpack the second portion of the reassembled data, sort the unpacked data in descending order of memory size, and display the parsed content on the table of the UI interface row by row.
The program starts to take the three-layer tree structure returned by the second part, the first layer is a 'program block name-dictionary with a file name as a key', the structure is traversed, each program block represents a deployable row of content in a UI interface, a QTreeWidgetItem object is built in the program, and proper font size, color and content (namely the program block name) are set and then inserted into the treeWidget.
And secondly, expanding a dictionary taking a file name as a key under the first-level program block, traversing the structure, obtaining binary list elements of a 'file name- (identifier name-memory size) list', wherein the file names need to be sorted in descending order according to the occupied memory sizes, traversing the identifiers under the file, calculating the total memory sizes occupied by all memory units, traversing item items of the treeWidget after obtaining the memory sizes of the file, obtaining correct index numbers according to the memory sizes of the file and the memory sizes of each item (namely the sizes of the inserted files), and then inserting the item items into the treWidget, so that a item column after descending order, namely a file column which is seen on a UI interface and is sorted in descending order of the memory sizes, is obtained.
Thirdly, the binary list of the identifier name-memory size is not developed in the last step, and the index is calculated after the binary list is developed by the same method, so that a item column which is ordered in a descending order, namely the identifier column which is ordered in the descending order of the memory size and is seen on the UI interface, can be obtained.
Fig. 10 finally shows the structure on the UI interface, and expands the memory occupation situation of all the memory units under the met_canlf.o file under the bss block. The final displayed results have the following characteristics:
1. first-level module, the expanded program block names are not ordered according to the memory size
The bss block occupies 38.781kb, the data block occupies 15.987kb, and the text block occupies 60.712kb.
2. Second-level module for sorting file names in descending order of memory size
Met_Canif.o occupies 28.524kb, met_Candriver.o occupies 4.07kb, met_Com_PhyStruct.o occupies 2.266kb, and the minimum Met_LDW.o occupies 0.051kb.
3. Three-level module, the identifier columns being ordered in descending memory size order
The maximum g_st_caniftxBuff under the Met_Canif.o file occupies 9.68kb, and the minimum can_Txmsimask occupies 0.094kb.
4. The map file generated under the InfraRed platform does not contain the start address and end address of the identifier and is therefore not shown here. Some platforms such as the map under the rasagile platform contain the start address, end address of the identifier,
taking the example of g_st_caniftxbuff under met_canlf.o file under the bss block, UI shows that it occupies 9.68kb, backtracking to g_st_caniftxbuff in the map file belongs to met_canlf.o file, belongs to the bss block, and the Size (memory Size) of g_st_caniftxbuff is 0x26b8, 9912/1024=9.68 kb.
Although embodiments of the present invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made therein without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.

Claims (3)

1. The resource distribution statistical method in the embedded development process is characterized by comprising the following steps:
s1: after a user imports a map file of a corresponding platform, map analysis tool software calls a corresponding analysis function, analyzes the map file of a corresponding format through a re module of Python, and extracts required content;
s2: after the software tool extracts the content, the parsed content is displayed on the graphical interface through GUI programming of Qt.
2. The method for counting resource distribution in an embedded development process according to claim 1, wherein: the extracting content in S1 includes:
program segments such as text (machine instruction after program source code compilation), data segments, i.e., memory sizes of explicitly initialized non-0 global variables, bss zero initialization segments, etc.;
o/. Obj can relocate the memory size, the starting address, the ending address of the binary file and sort in descending order of the memory size in each program segment;
each o/. Obj can relocate the memory size, start address, end address of the memory cells within the binary file and be sorted in descending memory size order within each o/. Obj file.
3. The method for counting resource distribution in an embedded development process according to claim 1, wherein: the map parsing tool software comprises a UI interface module and a parsing function module, wherein the UI interface module comprises a plurality of selection units, namely a map file platform unit, a unit memory ordering unit and an interface display unit, wherein the map file platform unit is selected to be associated with the parsing function module unit, a Infrax task compiler, a Ruisha CS+ compiler and an Enzhima Code Warrior compiler are stored in the parsing function module, the map file platform unit is selected to be used for selecting the compiler, the memory unit names and the memory occupation are extracted based on the compiler, and the memory ordering unit is used for ordering.
CN202310919594.5A 2023-07-25 2023-07-25 Resource distribution statistical method in embedded development process Pending CN117008948A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310919594.5A CN117008948A (en) 2023-07-25 2023-07-25 Resource distribution statistical method in embedded development process

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310919594.5A CN117008948A (en) 2023-07-25 2023-07-25 Resource distribution statistical method in embedded development process

Publications (1)

Publication Number Publication Date
CN117008948A true CN117008948A (en) 2023-11-07

Family

ID=88575677

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310919594.5A Pending CN117008948A (en) 2023-07-25 2023-07-25 Resource distribution statistical method in embedded development process

Country Status (1)

Country Link
CN (1) CN117008948A (en)

Similar Documents

Publication Publication Date Title
US5745745A (en) Text search method and apparatus for structured documents
CN109344230B (en) Code library file generation, code search, coupling, optimization and migration method
US7149971B2 (en) Method, apparatus, and system for providing multi-language character strings within a computer
JP2726568B2 (en) Character recognition method and device
RU2643467C1 (en) Comparison of layout similar documents
US6580440B1 (en) System and method for automatically creating and updating a graphical user interface
US20050005239A1 (en) System and method for automatic insertion of cross references in a document
US20110270858A1 (en) File type recognition analysis method and system
CN111522901A (en) Method and device for processing address information in text
US20090324132A1 (en) Fast approximate spatial representations for informal retrieval
CN107145538B (en) Table data query method, device and system
CN113419721B (en) Web-based expression editing method, device, equipment and storage medium
JP5780036B2 (en) Extraction program, extraction method and extraction apparatus
CN101369953B (en) Font network distribution method and system
JP2693914B2 (en) Search system
US6912516B1 (en) Place name expressing dictionary generating method and its apparatus
CN102110006A (en) System and method for expanding and developing application business
CN117008948A (en) Resource distribution statistical method in embedded development process
CN113177391B (en) Method for redirecting operation cursor in streaming interface, computing equipment and storage medium
CN110489528B (en) Electronic dictionary reconstruction method based on electronic book content and computing equipment
JP5184987B2 (en) Index information creating apparatus, index information creating method and program
JP4909754B2 (en) Place name notation dictionary creation method and place name notation dictionary creation device
JP2008210229A (en) Device, method and program for retrieving intellectual property information
KR100769465B1 (en) Query matching method and system using category matching
CN116340263B (en) Word document conversion method and device based on machine identification and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication