CN108628744B - Fault diagnosis method and device and electronic equipment - Google Patents

Fault diagnosis method and device and electronic equipment Download PDF

Info

Publication number
CN108628744B
CN108628744B CN201810407295.2A CN201810407295A CN108628744B CN 108628744 B CN108628744 B CN 108628744B CN 201810407295 A CN201810407295 A CN 201810407295A CN 108628744 B CN108628744 B CN 108628744B
Authority
CN
China
Prior art keywords
user
reference count
address
call
diagnosed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810407295.2A
Other languages
Chinese (zh)
Other versions
CN108628744A (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.)
Shenzhen Forward Industrial Co Ltd
Original Assignee
Shenzhen Forward Industrial Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Forward Industrial Co Ltd filed Critical Shenzhen Forward Industrial Co Ltd
Priority to CN201810407295.2A priority Critical patent/CN108628744B/en
Publication of CN108628744A publication Critical patent/CN108628744A/en
Application granted granted Critical
Publication of CN108628744B publication Critical patent/CN108628744B/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/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3636Software debugging by tracing the execution of the program
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/366Software debugging using diagnostics

Abstract

The embodiment of the invention relates to the technical field of C language programming, in particular to a fault diagnosis method and device and electronic equipment. The fault diagnosis method comprises the following steps: if the used object is destroyed and the information that the reference count of the used object is not zero is obtained, one of the call points of the used object is used as a call point to be diagnosed to obtain a corresponding user address, a preset user pairing table and a used object call point list are traversed according to the user address to obtain a call point list to be diagnosed, the sum of the number of times of use of adding one to the reference count and the sum of the number of times of use of subtracting one from the reference count, which are contained in the call point list to be diagnosed, are counted, whether the sum of the number of times of use of adding one to the reference count is the same as the sum of the number of times of use of subtracting one from the reference count is judged, if not, the call point to be diagnosed is judged as a fault call point, and the information of the call point list to be diagnosed and the user pairing table are stored. The method can accurately position the calling point with the reference counting fault.

Description

