CN110908819A - Method and device for locating code operation crash, terminal and memory - Google Patents

Method and device for locating code operation crash, terminal and memory Download PDF

Info

Publication number
CN110908819A
CN110908819A CN201811085437.4A CN201811085437A CN110908819A CN 110908819 A CN110908819 A CN 110908819A CN 201811085437 A CN201811085437 A CN 201811085437A CN 110908819 A CN110908819 A CN 110908819A
Authority
CN
China
Prior art keywords
function
identification
character
monitored
macro
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.)
Granted
Application number
CN201811085437.4A
Other languages
Chinese (zh)
Other versions
CN110908819B (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.)
Qianxun Spatial Intelligence Inc
Original Assignee
Qianxun Spatial Intelligence Inc
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 Qianxun Spatial Intelligence Inc filed Critical Qianxun Spatial Intelligence Inc
Priority to CN201811085437.4A priority Critical patent/CN110908819B/en
Publication of CN110908819A publication Critical patent/CN110908819A/en
Application granted granted Critical
Publication of CN110908819B publication Critical patent/CN110908819B/en
Active 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/0766Error or fault reporting or storing
    • G06F11/0778Dumping, i.e. gathering error/state information after a fault for later diagnosis
    • 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/079Root cause analysis, i.e. error or fault diagnosis
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention is suitable for the technical field of computers, and provides a method and a device for locating code operation crash, a terminal and a memory, wherein the method for locating code operation crash comprises the following steps: setting an association function associated with the positioning identifier; executing the logic of the correlation function when the function to be monitored runs, and acquiring a corresponding character string identifier; and analyzing whether the crash occurs and the position of the crash according to the character string identification. In the invention, the character string identification is generated according to the logic of the correlation function, and then the occurrence of the crash and the occurrence position thereof are analyzed, so that the method has universality and can be seamlessly integrated on different operating systems.

Description

