CN100573461C - In embedded system, analyze the method that storehouse uses - Google Patents
In embedded system, analyze the method that storehouse uses Download PDFInfo
- Publication number
- CN100573461C CN100573461C CNB2008100615782A CN200810061578A CN100573461C CN 100573461 C CN100573461 C CN 100573461C CN B2008100615782 A CNB2008100615782 A CN B2008100615782A CN 200810061578 A CN200810061578 A CN 200810061578A CN 100573461 C CN100573461 C CN 100573461C
- Authority
- CN
- China
- Prior art keywords
- storehouse
- function
- interrupt
- information
- code
- 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.)
- Expired - Fee Related
Links
Images
Abstract
The invention discloses the method for in embedded system, analyzing the storehouse use a kind of.This method may further comprise the steps: a) the dis-assembling executable file obtains assembly code; B) storehouse of adding up each fundamental block uses; C) storehouse that calculates each function uses; D) produce function call figure from assembly code; E) result of integrating step c and d, the storehouse that calculates each thread uses; F) the storehouse operational analysis of Interrupt Process function; G) according to the interrupt switch situation of system, the storehouse operational analysis of total system.The storehouse operational analysis method that the present invention proposes, except having the function of the storehouse operating position under the static analyzer worst case, also provide the storehouse operational analysis of Interrupt Process function and according to the interrupt switch situation of system, analyze the function of the storehouse use of total system, by thread being used the estimation of storehouse, make the more efficient and safe operation of system.
Description
Technical field
The present invention relates to a kind of method that storehouse uses of in embedded system, analyzing.
Background technology
In recent years, in the computer realm of fast development, embedded technology became one of them more and more important aspect, increased gradually in relevant application, also obtained significant progress.Particularly on the wireless sensor node, the primary processor that adopts is some simple microcontrollers usually, when exploitation multithread programs on these nodes, is a big problem for each thread distributing independent storehouse becomes efficiently at embedded device.
Under existing conditions, in order to distribute Limited resources efficiently, when each thread creation, the storehouse that takies when each thread operation need be provided uses information, this has brought all inconvenience just for procedure development person, if simultaneously wrong estimation the employed storehouse size of thread, the mistake in the time of then can causing the waste of resource or program run.
Summary of the invention
The purpose of this invention is to provide a kind of method that storehouse uses of in embedded system, analyzing, to running on the evaluation method that the required storehouse of the single thread of program uses in the embedded system, especially be applied in the middle of the resource-constrained embedded system, by thread being used the estimation of storehouse, make the more efficient and safe operation of system.The present invention also analyzes the storehouse use of Interrupt Process function and the storehouse of total system uses information.
The step of the technical solution used in the present invention is as follows:
A) analyzed executable file is carried out dis-assembling, obtain the assembly code of analyzed executable file;
B) be that unit divides with the fundamental block with resulting assembly code in the step a), at the assembly code in each fundamental block, the storehouse of adding up this fundamental block uses information;
C) storehouse of analyzing each function uses, and uses the storehouse of the fundamental block of adding up in the step b) to use information, and the storehouse use information of the fundamental block that each function contained is added up, and the storehouse that obtains this function uses information;
D) from assembly code, take out function call code and function return code,, obtain the function call figure of whole application program according to the position relation of function call correlative code;
E) use the analysis result that obtains in step c) and the step d), be starting point with program entry function and thread creation function respectively, according to function call figure, the storehouse of stack related function uses information, and the storehouse that calculates under the worst case of each thread uses information;
F) storehouse of analyzing the Interrupt Process function uses information, on the avr platform, extracts all with _ function that vector_N begins, and relatively the storehouse of these functions uses the information size, finds out maximal value wherein, uses information as the maximum storehouse of Interrupt Process function;
G) storehouse of analyzing total system uses information, from function call source of graph function, if there is interrupt switch instruction, with can not interrupt function in the function from interrupting that out code begins to be labeled as to the function that interrupts being called the OPEN, but otherwise be labeled as interrupt function; If but the function of the bottommost layer that the storehouse under the worst case that step e is calculated uses is an interrupt function, to use be exactly that the maximum storehouse that calculated of step e uses and the storehouse use addition gained of the Interrupt Process function that step f calculates to the maximum storehouse of system so; If the function of the bottommost layer that the storehouse under the worst case that step e calculated uses is can not interrupt function, to use be exactly step e result calculated to the maximum storehouse of system so; After step g was finished, the storehouse of whole application program used the static analysis process of information to finish, and obtains the system stack size of using under the worst case of analyzed application program.
The present invention compares with background technology, has useful effect to be:
Owing to adopted technique scheme, the storehouse operational analysis method that the present invention proposes, except having the function of the storehouse use information under the static analyzer worst case, also provide the storehouse operational analysis of Interrupt Process function and according to the interrupt switch situation of system, analyze the function of the storehouse use of total system, by thread being used the estimation of storehouse, make the more efficient and safe operation of system.
Description of drawings
Accompanying drawing is the schematic flow sheet of the inventive method.
Embodiment
Further specify technical scheme of the present invention in conjunction with example below, in following embodiment, the storehouse that provides a kind of analysis to run on the executable file on the AVR platform is used the method for information, but scrutable be that the inventive method is not limited to specific platform.As shown in drawings, concrete flow process is as follows:
A) analyzed executable file is carried out dis-assembling, obtain the assembly code of analyzed executable file.Use corresponding disassembler at different architectures, then the assembly code that obtains is saved in the related data structure.
A.1) when preserving the code that obtains of dis-assembling, the file that dis-assembling is obtained reads in line by line.If the operational code of the assembly code that reads in is branch, jump, call, return, load, store during this several types of push or pop, preserves; When if the operational code of the assembly code that reads in is other type, because instruction is not preserved not influence of storehouse.
A.2), label and subsequent article one instruction binding are preserved together if when running into label.
B) be that unit divides with the fundamental block with resulting assembly code among the step a, at the assembly code in each fundamental block, the storehouse of adding up this fundamental block uses information.
C) storehouse of analyzing each function uses, and uses the storehouse of the fundamental block of adding up among the step b to use, and the storehouse use information of the fundamental block that each function contained is added up, and the storehouse that obtains this function uses.
C.1) if run into circulation during the function inner analysis, then no matter circulate actual execution several times, only the storehouse consumption notation that loop body is produced once adding that circulation is prepared and the storehouse consumption that part produces is finished in circulation, constitutes the analysis that the storehouse of a loop structure uses;
C.2) if run into direct jump instruction during the function inner analysis, then the destination address from redirect begins further analysis;
C.3) if run into indirect jump instruction during the function inner analysis, can't know the destination address of redirect, preserve current time system all effective addresses in using, travel through these destination addresses, the result who uses the conduct that produces storehouse consumption maximum to analyze herein.
D) from assembly code, extract function call code and function return code,, obtain the function call figure of whole application program according to the position relation of function call correlative code.
E) using the analysis result that obtains in step c and the steps d, is starting point with program entry function and thread creation function respectively, and according to function call figure, the storehouse of stack related function uses, and the storehouse that calculates under the worst case of each thread uses information.
E.1) if current function does not call other function, then it has obtained its storehouse by step c and has used information;
E.2) if current function call user-defined function, those functions that are called that can in assembly code, find function to realize, calculate the storehouse consumption that these functions that are called produce successively, use maximal value wherein to add corresponding results among the step c, as the storehouse use information of this function;
E.3) if current function call system function, the storehouse that produces of these system functions uses the realization of information according to different platform so, obtains as fixed data.On the avr platform, obtain these data according to the realization in the avr-libc storehouse of respective version.
F) on the avr platform, extract all functions with " _ vector_N " beginning, relatively the storehouse of these functions uses size, finds out maximal value wherein, as the maximum storehouse use of Interrupt Process function.
F.1) if the Interrupt Process function is embodied as the Interrupt Process function of interrupt type, interrupt handling routine can be nested, and the storehouse of interrupt handling routine uses information to decide according to the level of nesting of reality permission so;
F.2) if the Interrupt Process function is embodied as the Interrupt Process function of signal type, in an Interrupt Process process, interrupt closing, then there is not nest relation between the interrupt handling routine, the maximum storehouse of interrupt handling routine uses and is just produced by independent some Interrupt Process functions itself, the storehouse consumption that more different Interrupt Process function self produces, the storehouse of maximum used information when maximal value wherein was exactly Interrupt Process.
G),, with can not interrupt function in the function, but otherwise be labeled as interrupt function from interrupting that out code begins to be labeled as to the function that interrupts being called the OPEN if there is interrupt switch instruction from function call source of graph function.If but the function of the bottommost layer that the storehouse under the worst case that step e is calculated uses is an interrupt function, to use be exactly that the maximum storehouse that calculated of step e uses and the storehouse use addition gained of the Interrupt Process function that step f calculates to the maximum storehouse of system so; If the function of the bottommost layer that the storehouse under the worst case that step e calculated uses is can not interrupt function, to use be exactly step e result calculated to the maximum storehouse of system so.After step g was finished, the storehouse of whole application program used the static analysis process of information to finish, and can obtain the system stack size of using under the worst case of analyzed application program.
Pass through above-mentioned steps, the storehouse operational analysis method that the present invention proposes, except having the function of the storehouse use information under the static analyzer worst case, also provide the storehouse operational analysis of Interrupt Process function and according to the interrupt switch situation of system, analyze the function that the storehouse of total system uses.
Claims (1)
1. in embedded system, analyze the method that storehouse uses for one kind, it is characterized in that the step of this method is as follows:
A) analyzed executable file is carried out dis-assembling, obtain the assembly code of analyzed executable file;
B) be that unit divides with the fundamental block with resulting assembly code in the step a), at the assembly code in each fundamental block, the storehouse of adding up this fundamental block uses information;
C) storehouse of analyzing each function uses, and uses the storehouse of the fundamental block of adding up in the step b) to use information, and the storehouse use information of the fundamental block that each function contained is added up, and the storehouse that obtains this function uses information;
D) from assembly code, take out function call code and function return code,, obtain the function call figure of whole application program according to the position relation of function call correlative code;
E) use the analysis result that obtains in step c) and the step d), be starting point with program entry function and thread creation function respectively, according to function call figure, the storehouse of stack related function uses information, and the storehouse that calculates under the worst case of each thread uses information;
F) storehouse of analyzing the Interrupt Process function uses information, on the avr platform, extracts all with _ function that vector_N begins, and relatively the storehouse of these functions uses the information size, finds out maximal value wherein, uses information as the maximum storehouse of Interrupt Process function;
G) storehouse of analyzing total system uses information, from function call source of graph function, if there is interrupt switch instruction, with can not interrupt function in the function from interrupting that out code begins to be labeled as to the function that interrupts being called the OPEN, but otherwise be labeled as interrupt function; If but the function of the bottommost layer that the storehouse under the worst case that step e is calculated uses is an interrupt function, to use be exactly that the maximum storehouse that calculated of step e uses and the storehouse use addition gained of the Interrupt Process function that step f calculates to the maximum storehouse of system so; If the function of the bottommost layer that the storehouse under the worst case that step e calculated uses is can not interrupt function, to use be exactly step e result calculated to the maximum storehouse of system so; After step g was finished, the storehouse of whole application program used the static analysis process of information to finish, and obtains the system stack size of using under the worst case of analyzed application program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2008100615782A CN100573461C (en) | 2008-05-07 | 2008-05-07 | In embedded system, analyze the method that storehouse uses |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2008100615782A CN100573461C (en) | 2008-05-07 | 2008-05-07 | In embedded system, analyze the method that storehouse uses |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101271408A CN101271408A (en) | 2008-09-24 |
CN100573461C true CN100573461C (en) | 2009-12-23 |
Family
ID=40005398
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2008100615782A Expired - Fee Related CN100573461C (en) | 2008-05-07 | 2008-05-07 | In embedded system, analyze the method that storehouse uses |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100573461C (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102012833A (en) * | 2010-11-09 | 2011-04-13 | 北京神舟航天软件技术有限公司 | Compilation process intermediate result-based static stack detection method |
CN104572448A (en) * | 2014-12-23 | 2015-04-29 | 大唐移动通信设备有限公司 | Method and device for realizing use condition of thread stack |
CN104484179A (en) * | 2014-12-23 | 2015-04-01 | 上海斐讯数据通信技术有限公司 | Stack recalling method |
CN107015904B (en) * | 2016-01-28 | 2022-04-19 | 中兴通讯股份有限公司 | Stack protection method and device |
TWI647565B (en) * | 2016-03-31 | 2019-01-11 | 物聯智慧科技(深圳)有限公司 | Calculation system and method for calculating stack size |
CN113312054A (en) * | 2021-05-27 | 2021-08-27 | 长沙海格北斗信息技术有限公司 | Software stack consumption analysis method and analysis device for embedded software architecture |
-
2008
- 2008-05-07 CN CNB2008100615782A patent/CN100573461C/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
CN101271408A (en) | 2008-09-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN100573461C (en) | In embedded system, analyze the method that storehouse uses | |
US9164754B1 (en) | Runtime patching of native-code programs | |
US9703565B2 (en) | Combined branch target and predicate prediction | |
CN101299192B (en) | Non-aligning access and storage processing method | |
US7428731B2 (en) | Continuous trip count profiling for loop optimizations in two-phase dynamic binary translators | |
US10248424B2 (en) | Control flow integrity | |
US9389868B2 (en) | Confidence-driven selective predication of processor instructions | |
RU2009109242A (en) | METHOD AND DEVICE FOR PERFORMING PROCESSOR INSTRUCTIONS BASED ON DYNAMICALLY VARIABLE DELAY | |
CN101876889A (en) | Method for performing a plurality of quick conditional branch instructions and relevant microprocessor | |
CN101884025B (en) | Method and system for accelerating procedure return sequences | |
US20170139693A1 (en) | Code execution method and device | |
US9965279B2 (en) | Recording performance metrics to predict future execution of large instruction sequences on either high or low performance execution circuitry | |
JPWO2009004709A1 (en) | Indirect branch processing program and indirect branch processing method | |
WO2005098613A3 (en) | Facilitating rapid progress while speculatively executing code in scout mode | |
JP2014038408A (en) | Stole reduction methods on pipeline of processor with simultaneous multi-threading capability, reduction device and reduction program | |
CN101639791B (en) | Method for improving interruption delay of embedded type real-time operation system | |
KR102147355B1 (en) | Method and apparatus for converting programs | |
CN105677297A (en) | Toggle realization method and device | |
CN103838616A (en) | Tree program branch based computer program immediate compiling method | |
CN106325963B (en) | Self-adaptive dynamic compiling and scheduling method and device | |
ATE493705T1 (en) | DETERMINISTIC RULE-BASED DISTRIBUTION OF OBJECTS TO OBJECT-PROCESSING CODE | |
KR101678607B1 (en) | Method of processing a sensitive instruction by delaying a processing time and apparatus performing the same | |
US9396044B2 (en) | Memory efficient thread-level speculation | |
CN102799434A (en) | Method for realizing automatic code transplantation by software protection device | |
CN112445520B (en) | Branch prediction optimization method for conditional branch instructions in loop |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C41 | Transfer of patent application or patent right or utility model | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20081219 Address after: 38, Da Da Lu, Xihu District, Zhejiang, Hangzhou Province, China: 310027 Applicant after: Zhejiang University Co-applicant after: INSIGMA GROUP CO., LTD. Address before: 38, Da Da Lu, Xihu District, Zhejiang, Hangzhou Province, China: 310027 Applicant before: Zhejiang University |
|
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20091223 Termination date: 20200507 |