Fault diagnosis method and device and electronic equipment
Technical Field
The embodiment of the invention relates to the technical field of C language programming, in particular to a fault diagnosis method and device and electronic equipment.
Background
In the C language code programming implementation, a user wants to use an object, such as a reference object, firstly needs to hold the object, the reference count of the operation object is increased by 1 to indicate that the user is using the object, and the reference is released and the reference count of the operation object is decreased by 1 until the user no longer needs to hold the object. In many scenarios, the resources occupied by the use objects need to be released, and before resource release, it is important to determine reference count failure information of the use objects.
Disclosure of Invention
In view of this, the invention provides a fault diagnosis method, a fault diagnosis device and an electronic device, so as to accurately locate a call point where a reference counting fault occurs.
In order to achieve the above object, an embodiment of the present invention provides a fault diagnosis method for diagnosing whether each call point corresponding to a user object fails or not in a C language code programming environment, where a user may hold or release the user object, a reference count of the user object is incremented by one when the user holds the user object, and the reference count of the user object is decremented by one when the user releases the user object, the method including:
if the using object is destroyed and the information that the reference count of the using object is not zero is obtained, taking one calling point of the using object as a calling point to be diagnosed, and obtaining a user address corresponding to the calling point to be diagnosed;
traversing a preset user pairing table and a use object calling point list according to the user address to obtain a calling point list to be diagnosed;
counting the sum of the number of times of use of the reference count plus one and the sum of the number of times of use of the reference count minus one contained in the list of the call points to be diagnosed;
and judging whether the sum of the number of times of use of the reference count increased by one is the same as the sum of the number of times of use of the reference count decreased by one, if not, judging the call point to be diagnosed as a fault call point, and storing the information in the call point list to be diagnosed and the information in the traversed user pairing table.
Optionally, the method further comprises:
and searching out corresponding function names or code position information by adopting a preset address and symbol mapping table according to the stored information in the call point list to be diagnosed and the information in the traversed user pairing table, and storing the function names or the code position information.
Optionally, the step of storing the information in the call site list to be diagnosed and the information in the traversed user pairing table includes:
storing the call site address of the reference count plus one, the sum of the use times of the reference count plus one, the sum of the call site address of the reference count minus one and the sum of the use times of the reference count minus one contained in the call site list to be diagnosed;
and storing the user address in the traversed user matching table.
Optionally, the call site address of the reference count plus one, the sum of the number of uses of the reference count plus one, the call site address of the reference count minus one, and the sum of the number of uses of the reference count minus one are obtained by:
obtaining the memory address of the called reference count plus one operation code in the instruction level, and taking the memory address as a calling point address of the reference count plus one;
obtaining the total number of times of the operation code which is added with one by the reference count, and taking the total number of times as the sum of the use times of the operation code which is added with one by the reference count;
obtaining the memory address of the called operation code with the reference count reduced by one in the instruction level, and taking the memory address as the call point address with the reference count reduced by one;
the total number of times the reference count minus one operation code is executed is obtained as the sum of the number of times the reference count minus one is used.
Optionally, the step of obtaining the user address corresponding to the call point to be diagnosed includes:
and judging whether the memory address of the user identity information exists or not, if so, taking the memory address of the user identity information as the user address, and if not, taking the memory address of the user operation function as the user address.
Optionally, the preset user pairing table is obtained by:
obtaining a blank matching table;
obtaining a plurality of call points where a reference count operation is performed;
aiming at each call point in the plurality of call points, obtaining a memory address using an operation function where the call point is located and taking the memory address as a user address of the call point;
adding the call site address of the reference count plus one in the plurality of call sites to the reference count plus list column in the blank pairing table, and adding the call site address of the reference count minus one in the plurality of call sites to the reference count minus list column in the blank pairing table;
and loading a plurality of user addresses to a user list column of the blank pairing table, and pairing each user address, each calling point address obtained by adding one to the reference count and each calling point address obtained by subtracting one from the reference count to obtain a preset user pairing table.
An embodiment of the present invention further provides a fault diagnosis apparatus for diagnosing whether each call point corresponding to a user object fails in a C language code programming environment, where a user may hold or release the user object, a reference count of the user object is incremented when the user holds the user object, and the reference count of the user object is decremented when the user releases the user object, the fault diagnosis apparatus including:
the user address acquisition module is used for taking one calling point of the using object as a calling point to be diagnosed and acquiring a user address corresponding to the calling point to be diagnosed if the using object is destroyed and the information that the reference count of the using object is not zero is acquired;
the traversal module is used for traversing a preset user pairing table and a use object calling point list according to the user address to obtain a calling point list to be diagnosed;
the statistical module is used for counting the sum of the use times of the reference count plus one and the sum of the use times of the reference count minus one in the call site list to be diagnosed;
and the judging module is used for judging whether the sum of the number of times of use of adding one to the reference count is the same as the sum of the number of times of use of subtracting one from the reference count, if not, judging the calling point to be diagnosed as a fault calling point, and storing the information in the calling point list to be diagnosed and the information in the traversed user pairing table.
Optionally, the fault diagnosis apparatus further includes an information processing module;
the information processing module is used for finding out corresponding function names or code position information by adopting a preset address and symbol mapping table according to the stored information in the call point list to be diagnosed and the information in the traversed user matching table, and storing the function names or the code position information.
The embodiment of the present invention further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the fault diagnosis method described above is implemented.
The embodiment of the invention also provides a computer-readable storage medium, which comprises a computer program, and the computer program controls the electronic equipment where the computer-readable storage medium is located to execute the fault diagnosis method when running.
The fault diagnosis method, the fault diagnosis device and the electronic equipment provided by the embodiment of the invention can judge the fault calling point according to whether the sum of the number of times of use of adding one to the reference count is equal to the sum of the number of times of use of subtracting one from the reference count, store the information in the calling point list to be diagnosed and the information in the traversed user pairing table, and accurately position the address of the fault calling point according to the information in the calling point list to be diagnosed and the information in the traversed user pairing table.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a block diagram of an electronic device 10 according to an embodiment of the present invention.
Fig. 2 is a flowchart of a fault diagnosis method according to an embodiment of the present invention.
FIG. 3 is a diagram illustrating the sub-steps included in step S23 shown in FIG. 2 according to one embodiment.
Fig. 4 is a block diagram of a fault diagnosis apparatus 20 according to an embodiment of the present invention.
Icon: 10-an electronic device; 11-a memory; 12-a processor; 13-a network module; 20-fault diagnosis means; 21-user address acquisition module; 22-traversal module; 23-a statistics module; 24-a judgment module; 25-information processing module.
Detailed Description
The reference count of the object is an integer greater than or equal to 0, and is used for recording the number of the objects referenced by the user. There are two operations for reference counting: the reference count is incremented by one and the reference count is decremented by one. When a user reference points to an object, the reference count of the object is incremented by one, and when a reference is removed, the reference count is decremented by one. When the reference count is not 0, the object is referred by the user, and the resources occupied by the object cannot be recycled; when the reference count is 0, the object has no user, the occupied resource can be safely released, and the system is recycled for reuse.
The reference count increment by one and the reference count decrement by one are a pair of reference count operations that require pairing. When the reference counting operation of the user is incorrect, the reference counting operation may be omitted, or the object bidirectional reference may occur, and the addition or subtraction of one to or from the incorrectly paired reference count will cause a fault phenomenon that the reference count is not 0 when the object resource is recycled. At this point, the system cannot normally reclaim the resources occupied by the object because its reference count is not 0, indicating that there is a situation where the user is using the object. In addition, the object only stores the reference count, but does not store the related information of the user, and cannot inform the user to remove the reference, so that the resource recovery cannot be safely carried out, and finally the problem that the resource leakage cannot be recovered and reused is caused.
The existing method for judging the fault is difficult to locate which user and which using object have reference counts which are not correctly paired.
The investigation shows that the reference counting operation is not correctly paired, and when a reference counting fault occurs, because the object only stores the number referred by the user, namely reference counting, and does not store information related to the user, because the users of the object may be too many and are not easy to store, and it is not known which user does not correctly pair the reference counting operation, the root cause of the reference counting fault needs to be located, and the difficulty lies in finding which user operates the reference counting and is not correctly paired.
The prior art method is that firstly, debugging information is added, or GDB and other debugging tools are used, and software developers adopt a method of manually combining source codes and continuously testing, reproducing and analyzing the debugging information to process the problems; secondly, the specific reference relation of the object is analyzed to find out the reference with problems, and the reference counting operation of faults is further found. The methods all have the same kind of problems, namely when the number of the users of the object is large, the number of the recorded reference relationship information is increased, the object reference is often large when the reference counting fault occurs, and the reference relationship is complex, so that the debugging information is very large and complex, the information amount required to be analyzed for processing the problem is increased undoubtedly, and the difficulty in tracing the cause of the problem is increased directly. In addition, the plus or minus operation code may be a many-to-many relationship, and even if a problem occurs in a specific reference relationship of an object, it is not possible to effectively locate which plus or minus operation code is caused by incorrect corresponding processing. Therefore, the prior art methods cannot effectively solve the fault problems of reference counting.
The above prior art solutions have shortcomings which are the results of practical and careful study of the inventor, and therefore, the discovery process of the above problems and the solutions proposed by the following embodiments of the present invention to the above problems should be the contribution of the inventor to the present invention in the course of the present invention.
Based on the above research, embodiments of the present invention provide a fault diagnosis method, apparatus, and electronic device, which can accurately locate a use object, a call point address, and a user address where a reference count fault occurs.
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, 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. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. 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.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
Fig. 1 shows a block diagram of an electronic device 10 according to an embodiment of the present invention. The electronic device 10 in the embodiment of the present invention may be a server with data storage, transmission, and processing functions, as shown in fig. 1, the electronic device 10 includes: memory 11, processor 12, network module 13 and fault diagnosis device 20.
The memory 11, the processor 12 and the network module 13 are electrically connected directly or indirectly to realize data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines. The memory 11 stores a fault diagnosis device 20, the fault diagnosis device 20 includes at least one software functional module which can be stored in the memory 11 in the form of software or firmware (firmware), and the processor 12 executes various functional applications and data processing by running the software programs and modules stored in the memory 11, such as the fault diagnosis device 20 in the embodiment of the present invention, so as to implement the fault diagnosis method in the embodiment of the present invention.
The Memory 11 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like. The memory 11 is used for storing a program, and the processor 12 executes the program after receiving an execution instruction.
The processor 12 may be an integrated circuit chip having data processing capabilities. The Processor 12 may be a general-purpose Processor including a Central Processing Unit (CPU), a Network Processor (NP), and the like. The various methods, steps and logic blocks disclosed in embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The network module 13 is used for establishing communication connection between the electronic device 10 and other communication terminal devices through a network, and implementing transceiving operation of network signals and data. The network signal may include a wireless signal or a wired signal.
It will be appreciated that the configuration shown in FIG. 1 is merely illustrative and that electronic device 10 may include more or fewer components than shown in FIG. 1 or may have a different configuration than shown in FIG. 1. The components shown in fig. 1 may be implemented in hardware, software, or a combination thereof.
An embodiment of the present invention also provides a computer-readable storage medium, which includes a computer program. The computer program controls the electronic device 10, in which the readable storage medium is located, to perform the following fault diagnosis method when executed.
In this embodiment, the fault diagnosis method is used for diagnosing whether each call point corresponding to a use object is faulty or not in a C language code programming environment, wherein a user can hold or release the use object, when the user holds the use object, the reference count of the use object is increased by one, and when the user releases the use object, the reference count of the use object is decreased by one.
Before the failure method is performed, a series of pre-operations and settings need to be made, which are as follows in the present embodiment.
And increasing the record function of the call point of the operation of adding one to the reference count at the position of the operation code of adding one to the reference count. It will be appreciated that the use of the reference count plus one action by the object is actually made by the reference count plus one opcode, which has a location in instruction level memory space, and the call site record function of the reference count plus one action records information about the reference count plus one action.
For example, xxx _ add _ refcnt is a reference plus an operation function whose location in memory space is locationM, and xxx _ add _ record is a record function of the call point of the reference count plus one operation incremented at location locationM.
Similarly, xxx _ dec _ refcnt is a function of a reference-minus operation, the location of which in memory space is located at position n, and xxx _ dec _ record is a function of a record of the call point of the reference-count-minus operation incremented at position located at position n.
The recording function can record a user address, a call point address and the number of running and using times, wherein the call point address is a code position in the corresponding source code. In other words, the recording function may record which user performed the operation of adding one to the reference count or subtracting one from the reference count for which user at which code position.
Furthermore, a user pairing table building function is added at the position of loading an initialization code in a system or a module, the user pairing table building function is used for building a user pairing table, when the code is initialized, the memory address of the code is determined, and the memory address of one instruction is unique in the system, so that when the code is initialized, the building of the user pairing table of the calling point can be started. The record maintenance of the user pairing table can add a call point pairing record to the pairing table when a system is initialized for a system static code; for a module code needing to be dynamically loaded, adding a call point pairing record into a pairing table when the module is loaded and initialized, wherein the module is loaded at the moment, and an instruction memory address corresponding to the module code is determined; correspondingly, when the module is unloaded and quits, the call site pairing record needs to be deleted from the pairing table.
The user pairing table comprises a plurality of user addresses of an adding operation calling point and a plurality of user addresses of a subtracting operation calling point, and the user addresses are shown in table 1:
TABLE 1
Figure BDA0001645639480000071
Figure BDA0001645639480000081
The user pairing table may be system global, and as shown in table 1, A, B, C may correspond to different types of users of different modules, for example, interface operations of network interface modules, and routing table entry operations of ipv4 and ipv6 modules.
For example, a user operating a network interface object may have interface management and routing of the 2 modules using the interface object, and assuming that the interface management has one plus-one call point (user address a1) and one minus-one call point (user address a2), and the routing has 3 plus-one call points (user addresses B1, B2, and B3, respectively) and two minus-one call points (user addresses B4 and B5, respectively), a user pairing table may be constructed as shown in table 2:
TABLE 2
A1 A2
B1、B2、B3 B4、B5
B1, B2, B3, B4 and B5 are user address lists of an adding operation calling point and a subtracting operation calling point respectively to form a many-to-many record, various combinations are not needed to form pairing records, and classification statistical calculation can be carried out according to the addition or subtraction of one when fault location is carried out, so that the user addresses corresponding to all calling points are added into a pairing table, and the addition and subtraction of one are only needed to be paired, which is also the reason for introducing users, various combinations of all calling points are not needed, and thus the setting is easier to carry out pairing.
Furthermore, the user and the call point are in a one-to-many relationship, one user can have a plurality of call points of the operation of adding one to or subtracting one from the reference count, and one call point only corresponds to one user.
After the foregoing pre-operation is performed, the fault diagnosis method provided by the embodiment of the present invention may be performed.
Fig. 2 is a flowchart illustrating a fault diagnosis method according to an embodiment of the present invention. The method steps defined by the method-related flow, as applied to the electronic device 10, may be implemented by the processor 12. The specific process shown in FIG. 2 will be described in detail below:
step S21, if the used object is destroyed and the information that the reference count of the used object is not zero is obtained, taking one of the call points of the used object as a call point to be diagnosed, and obtaining a user address corresponding to the call point to be diagnosed.
Before the use object is destroyed, it is necessary to ensure that the user of the use object releases the use object completely, that is, the reference count of the use object is 0 to be destroyed, and when the reference count of the use object is not 0, it is described that the call point of the use object is failed, and at this time, the fault diagnosis method is started.
For example, for a call point to be diagnosed using the object B, the address of the user XY of the call point to be diagnosed is obtained. The user address of the call point is the memory address of the use object or the operation function corresponding to the user, and as with the call point address, the user address has unique certainty in the system and is used for pairing and fault positioning of the call point.
Optionally, if the memory address of the user identity information exists, the memory address of the user identity information is used as the user address, and if the memory address of the user identity information does not exist, the memory address of the user operation function is used as the user address.
Step S22, traversing the preset user matching list and the use object call point list according to the user address, and obtaining a call point list to be diagnosed.
And traversing a preset user pairing table according to the addresses of the users XY to obtain a user address list of plus and minus pairs, namely the addresses of the users XY performing plus operation and the addresses of the users X and Y performing minus operation.
It can be understood that the user XY can perform an add operation on the call points of a plurality of objects, the user X and the user Y can perform a subtract operation on the call points of different objects, and for accurate positioning, it is necessary to know which users perform the add operation on the call point B to be diagnosed, and which users perform the subtract operation on the call point B to be diagnosed.
The list of call points for the preset usage object is shown in table 3:
TABLE 3
Figure BDA0001645639480000091
According to the user addresses (XY, X and Y) in the user address list, the call site list of the use object is traversed, the call site list of the use object B can be obtained according to the table (B1 and B2), and the call site list is used as a call site list to be diagnosed.
In step S23, the total of the number of times of use of the reference count plus one and the total of the number of times of use of the reference count minus one included in the call site list to be diagnosed are counted.
Referring to fig. 3, in the present embodiment, one implementation manner of step S23 is illustrated by step S231 and step S232.
Step S231, traversing the call point list to be diagnosed according to the operation of adding one to the reference count, and obtaining an address B1 of the call point to be diagnosed, which is the call point to be diagnosed, and a SUM1 of the number of times of use of adding one to the reference count.
The address of the calling point refers to a memory address of the called code position of the reference counting operation code at an instruction level, has unique determinacy in a system, and is used for determining the specific position of the reference counting operation code in the source code. The sum of the number of times of use is used to record the number of times the corresponding call point reference count plus one or minus one operation code was run, that is, the difference between the sum of the number of times of call point use of the reference count plus one operation and the sum of the number of times of call point use of the reference count minus one operation should be consistent with the value of the reference count of the object.
Step S232, traversing the call point list to be diagnosed according to the operation of subtracting one from the reference count, and obtaining the call point address B2 subtracted from the call point to be diagnosed and the SUM SUM2 of the number of times of use of subtracting one from the reference count.
And step S24, judging whether the sum of the number of times of use of the reference count increased by one is the same as the sum of the number of times of use of the reference count decreased by one, if not, judging the call point to be diagnosed as a fault call point, and storing the information in the list of the call point to be diagnosed and the information in the traversed user pairing table.
Judging whether the SUM1 and the SUM2 are the same or not, if not, judging the call point to be diagnosed of the object B as a fault call point, storing a call point address B1, a call point address B2, a SUM1 and a SUM2, and further storing a traversed user pairing table.
Therefore, the hidden fault calling points can be found, for example, if the fault calling points (taking a certain plus one calling point as an example) are not operated, but the reference counting of the fault calling points is in problem, the reference counting of the minus one calling point corresponding to the fault calling points is not diagnosed to be in problem, the fault calling points which are not operated can be found out by matching the table by a user, research personnel can find out the fault reason along the vine and the melon conveniently, and further development and improvement of the program are facilitated.
Alternatively, the user pairing table may be implemented as follows:
the method comprises the steps of obtaining a blank pairing table, obtaining a plurality of call points executing reference counting operation, aiming at each call point in the plurality of call points, obtaining a memory address using an operation function where the call point is located and taking the memory address as a user address of the call point, adding the call point address obtained by adding one to the reference count in the plurality of call points to a list adding column of the reference count in the blank pairing table, adding the call point address obtained by subtracting one from the reference count in the plurality of call points to a list subtracting column of the reference count in the blank pairing table, loading the plurality of user addresses to the user list column of the blank pairing table, and pairing each user address, each call point address obtained by adding one to the reference count and each call point address obtained by subtracting one from the reference count to obtain the user pairing table. It should be appreciated that the user matching table is completed before the fault diagnosis method is performed.
Alternatively, the information record of the call site using the object B is shown in Table 4
TABLE 4
Figure BDA0001645639480000101
It can be known from the above table that the reference counting of the call point address B1 and the call point address B2 is problematic, and the user addresses of the two addresses are also clear, so that research personnel can find the fault reason along the vine and the melon, and further development and improvement of the program are facilitated.
Optionally, after the information in the call point list to be diagnosed and the information in the traversed user pairing table are stored, the corresponding function name or code position can be found out by adopting a preset address and symbol mapping table, and the function name or the code position is stored, so that a further data analysis basis is provided for research personnel, and further development and improvement of a program are facilitated
On the basis of the above, as shown in fig. 4, an embodiment of the present invention provides a failure diagnosis apparatus 20, where the failure diagnosis apparatus 20 includes: a user address acquisition module 21, a traversal module 22, a statistic module 23, a judgment module 24 and an information processing module 25.
A user address obtaining module 21, configured to, if the used object is destroyed and information that the reference count of the used object is not zero is obtained, use one of the call points of the used object as a call point to be diagnosed, and obtain a user address corresponding to the call point to be diagnosed.
Since the user address obtaining module 21 is similar to the implementation principle of step S21 in fig. 2, it will not be further described here.
And the traversing module 22 is configured to traverse the preset user matching table and the use object call point list according to the user address to obtain a call point list to be diagnosed.
Since the traversing module 22 is similar to the implementation principle of step S22 in fig. 2, it will not be further described here.
And the counting module 23 is configured to count the sum of the number of times of use of the reference count plus one and the sum of the number of times of use of the reference count minus one, which are included in the call site list to be diagnosed.
Since the statistical module 23 is similar to the implementation principle of step S23 in fig. 2, it will not be further described here.
And the judging module 24 is configured to judge whether the sum of the number of times of use obtained by adding one to the reference count is the same as the sum of the number of times of use obtained by subtracting one from the reference count, determine the call point to be diagnosed as a failed call point if the two are not the same, and store information in the list of the call points to be diagnosed and information in the traversed user pairing table.
Since the implementation principle of the judging module 24 is similar to that of step S24 in fig. 2, no further description is made here.
And the information processing module 25 is configured to find out a corresponding function name or code position information by using a preset address and symbol mapping table according to the stored information in the call point list to be diagnosed and the information in the traversed user pairing table, and store the function name or the code position information.
Since the information processing module 25 is similar to the implementation principle of step S24 in fig. 2, it will not be further described here.
In summary, the fault diagnosis method, the fault diagnosis device and the electronic device provided by the embodiment of the invention can analyze a small amount of fault information, can locate the specific position of the problem calling point in the source code, reduce the complexity of analyzing the fault information by software developers, and improve the accuracy and efficiency of analyzing, quoting and counting the fault problems.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus and method embodiments described above are illustrative only, as the flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention or a part thereof, which essentially contributes to the prior art, can be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, an electronic device 10, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes. It should be noted that, in this document, 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.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A fault diagnosis method for diagnosing whether each call point corresponding to a user object has a fault or not in a C language code programming environment, wherein a user can hold or release the user object, the reference count of the user object is incremented when the user holds the user object, and the reference count of the user object is decremented when the user releases the user object, the method comprising:
if the using object is destroyed and the information that the reference count of the using object is not zero is obtained, taking one calling point of the using object as a calling point to be diagnosed, and obtaining a user address corresponding to the calling point to be diagnosed;
traversing a preset user pairing table according to the user address to obtain a user address list of plus one and minus one pairing; the user pairing table comprises a plurality of user addresses of an plus operation calling point and a plurality of user addresses of a minus operation calling point;
traversing the call point list of the use object according to the user address in the user address list to obtain the call point list of the use object, and taking the call point list of the use object as a call point list to be diagnosed;
counting the sum of the number of times of use of the reference count plus one and the sum of the number of times of use of the reference count minus one contained in the list of the call points to be diagnosed;
and judging whether the sum of the number of times of use of the reference count increased by one is the same as the sum of the number of times of use of the reference count decreased by one, if not, judging the call point to be diagnosed as a fault call point, and storing the information in the call point list to be diagnosed and the information in the traversed user pairing table.
2. The fault diagnosis method according to claim 1, characterized in that the method further comprises:
and searching out corresponding function names or code position information by adopting a preset address and symbol mapping table according to the stored information in the call point list to be diagnosed and the information in the traversed user pairing table, and storing the function names or the code position information.
3. The method of claim 1, wherein the step of storing the information in the list of call points to be diagnosed and the information in the traversed user match table comprises:
storing the call site address of the reference count plus one, the sum of the use times of the reference count plus one, the sum of the call site address of the reference count minus one and the sum of the use times of the reference count minus one contained in the call site list to be diagnosed;
and storing the user address in the traversed user matching table.
4. The failure diagnosis method according to claim 3, wherein the call site address of the reference count increased by one, the sum of the number of uses of the reference count increased by one, the call site address of the reference count decreased by one, and the sum of the number of uses of the reference count decreased by one are obtained by:
obtaining the memory address of the called reference count plus one operation code in the instruction level, and taking the memory address as a calling point address of the reference count plus one;
obtaining the total number of times of the operation code which is added with one by the reference count, and taking the total number of times as the sum of the use times of the operation code which is added with one by the reference count;
obtaining the memory address of the called operation code with the reference count reduced by one in the instruction level, and taking the memory address as the call point address with the reference count reduced by one;
the total number of times the reference count minus one operation code is executed is obtained as the sum of the number of times the reference count minus one is used.
5. The fault diagnosis method according to claim 1, wherein the step of obtaining the user address corresponding to the call point to be diagnosed comprises:
and judging whether the memory address of the user identity information exists or not, if so, taking the memory address of the user identity information as the user address, and if not, taking the memory address of the user operation function as the user address.
6. The fault diagnosis method according to claim 1, characterized in that the preset user pairing table is obtained by the following steps:
obtaining a blank matching table;
obtaining a plurality of call points where a reference count operation is performed;
aiming at each call point in the plurality of call points, obtaining a memory address using an operation function where the call point is located and taking the memory address as a user address of the call point;
adding the call site address of the reference count plus one in the plurality of call sites to the reference count plus list column in the blank pairing table, and adding the call site address of the reference count minus one in the plurality of call sites to the reference count minus list column in the blank pairing table;
and loading a plurality of user addresses to a user list column of the blank pairing table, and pairing each user address, each calling point address obtained by adding one to the reference count and each calling point address obtained by subtracting one from the reference count to obtain a preset user pairing table.
7. A failure diagnosis apparatus for diagnosing whether or not a call point corresponding to a user object fails in a C language code programming environment, wherein the user can hold or release the user object, wherein a reference count of the user object is incremented when the user holds the user object, and wherein the reference count of the user object is decremented when the user releases the user object, the failure diagnosis apparatus comprising:
the user address acquisition module is used for taking one calling point of the using object as a calling point to be diagnosed and acquiring a user address corresponding to the calling point to be diagnosed if the using object is destroyed and the information that the reference count of the using object is not zero is acquired;
the traversal module is used for traversing a preset user pairing table according to the user address to obtain a user address list of plus and minus one pairing; the user pairing table comprises a plurality of user addresses of an plus operation calling point and a plurality of user addresses of a minus operation calling point; traversing the call point list of the use object according to the user address in the user address list to obtain the call point list of the use object, and taking the call point list of the use object as a call point list to be diagnosed;
the statistical module is used for counting the sum of the use times of the reference count plus one and the sum of the use times of the reference count minus one in the call site list to be diagnosed;
and the judging module is used for judging whether the sum of the number of times of use of adding one to the reference count is the same as the sum of the number of times of use of subtracting one from the reference count, if not, judging the calling point to be diagnosed as a fault calling point, and storing the information in the calling point list to be diagnosed and the information in the traversed user pairing table.
8. The failure diagnosing device according to claim 7, characterized in that the failure diagnosing device further includes an information processing module;
the information processing module is used for finding out corresponding function names or code position information by adopting a preset address and symbol mapping table according to the stored information in the call point list to be diagnosed and the information in the traversed user matching table, and storing the function names or the code position information.
9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the fault diagnosis method of any one of claims 1 to 6 when executing the computer program.
10. A computer-readable storage medium, comprising a computer program, which when executed controls an electronic device in which the computer-readable storage medium is located to perform the fault diagnosis method according to any one of claims 1 to 6.
CN201810407295.2A 2018-04-28 2018-04-28 Fault diagnosis method and device and electronic equipment Active CN108628744B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810407295.2A CN108628744B (en) 2018-04-28 2018-04-28 Fault diagnosis method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810407295.2A CN108628744B (en) 2018-04-28 2018-04-28 Fault diagnosis method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN108628744A CN108628744A (en) 2018-10-09
CN108628744B true CN108628744B (en) 2022-03-15