Method and device for locating code operation crash, terminal and memory
Technical Field
The invention belongs to the technical field of computers, and particularly relates to a method and a device for locating code operation crash, a terminal and a memory.
Background
In some embedded devices, the functions of an operating system used in particular are not so powerful, and the operating system does not provide stack information when tracking crash (crash); even on similar single-chip computers without operating systems. When crash occurs, no stack system is available for analysis and investigation, so that vulnerability (bug) solving becomes very difficult.
The prior art has various modes for capturing the crash stack, and different modes of the system cause difficulty in development. Some signals (signals) that cause crash cannot be captured, so even with a capture crash mechanism, crash cannot be captured in some cases. Especially some embedded devices have no crash stack capture mechanism at all, so problems occur and it is not known where the problem occurs at all.
The existing method of logging (log) also has limitations, especially for embedded devices, such as too large size, difficult size control, limited memory of embedded devices, and generally each log statement has more than dozens of bytes, which affects the embedded performance; in addition, in software development, log is not marked basically in release products. The problem of Release is not applicable in this way
Disclosure of Invention
The embodiment of the invention provides a method and a device for positioning code operation crash, a terminal and a memory, and aims to solve the problems that when a code crashes, the occurrence point of the crash, the context before and after the crash and the analysis of the code are convenient in the prior art.
A method of locating a code run crash, comprising:
setting an association function associated with the positioning identifier;
executing the logic of the correlation function when the function to be monitored runs, and acquiring a corresponding character string identifier;
and analyzing whether the crash occurs and the position of the crash according to the character string identification.
Preferably, the setting of the association function associated with the positioning identifier specifically includes:
defining an identification macro as the positioning identification;
adding the identification macro in the function to be monitored;
replacing the identification macro in the function to be monitored with the correlation function.
Preferably, the definition identifier macro is used as the positioning identifier, and specifically includes: defining a first identification macro, a second identification macro and a third identification macro as null by the macro in the public header file;
the adding the identification macro in the function to be monitored specifically includes: the first identification macro is marked on the entry point of the function to be monitored, the second identification macro is marked on the exit point of the function to be monitored, and any third identification macro is marked between the entry point and the exit point of the function to be monitored;
the replacing the identification macro in the function to be monitored with the association function specifically includes: and respectively replacing the first identification macro, the second identification macro and the third identification macro with the association functions of different variables.
Preferably, the logic for executing the association function when the function to be monitored runs and acquiring the corresponding character string identifier specifically include:
when the function to be monitored runs to the first identification macro, writing a first character at a position corresponding to the character string identification;
when the function to be monitored runs to the second identification macro, writing a second character at the position corresponding to the character string identification;
when the function to be monitored runs to the third identification macro, writing a third character in the corresponding position of the character string identification;
and writing a fourth character at the corresponding position of the character string identifier at the identifier macro where the function to be monitored does not run.
Preferably, the executing the logic of the association function when the function to be monitored runs and acquiring the corresponding character string identifier further includes:
when the character string mark repeatedly appears in the first character, all characters between the first previous character and the corresponding second character are cleared.
Preferably, the analyzing whether a crash occurs and a location of the crash according to the character string identifier further includes:
traversing the character string identification;
when the first character is found, if the second character is not found later or another first character appears, the first character is interpreted to be crashed;
and if another first character appears after the first character is found, the function to be monitored, in which the previous first character is located, is crashed.
Preferably, the replacing the first identification macro, the second identification macro, and the third identification macro with the association functions of different variables respectively includes:
setting a global variable n;
if any identification macro is encountered, n is added with 1;
replacing the first identification macro with the association function with a variable of 10000+ n, replacing the second identification macro with the association function with a variable of-n, and replacing the third identification macro with the association function with a variable of n.
Preferably, the logic for executing the association function when the function to be monitored runs and acquiring the corresponding character string identifier specifically include:
when the function to be monitored runs to the correlation function with the variable larger than 10000, writing's' at the corresponding position of the character string identification;
when the function to be monitored runs to the correlation function with the variable less than 0, 'e' is written at the corresponding position of the character string identifier;
when the function to be monitored runs to the correlation function between the variables 0 to 10000, '1' is written at the corresponding position of the character string identifier;
and writing '0' in the corresponding position of the character string identifier at the identification macro where the function to be monitored does not run.
The invention also provides a device for positioning code operation crash, which is characterized by comprising the following components:
the setting unit is used for setting an association function associated with the positioning identifier;
the execution unit is connected with the setting unit and used for executing the logic of the association function when the function to be monitored runs and acquiring the corresponding character string identifier;
and the analysis unit is connected with the execution unit and used for analyzing whether the character string is broken down or not and the position of the broken down according to the character string identification.
The present invention also provides a memory storing a computer program, wherein the computer program is executed by a processor to perform the steps of:
setting an association function associated with the positioning identifier;
executing the logic of the correlation function when the function to be monitored runs, and acquiring a corresponding character string identifier;
and analyzing whether the crash occurs and the position of the crash according to the character string identification.
The invention also provides a terminal, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor executes the computer program to realize the following steps:
setting an association function associated with the positioning identifier;
executing the logic of the correlation function when the function to be monitored runs, and acquiring a corresponding character string identifier;
and analyzing whether the crash occurs and the position of the crash according to the character string identification.
In the embodiment of the invention, the character string identification is generated according to the logic of the correlation function, and then the occurrence of the crash and the occurrence position thereof are analyzed, so that the method has universality and can be seamlessly integrated on different operating systems.
Drawings
FIG. 1 is a flowchart of a method for locating a code crash according to a first embodiment of the present invention;
FIG. 2 is a flowchart of a preferred embodiment of a method for locating a code crash according to a first embodiment of the present invention;
FIG. 3 is a block diagram of an apparatus for locating a code crash according to a second embodiment of the present invention;
FIG. 4 is a block diagram of a preferred embodiment of an apparatus for locating code crash in accordance with the present invention;
fig. 5 is a block diagram of a terminal according to a fourth embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
In an embodiment of the present invention, a method for locating a code operation crash includes: setting an association function associated with the positioning identifier; executing the logic of the correlation function when the function to be monitored runs, and acquiring a corresponding character string identifier; and analyzing whether the crash occurs and the position of the crash according to the character string identification.
In order to explain the technical means of the present invention, the following description will be given by way of specific examples.
The first embodiment is as follows:
fig. 1 is a flowchart illustrating a method for locating a code running crash according to a first embodiment of the present invention, where the method includes:
step S1, setting an association function associated with the positioning identification;
a crash (crash) must occur within a certain function. Specifically, a plurality of positioning identifiers are set in the function to be monitored, and variables of the association function are set to be associated with the positioning identifiers, such as an entry point, an exit point, and an intermediate point between the entry point and the exit point of the function to be monitored.
Step S2, executing the logic of the correlation function when the function to be monitored runs, and acquiring the corresponding character string identification;
specifically, when the function to be monitored runs to any positioning identifier, the value of the variable associated with the positioning identifier is obtained, and then the logic of the associated function is executed according to the variable to obtain the character at the corresponding position in the character string identifier.
Step S3, analyzing whether the character string is broken down and the broken down position according to the character string identification;
specifically, a function entry point that is operating normally must correspond to an exit point. If no character indicating the exit point of the function to be monitored exists behind the character indicating the entry point of the function to be monitored in the character string identifier or another character indicating the entry point of the function to be monitored exists behind the character indicating the entry point of the function to be monitored, the crash is indicated. If a character indicating the entry point of the function to be monitored is followed by another character indicating the entry point of the function to be monitored in the character string identifier, the crash occurs in the previous function to be monitored. And in the operation starting stage, the character string identification recorded in the last operation is analyzed, and the traversal is performed once, so that the problem point of the crash can be remotely monitored even if the version is formally sent out.
In the embodiment, the character string identification is generated according to the logic of the association function, and then the occurrence of the crash and the occurrence position thereof are analyzed, so that the method has universality and can be seamlessly integrated on different operating systems.
In a preferable embodiment of this embodiment (see fig. 2), the step S1 specifically includes:
step S10, defining an identification macro as the positioning identification;
specifically, the macro defines a first identification macro BRKS _, a second identification macro BRKE _, and a third identification macro BRK _ as null in the common header file. To ensure that compilation does not report errors, a macro definition like # define BRK _ # define BRKS _ # define BRKE _ is defined in a common header file within the project.
Step S11, adding the identification macro in the function to be monitored;
specifically, the first identification macro BRKS _ is marked at an entry point of the function to be monitored, the second identification macro BRKE _ is marked at an exit point of the function to be monitored, and any number of the third identification macrosbrks _ are marked between the entry point and the exit point of the function to be monitored. The more the third identification macro BRK _ is set between the entry point and the exit point of the function to be monitored, the more accurate the positioning is.
Step S12, replace the identification macro in the function to be monitored with the correlation function.
Specifically, the first identification macro BRKS _, the second identification macro BRKE _, and the third identification macro BRK _ are respectively replaced with the association functions of different variables. Before issuing and packaging the code out of the library, replacing a first identification macro BRKS _/a second identification macro BRKE _/a third identification macro BRK _ in the code with an association function BRK (i) through an external script, wherein i is a number.
More specifically: the c files are uniquely ordered according to names, each file is traversed according to the sequence, and key character strings of BRK (binary key K)/BRKS (binary key K)/BRKE (binary key K) are searched. Setting a global variable n, wherein the initial value is 0; if any identification macro is encountered, n is added with 1; replacing the first identification macro BRKS _ with the correlation function with a variable of 10000+ n, replacing the second identification macro BRKE _ with the correlation function with a variable of-n, and replacing the third identification macro BRK _ with the correlation function with a variable of n. Namely, changing BRKS _ to BRK (100000+ n), BRK _ to BRK (n), BRKE _ to BRK (-n); therefore, the analysis is convenient, when the point is more than 10000, the points are all the entry points of the function to be monitored, the point less than 0 is the exit point of the function to be monitored, and the other points belong to the points between the entry points and the exit point.
In a preferred embodiment of this embodiment, in step S2, the logic of the association function is executed according to the variables associated with the first identification macro BRKS _/the second identification macro BRKE _/the third identification macro BRK _, and the corresponding string identification is obtained. The step S2 specifically includes: when the function to be monitored runs to the first identification macro BRKS _ position, writing a first character at a position corresponding to the character string identification; when the function to be monitored runs to the second identification macro BRKE _ position, writing a second character in the corresponding position of the character string identification; when the function to be monitored runs to the third identification macro BRK _ position, writing a third character in the corresponding position of the character string identification; and writing a fourth character at the corresponding position of the character string identifier at the identifier macro where the function to be monitored does not run.
More specifically, a function, such as the function void BRK (int k) { xxx }, is defined in the code, and the function is to analyze whether the current point is an entry point, an exit point or an intermediate point of the entry point and the exit point when the association function BRK (i) is executed, and then record the current point on the corresponding character of the character string. When the function to be monitored runs to the correlation function with the variable larger than 10000, writing's' at the corresponding position of the character string identification; when the function to be monitored runs to the correlation function with the variable less than 0, 'e' is written at the corresponding position of the character string identifier; when the function to be monitored runs to the correlation function between the variables 0 to 10000, '1' is written at the corresponding position of the character string identifier; and writing '0' in the corresponding position of the character string identifier at the identification macro where the function to be monitored does not run. In other embodiments of the present invention, the first character, the second character, the third character and the fourth character may also be set as other different characters, which is not limited herein.
In terms of C engineering, the file name of each x.c file is unique, so that the x.c installation file names can be ordered, and i in the association function brk (i) can be fixed. Each association function BRK (i) corresponds to a character in the file, wherein the character s/e/1 represents that the file is operated, and the character 0 represents that the file is not operated; since the function entry point and exit point are special, the character s represents the entry point and the character e represents the exit point. The file records thus run like this s00e00s1111e 000. For example, BRK (100001) runs to find the entry point, write's' at the first character in the string, write '1' at the third character if BRK (2), and write 'e' at the third character if BRK (-3); such a string is finally formed like sle0000.
The step S3 specifically includes: traversing the character string identification; when the first character is found, if the second character is not found later or another first character appears, the first character is interpreted to be crashed; and if another first character appears after the first character is found, the function to be monitored, in which the previous first character is located, is crashed. More specifically, if the character is found to be's', the character is found backwards, and if 'e' is not found later or another's' appears later, it indicates that crash occurs inside the function to be monitored, which is's'. For example, the string id of s00s11e, we find that the first s is followed by another s instead of e, indicating that crash occurs in the function where the previous s is located. For example, s111s100e, if it is found that's' occurs after the first's', and no corresponding 'e' is found, crash occurs in the function to be monitored in which the first's' is located, i.e., the function to be monitored in the statement BRK (100001), and further occurs after the 4 th point, i.e., the statement BRK (4). Since the fourth point is 1, it indicates that the BRK (4) is operating normally.
It should be noted that, in step S3, when the character string identifier repeatedly appears in the first character, all characters between the first previous first character and the corresponding second character are cleared. For example, at the time of encoding, when at the time of entry point s, the mark between s and the following e is completely cleared when the previous run is found. For example, when the BRK is run for the second time (100001), and the first position is found to be's', the identifier between the first s and the following e of the s1e0000 … character string is cleared to become 0000000 …, and then the first position is identified as s to become s000000 …. This is because crash may occur when a function runs the nth time. The character string identification needs to reflect the last clearing, and the last analysis cannot be influenced by the identification which normally operates last time. As such, little space overhead is required. Unlike printf records that if a function is frequently called, the log printed in the function has many repeated records, even if the association function brk (i) is run 1000 times, the index (index) in the string identifier corresponding to the file is 1, 0, s, e, and only one character space is occupied.
The method for locating the code running crash does not need a specific language, and any language can realize the energy supply. But c language is more appropriate when running on embedded devices.
In the embodiment, the character string identification is generated according to the logic of the association function, and then the occurrence and the occurrence position of the crash are analyzed, so that the method has universality and is independent of an operating system or hardware, the system function independent of a specific platform is realized, and seamless integration can be realized on different operating systems.
Second, even when an uncollected signal that causes the crash occurs, the context of the crash stack can be recorded, thereby quickly locating the problem.
Furthermore, the required space overhead is small. One print dot occupies only one character, and generally, small and medium-sized software estimates that 1000 characters (about 1 kb) are almost sufficient. In addition, the same printing point runs n (n ═ 1) times, and only 1 byte is occupied, and one of characters of '1', '0','s', 'e' is displayed.
Example two:
as shown in fig. 3, a block diagram of an apparatus for locating a code crash according to a second embodiment of the present invention includes: setting unit 1, execution unit 2 connected with setting unit 1, analysis unit 3 connected with execution unit 2, wherein:
a setting unit 1, configured to set an association function associated with the positioning identifier;
specifically, a crash (crash) must occur within a certain function. Specifically, a plurality of positioning identifiers are set in the function to be monitored, and variables of the association function are set to be associated with the positioning identifiers, such as an entry point, an exit point, and an intermediate point between the entry point and the exit point of the function to be monitored.
The execution unit 2 is used for executing the logic of the association function when the function to be monitored runs and acquiring a corresponding character string identifier;
specifically, when the function to be monitored runs to any positioning identifier, the value of the variable associated with the positioning identifier is obtained, and then the logic of the associated function is executed according to the variable to obtain the character at the corresponding position in the character string identifier.
The analysis unit 3 is used for analyzing whether the character string is broken down or not and the broken down position according to the character string identification;
specifically, a function entry point that is operating normally must correspond to an exit point. If no character indicating the exit point of the function to be monitored exists behind the character indicating the entry point of the function to be monitored in the character string identifier or another character indicating the entry point of the function to be monitored exists behind the character indicating the entry point of the function to be monitored, the crash is indicated. If a character indicating the entry point of the function to be monitored is followed by another character indicating the entry point of the function to be monitored in the character string identifier, the crash occurs in the previous function to be monitored. And in the operation starting stage, the character string identification recorded in the last operation is analyzed, and the traversal is performed once, so that the problem point of the crash can be remotely monitored even if the version is formally sent out.
In the embodiment, the character string identification is generated according to the logic of the association function, and then the occurrence of the crash and the occurrence position thereof are analyzed, so that the method has universality and can be seamlessly integrated on different operating systems.
In a preferred aspect of the present embodiment, referring to fig. 4, the setting unit 1 includes: a macro definition unit 10, a macro adding unit 11 connected to the macro definition unit 10, and a macro replacing unit 12 connected to the macro adding unit 11, wherein:
a macro definition unit 10, configured to define an identification macro as the positioning identification;
specifically, the macro defines a first identification macro BRKS _, a second identification macro BRKE _, and a third identification macro BRK _ as null in the common header file. To ensure that compilation does not report errors, a macro definition like # define BRK _ # define BRKS _ # define BRKE _ is defined in a common header file within the project.
A macro adding unit 11, configured to add the identification macro to the function to be monitored;
specifically, the first identification macro BRKS _ is marked at an entry point of the function to be monitored, the second identification macro BRKE _ is marked at an exit point of the function to be monitored, and any number of the third identification macrosbrks _ are marked between the entry point and the exit point of the function to be monitored. The more the third identification macro BRK _ is set between the entry point and the exit point of the function to be monitored, the more accurate the positioning is.
A macro replacing unit 12, configured to replace the identification macro in the function to be monitored with the association function.
Specifically, the first identification macro BRKS _, the second identification macro BRKE _, and the third identification macro BRK _ are respectively replaced with the association functions of different variables. Before issuing and packaging the code out of the library, replacing a first identification macro BRKS _/a second identification macro BRKE _/a third identification macro BRK _ in the code with an association function BRK (i) through an external script, wherein i is a number.
More specifically: the c files are uniquely ordered according to names, each file is traversed according to the sequence, and key character strings of BRK (binary key K)/BRKS (binary key K)/BRKE (binary key K) are searched. Setting a global variable n, wherein the initial value is 0; if any identification macro is encountered, n is added with 1; replacing the first identification macro BRKS _ with the correlation function with a variable of 10000+ n, replacing the second identification macro BRKE _ with the correlation function with a variable of-n, and replacing the third identification macro BRK _ with the correlation function with a variable of n. Namely, changing BRKS _ to BRK (100000+ n), BRK _ to BRK (n), BRKE _ to BRK (-n); therefore, the analysis is convenient, when the point is more than 10000, the points are all the entry points of the function to be monitored, the point less than 0 is the exit point of the function to be monitored, and the other points belong to the points between the entry points and the exit point.
In a preferred embodiment of this embodiment, the execution unit 2 executes the logic of the association function according to the variables associated with the first identification macro BRKS _/the second identification macro BRKE _/the third identification macro BRK _, and obtains the corresponding string identification. The method specifically comprises the following steps: when the function to be monitored runs to the first identification macro BRKS _ position, the execution unit 2 writes a first character at the corresponding position of the character string identification; when the function to be monitored runs to the second identification macro BRKE _ position, the execution unit 2 writes a second character at the corresponding position of the character string identification; when the function to be monitored runs to the third identification macro BRK _ position, the execution unit 2 writes a third character at the corresponding position of the character string identification; and at the identification macro where the function to be monitored does not run, the execution unit 2 writes a fourth character at a corresponding position of the character string identification.
More specifically, a function, such as the function void BRK (int k) { xxx }, is defined in the code, and the function is to analyze whether the current point is an entry point, an exit point or an intermediate point of the entry point and the exit point when the association function BRK (i) is executed, and then record the current point on the corresponding character of the character string. When the function to be monitored runs to the correlation function with the variable larger than 10000, the execution unit 2 writes's' at the corresponding position of the character string identifier; when the function to be monitored runs to the correlation function with the variable less than 0, the execution unit 2 writes 'e' at the corresponding position of the character string identifier; when the function to be monitored runs to the correlation function between the variables 0 to 10000, the execution unit 2 writes '1' at the corresponding position of the character string identifier; and at the identified macro where the function to be monitored does not run, the execution unit 2 writes '0' at the corresponding position of the character string identification. In other embodiments of the present invention, the first character, the second character, the third character and the fourth character may also be set as other different characters, which is not limited herein.
In terms of C engineering, the file name of each x.c file is unique, so that the x.c installation file names can be ordered, and i in the association function brk (i) can be fixed. Each association function BRK (i) corresponds to a character in the file, wherein the character s/e/1 represents that the file is operated, and the character 0 represents that the file is not operated; since the function entry point and exit point are special, the character s represents the entry point and the character e represents the exit point. The file records thus run like this s00e00s1111e 000. For example, BRK (100001) runs to find the entry point, write's' at the first character in the string, write '1' at the third character if BRK (2), and write 'e' at the third character if BRK (-3); such a string is finally formed like s1e0000.
The analysis unit 3 traverses the character string identification; when the first character is found, if the second character is not found later or another first character appears, the first character is interpreted to be crashed; and if another first character appears after the first character is found, the function to be monitored, in which the previous first character is located, is crashed.
More specifically, the analysis unit 3 finds a character's' later, and if 'e' is not found later or another's' appears later, it indicates that crash occurs inside the's' function to be monitored. For example, s111s100e, if the analysis unit 3 finds that's' occurs after the first's', but does not find the corresponding 'e', then crash occurs in the function to be monitored in which the first's' is located, i.e., the function to be monitored in the statement BRK (100001), and further occurs after the 4 th point, i.e., the statement BRK (4). Since the fourth point is 1, it indicates that the BRK (4) is operating normally.
It should be noted that, when the character string identifier repeatedly appears in the first character, the analysis unit 3 clears all characters between the first previous character and the corresponding second character. For example, at the time of encoding, when the analysis unit 3 finds that it has run before at the time of entry point s, the flag between s and the following e is completely cleared. For example, when the BRK is run for the second time (100001), the parsing unit 3 finds that the first position is already's', clears the mark between the first s and the following e of the sle0000 … character string to 0000000 …, and then marks the first position as s to become s000000 …. This is because crash may occur when a function runs the nth time. The character string identification needs to reflect the last clearing, and the last analysis cannot be influenced by the identification which normally operates last time. As such, little space overhead is required. Unlike printf records that if a function is frequently called, the log printed in the function has many repeated records, even if the association function brk (i) is run 1000 times, the index (index) in the string identifier corresponding to the file is 1, 0, s, e, and only one character space is occupied.
The method for locating the code running crash does not need a specific language, and any language can realize the energy supply. But c language is more appropriate when running on embedded devices.
In the embodiment, the character string identification is generated according to the logic of the association function, and then the occurrence and the occurrence position of the crash are analyzed, so that the method has universality and is independent of an operating system or hardware, the system function independent of a specific platform is realized, and seamless integration can be realized on different operating systems.
Second, even when an uncollected signal that causes the crash occurs, the context of the crash stack can be recorded, thereby quickly locating the problem.
Furthermore, the required space overhead is small. One print dot occupies only one character, and generally, small and medium-sized software estimates that 1000 characters (about 1 kb) are almost sufficient. In addition, the same printing point runs n (n ═ 1) times, and only 1 byte is occupied, and one of characters of '1', '0','s', 'e' is displayed.
Example three:
fig. 5 is a block diagram of a terminal according to a third embodiment of the present invention, where the terminal includes: a memory (memory)51, a processor (processor)52 and a communication bus 53, wherein the processor 52 and the memory 51 are mutually communicated through the communication bus 53.
A memory 51 for storing various data;
in particular, the memory 51 is used for storing various data, such as data during a crash of the operation of the positioning code, received data, etc., and is not limited herein, and the memory further includes a plurality of computer programs.
The processor 52 is used for calling various computer programs in the memory 51 to execute a method for locating a code running crash provided by the first embodiment, for example:
setting an association function associated with the positioning identifier;
executing the logic of the correlation function when the function to be monitored runs, and acquiring a corresponding character string identifier;
and analyzing whether the crash occurs and the position of the crash according to the character string identification.
In the embodiment, the character string identification is generated according to the logic of the association function, and then the occurrence of the crash and the occurrence position thereof are analyzed, so that the method has universality and can be seamlessly integrated on different operating systems.
The present invention also provides a memory, in which a plurality of computer programs are stored, and the computer programs are called by a processor to execute the method for locating a code running crash described in the first embodiment.
In the embodiment, the character string identification is generated according to the logic of the association function, and then the occurrence and the occurrence position of the crash are analyzed, so that the method has universality and is independent of an operating system or hardware, the system function independent of a specific platform is realized, and seamless integration can be realized on different operating systems.
Second, even when an uncollected signal that causes the crash occurs, the context of the crash stack can be recorded, thereby quickly locating the problem.
Furthermore, the required space overhead is small. One print dot occupies only one character, and generally, small and medium-sized software estimates that 1000 characters (about 1 kb) are almost sufficient. In addition, the same printing point runs n (n ═ 1) times, and only 1 byte is occupied, and one of characters of '1', '0','s', 'e' is displayed.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation.
Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention. The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (11)

