CN103383566B - A kind of program flow method for supervising - Google Patents
A kind of program flow method for supervising Download PDFInfo
- Publication number
- CN103383566B CN103383566B CN201310253760.9A CN201310253760A CN103383566B CN 103383566 B CN103383566 B CN 103383566B CN 201310253760 A CN201310253760 A CN 201310253760A CN 103383566 B CN103383566 B CN 103383566B
- Authority
- CN
- China
- Prior art keywords
- subroutine
- circulation
- program flow
- supervising
- identification 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 16
- 238000012544 monitoring process Methods 0.000 claims abstract description 17
- 230000005540 biological transmission Effects 0.000 claims description 3
- 238000012163 sequencing technique Methods 0.000 claims description 3
- 230000006870 function Effects 0.000 abstract description 5
- 230000004913 activation Effects 0.000 abstract description 2
- 230000006835 compression Effects 0.000 abstract description 2
- 238000007906 compression Methods 0.000 abstract description 2
- 125000004122 cyclic group Chemical group 0.000 abstract description 2
- 230000000737 periodic effect Effects 0.000 abstract description 2
- 238000004364 calculation method Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The present invention relates to a kind of program flow method for supervising, solve the problem of multiple subprogram activation monitoring in engine control software.The control of Modern Engine is all carry out Electronic Control by engine controller, is generally made up of multiple subroutine in the control software design of engine controller.Operation due to engine is a kind of state of cyclic operation gone round and begun again, if Otto cycle engine is exactly continuous periodic duty in air inlet, compression, acting and exhaust four strokes.Therefore corresponding control software design is also run in circulation a corresponding engine four-stroke-cycle to carry out recursive call to a series of subroutine, realizes controlling functions.Subroutine in each circulation successively calls order and call number is changeless.<!--1-->
Description
Technical field
The present invention relates to a kind of program flow method for supervising.
Background technology
The software program of engine controller is increasingly sophisticated, often be made up of multiple subroutine, in regular hour loop cycle, multiple subroutine is had to need to perform by certain sequencing and number of times, how to monitor these subroutines whether to perform with number of times in the correct order, can detect in time when software generation run time fault, not yet cause the attention of developer.
Summary of the invention
The object of the present invention is to provide a kind of program flow method for supervising, when making the subroutine in engine controller software fail to perform according to predefined procedure and number of times, can detect in time, thus enable software take fault counter-measure.
Before each circulation, produce a random number, in each subroutine, increase a sub-program identification code; Utilize MD5 algorithm random number and subroutine identification code to be calculated, if any one subroutine does not perform by expection, the result that MD5 algorithm calculates will be different from desired value, thus find mistake.
Concrete technical scheme is as follows:
A kind of program flow method for supervising, adopts following steps:
(1), before program flow circulates at every turn, a random number is produced;
(2) a sub-program identification code is increased in each subroutine in program flow;
(3) MD5 algorithm is utilized random number and subroutine identification code to be calculated;
(4) if any one subroutine does not perform by expection, the result that MD5 algorithm calculates will be different from desired value, thus find mistake.
Further, described program flow is the software program of engine controller, is made up of multiple subroutine, in regular hour loop cycle, has multiple subroutine perform by certain sequencing and number of times and circulate.
Further, step (3) specifically comprises the steps:
(3-1), before in circulation, first invoked subroutine execution terminates, carry out MD5 computing after this random number being added the identification code of oneself, operation result is the numeral of 128;
(3-2) before second invoked subroutine performs and terminate, after 128 bit digital obtained are added the identification code of oneself, carry out MD5 computing after previous subroutine MD5 computing, generate new 128 bit digital,
(3-3) by that analogy, until last invoked subroutine performs end in this time circulation, 128 bit digital calculated for the last time in this time circulation are obtained.
Further, step (4) specifically comprises the steps:
(4-1) control software design calls a monitoring subroutine before circulation terminates;
(4-2) this monitoring subroutine carries out MD5 computing by calling order and the number of times of each subroutine expection in this circulation to random number and identification code corresponding to each subroutine;
(4-3) 128 bit digital previous step calculated and comparing previously by 128 bit digital that each subroutine generates;
If (4-4) two numerals are consistent, then illustrate that in this time circulation, each subroutine is called by expection;
If (4-5) two numerals are inconsistent, then illustrate this circulation in-line subroutine call order or number of times there occurs mistake.
Further, a random number is produced by control software design in step (1).
Further, described in step (2), between each subroutine, identification code is different.
Further, in step (2), the identification code numeral of a byte or multiple byte represents, its span covers all subroutine numbers needing to carry out monitoring in this circulation.
Further, successively order is called to each subroutine in circulation and call number is monitored
Further, MD5 algorithm is this area general information digest algorithm, for guaranteeing that information transmission is unanimously complete.
Compared with currently available technology, the present invention effectively can detect that subroutine leaks execution, many execution, the incorrect mistake of execution sequence; Scheme is easy, is easy to realize.
Accompanying drawing explanation
Fig. 1 is program flow of the present invention monitoring process flow diagram
Embodiment
Describe the present invention with reference to the accompanying drawings below, it is a kind of preferred embodiment in numerous embodiments of the present invention.
A kind of program flow monitoring scheme, solves the problem of multiple subprogram activation monitoring in engine control software.The control of Modern Engine is all carry out Electronic Control by engine controller, is generally made up of multiple subroutine in the control software design of engine controller.Operation due to engine is a kind of state of cyclic operation gone round and begun again, if Otto cycle engine is exactly continuous periodic duty in air inlet, compression, acting and exhaust four strokes.Therefore corresponding control software design is also run in circulation a corresponding engine four-stroke-cycle to carry out recursive call to a series of subroutine, realizes controlling functions.Subroutine in each circulation successively calls order and call number is changeless.
In order to successively call order to each subroutine in circulation and call number is monitored, arrange an identification code to each subroutine, between each subroutine, identification code is different, has uniqueness.Identification code can represent by the numeral of a byte or multiple byte, and its span covers all subroutine numbers needing to carry out monitoring in this circulation.
When each circulation starts, control software design produces a random number, and before in Posterior circle, first invoked subroutine execution terminates, carry out MD5 computing after this random number being added the identification code of oneself, operation result is the numeral of 128.Second invoked subroutine carries out MD5 computing after 128 bit digital obtained after previous subroutine MD5 computing are added the identification code of oneself before performing and terminating, and generates new 128 bit digital.By that analogy, until last invoked subroutine performs end in this time circulation, 128 bit digital calculated for the last time in this time circulation are obtained.
Then control software design calls a monitoring subroutine before this circulation terminates, this monitoring subroutine carries out MD5 computing by calling order and the number of times of each subroutine expection in this circulation to random number and identification code corresponding to each subroutine, compares by 128 bit digital calculated with previously by 128 bit digital that each subroutine generates.If two numerals are consistent, then illustrate that in this time circulation, each subroutine is called by expection; If two numerals are inconsistent, then illustrate this circulation in-line subroutine call order or number of times there occurs mistake.
MD5 algorithm is a kind of message digest algorithm, and for guaranteeing that information transmission is unanimously complete, main flow programming language generally existing MD5 realizes.The present invention utilizes this algorithm to monitor program flow, guarantees that program flow is consistent with expection.
For better this programme being described, below for an example of the present invention illustrates:
Suppose that engine control circulation comprises subroutine A, subroutine B and subroutine C, the identification code that subroutine A is set be 1, subroutine B identification code be 2, subroutine C identification code be 3.Design a monitoring subroutine M in addition.A complete engine control circulation needs call subroutine A, subroutine B and subroutine C successively each once, then calls monitoring subroutine M and monitors.As shown in Figure 1:
During call subroutine A, to random number R that this circulation generates, subroutine A, except completing the controlling functions of engine needs originally, also adds that identification code 1 carries out MD5 calculating, obtains the digital MD5_A of 128.During call subroutine B, to the MD5_A of input, subroutine B, except completing the controlling functions of engine needs originally, also adds that identification code 2 carries out MD5 calculating, obtains the digital MD5_B of 128.During call subroutine C, to the MD5_B of input, subroutine C, except completing the controlling functions of engine needs originally, also adds that identification code 3 carries out MD5 calculating, obtains the digital MD5_C of 128.
The operation order that monitoring subroutine M only expects by each subroutine and number of times carry out the verify calculation of MD5.In this example, random number R is added that identification code 1 is carried out first time MD5 and calculated by monitoring subroutine M, 128 bit digital obtained add that identification code 2 is carried out second time MD5 and calculated, 128 bit digital obtained add that identification code 3 is carried out third time MD5 and calculated, and finally obtain the digital MD5_M of 128.
Relatively whether these two numerals of MD5_C and MD5_M are equal, if equal, illustrate that each subroutine is the subroutine A-> subroutine B-> subroutine C according to expection in this circulation, and each subroutine mode only run once performs.If unequal, then illustrate that each subroutine calls order in this circulation or mistake has appearred in number of times.
Above by reference to the accompanying drawings to invention has been exemplary description; obvious specific implementation of the present invention is not subject to the restrictions described above; as long as have employed the various improvement that method of the present invention is conceived and technical scheme is carried out; or directly apply to other occasion, all within protection scope of the present invention without improving.
Claims (8)
1. a program flow method for supervising, is characterized in that, adopts following steps:
(1), before program flow circulates at every turn, a random number is produced;
(2) program flow is made up of multiple subroutine, increases a sub-program identification code in each subroutine;
(3) MD5 algorithm is utilized random number and subroutine identification code to be calculated;
(4) if any one subroutine does not perform by expection, the result that MD5 algorithm calculates will be different from desired value, thus find mistake;
Step (3) specifically comprises the steps:
(3-1), before in circulation, first invoked subroutine execution terminates, carry out MD5 computing after this random number being added the identification code of oneself, operation result is the numeral of 128;
(3-2) before second invoked subroutine performs and terminate, after 128 bit digital obtained are added the identification code of oneself, carry out MD5 computing after previous subroutine MD5 computing, generate new 128 bit digital,
(3-3) by that analogy, until last invoked subroutine performs end in this time circulation, 128 bit digital calculated for the last time in this time circulation are obtained.
2. program flow method for supervising as claimed in claim 1, it is characterized in that, described program flow is the software program of engine controller, is made up of multiple subroutine, in regular hour loop cycle, multiple subroutine is had to perform by certain sequencing and number of times and circulate.
3. program flow method for supervising as claimed in claim 1 or 2, it is characterized in that, step (4) specifically comprises the steps:
(4-1) control software design calls a monitoring subroutine before circulation terminates;
(4-2) this monitoring subroutine carries out MD5 computing by calling order and the number of times of each subroutine expection in this circulation to random number and identification code corresponding to each subroutine;
(4-3) 128 bit digital previous step calculated and comparing previously by 128 bit digital that each subroutine generates;
If (4-4) two numerals are consistent, then illustrate that in this time circulation, each subroutine is called by expection;
If (4-5) two numerals are inconsistent, then illustrate this circulation in-line subroutine call order or number of times there occurs mistake.
4. program flow method for supervising as claimed in claim 1 or 2, is characterized in that, produce a random number in step (1) by the software program of described controller.
5. program flow method for supervising as claimed in claim 1 or 2, it is characterized in that, in step (2), between each subroutine, identification code is different.
6. program flow method for supervising as claimed in claim 1 or 2, is characterized in that, in step (2), the identification code numeral of a byte or multiple byte represents, its span covers all subroutine numbers needing to carry out monitoring in this circulation.
7. program flow method for supervising as claimed in claim 1 or 2, is characterized in that, successively calls order and call number is monitored to each subroutine in circulation.
8. program flow method for supervising as claimed in claim 1 or 2, it is characterized in that, MD5 algorithm is this area general information digest algorithm, for guaranteeing that information transmission is unanimously complete.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310253760.9A CN103383566B (en) | 2013-06-24 | 2013-06-24 | A kind of program flow method for supervising |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310253760.9A CN103383566B (en) | 2013-06-24 | 2013-06-24 | A kind of program flow method for supervising |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103383566A CN103383566A (en) | 2013-11-06 |
CN103383566B true CN103383566B (en) | 2015-10-28 |
Family
ID=49491389
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310253760.9A Active CN103383566B (en) | 2013-06-24 | 2013-06-24 | A kind of program flow method for supervising |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103383566B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105955115A (en) * | 2016-05-10 | 2016-09-21 | 重庆长安汽车股份有限公司 | Method and device for monitoring program flow of whole automobile controller |
CN106776236B (en) * | 2017-02-07 | 2020-05-08 | 北京龙鼎源科技股份有限公司 | Method and apparatus for monitoring execution of a program |
CN108646708B (en) * | 2018-05-02 | 2020-05-22 | 阳光电源股份有限公司 | Program flow monitoring method and system |
CN110135198B (en) * | 2019-02-18 | 2021-06-22 | 北京车和家信息技术有限公司 | Program flow monitoring method and system and vehicle |
CN111427723B (en) * | 2020-03-19 | 2023-05-30 | 阳光电源股份有限公司 | AutoSAR-based program flow monitoring method and application device |
CN118277200B (en) * | 2024-04-02 | 2024-09-03 | 上海利氪科技有限公司 | Software program flow monitoring method, electronic device and storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1154771A (en) * | 1994-07-29 | 1997-07-16 | 荷兰皇家·Ptt·有限公司 | Method and apparatus for the verification of data sequences |
US7168065B1 (en) * | 1999-03-09 | 2007-01-23 | Gemplus | Method for monitoring program flow to verify execution of proper instructions by a processor |
CN101166087A (en) * | 2007-09-30 | 2008-04-23 | 奇瑞汽车有限公司 | A secure validation method for car diagnosis communication |
CN101533367A (en) * | 2008-03-14 | 2009-09-16 | 英业达股份有限公司 | Method for analyzing program error and method for making interpretation data thereof |
CN101763291A (en) * | 2009-12-30 | 2010-06-30 | 中国人民解放军国防科学技术大学 | Method for detecting error of program control flow |
US20130145219A1 (en) * | 2011-12-02 | 2013-06-06 | Fisher Controls International Llc | Program flow control monitoring routines, related methods and systems |
-
2013
- 2013-06-24 CN CN201310253760.9A patent/CN103383566B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1154771A (en) * | 1994-07-29 | 1997-07-16 | 荷兰皇家·Ptt·有限公司 | Method and apparatus for the verification of data sequences |
US7168065B1 (en) * | 1999-03-09 | 2007-01-23 | Gemplus | Method for monitoring program flow to verify execution of proper instructions by a processor |
CN101166087A (en) * | 2007-09-30 | 2008-04-23 | 奇瑞汽车有限公司 | A secure validation method for car diagnosis communication |
CN101533367A (en) * | 2008-03-14 | 2009-09-16 | 英业达股份有限公司 | Method for analyzing program error and method for making interpretation data thereof |
CN101763291A (en) * | 2009-12-30 | 2010-06-30 | 中国人民解放军国防科学技术大学 | Method for detecting error of program control flow |
US20130145219A1 (en) * | 2011-12-02 | 2013-06-06 | Fisher Controls International Llc | Program flow control monitoring routines, related methods and systems |
Non-Patent Citations (1)
Title |
---|
一种检测程序控制流故障的方法;李红兵 等;《微计算机信息》;20100605(第16期);第1-3页 * |
Also Published As
Publication number | Publication date |
---|---|
CN103383566A (en) | 2013-11-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103383566B (en) | A kind of program flow method for supervising | |
CN109271331B (en) | Log generation method and device, computer equipment and storage medium | |
Pretschner et al. | One evaluation of model-based testing and its automation | |
CN109240924B (en) | Application program testing method and device | |
CN112783705B (en) | Test method, device, system, chip and electronic equipment | |
CN108875320B (en) | Software security protection method and device, electronic equipment and computer storage medium | |
US10331513B2 (en) | Zero overhead code coverage analysis | |
US20210004212A1 (en) | Method and apparatus for compiling source code object, and computer | |
CN105912447B (en) | A kind of monitoring method of embedded program execution sequence | |
CN113709126A (en) | Network protocol security fuzzy test method, device, equipment and storage medium | |
CN104321660A (en) | System and method for generating diagnostic test files associated with a battery pack | |
CN103324890A (en) | Method and device for detecting vulnerable local files of links | |
CN106095609B (en) | Walking data check, modification method and system | |
CN110908869B (en) | Application program data monitoring method, device, equipment and storage medium | |
CN107301105B (en) | Method and device for checking hot patch or dynamic library | |
CN106647612A (en) | PLC vulnerability discovery method based on state relational map | |
CN114779913B (en) | Resetting method and chip for adaptively adjusting working frequency | |
CN104063317B (en) | Instruction diagnosis method | |
JP6434840B2 (en) | Electronic control unit | |
CN115828244A (en) | Memory leak detection method and device and related equipment | |
US11017085B2 (en) | Methods and nodes for anomaly detection in computer applications | |
CN109992482B (en) | Method, device, computer equipment and storage medium for observing middleware destructor | |
Panjiyar et al. | Defending against code injection attacks using Secure Design Pattern | |
US20180039510A1 (en) | Management of control parameters in electronic systems | |
CN111427723B (en) | AutoSAR-based program flow monitoring method and application device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant |