CN107038084B - Program detection method and device - Google Patents

Program detection method and device Download PDF

Info

Publication number
CN107038084B
CN107038084B CN201610075249.8A CN201610075249A CN107038084B CN 107038084 B CN107038084 B CN 107038084B CN 201610075249 A CN201610075249 A CN 201610075249A CN 107038084 B CN107038084 B CN 107038084B
Authority
CN
China
Prior art keywords
basic block
instruction
current
tag
dynamic
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
Application number
CN201610075249.8A
Other languages
Chinese (zh)
Other versions
CN107038084A (en
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.)
Beijing University of Posts and Telecommunications
Original Assignee
Beijing University of Posts and Telecommunications
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 Beijing University of Posts and Telecommunications filed Critical Beijing University of Posts and Telecommunications
Priority to CN201610075249.8A priority Critical patent/CN107038084B/en
Publication of CN107038084A publication Critical patent/CN107038084A/en
Application granted granted Critical
Publication of CN107038084B publication Critical patent/CN107038084B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0706Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment
    • G06F11/0736Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment in functional embedded systems, i.e. in a data processing system designed as a combination of hardware and software dedicated to performing a certain function
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W12/00Security arrangements; Authentication; Protecting privacy or anonymity
    • H04W12/04Key management, e.g. using generic bootstrapping architecture [GBA]

Abstract

The embodiment of the invention discloses a program detection method and a device, wherein the method comprises the following steps: the method comprises the steps that a first dynamic label and a second dynamic label are set in advance for a program running in a network node, the program is divided into a plurality of basic blocks in advance, each basic block is provided with a first static label and a second static label, an instruction label is set for a issued wireless control instruction at the same time, and further, in the process of responding to the wireless control instruction, when any basic block is executed, whether a control flow error belonging to an error type in the node occurs or not is judged based on the two static labels and the first dynamic label, and further, when a special basic block is executed, whether a control flow error belonging to a communication error type occurs or not can also be judged based on the second dynamic label and the instruction label. The embodiment of the invention can effectively detect the control flow error of the program in the network node in the process of responding to the wireless control instruction.

Description