1. A method for locating a code run crash, comprising:
setting an association function associated with the positioning identifier;
executing the logic of the correlation function when the function to be monitored runs, and acquiring a corresponding character string identifier;
and analyzing whether the crash occurs and the position of the crash according to the character string identification.
2. The method according to claim 1, wherein the setting of the association function associated with the positioning identifier is specifically:
defining an identification macro as the positioning identification;
adding the identification macro in the function to be monitored;
replacing the identification macro in the function to be monitored with the correlation function.
3. The method of claim 2,
the defining identification macro is used as the positioning identification, and specifically includes: defining a first identification macro, a second identification macro and a third identification macro as null by the macro in the public header file;
the adding the identification macro in the function to be monitored specifically includes: the first identification macro is marked on the entry point of the function to be monitored, the second identification macro is marked on the exit point of the function to be monitored, and any third identification macro is marked between the entry point and the exit point of the function to be monitored;
the replacing the identification macro in the function to be monitored with the association function specifically includes: and respectively replacing the first identification macro, the second identification macro and the third identification macro with the association functions of different variables.
4. The method according to claim 3, wherein the logic for executing the association function when the function to be monitored runs and obtaining the corresponding string identifier are specifically:
when the function to be monitored runs to the first identification macro, writing a first character at a position corresponding to the character string identification;
when the function to be monitored runs to the second identification macro, writing a second character at the position corresponding to the character string identification;
when the function to be monitored runs to the third identification macro, writing a third character in the corresponding position of the character string identification;
and writing a fourth character at the corresponding position of the character string identifier at the identifier macro where the function to be monitored does not run.
5. The method of claim 4, wherein the logic that executes the association function when the function to be monitored is running and obtains the corresponding string identifier further comprises:
when the character string mark repeatedly appears in the first character, all characters between the first previous character and the corresponding second character are cleared.
6. The method of claim 4, wherein analyzing whether a crash occurs and a location of the crash based on the string identification further comprises:
traversing the character string identification;
when the first character is found, if the second character is not found later or another first character appears, the first character is interpreted to be crashed;
and if another first character appears after the first character is found, the function to be monitored, in which the previous first character is located, is crashed.
7. The method according to claim 3, wherein the step of replacing the first identification macro, the second identification macro, and the third identification macro with the association functions of different variables respectively comprises:
setting a global variable n;
if any identification macro is encountered, n is added with 1;
replacing the first identification macro with the association function with a variable of 10000+ n, replacing the second identification macro with the association function with a variable of-n, and replacing the third identification macro with the association function with a variable of n.
8. The method according to claim 7, wherein the logic for executing the association function when the function to be monitored runs and obtaining the corresponding string identifier specifically are:
when the function to be monitored runs to the correlation function with the variable larger than 10000, writing's' at the corresponding position of the character string identification;
when the function to be monitored runs to the correlation function with the variable less than 0, 'e' is written at the corresponding position of the character string identifier;
when the function to be monitored runs to the correlation function between the variables 0 to 10000, '1' is written at the corresponding position of the character string identifier;
and writing '0' in the corresponding position of the character string identifier at the identification macro where the function to be monitored does not run.
9. An apparatus for locating a code run crash, comprising:
the setting unit is used for setting an association function associated with the positioning identifier;
the execution unit is connected with the setting unit and used for executing the logic of the association function when the function to be monitored runs and acquiring the corresponding character string identifier;
and the analysis unit is connected with the execution unit and used for analyzing whether the character string is broken down or not and the position of the broken down according to the character string identification.
10. A memory storing a computer program, the computer program being executable by a processor to perform the steps of:
setting an association function associated with the positioning identifier;
executing the logic of the correlation function when the function to be monitored runs, and acquiring a corresponding character string identifier;
and analyzing whether the crash occurs and the position of the crash according to the character string identification.
11. A terminal comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor when executing the computer program implements the steps of the method of locating a code run crash as claimed in any one of claims 1 to 8.
CN201811085437.4A 2018-09-17 2018-09-17 Method and device for locating code operation breakdown, terminal and memory Active CN110908819B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811085437.4A CN110908819B (en) 2018-09-17 2018-09-17 Method and device for locating code operation breakdown, terminal and memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811085437.4A CN110908819B (en) 2018-09-17 2018-09-17 Method and device for locating code operation breakdown, terminal and memory