Family

ID=63695139

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810407295.2A Active CN108628744B (en) 2018-04-28 2018-04-28 Fault diagnosis method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN108628744B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109710530A (en) * 2018-12-28 2019-05-03 珠海西山居互动娱乐科技有限公司 A kind of method and device of the memory overflow of test object
CN113031552B (en) * 2021-03-09 2022-10-25 浙江菲达环保科技股份有限公司 Cooperative control method and system for environmental protection equipment behind furnace

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100535870C (en) * 2006-12-29 2009-09-02 中兴通讯股份有限公司 Embedded system progress abnormal tracking position-finding method
CN101587455B (en) * 2008-12-11 2010-09-22 南京南瑞继保电气有限公司 Method for checking memory leak for vxWorks operating system
US8539454B2 (en) * 2009-12-09 2013-09-17 International Business Machines Corporation Method and system for detecting memory leaks
CN103123601B (en) * 2011-11-17 2016-05-25 北京神州泰岳软件股份有限公司 The method and apparatus of the software development trouble shoot based on Symbian system
CN103309796B (en) * 2012-03-09 2016-06-15 腾讯科技(深圳)有限公司 A kind of monitoring method and apparatus of The Component Object Model object
US10241895B2 (en) * 2013-06-07 2019-03-26 Apple Inc. Memory stack trace management tool
CN103761089B (en) * 2014-01-14 2017-09-15 清华大学 The method that kinematic function call relation is determined based on register transfer language
CN107092554B (en) * 2016-02-18 2021-03-02 阿里巴巴集团控股有限公司 Method and device for confirming fault code of application program