Program detection method and device
Technical Field
The present invention relates to the field of wireless communications, and in particular, to a method and an apparatus for detecting a program.
Background
With the development of Wireless communication technology, Wireless Sensor Networks (WSNs) are applied more and more widely, and specifically, a Wireless Sensor network is a multi-hop self-organizing network system formed by a large number of network nodes deployed in a monitoring area communicating with each other.
After receiving a wireless control instruction issued by another network node, a program running in the network node in the wireless sensor network may execute corresponding code content to respond to the wireless control instruction, but a control flow error may occur in the process of responding to the wireless control instruction. Wherein the control flow error includes: control flow errors occurring inside the nodes and control flow errors caused by data variation of the issued wireless control commands, specifically, the reasons for the control flow errors occurring inside the nodes are as follows: in a severe environment, high-energy particles and the like may change components (gate circuits, SRAM cells, latches and the like) instantaneously, transient faults in the hardware may be reflected in software, unpredictable errors such as data bit flipping, register state change, storage instruction errors, program run-off and the like may be caused, and the errors may bring about transient faults, and further the transient faults cause control flow errors in a program; for the control flow error caused by data variation of the issued wireless control command: when a hardware error occurs in a network node, the issued wireless control command may be altered, so that the software performs an erroneous action. Wherein, the transient fault is a soft fault caused by external environment, and does not mean that the network node has a fault.
Of course, other wireless communication networks than wireless sensor networks, such as: in unmanned aerial vehicle communication networks and industrial control networks, control flow errors may also occur in the process of responding to wireless control instructions by network nodes.
Therefore, how to detect a control flow error occurring in the process of responding to the radio control command by the program in the network node is an urgent problem to be solved.
Disclosure of Invention
An object of the embodiments of the present invention is to provide a method and an apparatus for detecting a program, so as to effectively detect a control flow error occurring in a process of responding to a radio control command by a program in a network node.
In order to achieve the above object, an embodiment of the present invention discloses a program detection method, which is applied to a network node in a wireless communication network; the method comprises the following steps:
a program running in a network node receives a wireless control instruction issued by other network nodes, wherein the program is preset with a first dynamic tag, the program is composed of n basic blocks, each basic block is provided with a first static tag and a second static tag, the first static tag is used for identifying information of the current basic block and belongs to a first data value of n + 1-bit binary data, the second static tag is used for identifying information of a subsequent basic block of the current basic block and belongs to a second data value of n + 1-bit binary data, the first dynamic tag is a third data value of n + 1-bit binary data and is all 1 during initialization, and the subsequent basic block of the current basic block is: the next basic block adjacent to the current basic block in the program execution process;
before executing an entry instruction of a first basic block, performing logical AND operation on a first static tag and a current first dynamic tag of the first basic block to obtain a first class of operation result, wherein the first basic block is any basic block related to a response received instruction in n basic blocks in the program;
judging whether the first type operation result is 0, if so, determining that the program has control flow errors occurring in the node, otherwise,
updating a current first dynamic label according to the first type of operation result;
before executing an instruction of a predetermined position before an exit instruction of the first basic block, performing logical or operation on a current second dynamic tag and a current first dynamic tag to obtain a second type operation result, and updating the current second dynamic tag according to the second type operation result, wherein the second dynamic tag is preset for the program, is a fourth data value of binary data belonging to n +1 bits, and is all set to 0 during initialization;
before executing an exit instruction of the first basic block, judging whether the first basic block is a special basic block, if so, judging whether a current second dynamic label is equal to an instruction label of the first basic block, if not, determining that the program has a control flow error in a communication process, if so, initializing the current second dynamic label after the exit instruction is executed, wherein the special basic block is a basic block for executing actions, and the instruction label is used for pre-storing a path, which is passed by a wireless control instruction issued by other network nodes when the wireless control instruction is executed to the final output in the program, inserting the path into the basic block along with the arrival of the wireless control instruction, and belongs to a fifth data value of n + 1-bit binary data; when the exit instruction of the first basic block is executed, judging whether the first basic block is the last basic block related to the wireless control instruction, if so, initializing a current first dynamic tag, if not, updating the current first dynamic tag according to a second static tag of the first basic block, taking a next basic block in the basic block related to the wireless control instruction as the first basic block, and continuing to execute the step of performing logical AND operation on the first static tag of the first basic block and the current first dynamic tag before executing the entry instruction of the first basic block to obtain a first type of operation result.
Specifically, in n +1 bits of the first static tag, the highest bit is 0, the ith bit is 1, and the rest bits are 0, where i is the sequence bit of the current basic block in all the basic blocks;
in the n +1 bits of the second static label, the highest bit is 1, the mth bit is 1, the rest bits are 0, and m is the sequence bit of the successor basic block of the current basic block in all the basic blocks;
in the n +1 bits of the instruction tag, the highest bit is 0, the jth bit is 1, and the rest bits are 0, where j is the sequence bit of each basic block in all the basic blocks in the path traversed by the wireless control instruction when the wireless control instruction is executed to the final output in the program.
Specifically, the updating the current first dynamic tag according to the first class operation result includes:
determining the value of the first type of operation result as a current first dynamic label;
correspondingly, the updating the current second dynamic tag according to the second type of operation result includes:
determining the value of the second type of operation result as a current second dynamic label; correspondingly, the updating the current first dynamic tag according to the second static tag of the first basic block includes:
determining the second static label of the first basic block as the current first dynamic label.
Specifically, the method of inserting an instruction for setting a tag into any basic block includes:
for the case where the current basic block is not a special basic block:
a test instruction is inserted before the entry instruction of the current basic block: if ((G ═ G)&Li) ═ 0) error; wherein G is a first dynamic tag, LiA first static label for a current basic block;
inserting an Update S instruction before an instruction of a predetermined position before an exit instruction of a current basic block: s ═ S | G; wherein S is a second dynamic tag;
inserting an Update G instruction after the exit instruction of the current basic block: g ═ Bi(ii) a Wherein B isiA second static label for the current basic block;
for the case where the current basic block is a special basic block:
a test instruction is inserted before the entry instruction of the current basic block: if ((G ═ G)&Li) ═ 0) error; wherein G is a first dynamic tag, LiA first static label for a current basic block;
inserting an Update S instruction before an instruction of a predetermined position before an exit instruction of a current basic block: s ═ S | G; wherein S is a second dynamic tag;
a test instruction is inserted before the exit instruction of the current basic block: if (S ≠ C) error, wherein C is an instruction tag;
inserting an Update S instruction after the exit instruction of the current basic block: s is 0;
inserting an Update G instruction after the exit instruction of the current basic block: g ═ Bi(ii) a Wherein B isiThe second static label of the current basic block.
In order to achieve the above object, the embodiment of the present invention further discloses a program detection apparatus, which is applied to a network node in a wireless communication network; the device comprises:
a wireless control instruction receiving unit, configured to receive a wireless control instruction issued by another network node by a program running in the network node, where the program is preset with a first dynamic tag, the program is composed of n basic blocks, each basic block is provided with a first static tag and a second static tag, the first static tag is a first data value of binary data belonging to n +1 bits and used for identifying information of a current basic block, the second static tag is a second data value of binary data belonging to n +1 bits and used for identifying information of a subsequent basic block of the current basic block, the first dynamic tag is a third data value of binary data belonging to n +1 bits and is all 1 when initialized, and the subsequent basic block of the current basic block is: the next basic block adjacent to the current basic block in the program execution process;
a first-class operation result calculation unit, configured to perform a logical and operation on a first static tag and a current first dynamic tag of a first basic block before executing an entry instruction of the first basic block to obtain a first-class operation result, where the first basic block is any basic block related to a response received instruction in n basic blocks in the program;
the first judging unit is used for judging whether the first type of operation result is 0 or not, if so, the first result determining unit is executed, and if not, the first dynamic label updating unit is executed;
the first result determining unit is used for determining that the program has control flow errors which occur in nodes;
the first dynamic label updating unit is used for updating a current first dynamic label according to the first type of operation result;
a second dynamic tag determination unit, configured to perform a logical or operation on a current second dynamic tag and a current first dynamic tag before executing an instruction at a predetermined position before an exit instruction of the first basic block to obtain a second type operation result, and update the current second dynamic tag according to the second type operation result, where the second dynamic tag is preset for the program, and the second dynamic tag is a fourth data value belonging to n + 1-bit binary data and is set to 0 when initialized;
a second judging unit, configured to judge whether the first basic block is a special basic block before executing an exit instruction of the first basic block, execute a third judging unit if the first basic block is judged to be the special basic block, and execute a fourth judging unit if the first basic block is judged not to be the special basic block;
the third judging unit is configured to judge whether a current second dynamic tag is equal to an instruction tag of the first basic block, if not, execute the second result determining unit, and if so, execute the second dynamic tag initializing unit, where the special basic block is a basic block used for executing an action, and the instruction tag is used to pre-store a path that the wireless control instruction issued by another network node passes through when being executed in a program to be finally output, is inserted into the basic block along with arrival of the wireless control instruction, and belongs to a fifth data value of n + 1-bit binary data;
the second result determination unit is used for determining that the program has a control flow error belonging to the communication process,
the second dynamic label initialization unit initializes the current second dynamic label after the exit instruction is executed, and triggers the fourth judgment unit;
a fourth determining unit, configured to determine, when the exit instruction of the first basic block is executed, whether the first basic block is a last basic block related to the wireless control instruction, if yes, initialize a current first dynamic tag, if not, update the current first dynamic tag according to a second static tag of the first basic block, and trigger the first-class operation result calculating unit by using a next basic block in the basic blocks associated with the wireless control instruction as the first basic block.
Specifically, in n +1 bits of the first static tag, the highest bit is 0, the ith bit is 1, and the rest bits are 0, where i is the sequence bit of the current basic block in all the basic blocks;
in the n +1 bits of the second static label, the highest bit is 1, the mth bit is 1, the rest bits are 0, and m is the sequence bit of the successor basic block of the current basic block in all the basic blocks;
in the n +1 bits of the instruction tag, the highest bit is 0, the jth bit is 1, and the rest bits are 0, where j is the sequence bit of each basic block in all the basic blocks in the path traversed by the wireless control instruction when the wireless control instruction is executed to the final output in the program.
Specifically, the updating the current first dynamic tag by the first dynamic tag updating unit according to the first type of operation result includes:
determining the value of the first type of operation result as a current first dynamic label;
correspondingly, the updating the current second dynamic tag by the second dynamic tag updating unit according to the second type of operation result includes:
determining the value of the second type of operation result as a current second dynamic label;
correspondingly, the updating, by the fourth determining unit, the current first dynamic tag according to the second static tag of the first basic block includes:
determining the second static label of the first basic block as the current first dynamic label.
Specifically, the method of inserting an instruction for setting a tag into any basic block includes:
for the case where the current basic block is not a special basic block:
a test instruction is inserted before the entry instruction of the current basic block: if (, (G=G&Li) ═ 0) error; wherein G is a first dynamic tag, LiA first static label for a current basic block;
inserting an Update S instruction before an instruction of a predetermined position before an exit instruction of a current basic block: s ═ S | G; wherein S is a second dynamic tag;
inserting an Update G instruction after the exit instruction of the current basic block: g ═ Bi(ii) a Wherein B isiA second static label for the current basic block;
for the case where the current basic block is a special basic block:
a test instruction is inserted before the entry instruction of the current basic block: if ((G ═ G)&Li) ═ 0) error; wherein G is a first dynamic tag, LiA first static label for a current basic block;
inserting an Update S instruction before an instruction of a predetermined position before an exit instruction of a current basic block: s ═ S | G; wherein S is a second dynamic tag;
a test instruction is inserted before the exit instruction of the current basic block: if (S ≠ C) error, wherein C is an instruction tag;
inserting an Update S instruction after the exit instruction of the current basic block: s is 0;
inserting an Update G instruction after the exit instruction of the current basic block: g ═ Bi(ii) a Wherein B isiThe second static label of the current basic block.
In summary, the method and apparatus for detecting a program according to the embodiments of the present invention set a first dynamic tag and a second dynamic tag for a program executed by a network node in a wireless communication network, setting a first static label and a second static label for each basic block in the program, setting an instruction label for the issued wireless control instruction, and further, in the process of responding to the wireless control instruction, when any basic block is executed, whether a control flow error occurs inside the node is judged based on the two static tags and the first dynamic tag, and further, when executing the special basic block, judging whether a control flow error belonging to the communication process occurs or not based on two static tags, two dynamic tags and an instruction tag, to detect control flow errors in the communication process while detecting control flow errors occurring inside the nodes. Therefore, the method and the device can effectively detect the control flow error of the program in the network node in the process of responding to the wireless control command.
Of course, it is not necessary for any product or method of practicing the invention to achieve all of the above-described advantages at the same time.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a diagram illustrating examples of data variations in a random bit failure model according to an embodiment of the present invention;
FIG. 2 is a general layout diagram of a program detection method according to an embodiment of the present invention;
fig. 3(a), (b), and (c) are schematic diagrams of a first static tag, a second static tag, and an instruction tag, respectively, according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating basic blocks into which instructions for setting tags are inserted according to an embodiment of the present invention;
FIG. 5 is a diagram illustrating basic blocks capable of performing actions with instructions inserted for setting tags according to an embodiment of the present invention;
fig. 6 is a flowchart illustrating a program detection method according to an embodiment of the present invention;
FIG. 7 is program code for bubble ordering in one embodiment provided by an embodiment of the present invention.
FIG. 8 is a flow chart of the bubble sort routine shown in FIG. 7;
FIG. 9 is an exemplary diagram of a certain basic block insert instruction in the bubble sort shown in FIG. 7;
FIG. 10 is a diagram illustrating an internal control flow error of a basic block according to an embodiment of the present invention;
FIG. 11 is a diagram illustrating basic inter-block control flow errors, according to an embodiment of the present invention;
fig. 12 is a schematic structural diagram of a program detecting device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to effectively detect a control flow error occurring in a process of responding to a wireless control instruction by a program in a network node, embodiments of the present invention provide a program detection method and apparatus. It should be emphasized that the network node mentioned in the embodiment of the present invention may be a network node in a wireless sensor network, and may also be a network node in other wireless communication networks besides the wireless sensor network, for example: the wireless network may be: unmanned aerial vehicle communication networks, industrial control networks, and the like, are not exhaustive herein.
In order to facilitate understanding of the program detection method provided by the embodiment of the present invention, a principle content on which the program detection method provided by the embodiment of the present invention is based is first described. The specific introduction is as follows:
first, for the introduction of the substance of a control flow error:
the control flow errors generated by the program in the network node in the process of responding to the wireless control instruction mainly include: control flow errors occurring inside the nodes and control flow errors caused by data variation of the issued wireless control instructions, wherein for convenience of description, the control flow errors in the communication process are referred to below for short for node program control flow errors caused by data variation of the issued wireless control instructions.
For control flow errors caused by transient faults occurring inside nodes, an SEU (single Event update) fault model is generally adopted in the prior art for detection, and because the probability of two or more transient faults occurring at the same time is low, the SEU fault model considers that only one transient fault occurs in hardware in the process of completing a certain action, so that one data bit is turned over. For control flow errors during communication, data variation may include three reasons: (1) before sending, the network node writes an error; (2) in a wireless channel, data is changed; (3) after receiving the data, reading the data and generating errors; in the data transmission process, data is transmitted and received in a binary mode, so that when data is changed, certain data bits are turned over.
In summary, whether a transient fault occurs inside a node or data is changed abnormally in a communication process, the data bit is finally turned over. Therefore, the present invention first proposes a random bit failure model that assumes: when a node executes an action, a transient fault occurs only once in the node or during communication, so that one bit of data is inverted, for example, the control command d2 becomes d3, as shown in fig. 1, the control command d2 is 11000010, and after the first bit of d2 is inverted, the control command d3 becomes 11000011. Obviously, the occurrence of such errors is random.
Moreover, transient faults occurring in the node and in the communication process can cause five types of control flow errors, wherein the third type of errors is a transient fault of a part of the node, and more mainly a transient fault of a issued command. Specifically, five control flow errors are as follows:
(1) basic block internal control flow errors;
(2) illegally jumping from the tail of one basic block to the head of another basic block;
(3) skipping from one basic block end error to another basic block beginning;
(4) the tail of one basic block is at any position from the tail of another basic block;
(5) anywhere from one basic block to anywhere from another basic block.
Secondly, the pre-processing of the running program in the network node is as follows:
the program is divided in advance, and the following definitions are given:
basic blocks: some continuous instruction sets are executed in sequence inside the basic block, and jump and call do not occur. The first instruction of the basic block is an entry, other basic blocks can enter through jumping, calling and the like, other instructions cannot jump into the basic block, the last instruction is an exit of the program, the basic block can be jumped to, and other instructions cannot jump out of the basic block.
And (3) program flow chart: after dividing a program into basic blocks, the program can be represented by a graph consisting of a basic block set V and a connected set E of "edges" between the basic blocks, i.e., a Program Flow Graph (PFG): p ═ { V, E }, where V ═ V }, in which1,v2,…vi,…,vn},E={e1,e2,…,ei,…,em},viRepresenting a basic block, edge eiRepresenting a slave basic block viTo basic block vjBranch br ofi,j
The subsequent basic block: when br is in the program flow graph P ═ V, E }, the program flow graph P is as followsi,jE.g., E, define vjIs v isiSuccessor basic blocks, and, viThe set of all subsequent basic blocks, called the set of subsequent basic blocks, is denoted by suc (v)i)。
Again, for the introduction of specific details of each type of tag:
as shown in fig. 2, the embodiment of the present invention detects a control flow error occurring inside a node by setting one dynamic tag and two static tags for a program, and adds another dynamic tag and an instruction tag on the basis of detecting a control flow error occurring inside a node to detect a control flow error in a communication process while detecting a control flow error occurring inside a node, and the instruction tags are issued simultaneously in an instruction issuing process.
Two static labels used for detecting control flow errors occurring inside the nodes are as follows: l isiAnd Bi,LiFor identifying current basic block information, BiThe dynamic tag is used for recording the information of the subsequent basic block, and can be G, and is used for recording the running state of the program along with the dynamic update of the program; furthermore, in order to simultaneously detect control flow errors in the communication process, a dynamic tag S and an instruction tag C are addedjThe dynamic label S is dynamically updated along with the execution of the program and is used for recording the running state of the program, and the instruction label CjAnd simultaneously issuing the accompanying wireless control instruction to the nodes, and pre-storing an execution path of the wireless control instruction. The following details each tag:
first, assume that a program running in a network node has n basic blocks, each of which is defined as v1,v2,…vi,…,vnWhere i is the index of the basic block, 0. ltoreq. i.ltoreq.n, j representing the instruction number.
Static label Li: for identifying the current basic block viAnd (4) information. Specifically, LiThere are n +1 bits, the highest bit is 0, the ith bit is 1, and the rest are 0, as shown in fig. 3 (a).
Static label Bi: for identifying the current basic block viOf the subsequent basic block. Specifically, BiThere are n +1 bits, the most significant bit is always 1, if suc (v)i)={vm,vk…, as shown in fig. 3 (b).
Instruction tag Cj: the method is used for pre-storing the path which is passed by the issued instruction when the instruction is executed to the final output in the program, and simultaneously inputting along with the arrival of the instruction. Specifically, CjThere are n +1 bits in total. The most significant bit is always 0 if the execution path of the instruction includes { v }m,vk…, as shown in fig. 3 (c).
And (3) dynamic label G: n +1 bits, updated at the end of each basic block and initialized to all 1's.
And (3) dynamic label S: n +1 bits, updated in the middle of each basic block, all set to 0 at initialization.
It should be noted that binary 0 and 1 in each tag described in the present invention are only one kind of characterization. In electronic engineering, binary 0 and binary 1 have two definitions, one is high level defined as 1 and low level defined as 0, and the other is high level defined as 0 and low level defined as 1.
Finally, introduction to the insertion method of each tag:
in order to detect control flow errors occurring inside the nodes, some instructions are inserted into various basic blocks in the program, as shown in fig. 4:
wherein, the test instruction: if ((G ═ G)&Li) ═ 0) error. By this instruction, detection can be performed at the entry of the basic block, and the G signal is updated.
Update S instruction: s | G. The S signal is updated so that the S signal can carry the basic block information that passes through.
Update G instruction: g ═ Bi. And updating the G signal so that G carries the information of the subsequent node.
Furthermore, in order to detect a control flow error in a communication process while detecting a control flow error occurring inside a node, some additional instructions need to be inserted into a basic block for performing an action, where the basic block for performing an action is regarded as a special basic block by the embodiment of the present invention. As shown in fig. 5:
here, test, Update S, Update G at the first position are consistent with the basic block shown in fig. 4.
Test instruction at the second place: and if (S ≠ C) error for judging whether the actual execution path is consistent with the prestored execution path.
Update S instruction at second: s is initialized after each completed action when S is 0.
Based on the above-described principle contents, a program detection method provided by an embodiment of the present invention is described below. It should be noted that, in this embodiment, a control flow error occurring inside a node is detected by using one dynamic tag and two static tags; and by adding another dynamic label and an instruction label, the control flow error in the communication process is detected while the control flow error in the node is detected, so that the aim of effectively detecting the control flow error in the process of responding to the wireless control instruction by the program in the network node is fulfilled.
It should be noted that, in the implementation of the present invention, the first dynamic tag is the above dynamic tag G, and the first static tag is the above static tag LiThe second static label is the static label BiThe second dynamic tag is the dynamic tag S, and the instruction tag is the instruction tag Cj
As shown in fig. 6, a program detecting method provided in an embodiment of the present invention may include the following steps:
s101, a program running in a network node receives a wireless control instruction issued by other network nodes;
the program is preset with a first dynamic tag, the program is composed of n basic blocks, each basic block is provided with a first static tag and a second static tag, the first static tag is used for identifying information of the current basic block and belongs to a first data value of n + 1-bit binary data, the second static tag is used for identifying information of a subsequent basic block of the current basic block and belongs to a second data value of n + 1-bit binary data, the first dynamic tag is a third data value of n + 1-bit binary data and is all 1 when initialized, and the subsequent basic block of the current basic block is: and the next basic block adjacent to the current basic block in the program execution process.
Specifically, in n +1 bits of the first static tag, the highest bit is 0, the ith bit is 1, and the rest bits are 0, where i is an order bit of the current basic block in all the basic blocks. Also, a detailed diagram of the first static tag can be seen in fig. 3 (a).
Specifically, in the n +1 bits of the second static tag, the highest bit is 1, the mth bit is 1, and the rest bits are 0, where m is an order bit of all basic blocks of a subsequent basic block of the current basic block. Also, a detailed diagram of the second static tag can be seen in fig. 3 (b).
It should be noted that the method for dividing the program into a plurality of basic blocks in advance can be implemented by using the prior art, and is not described herein again.
S102, before executing an entry instruction of a first basic block, performing logical AND operation on a first static tag and a current first dynamic tag of the first basic block to obtain a first-class operation result, wherein the first basic block is any basic block related to a response received instruction in n basic blocks in the program;
s103, judging whether the first type operation result is 0, if so, executing S104, otherwise, executing S105;
s104, determining that the program has control flow errors which occur in the node;
s105, updating the current first dynamic label according to the first type operation result;
specifically, the updating the current first dynamic tag according to the first class operation result includes: and determining the value of the first type of operation result as a current first dynamic label.
In practical application, in the case that the program is executed correctly, since the current first dynamic tag G records information of a basic block succeeding the last basic block when the last basic block is updated at the end of the last basic block, the test instruction is executed before the entry instruction of the first basic block is executed, and the first static tag L of the first basic block is usediAnd when the first dynamic label G is subjected to logical AND operation with the current first dynamic label G, the obtained first type operation result cannot be 0. If the obtained first type operation result is 0, the program is indicated to have a control flow error which occurs inside the node. Labeling L a first static label of the first basic blockiWhen the first static label G and the current first dynamic label G are subjected to logic AND operation, the obtained first type of operation result is the first static label of the first basic blockLabel LiThe value of (c). Updating the current first dynamic label G according to the first class operation result, namely updating the first static label LiIs assigned to the first dynamic label G.
S106, before executing the instruction of the preset position before the exit instruction of the first basic block, carrying out logical OR operation on the current second dynamic label and the current first dynamic label to obtain a second type operation result, and updating the current second dynamic label according to the second type operation result;
specifically, the second dynamic tag is preset for the program, and the second dynamic tag is a fourth data value of n + 1-bit binary data and is set to 0 during initialization.
Specifically, the updating the current second dynamic tag according to the second type of operation result includes: and determining the value of the second type of operation result as a current second dynamic label.
Note that the instruction of the predetermined position before the exit instruction of the first basic block may be any instruction before the exit instruction of the first basic block. Before any instruction before the exit instruction of the first basic block is executed, for example, when the instruction is executed to the middle of the first basic block, the Update S instruction is executed, the current second dynamic tag S and the current first dynamic tag G are logically or-operated to obtain a second type operation result, and the value of the second type operation result is assigned to the current second dynamic tag S.
S107, before executing the exit instruction of the first basic block, judging whether the first basic block is a special basic block, if so, executing S108; if the first basic block is judged not to be the special basic block, directly executing S111;
specifically, the special basic block is a basic block for executing an action; the instruction tag is used for prestoring paths traversed by the wireless control instructions issued by other network nodes when the wireless control instructions are executed to final output in a program, the paths are inserted into the basic blocks along with the arrival of the wireless control instructions, the fifth data values belong to n +1 bits of binary data, in the n +1 bits of the instruction tag, the highest bit is 0, the jth bit is 1, and the rest bits are 0, wherein j is the sequential bits of all basic blocks of each basic block in the path traversed by the wireless control instructions when the wireless control instructions are executed to final output in the program. Also, a detailed diagram of the instruction tag can be seen in fig. 3 (c).
S108, judging whether the current second dynamic label is equal to the instruction label of the first basic block or not;
in practical application, it is determined whether the current second dynamic tag S is equal to the instruction tag of the first basic block, for example, a test instruction at the second point is executed, by determining whether the current second dynamic tag S is equal to the instruction tag C of the first basic blockjAnd judging whether the actual execution path of the wireless control command is consistent with the prestored execution path.
S109, determining that the program has a control flow error in the communication process;
in practical application, when the program is executed to a special basic block, if the program is executed correctly and the issued control command is not changed, the current value of the second dynamic tag S and the pre-stored command tag C are the samejAre equal. Otherwise, if the program is not executed through the existing path or the issued control instruction is changed, the current value of the second dynamic tag S and the pre-stored instruction tag CjIs not equal, it is determined that the program has a control flow error that belongs to the communication process.
S110, initializing the current second dynamic label after the exit instruction is executed, and executing S111;
s111, when the exit instruction of the first basic block is executed, judging whether the first basic block is the last basic block related to the wireless control instruction, if so, executing S112, and if not, executing S113;
s112, initializing a current first dynamic label;
s113, updating the current first dynamic tag according to the second static tag of the first basic block, and taking the next basic block in the basic blocks associated with the wireless control command as the first basic block, and returning to S102.
Specifically, the updating the current first dynamic tag according to the second static tag of the first basic block includes: determining the second static label of the first basic block as the current first dynamic label.
In practical application, the current first dynamic tag is updated according to the second static tag of the first basic block, for example, an update G instruction is executed, and the second static tag B of the first basic block is updatediThe value of (c) is given to the current first dynamic label G, and the current first dynamic label G is updated so that the current first dynamic label G carries information of a basic block subsequent to the first basic block.
The program detection method of the embodiment of the invention sets the first dynamic label and the second dynamic label for the program operated by the network node in the wireless communication network, setting a first static label and a second static label for each basic block in the program, setting an instruction label for the issued wireless control instruction, and further, in the process of responding to the wireless control instruction, when any basic block is executed, whether a control flow error occurs inside the node is judged based on the two static tags and the first dynamic tag, and further, when executing the special basic block, judging whether a control flow error belonging to the communication process occurs or not based on two static tags, two dynamic tags and an instruction tag, to detect control flow errors in the communication process while detecting control flow errors occurring inside the nodes. Therefore, the method and the device can effectively detect the control flow error of the program in the network node in the process of responding to the wireless control command.
In the following, bubble sorting is used as a specific application example to introduce the program detection method provided in the embodiment of the present invention, and the specific application example can detect a control flow error occurring inside a node and a control flow error in a program caused by a data variance of a wireless control instruction issued.
The control flow errors generated in the process of responding to the wireless control command by the program running in the network node can include the control flow errors generated in the node itself and the node program control flow errors caused by data variation of the issued command. For the purpose of being able to be embodied in a program, the program may be modified on the basis of bubble sorting. To simplify the analysis process, only the situation of two instructions may be considered and the output print data may be used to represent the node performing the action. The modified procedure is shown in fig. 7.
According to the modified bubble sorting code, in combination with the given definition, the flow chart of bubble sorting may be as shown in fig. 8, where in this procedure the number n of basic blocks is 7, where v is1,v2,……v7Etc. represent basic blocks, v2Is suc (v)2)={v3,v4Specific basic blocks v shown in the figure6、v7Is a basic block for performing actions.
Specific data information of each type of tag is as follows:
L200000010: for identifying v2The information of (a);
B210001100: for identifying v2Information of the subsequent basic block of (2);
C100111111: instruction C1Needs to go through the basic block (v)1,v2,v3,v4,v5,v6)。
The label insertion method is exemplified as follows:
for basic block v3The label insertion method is shown in fig. 9.
The bubble program algorithm execution flow is as follows:
for the bubbling program, for v1Basic Block, G initialized to 11111111, performed correctly1Then G ═ B110000010, jump to v if normal2At the inlet, G is G ═ G&L2=10000010&00000010 ≠ 0, without error. Otherwise, if from basic block v1At the outletJump to basic block v3Then at basic block v3In which the test instruction G is started to be executed G&L3=10000010&00000100 ═ 0, an error was detected.
For instruction C ═ 1, when it executes correctly, S ═ 00111111, then at the beginning, C1The prestored value is 00111111. Like C2Is 01011111. Then if the instruction changes from C-1 to C-2 due to the instruction data change, then since S-01011111 is not equal to the pre-stored C1Value, error is detected. In addition, if during program execution, an error occurs in the program flow, for example from v2Directly jump to v6S is 00100011, which is not equal to the prestored value, and a control flow error can be detected.
Further, in order to facilitate understanding of the method provided by the embodiment of the present invention, a detection process of the method provided by the embodiment of the present invention on a control flow error inside a node is described below with reference to a specific error type.
The detection process of the program detection method provided by the embodiment of the invention for the control flow error in the node can be as follows:
(1) detection of control flow errors that can occur inside basic blocks:
control flow errors can occur inside basic blocks, as shown in fig. 10, with dashed lines representing the wrong jump pattern.
Error type 1: jumping from the upper part to the upper part of the basic block or from the lower part to the lower part of the basic block.
Error type 2: jumping from the upper to the lower part of the basic block.
Error type 3: jumping from the lower part to the upper part of the basic block.
The probability of error occurrence inside the basic block is small, especially for the case of small program size. It is apparent that the probability of the error type 1 occurring is much smaller.
When the error type 2 occurs, the method provided by the invention cannot detect, but at this time, the program is likely to be in a dead loop, and the program cannot be continuously executed, so that the node cannot generate the wrong output.
When an error 3 occurs, in which the update S statement is not executed, i.e. the S signal cannot take the position information of the module, then the path recorded by him is in error, and before output it is compared with the pre-stored CjWhen the values are compared, they can be detected.
(2) Detection of basic inter-block control flow errors:
the basic inter-block error type is shown in fig. 11. The solid lines represent the correct jumps and the dashed lines represent the wrong jumps.
Error type 4: from a basic block viIs erroneously jumped to an entry v of another basic blockj,vjBelong to suc (v)i). The error is caused by the 'condition' judgment error of the conditional branch statement itself, and is a control flow error caused by a data flow error. One of the two sources of such errors is a node internal data error, and after the update S is executed, the path recorded by S does not match the value in the instruction tag, and can be detected. The other is a main source, which is caused by the variation of the issued command in the communication process, and will be specifically described in the following detection process of control flow errors in the communication process.
Error type 5: illegal jumping from the exit of one basic block to an arbitrary position of another basic block, vjBelong to suc (v)i). This error needs to be considered in two types, one is to jump to the top of the basic block, at this time, since the test instruction is not executed, the highest bit of G is 1, after the execution of update S, the n +1 bit of S is 1, and finally C and S are addedjAfter the values are compared, an error can be detected. The other is to jump to the lower part of the basic block, at this time, since update S is not executed, S cannot record the information of the execution path at this time. Then it is to the final and CjAfter the values are compared, an error can be detected.
Error type 6: illegal jump from an arbitrary position of one basic block to an entry of another basic block, vjBelong to suc (v)i). Since the G signal is not updated, at entry, when the test instruction is executedAn error can be detected.
Error type 7: from an arbitrary position of one basic block, illegal jumping to an arbitrary position of another basic block, vjBelong to suc (v)i). Such errors are classified into four cases. First, jump from the top of one basic block to the top of another, then this time because at vjSince the G signal is not updated, the value after update S is executed records viInformation of (1), v not recordedjAnd (4) information. A second type of jump from the upper part of one basic block to the lower part of another basic block, vi、vjThere is no way to record the information of (1). The third one jumps from the lower part of one basic block to the upper part of another basic block, as in the first case. A fourth jump from the lower part of one basic block to the lower part of another basic block, when the S signal cannot record vjThe information of (1). All four cases can be detected.
Error type 8: from the exit of one basic block, illegal jumps to the entry of another basic block, vjDo not belong to suc (v)i). At this time, an error can be detected when the test instruction is executed.
Error type 9: illegal jumping from an arbitrary position of one basic block to an exit of another basic block, vjDo not belong to suc (v)i). The same type 8.
Error type 10: illegal jumping from the exit of one basic block to an arbitrary position of another basic block, vjDo not belong to suc (v)i)。
Error type 11: from an arbitrary position of one basic block, illegal jumping to an arbitrary position of another basic block, vjDo not belong to suc (v)i). Of the same type 10.
Similarly, in order to facilitate understanding of the method provided by the embodiment of the present invention, the following further describes a detection process of the method provided by the embodiment of the present invention on a control flow error in a communication process.
The detection process of the program detection method provided by the embodiment of the invention for the control flow error in the communication process can be as follows:
after an instruction change, after the fault has passed into the node, the above-mentioned error type 4 results. If the changed instruction does not exist in the internal program of the node, the node does not execute any action at the moment and does not output errors. If the changed instruction exists in the node, the program in the node can not execute the program according to the execution flow prestored in the instruction tag, and after update S, the execution path recorded by the dynamic tag S is not consistent with the path prestored in the instruction tag, so that the detection can be carried out.
In the above analysis we have not considered the checked condition in simultaneous communication, and in the following we consider the checked condition, exemplified by CRC.
With a CRC check, there are three cases.
1) In three kinds of errors of data variation of the instruction, two situations of a network node writing error before sending and a data reading error after receiving data are detected without any method;
2) the CRC cannot completely detect errors, the detection probability is generally 99.7%, and the detection is necessary for instruction data with very high reliability requirements;
3) when CRC is implemented in software, errors may occur in the program itself.
Therefore, when CRC check is available, it is necessary to add check for instruction data whose reliability is very high. The instruction label is not only used for detecting the correctness of the issued instruction, but also used for pre-storing the execution path of the instruction, and ensuring that the program reaches the position needing to execute the action according to the correct path. The above analysis shows that the method provided by the embodiment of the invention is valuable when verification is available.
Corresponding to the above method embodiment, the embodiment of the present invention further provides a program detection apparatus. As shown in fig. 12, the apparatus may include:
a wireless control instruction receiving unit 1201, configured to receive a wireless control instruction issued by another network node by a program running in the network node, where the program is preset with a first dynamic tag, the program is composed of n basic blocks, each basic block is provided with a first static tag and a second static tag, the first static tag is a first data value of binary data belonging to n +1 bits and used for identifying information of a current basic block, the second static tag is a second data value of binary data belonging to n +1 bits and used for identifying information of a subsequent basic block of the current basic block, the first dynamic tag is a third data value of binary data belonging to n +1 bits and is all 1 when initialized, and the subsequent basic block of the current basic block is: the next basic block adjacent to the current basic block in the program execution process;
a first-class operation result calculation unit 1202, configured to perform a logical and operation on a first static tag and a current first dynamic tag of a first basic block before executing an entry instruction of the first basic block to obtain a first-class operation result, where the first basic block is any basic block related to a response received instruction in n basic blocks in the program;
a first determining unit 1203, configured to determine whether the first type operation result is 0, if so, execute the first result determining unit 1204, otherwise, execute the first dynamic tag updating unit 1205;
the first result determining unit 1204 is configured to determine that a control flow error occurring inside a node occurs in the program;
the first dynamic tag updating unit 1205 is configured to update a current first dynamic tag according to the first type operation result;
a second dynamic tag determining unit 1206, configured to perform a logical or operation on a current second dynamic tag and a current first dynamic tag before executing an instruction at a predetermined position before an exit instruction of the first basic block to obtain a second type operation result, and update the current second dynamic tag according to the second type operation result, where the second dynamic tag is preset for the program, and the second dynamic tag is a fourth data value belonging to n + 1-bit binary data and is all set to 0 when initialized;
a second judging unit 1207, configured to, before executing an exit instruction of the first basic block, judge whether the first basic block is a special basic block, if the first basic block is judged to be the special basic block, execute a third judging unit 1208, and if the first basic block is judged not to be the special basic block, execute a fourth judging unit 1211;
the third determining unit 1208 is configured to determine whether the current second dynamic tag is equal to the instruction tag of the first basic block, if not, execute the second result determining unit 1209, and if so, execute the second dynamic tag initializing unit 1210, where the special basic block is a basic block used for performing an action, and the instruction tag is configured to pre-store a fifth data value of n + 1-bit binary data, which is inserted into the basic block along with arrival of the wireless control instruction and is passed through a path of the wireless control instruction issued by another network node when the wireless control instruction is executed in a program to be finally output;
the second result determination unit 1209, is used to determine that the program has a control flow error belonging to the communication process,
the second dynamic tag initialization unit 1210 initializes the current second dynamic tag after the exit instruction is executed, and triggers the fourth determination unit 1211;
a fourth determining unit 1211, configured to, when the exit instruction of the first basic block is executed, determine whether the first basic block is a last basic block related to the radio control instruction, if so, initialize a current first dynamic tag, if not, update the current first dynamic tag according to a second static tag of the first basic block, and trigger the first-class operation result calculating unit 1202 by using a next basic block in the basic block related to the radio control instruction as the first basic block.
Specifically, in n +1 bits of the first static tag, the highest bit is 0, the ith bit is 1, and the rest bits are 0, where i is the sequence bit of the current basic block in all the basic blocks;
in the n +1 bits of the second static label, the highest bit is 1, the mth bit is 1, the rest bits are 0, and m is the sequence bit of the successor basic block of the current basic block in all the basic blocks;
in the n +1 bits of the instruction tag, the highest bit is 0, the jth bit is 1, and the rest bits are 0, where j is the sequence bit of each basic block in all the basic blocks in the path traversed by the wireless control instruction when the wireless control instruction is executed to the final output in the program.
Specifically, the updating unit 1205 for updating the current first dynamic tag according to the first type of operation result includes:
determining the value of the first type of operation result as a current first dynamic label;
correspondingly, the second dynamic tag updating unit 1206 updates the current second dynamic tag according to the second type of operation result, including:
determining the value of the second type of operation result as a current second dynamic label; correspondingly, the updating of the current first dynamic tag by the fourth judging unit 1211 according to the second static tag of the first basic block includes:
determining the second static label of the first basic block as the current first dynamic label.
Specifically, the method of inserting an instruction for setting a tag into any basic block includes:
for the case where the current basic block is not a special basic block:
a test instruction is inserted before the entry instruction of the current basic block: if ((G ═ G)&Li) ═ 0) error; wherein G is a first dynamic tag, LiA first static label for a current basic block;
inserting an Update S instruction before an instruction of a predetermined position before an exit instruction of a current basic block: s ═ S | G; wherein S is a second dynamic tag;
inserting an Update G instruction after the exit instruction of the current basic block: g ═ Bi(ii) a Wherein B isiA second static label for the current basic block;
for the case where the current basic block is a special basic block:
entry in the current basic blockInsert test instruction before instruction: if ((G ═ G)&Li) ═ 0) error; wherein G is a first dynamic tag, LiA first static label for a current basic block;
inserting an Update S instruction before an instruction of a predetermined position before an exit instruction of a current basic block: s ═ S | G; wherein S is a second dynamic tag;
a test instruction is inserted before the exit instruction of the current basic block: if (S ≠ C) error, wherein C is an instruction tag;
inserting an Update S instruction after the exit instruction of the current basic block: s is 0;
inserting an Update G instruction after the exit instruction of the current basic block: g ═ Bi(ii) a Wherein B isiThe second static label of the current basic block.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The program detecting device of the embodiment of the invention sets the first dynamic label and the second dynamic label for the program operated by the network node in the wireless communication network, setting a first static label and a second static label for each basic block in the program, setting an instruction label for the issued wireless control instruction, and further, in the process of responding to the wireless control instruction, when any basic block is executed, whether a control flow error occurs inside the node is judged based on the two static tags and the first dynamic tag, and further, when executing the special basic block, judging whether a control flow error belonging to the communication process occurs or not based on two static tags, two dynamic tags and an instruction tag, to detect control flow errors in the communication process while detecting control flow errors occurring inside the nodes. Therefore, the method and the device can effectively detect the control flow error of the program in the network node in the process of responding to the wireless control command.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
Those skilled in the art will appreciate that all or part of the steps in the above method embodiments may be implemented by a program to instruct relevant hardware to perform the steps, and the program may be stored in a computer-readable storage medium, which is referred to herein as a storage medium, such as: ROM/RAM, magnetic disk, optical disk, etc.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (8)