Publications (2)

Publication Number Publication Date
CN110908819A true CN110908819A (en) 2020-03-24
CN110908819B CN110908819B (en) 2023-07-04

Family

ID=69812705

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811085437.4A Active CN110908819B (en) 2018-09-17 2018-09-17 Method and device for locating code operation breakdown, terminal and memory

Country Status (1)

Country Link
CN (1) CN110908819B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113419886A (en) * 2021-06-21 2021-09-21 网易(杭州)网络有限公司 Method, apparatus and computer-readable storage medium for handling program crash

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1728106A (en) * 2004-07-26 2006-02-01 中兴通讯股份有限公司 Method for positioning malfunction of application program
CN103034575A (en) * 2012-11-29 2013-04-10 北京奇虎科技有限公司 Crash analysis method and device
KR20140050333A (en) * 2012-10-19 2014-04-29 에스케이플래닛 주식회사 System and method for controlling crash log report
CN103914379A (en) * 2014-03-25 2014-07-09 北京邮电大学 Automatic fault injection and fault detecting method and system
CN106294134A (en) * 2016-07-29 2017-01-04 腾讯科技(深圳)有限公司 The collapse localization method of code and device
CN106294071A (en) * 2016-08-11 2017-01-04 宁波舜宇光电信息有限公司 A kind of software crash formation gathering method and system thereof

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1728106A (en) * 2004-07-26 2006-02-01 中兴通讯股份有限公司 Method for positioning malfunction of application program
KR20140050333A (en) * 2012-10-19 2014-04-29 에스케이플래닛 주식회사 System and method for controlling crash log report
CN103034575A (en) * 2012-11-29 2013-04-10 北京奇虎科技有限公司 Crash analysis method and device
CN103914379A (en) * 2014-03-25 2014-07-09 北京邮电大学 Automatic fault injection and fault detecting method and system
CN106294134A (en) * 2016-07-29 2017-01-04 腾讯科技(深圳)有限公司 The collapse localization method of code and device
CN106294071A (en) * 2016-08-11 2017-01-04 宁波舜宇光电信息有限公司 A kind of software crash formation gathering method and system thereof

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113419886A (en) * 2021-06-21 2021-09-21 网易(杭州)网络有限公司 Method, apparatus and computer-readable storage medium for handling program crash
CN113419886B (en) * 2021-06-21 2022-05-03 网易(杭州)网络有限公司 Method, apparatus and computer-readable storage medium for handling program crash

