CN111737040B - Program code repairing method and device - Google Patents
Program code repairing method and device Download PDFInfo
- Publication number
- CN111737040B CN111737040B CN202010572321.4A CN202010572321A CN111737040B CN 111737040 B CN111737040 B CN 111737040B CN 202010572321 A CN202010572321 A CN 202010572321A CN 111737040 B CN111737040 B CN 111737040B
- Authority
- CN
- China
- Prior art keywords
- code
- variable
- error
- type
- code segment
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 37
- 238000002372 labelling Methods 0.000 claims abstract description 60
- 230000008439 repair process Effects 0.000 claims description 17
- 238000012545 processing Methods 0.000 abstract description 8
- 239000012634 fragment Substances 0.000 abstract description 3
- 238000004590 computer program Methods 0.000 description 7
- 238000010586 diagram Methods 0.000 description 7
- 238000004891 communication Methods 0.000 description 6
- 230000006870 function Effects 0.000 description 6
- 230000003287 optical effect Effects 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 239000013307 optical fiber Substances 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000036541 health Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000000638 solvent extraction Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/0703—Error 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/0793—Remedial or corrective actions
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/0703—Error 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/079—Root cause analysis, i.e. error or fault diagnosis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/34—Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
- G06F11/3466—Performance evaluation by tracing or monitoring
- G06F11/3476—Data logging
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- Software Systems (AREA)
- Computer Hardware Design (AREA)
- Health & Medical Sciences (AREA)
- Biomedical Technology (AREA)
- Debugging And Monitoring (AREA)
Abstract
The present disclosure provides a program code repairing method, apparatus, electronic device, and computer-readable storage medium. The method comprises the following steps: acquiring a log file generated when an application program runs in error; the log file contains interface identifiers and error codes of code fragments of which the application program is in error; acquiring variables and labeling types of the variables contained in each row of codes in the code segment according to the interface identification; the labeling type is the data type of a pre-labeled variable; and repairing the error code or reversely deducing the error reason according to the variable and the labeling type of the variable. According to the embodiment of the disclosure, the log file generated when the application program runs in error is obtained, the variable and the labeling type of the variable contained in each row of codes in the code segment are obtained according to the interface identification in the log file, the error code is repaired or the error cause is deduced reversely according to the variable and the labeling type of the variable, manual processing is not needed, and the code repairing speed and the repairing efficiency can be improved.
Description
Technical Field
The present disclosure relates to the field of application program technologies, and in particular, to a program code repairing method, apparatus, and computer readable storage medium.
Background
With the development of internet applications, the running stability of an online application program or program code of a system is a measure of the health of an application program. After the running error of the application program, the code of the application program needs to be repaired as soon as possible according to the reason or the position of the running error of the application program.
In the prior art, when the program code runs in error, the error is usually searched manually and repaired, but the time and the labor are consumed for manually searching the error and repairing, the repairing speed of the program code is low, and the repairing efficiency is low.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
The technical problem solved by the present disclosure is to provide a program code repairing method, so as to at least partially solve the technical problems of time and effort consuming manual error searching and repairing, slow program code repairing speed and low repairing efficiency in the prior art. Further, a program code repairing device, a program code repairing hardware device, a computer-readable storage medium, and a program code repairing terminal are provided.
In order to achieve the above object, according to one aspect of the present disclosure, there is provided the following technical solutions:
a program code repair method, comprising:
Acquiring a log file generated when an application program runs in error; the log file comprises an interface identifier and an error code of a code segment of the application program with errors;
Acquiring variables contained in each row of codes in the code segment and the labeling types of the variables according to the interface identifiers; the labeling type is the data type of the variables which are labeled in advance;
And repairing the error code or reversely deducing the error reason according to the variable and the labeling type of the variable.
In order to achieve the above object, according to one aspect of the present disclosure, there is provided the following technical solutions:
A program code repair apparatus comprising:
The log file acquisition module is used for acquiring a log file generated when the application program runs in error; the log file comprises an interface identifier and an error code of a code segment of the application program with errors;
the marking type acquisition module is used for acquiring the variable contained in each row of codes in the code segment and the marking type of the variable according to the interface identifier; the labeling type is the data type of the variables which are labeled in advance;
And the code repairing module is used for repairing the error code or deducing the error reason reversely according to the variable and the labeling type of the variable.
In order to achieve the above object, according to one aspect of the present disclosure, there is provided the following technical solutions:
an electronic device, comprising:
a memory for storing non-transitory computer readable instructions; and
A processor configured to execute the computer readable instructions such that the processor, when executed, implements the program code repair method of any of the above.
In order to achieve the above object, according to one aspect of the present disclosure, there is provided the following technical solutions:
A computer readable storage medium storing non-transitory computer readable instructions which, when executed by a computer, cause the computer to perform the program code repair method of any of the preceding claims.
In order to achieve the above object, according to still another aspect of the present disclosure, there is further provided the following technical solutions:
a program code repairing terminal comprises any one of the program code repairing devices.
According to the embodiment of the disclosure, the log file generated when the application program runs in error is obtained, the variable contained in each row of codes in the code segment and the labeling type of the variable are obtained according to the interface identifier in the log file, the error code is repaired or the error cause is deduced reversely according to the variable and the labeling type of the variable, manual processing is not needed, and the code repairing speed and the repairing efficiency can be improved.
The foregoing description is only an overview of the disclosed technology, and may be implemented in accordance with the disclosure of the present disclosure, so that the above-mentioned and other objects, features and advantages of the present disclosure can be more clearly understood, and the following detailed description of the preferred embodiments is given with reference to the accompanying drawings.
Drawings
The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by reference to the following detailed description when taken in conjunction with the accompanying drawings. The same or similar reference numbers will be used throughout the drawings to refer to the same or like elements. It should be understood that the figures are schematic and that elements and components are not necessarily drawn to scale.
FIG. 1 is a flow diagram of a program code repair method according to one embodiment of the present disclosure;
FIG. 2 is a flow diagram of a program code repair apparatus according to one embodiment of the present disclosure;
fig. 3 is a schematic structural view of an electronic device according to an embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure have been shown in the accompanying drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, or in parallel. Furthermore, method embodiments may include additional steps or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "including" and variations thereof as used herein are intended to be open-ended, i.e., including, but not limited to. The term "based on" is based at least in part on. The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments. Related definitions of other terms will be given in the description below.
Example 1
In order to solve the technical problems of low program code repairing speed and low repairing efficiency caused by time and labor consumption for manually searching errors and repairing a plurality of errors in the prior art, the embodiment of the disclosure provides a program code repairing method. As shown in fig. 1, the program code repairing method mainly includes the following steps S11 to S13.
Step S11: acquiring a log file generated when an application program runs in error; the log file contains an interface identifier and an error code of a code segment of the application program with errors.
The application program can be a system self-contained program in a computer or a smart phone, or can be an installed application program.
Specifically, when an application program runs in error, it generally generates a log file, where the log file includes a code for transmitting the error, that is, an error code, and in addition, the log file of this embodiment further includes an interface identifier of the code segment in which the error occurs.
For example, when an application program runs on line, the code reports errors, and the interface identification and the error code of the code segment with the errors are reported. Such as: after the interface identifier id=id1 is returned, the front end reports errors after some programs are executed. At this time, the interface identifier and the error code of the code segment with the error are uploaded as follows:
Step S12: acquiring variables contained in each row of codes in the code segment and the labeling types of the variables according to the interface identifiers; the labeling type is the data type of the variables which are labeled in advance.
The data types include String, number, boolean value Boolean, array, object, default, arbitrary value AnyOne, etc.
Specifically, the user may pre-label the data type of the variable contained in each line of code in the code segment. The specific labeling method is shown in the following table:
Data type | Description of the invention | Application method |
String | Character string | type:String |
Number | Digital number | type:Number |
Boolean | Boolean value | type:Boolean |
Array | Array of arrays | type:Array |
Object | Object(s) | type:Object |
Default | Default value | type:Default |
AnyOne | Any one value | type:AnyOne |
For the above code fragment, id=id1 may be defined as the interface identifier of the code fragment, and the following label type code may be added:
Step S13: and repairing the error code or reversely deducing the error reason according to the variable and the labeling type of the variable.
According to the embodiment, the log file generated when the application program runs in error is obtained, the variable contained in each row of codes in the code segment and the labeling type of the variable are obtained according to the interface identifier in the log file, the error code is repaired or the error cause is deduced reversely according to the variable and the labeling type of the variable, manual processing is not needed, and the code repairing speed and the repairing efficiency can be improved.
In an alternative embodiment, the method further comprises:
Step S14: dividing the code of the application program into at least one code segment, and adding an interface identification to each code segment.
In particular, the division may be performed according to sub-functions included in the code, for example, each sub-function being a code segment.
Step S15: and marking the data types of the variables contained in each line of codes in each code segment respectively.
Step S16: and generating a type annotation file according to the interface identification of each code segment and the data type of the annotated variable.
Correspondingly, the step S12 specifically includes:
step S121: and obtaining the type annotation file.
Step S122: and acquiring the variable contained in each row of codes in the code segment and the labeling type of the variable from the type labeling file according to the interface identifier.
In an alternative embodiment, step S13 specifically includes:
Step S131: and determining the error variable in the error code according to the marked variable.
Step S132: and correcting the value of the error variable according to the labeling type of the error variable.
For example, the value of key3-3 is analyzed to be 21, but this value is not in the enumerated range, based on the labeling type of the variable as compared to errorStack. At this point a repair scheme may be generated based on this error addition. Example codes for if reported errors are as follows:
const useValueAddOne=[1,2,3,4].filter(item=>item===key33)[0]+1
the following repair scheme codes may be generated:
const useValueAddOne=[1,2,3,4,21].filter(item=>item===key33)[0]+1
in an alternative embodiment, step S13 specifically includes:
step S134: and determining the data type of the error variable in the error code.
Step S135: and deducing the error reason reversely according to the data type and the labeling type of the error variable.
The log file reported is assumed to be as follows
The data type of key3 can be found to change from Array to String. The list Array is implemented as String in the code by the reverse inference service provider based on the misunderstanding.
It will be appreciated by those skilled in the art that obvious modifications (e.g., overlapping of enumerated modes) or equivalent substitutions may be made on the basis of the various embodiments described above.
In the foregoing, although the steps in the embodiments of the program code repairing method are described in the above order, it should be clear to those skilled in the art that the steps in the embodiments of the disclosure are not necessarily performed in the above order, but may be performed in reverse order, parallel, cross, etc., and other steps may be further added by those skilled in the art on the basis of the above steps, and these obvious modifications or equivalent alternatives should also be included in the protection scope of the disclosure and are not repeated herein.
The following is an embodiment of the disclosed apparatus, which may be used to perform steps implemented by an embodiment of the disclosed method, and for convenience of explanation, only those portions relevant to the embodiment of the disclosed method are shown, and specific technical details are not disclosed, referring to the embodiment of the disclosed method.
Example two
In order to solve the technical problems of low program code repairing speed and low repairing efficiency caused by time and labor consumption for manually searching errors and repairing a plurality of errors in the prior art, the embodiment of the disclosure provides a program code repairing device. The apparatus may perform the steps of the program code repair method embodiment described in the first embodiment. As shown in fig. 2, the apparatus mainly includes: a log file acquisition module 21, a label type acquisition module 22 and a code repair module 23; wherein,
The log file obtaining module 21 is configured to obtain a log file generated when an application program runs in error, where the log file includes an interface identifier and an error code of a code segment in which the application program has an error;
the annotation type obtaining module 22 is configured to obtain, according to the interface identifier, a variable included in each line of code in the code segment and an annotation type of the variable; the labeling type is the data type of the variables which are labeled in advance;
the code repairing module 23 is used for repairing the error code or deducing the error reason reversely according to the variable and the labeling type of the variable.
Further, the device further comprises: a code segment partitioning module 24, a type labeling module 25 and a labeling file generating module 26; wherein,
The code segment dividing module 24 is configured to divide the code of the application program into at least one code segment, and add an interface identifier to each code segment;
the type labeling module 25 is configured to label the data types of the variables contained in each line of code in each code segment;
The annotation file generation module 26 is configured to generate a type annotation file according to the interface identifier of each code segment and the data type of the annotated variable;
accordingly, the label type obtaining module 22 is specifically configured to: acquiring the type annotation file; and acquiring the variable contained in each row of codes in the code segment and the labeling type of the variable from the type labeling file according to the interface identifier.
Further, the code repair module 23 is specifically configured to: determining an error variable in the error code according to the marked variable; and correcting the value of the error variable according to the labeling type of the error variable.
Further, the code repair module 23 is specifically configured to: determining the data type of an error variable in the error code; and deducing the error reason reversely according to the data type and the labeling type of the error variable.
For detailed descriptions of the working principles, the technical effects, etc. of the embodiments of the program code repairing apparatus, reference may be made to the related descriptions in the foregoing embodiments of the program code repairing method, which are not repeated herein.
Example III
Referring now to fig. 3, a schematic diagram of an electronic device 300 suitable for use in implementing embodiments of the present disclosure is shown. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 3 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 3, the electronic device 300 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 301 that may perform various suitable actions and processes in accordance with a program stored in a Read Only Memory (ROM) 302 or a program loaded from a storage means 308 into a Random Access Memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic apparatus 300 are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input/output (I/O) interface 305 is also connected to bus 304.
In general, the following devices may be connected to the I/O interface 305: input devices 306 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 307 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 308 including, for example, magnetic tape, hard disk, etc.; and communication means 309. The communication means 309 may allow the electronic device 300 to communicate with other devices wirelessly or by wire to exchange data. While fig. 3 shows an electronic device 300 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a non-transitory computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via a communication device 309, or installed from a storage device 308, or installed from a ROM 302. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing means 301.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), etc., or any suitable superposition of the above.
In some embodiments, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring a log file generated when an application program runs in error; the log file comprises an interface identifier and an error code of a code segment of the application program with errors; acquiring variables contained in each row of codes in the code segment and the labeling types of the variables according to the interface identifiers; the labeling type is the data type of the variables which are labeled in advance; and repairing the error code or reversely deducing the error reason according to the variable and the labeling type of the variable.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including but not limited to an object oriented programming language such as Java, smalltalk, C ++, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of remote computers, the remote computer may be connected to the user computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (e.g., connected through the internet using an internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. 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 or flowchart illustration, and combinations of blocks in the block diagrams 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.
The units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. The name of the unit does not in any way constitute a limitation of the unit itself, for example the first acquisition unit may also be described as "unit acquiring at least two internet protocol addresses".
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable superposition of the above. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable overlay of the foregoing.
According to one or more embodiments of the present disclosure, there is provided a program code repairing method including:
Acquiring a log file generated when an application program runs in error; the log file comprises an interface identifier and an error code of a code segment of the application program with errors;
Acquiring variables contained in each row of codes in the code segment and the labeling types of the variables according to the interface identifiers; the labeling type is the data type of the variables which are labeled in advance;
And repairing the error code or reversely deducing the error reason according to the variable and the labeling type of the variable.
Further, the method further comprises:
dividing the code of the application program into at least one code segment, and adding an interface identifier to each code segment;
marking the data type of the variable contained in each line of code in each code segment respectively;
Generating a type annotation file according to the interface identification of each code segment and the data type of the annotated variable;
Correspondingly, the obtaining the variable contained in each line of code in the code segment and the labeling type of the variable according to the interface identifier includes:
acquiring the type annotation file;
And acquiring the variable contained in each row of codes in the code segment and the labeling type of the variable from the type labeling file according to the interface identifier.
Further, the repairing the error code according to the variable and the labeling type of the variable includes:
determining an error variable in the error code according to the marked variable;
And correcting the value of the error variable according to the labeling type of the error variable.
Further, the reverse deducing the error reason according to the variable and the labeling type of the variable comprises the following steps:
Determining the data type of an error variable in the error code;
and deducing the error reason reversely according to the data type and the labeling type of the error variable.
According to one or more embodiments of the present disclosure, there is provided a program code repairing apparatus including:
The log file acquisition module is used for acquiring a log file generated when the application program runs in error; the log file comprises an interface identifier and an error code of a code segment of the application program with errors;
the marking type acquisition module is used for acquiring the variable contained in each row of codes in the code segment and the marking type of the variable according to the interface identifier; the labeling type is the data type of the variables which are labeled in advance;
And the code repairing module is used for repairing the error code or deducing the error reason reversely according to the variable and the labeling type of the variable.
Further, the device further comprises:
The code segment dividing module is used for dividing the code of the application program into at least one code segment and adding an interface identifier to each code segment;
the type marking module is used for marking the data types of the variables contained in each line of codes in each code segment respectively;
The annotation file generation module is used for generating a type annotation file according to the interface identification of each code segment and the data type of the annotated variable;
Correspondingly, the annotation type acquisition module is specifically configured to: acquiring the type annotation file; and acquiring the variable contained in each row of codes in the code segment and the labeling type of the variable from the type labeling file according to the interface identifier.
Further, the code repair module is specifically configured to: determining an error variable in the error code according to the marked variable; and correcting the value of the error variable according to the labeling type of the error variable.
Further, the code repair module is specifically configured to: determining the data type of an error variable in the error code; and deducing the error reason reversely according to the data type and the labeling type of the error variable.
According to one or more embodiments of the present disclosure, there is provided an electronic device including:
a memory for storing non-transitory computer readable instructions; and
And a processor configured to execute the computer readable instructions such that the processor performs the program code repairing method described above.
According to one or more embodiments of the present disclosure, there is provided a computer-readable storage medium storing non-transitory computer-readable instructions that, when executed by a computer, cause the computer to perform the program code repair method described above.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by those skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific arrangements of the technical features described above, but also encompasses other arrangements of the technical features described above, or their equivalents, in any manner without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcompositions.
Although the subject matter has been described in language specific to structural features or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.
Claims (6)
1. A method of repairing program code, comprising:
Acquiring a log file generated when an application program runs in error; the log file comprises an interface identifier and an error code of a code segment of the application program with errors;
Acquiring variables contained in each row of codes in the code segment and the labeling types of the variables according to the interface identifiers; the labeling type is the data type of the variables which are labeled in advance;
Repairing or reversely deducing the error reason according to the variable and the labeling type of the variable;
The step of obtaining the variable contained in each line of code in the code segment and the labeling type of the variable according to the interface identifier comprises the following steps:
Obtaining a type annotation file;
acquiring variables and annotation types of the variables contained in each row of codes in the code segment from the type annotation file according to the interface identifier;
the method further comprises the steps of:
dividing the code of the application program into at least one code segment, and adding an interface identifier to each code segment;
marking the data type of the variable contained in each line of code in each code segment respectively;
And generating a type annotation file according to the interface identification of each code segment and the data type of the annotated variable.
2. The method of claim 1, wherein the repairing the error code according to the variable and the type of annotation of the variable comprises:
determining an error variable in the error code according to the marked variable;
And correcting the value of the error variable according to the labeling type of the error variable.
3. The method of claim 1, wherein said reverse inferring of error causes based on said variables and annotation types of said variables comprises:
Determining the data type of an error variable in the error code;
and deducing the error reason reversely according to the data type and the labeling type of the error variable.
4. A program code repairing apparatus, comprising:
The log file acquisition module is used for acquiring a log file generated when the application program runs in error; the log file comprises an interface identifier and an error code of a code segment of the application program with errors;
the marking type acquisition module is used for acquiring the variable contained in each row of codes in the code segment and the marking type of the variable according to the interface identifier; the labeling type is the data type of the variables which are labeled in advance;
the code repairing module is used for repairing the error code or deducing the error reason reversely according to the variable and the labeling type of the variable;
The step of obtaining the variable contained in each line of code in the code segment and the labeling type of the variable according to the interface identifier comprises the following steps:
Obtaining a type annotation file;
acquiring variables and annotation types of the variables contained in each row of codes in the code segment from the type annotation file according to the interface identifier;
Further comprises:
dividing the code of the application program into at least one code segment, and adding an interface identifier to each code segment;
marking the data type of the variable contained in each line of code in each code segment respectively;
And generating a type annotation file according to the interface identification of each code segment and the data type of the annotated variable.
5. An electronic device, comprising:
a memory for storing non-transitory computer readable instructions; and
A processor for executing the computer readable instructions such that the processor, when executed, implements the program code repair method according to any one of claims 1-3.
6. A computer readable storage medium storing non-transitory computer readable instructions which, when executed by a computer, cause the computer to perform the program code repair method of any one of claims 1-3.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010572321.4A CN111737040B (en) | 2020-06-22 | 2020-06-22 | Program code repairing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010572321.4A CN111737040B (en) | 2020-06-22 | 2020-06-22 | Program code repairing method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111737040A CN111737040A (en) | 2020-10-02 |
CN111737040B true CN111737040B (en) | 2024-05-28 |
Family
ID=72650260
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010572321.4A Active CN111737040B (en) | 2020-06-22 | 2020-06-22 | Program code repairing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111737040B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113157256B (en) * | 2021-03-25 | 2024-03-19 | 北京达佳互联信息技术有限公司 | Method and device for generating interface code, electronic equipment, storage medium and product |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6110224A (en) * | 1996-02-08 | 2000-08-29 | Fujitsu Limited | Program analyzing apparatus which categorizes variables into domains and method thereof |
CN109240917A (en) * | 2018-08-13 | 2019-01-18 | 山东中创软件工程股份有限公司 | A kind of blog management method and relevant apparatus |
CN109766205A (en) * | 2018-12-19 | 2019-05-17 | 益萃网络科技(中国)有限公司 | Abnormality eliminating method, device, computer equipment and storage medium |
CN110837429A (en) * | 2019-10-12 | 2020-02-25 | 平安科技(深圳)有限公司 | Intelligent repairing method and device for online codes of web terminal |
CN111143185A (en) * | 2019-12-30 | 2020-05-12 | 珠海金山网络游戏科技有限公司 | Log-based fault analysis method and device |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030126590A1 (en) * | 2001-12-28 | 2003-07-03 | Michael Burrows | System and method for dynamic data-type checking |
US7478367B2 (en) * | 2005-01-11 | 2009-01-13 | International Business Machines Corporation | Dynamic source code analyzer |
US8407673B2 (en) * | 2007-11-27 | 2013-03-26 | International Business Machines Corporation | Trace log rule parsing |
US8943370B2 (en) * | 2012-06-21 | 2015-01-27 | International Business Machines Corporation | Trace value correlation with data field declarations |
US9164821B2 (en) * | 2012-12-14 | 2015-10-20 | International Business Machines Corporation | Performing diagnostic tracing of an executing application to identify suspicious pointer values |
KR102587127B1 (en) * | 2017-12-26 | 2023-10-11 | 삼성전자주식회사 | Method and apparatus for managing operational data of appliance device for failure prediction |
-
2020
- 2020-06-22 CN CN202010572321.4A patent/CN111737040B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6110224A (en) * | 1996-02-08 | 2000-08-29 | Fujitsu Limited | Program analyzing apparatus which categorizes variables into domains and method thereof |
CN109240917A (en) * | 2018-08-13 | 2019-01-18 | 山东中创软件工程股份有限公司 | A kind of blog management method and relevant apparatus |
CN109766205A (en) * | 2018-12-19 | 2019-05-17 | 益萃网络科技(中国)有限公司 | Abnormality eliminating method, device, computer equipment and storage medium |
CN110837429A (en) * | 2019-10-12 | 2020-02-25 | 平安科技(深圳)有限公司 | Intelligent repairing method and device for online codes of web terminal |
CN111143185A (en) * | 2019-12-30 | 2020-05-12 | 珠海金山网络游戏科技有限公司 | Log-based fault analysis method and device |
Also Published As
Publication number | Publication date |
---|---|
CN111737040A (en) | 2020-10-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110960855B (en) | Communication protocol code updating method and device, electronic equipment and storage medium | |
CN112395253B (en) | Index file generation method, terminal device, electronic device and medium | |
CN110634047A (en) | Method and device for recommending house resources, electronic equipment and storage medium | |
CN115757400B (en) | Data table processing method, device, electronic equipment and computer readable medium | |
CN112099982B (en) | Crash information positioning method and device, medium and electronic equipment | |
CN112016284B (en) | Electronic form processing method and device | |
CN112115153A (en) | Data processing method, device, equipment and storage medium | |
CN111857720B (en) | User interface state information generation method and device, electronic equipment and medium | |
CN110765752B (en) | Test question generation method and device, electronic equipment and computer readable storage medium | |
CN111597107A (en) | Information output method and device and electronic equipment | |
CN111737040B (en) | Program code repairing method and device | |
CN111596992A (en) | Navigation bar display method and device and electronic equipment | |
CN111143355B (en) | Data processing method and device | |
CN113176989B (en) | Log file analysis method, device, equipment and storage medium | |
CN112100211B (en) | Data storage method, apparatus, electronic device, and computer readable medium | |
CN112084086B (en) | Information collection method, device, medium and electronic equipment | |
CN111782895B (en) | Retrieval processing method and device, readable medium and electronic equipment | |
CN111460020B (en) | Method, device, electronic equipment and medium for resolving message | |
CN112905090A (en) | Spreadsheet processing method, device, terminal and storage medium | |
CN111857879B (en) | Data processing method, device, electronic equipment and computer readable medium | |
CN113032808B (en) | Data processing method and device, readable medium and electronic equipment | |
CN111026983B (en) | Method, device, medium and electronic equipment for realizing hyperlink | |
CN118035594B (en) | Method, apparatus, electronic device and computer readable medium for accessing production document | |
CN111581305B (en) | Feature processing method, device, electronic equipment and medium | |
CN111104626B (en) | Information storage method and device |
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 |