1. A program detection method, characterized by being applied to a network node in a wireless communication network; the method comprises the following steps:
a program running in a network node receives a wireless control instruction issued by other network nodes, wherein the program is preset with a first dynamic tag, the program is composed of n basic blocks, each basic block is provided with a first static tag and a second static tag, the first static tag is used for identifying information of the current basic block and belongs to a first data value of n + 1-bit binary data, the second static tag is used for identifying information of a subsequent basic block of the current basic block and belongs to a second data value of n + 1-bit binary data, the first dynamic tag is a third data value of n + 1-bit binary data and is all 1 during initialization, and the subsequent basic block of the current basic block is: the next basic block adjacent to the current basic block in the program execution process;
before executing an entry instruction of a first basic block, performing logical AND operation on a first static tag and a current first dynamic tag of the first basic block to obtain a first class of operation result, wherein the first basic block is any basic block related to a response received instruction in n basic blocks in the program;
judging whether the first type operation result is 0, if so, determining that the program has control flow errors occurring in the node, otherwise,
updating a current first dynamic label according to the first type of operation result;
before executing an instruction of a predetermined position before an exit instruction of the first basic block, performing logical or operation on a current second dynamic tag and a current first dynamic tag to obtain a second type operation result, and updating the current second dynamic tag according to the second type operation result, wherein the second dynamic tag is preset for the program, is a fourth data value of binary data belonging to n +1 bits, and is all set to 0 during initialization;
before executing an exit instruction of the first basic block, judging whether the first basic block is a special basic block, if so, judging whether a current second dynamic label is equal to an instruction label of the first basic block, if not, determining that the program has a control flow error in a communication process, if so, initializing the current second dynamic label after the exit instruction is executed, wherein the special basic block is a basic block for executing actions, and the instruction label is used for pre-storing a path, which is passed by a wireless control instruction issued by other network nodes when the wireless control instruction is executed to the final output in the program, inserting the path into the basic block along with the arrival of the wireless control instruction, and belongs to a fifth data value of n + 1-bit binary data; when the exit instruction of the first basic block is executed, judging whether the first basic block is the last basic block related to the wireless control instruction, if so, initializing a current first dynamic tag, if not, updating the current first dynamic tag according to a second static tag of the first basic block, taking a next basic block in the basic block related to the wireless control instruction as the first basic block, and continuing to execute the step of performing logical AND operation on the first static tag of the first basic block and the current first dynamic tag before executing the entry instruction of the first basic block to obtain a first type of operation result.
2. The method according to claim 1, wherein the highest bit of the n +1 bits of the first static tag is 0, the ith bit is 1, and the rest bits are 0, wherein i is the sequential bit of the current basic block in all basic blocks;
in the n +1 bits of the second static label, the highest bit is 1, the mth bit is 1, the rest bits are 0, and m is the sequence bit of the successor basic block of the current basic block in all the basic blocks;
in the n +1 bits of the instruction tag, the highest bit is 0, the jth bit is 1, and the rest bits are 0, where j is the sequence bit of each basic block in all the basic blocks in the path traversed by the wireless control instruction when the wireless control instruction is executed to the final output in the program.
3. The method of claim 1, wherein updating the current first dynamic tag according to the result of the first type of operation comprises:
determining the value of the first type of operation result as a current first dynamic label;
correspondingly, the updating the current second dynamic tag according to the second type of operation result includes:
determining the value of the second type of operation result as a current second dynamic label; correspondingly, the updating the current first dynamic tag according to the second static tag of the first basic block includes:
determining the second static label of the first basic block as the current first dynamic label.
4. A method according to any of claims 1-3, wherein inserting instructions for setting tags in any basic block comprises:
for the case where the current basic block is not a special basic block:
a test instruction is inserted before the entry instruction of the current basic block: if ((G ═ G)&Li) ═ 0) error; wherein G is a first dynamic tag, LiA first static label for a current basic block;
inserting an Update S instruction before an instruction of a predetermined position before an exit instruction of a current basic block: s ═ S | G; wherein S is a second dynamic tag;
inserting an Update G instruction after the exit instruction of the current basic block: g ═ Bi(ii) a Wherein B isiA second static label for the current basic block;
for the case where the current basic block is a special basic block:
a test instruction is inserted before the entry instruction of the current basic block: if ((G ═ G)&Li) ═ 0) error; wherein G is a first dynamic tag, LiA first static label for a current basic block;
inserting an Update S instruction before an instruction of a predetermined position before an exit instruction of a current basic block: s ═ S | G; wherein S is a second dynamic tag;
a test instruction is inserted before the exit instruction of the current basic block: if (S ≠ C) error, wherein C is an instruction tag;
inserting an Update S instruction after the exit instruction of the current basic block: s is 0;
inserting an Update G instruction after the exit instruction of the current basic block: g ═ Bi(ii) a Wherein B isiThe second static label of the current basic block.
5. A program detection apparatus, for application to a network node in a wireless communication network; the device comprises:
a wireless control instruction receiving unit, configured to receive a wireless control instruction issued by another network node by a program running in the network node, where the program is preset with a first dynamic tag, the program is composed of n basic blocks, each basic block is provided with a first static tag and a second static tag, the first static tag is a first data value of binary data belonging to n +1 bits and used for identifying information of a current basic block, the second static tag is a second data value of binary data belonging to n +1 bits and used for identifying information of a subsequent basic block of the current basic block, the first dynamic tag is a third data value of binary data belonging to n +1 bits and is all 1 when initialized, and the subsequent basic block of the current basic block is: the next basic block adjacent to the current basic block in the program execution process;
a first-class operation result calculation unit, configured to perform a logical and operation on a first static tag and a current first dynamic tag of a first basic block before executing an entry instruction of the first basic block to obtain a first-class operation result, where the first basic block is any basic block related to a response received instruction in n basic blocks in the program;
the first judging unit is used for judging whether the first type of operation result is 0 or not, if so, the first result determining unit is executed, and if not, the first dynamic label updating unit is executed;
the first result determining unit is used for determining that the program has control flow errors which occur in nodes;
the first dynamic label updating unit is used for updating a current first dynamic label according to the first type of operation result;
a second dynamic tag determination unit, configured to perform a logical or operation on a current second dynamic tag and a current first dynamic tag before executing an instruction at a predetermined position before an exit instruction of the first basic block to obtain a second type operation result, and update the current second dynamic tag according to the second type operation result, where the second dynamic tag is preset for the program, and the second dynamic tag is a fourth data value belonging to n + 1-bit binary data and is set to 0 when initialized;
a second judging unit, configured to judge whether the first basic block is a special basic block before executing an exit instruction of the first basic block, execute a third judging unit if the first basic block is judged to be the special basic block, and execute a fourth judging unit if the first basic block is judged not to be the special basic block;
the third judging unit is configured to judge whether a current second dynamic tag is equal to an instruction tag of the first basic block, if not, execute the second result determining unit, and if so, execute the second dynamic tag initializing unit, where the special basic block is a basic block used for executing an action, and the instruction tag is used to pre-store a path that the wireless control instruction issued by another network node passes through when being executed in a program to be finally output, is inserted into the basic block along with arrival of the wireless control instruction, and belongs to a fifth data value of n + 1-bit binary data;
the second result determination unit is used for determining that the program has a control flow error belonging to the communication process,
the second dynamic label initialization unit initializes the current second dynamic label after the exit instruction is executed, and triggers the fourth judgment unit;
a fourth determining unit, configured to determine, when the exit instruction of the first basic block is executed, whether the first basic block is a last basic block related to the wireless control instruction, if yes, initialize a current first dynamic tag, if not, update the current first dynamic tag according to a second static tag of the first basic block, and trigger the first-class operation result calculating unit by using a next basic block in the basic blocks associated with the wireless control instruction as the first basic block.
6. The apparatus according to claim 5, wherein the highest bit of the n +1 bits of the first static tag is 0, the ith bit is 1, and the rest bits are 0, wherein i is the sequential bit of the current basic block in all basic blocks;
in the n +1 bits of the second static label, the highest bit is 1, the mth bit is 1, the rest bits are 0, and m is the sequence bit of the successor basic block of the current basic block in all the basic blocks;
in the n +1 bits of the instruction tag, the highest bit is 0, the jth bit is 1, and the rest bits are 0, where j is the sequence bit of each basic block in all the basic blocks in the path traversed by the wireless control instruction when the wireless control instruction is executed to the final output in the program.
7. The apparatus of claim 5, wherein the first dynamic tag updating unit updates the current first dynamic tag according to the first type of operation result, and comprises:
determining the value of the first type of operation result as a current first dynamic label;
correspondingly, the updating the current second dynamic tag by the second dynamic tag updating unit according to the second type of operation result includes:
determining the value of the second type of operation result as a current second dynamic label;
correspondingly, the updating, by the fourth determining unit, the current first dynamic tag according to the second static tag of the first basic block includes:
determining the second static label of the first basic block as the current first dynamic label.
8. The apparatus according to any one of claims 5-7, wherein the manner of inserting the instruction for setting the tag in any basic block comprises:
for the case where the current basic block is not a special basic block:
a test instruction is inserted before the entry instruction of the current basic block: if ((G ═ G)&Li) ═ 0) error; wherein G is a first dynamic tag, LiA first static label for a current basic block;
inserting an Update S instruction before an instruction of a predetermined position before an exit instruction of a current basic block: s ═ S | G; wherein S is a second dynamic tag;
inserting an Update G instruction after the exit instruction of the current basic block: g ═ Bi(ii) a Wherein B isiA second static label for the current basic block;
for the case where the current basic block is a special basic block:
a test instruction is inserted before the entry instruction of the current basic block: if ((G ═ G)&Li) ═ 0) error; wherein G is a first dynamic tag, LiA first static label for a current basic block;
inserting an Update S instruction before an instruction of a predetermined position before an exit instruction of a current basic block: s ═ S | G; wherein S is a second dynamic tag;
a test instruction is inserted before the exit instruction of the current basic block: if (S ≠ C) error, wherein C is an instruction tag;
inserting an Update S instruction after the exit instruction of the current basic block: s is 0;
inserting an Update G instruction after the exit instruction of the current basic block: g ═ Bi(ii) a Wherein B isiThe second static label of the current basic block.
CN201610075249.8A 2016-02-03 2016-02-03 Program detection method and device Expired - Fee Related CN107038084B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610075249.8A CN107038084B (en) 2016-02-03 2016-02-03 Program detection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610075249.8A CN107038084B (en) 2016-02-03 2016-02-03 Program detection method and device