Also Published As

Publication number Publication date
CN110908819B (en) 2023-07-04

Similar Documents

Publication Publication Date Title
CN109800159B (en) Program debugging method, program debugging device, terminal device, and storage medium
US7210123B2 (en) Software evaluation system having source code and function unit identification information in stored administration information
US7058927B2 (en) Computer software run-time analysis systems and methods
US20050160431A1 (en) Method and mechanism for debugging a series of related events within a computer system
CN107800757B (en) User behavior recording method and device
CN111930472B (en) Code debugging method and device, electronic equipment and storage medium
CN111884876A (en) Method, device, equipment and medium for detecting protocol type of network protocol
CN110990346A (en) File data processing method, device, equipment and storage medium based on block chain
CN110287700B (en) iOS application security analysis method and device
CN110414218B (en) Kernel detection method and device, electronic equipment and storage medium
EP3514680B1 (en) Identification of changes in functional behavior and runtime behavior of a system during maintenance cycles
CN115328796A (en) Software vulnerability auxiliary positioning method and system for ARM architecture
CN110908819B (en) Method and device for locating code operation breakdown, terminal and memory
CN113360379B (en) Program test environment creation method and program test environment creation apparatus
US9916220B2 (en) Smart logging of trace data for storage systems
CN116305131B (en) Static confusion removing method and system for script
Radu et al. Grey-box analysis and fuzzing of automotive electronic components via control-flow graph extraction
US20140165041A1 (en) Crash notification between debuggers
CN113407416B (en) File operation IP tracing method and system
US20050149809A1 (en) Real time determination of application problems, using a lightweight diagnostic tracer
CN110096281B (en) Code analysis method, analysis server, storage medium and device
CN114356290A (en) Data processing method and device and computer readable storage medium
CN114546836A (en) Public component library automatic testing method and device based on push-down automaton guidance
CN114741700A (en) Public component library vulnerability availability analysis method and device based on symbolic taint analysis
CN114186278A (en) Database abnormal operation identification method and device and electronic equipment

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 200438 9 / F, 10 / F, 11 / F, 12 / F, 38 Lane 1688, Guoquan North Road, Yangpu District, Shanghai

Applicant after: QIANXUN SPATIAL INTELLIGENCE Inc.

Address before: Room j165, 1st floor, building 64, 1436 Jungong Road, Yangpu District, Shanghai, 200433

Applicant before: QIANXUN SPATIAL INTELLIGENCE Inc.

GR01 Patent grant
GR01 Patent grant