Also Published As

Publication number Publication date
CN108628744A (en) 2018-10-09

Similar Documents

Publication Publication Date Title
US9547579B1 (en) Method and apparatus for automatically detecting defects
CN108427613B (en) Abnormal interface positioning method and device, computer equipment and storage medium
US8397104B2 (en) Creation of test plans
CN107329894B (en) Application program system testing method and device and electronic equipment
CN111753306B (en) Intelligent contract vulnerability detection method and device, electronic equipment and storage medium
CN108628744B (en) Fault diagnosis method and device and electronic equipment
CN112799953A (en) Interface testing method and device, computer equipment and storage medium
CN112363937A (en) Method and device for testing differential coverage rate, computer equipment and storage medium
CN107145447B (en) Method and device for detecting memory leakage and electronic equipment
CN110287700B (en) iOS application security analysis method and device
CN112637888B (en) Coverage hole area identification method, device, equipment and readable storage medium
CN111124828B (en) Data processing method, device, equipment and storage medium
CN105912467B (en) Performance test method and device
CN110147313B (en) Log output method and device
CN105159826B (en) A kind of method and apparatus of wrong sentence in positioning target program
CN116738091A (en) Page monitoring method and device, electronic equipment and storage medium
CN115686921A (en) Multipath anomaly detection and repair method, device, equipment and medium
CN114141302A (en) Test method of solid state disk and electronic equipment
CN113868137A (en) Method, device and system for processing buried point data and server
CN107102938B (en) Test script updating method and device
CN107861842B (en) Metadata damage detection method, system, equipment and storage medium
CN115129575A (en) Code coverage result generation method and device
CN110647473A (en) Anti-interference method and device for automatic regression test, computer equipment and storage medium
CN115357513B (en) Program ambiguity test method, device, equipment and storage medium
CN112541183B (en) Data processing method and device, edge computing equipment and storage medium

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