Publications (2)

Publication Number Publication Date
CN107038084A CN107038084A (en) 2017-08-11
CN107038084B true CN107038084B (en) 2021-04-13

Family

ID=59532232

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610075249.8A Expired - Fee Related CN107038084B (en) 2016-02-03 2016-02-03 Program detection method and device

Country Status (1)

Country Link
CN (1) CN107038084B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107656828B (en) * 2017-08-28 2021-03-26 龙芯中科技术股份有限公司 Method and device for detecting program running deviation path
CN110806972A (en) * 2019-10-10 2020-02-18 南京航空航天大学 Control flow error detection method based on basic block repartitioning
CN116450402B (en) * 2023-06-15 2023-08-18 北京智芯微电子科技有限公司 Program flow monitoring method, compiling device, processor and computer equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101763291A (en) * 2009-12-30 2010-06-30 中国人民解放军国防科学技术大学 Method for detecting error of program control flow
US7761742B2 (en) * 2004-09-20 2010-07-20 International Business Machines Corporation Monitoring system with trusted corrective actions
CN101944064A (en) * 2010-10-12 2011-01-12 中国人民解放军国防科学技术大学 Control flow error detection optimizing method based on reconstructed control flow graph
CN104461886A (en) * 2014-12-10 2015-03-25 深圳航天东方红海特卫星有限公司 Control flow error detection method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9009535B2 (en) * 2012-08-16 2015-04-14 International Business Machines Corporation Anomaly detection at the level of run time data structures

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7761742B2 (en) * 2004-09-20 2010-07-20 International Business Machines Corporation Monitoring system with trusted corrective actions
CN101763291A (en) * 2009-12-30 2010-06-30 中国人民解放军国防科学技术大学 Method for detecting error of program control flow
CN101944064A (en) * 2010-10-12 2011-01-12 中国人民解放军国防科学技术大学 Control flow error detection optimizing method based on reconstructed control flow graph
CN104461886A (en) * 2014-12-10 2015-03-25 深圳航天东方红海特卫星有限公司 Control flow error detection method

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
"Android的应用程序安全评估系统设计";李铮山,林干,范文浩,吴帆;《SOFTWARE》;20121231;第33卷(第12期);第287-291页 *
"一种基于虚拟基本块和格式化标签的控制流检测方法";李建立等;《计算机学报》;20141130;第37卷(第11期);第2287-2297页 *
"无线通信及相关电磁兼容性问题";刘元安;《电子科技导报》;19991031(第10期);第6-9页 *

Also Published As

Publication number Publication date
CN107038084A (en) 2017-08-11

Similar Documents

Publication Publication Date Title
US8312440B2 (en) Method, computer program product, and hardware product for providing program individuality analysis for source code programs
US7529653B2 (en) Message packet logging in a distributed simulation system
CN107038084B (en) Program detection method and device
CN113572726B (en) Multimode network control-data plane consistency verification method and device
Garmabaki et al. Multi up-gradation software reliability growth model with faults of different severity
CN103049374B (en) Automatic testing method and device
CN103914374A (en) Program slicing and frequent pattern extraction based code defect detection method and device
CN109102138B (en) Abnormal segment extraction method for workflow network inspection, readable storage medium and terminal
CN112241370B (en) API interface class checking method, system and device
Zaman et al. Prefix imputation of orphan events in event stream processing
CN110286912B (en) Code detection method and device and electronic equipment
US11586976B2 (en) Method and apparatus for creating tests for execution in a storage environment
CN111488276A (en) Software reliability testing method and device based on code tracking
CN116185853A (en) Code verification method and device
US20220091968A1 (en) System and method for automated generation of test cases and test data for validating a software application
CN110297926A (en) The spaceborne in-orbit configuration method of image processing apparatus
CN115756394A (en) Embedded software requirement safety verification method by means of failure data
CN115904997A (en) Intelligent assessment replay test method based on deep learning
CN111782553B (en) Software reaction defect analysis method based on fault injection
CN112395198B (en) Software defect discovery method based on differential subgraph mining
CN108519950A (en) Terminal, the fault detection method of application software and its device and readable storage medium storing program for executing
Morvan et al. Diagnosability of pushdown systems
Kheddam et al. Online monitoring and diagnosis of RFID readers and tags
US11956117B1 (en) Network monitoring and healing based on a behavior model
US7475369B1 (en) Eliminate false passing of circuit verification through automatic detecting of over-constraining in formal verification

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20210413

Termination date: 20220203

CF01 Termination of patent right due to non-payment of annual fee