CN111737040A - Program code repairing method and device - Google Patents

Program code repairing method and device Download PDF

Info

Publication number
CN111737040A
CN111737040A CN202010572321.4A CN202010572321A CN111737040A CN 111737040 A CN111737040 A CN 111737040A CN 202010572321 A CN202010572321 A CN 202010572321A CN 111737040 A CN111737040 A CN 111737040A
Authority
CN
China
Prior art keywords
code
variable
error
type
log file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010572321.4A
Other languages
Chinese (zh)
Other versions
CN111737040B (en
Inventor
张午
马浩
沈静
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology 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 Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010572321.4A priority Critical patent/CN111737040B/en
Priority claimed from CN202010572321.4A external-priority patent/CN111737040B/en
Publication of CN111737040A publication Critical patent/CN111737040A/en
Application granted granted Critical
Publication of CN111737040B publication Critical patent/CN111737040B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0793Remedial or corrective actions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/079Root cause analysis, i.e. error or fault diagnosis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording 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/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software 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 disclosure provides a program code repair method, a device, an electronic device and a computer readable storage medium. The method comprises the following steps: acquiring a log file generated when an application program runs in error; wherein, the log file contains the interface identification and error code of the code segment with error of the application program; obtaining variables and marking types of the variables contained in each line of codes in the code segments according to the interface identifiers; wherein the marking type is a data type of a variable marked in advance; and repairing the error code or reversely deducing the error reason according to the variable and the labeled type of the variable. According to the method and the device, the log file generated when the application program runs wrongly is obtained, the variable and the labeling type of the variable contained in each line of code in the code segment are obtained according to the interface identification in the log file, the error code is repaired or the error reason is deduced reversely according to the labeling type of the variable and the variable, manual processing is not needed, and the code repairing speed and the repairing efficiency can be improved.

Description

Program code repairing method and device
Technical Field
The present disclosure relates to the field of application program technologies, and in particular, to a method and an apparatus for repairing a program code, and a computer-readable storage medium.
Background
With the development of internet applications, the stability of running an on-line application or the program code of a system is a measure of the health of an application. After the application program runs in error, 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 a program code has an error during operation, the error is usually found and repaired manually, but the manual error finding and repair takes time and labor, the program code repair speed is slow, and the repair 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 method for repairing a program code, so as to at least partially solve the technical problems of time and labor consumption for manually searching for an error and repairing, slow speed for repairing a program code, and low efficiency for repairing a program code in the prior art. Further, a program code recovery apparatus, a program code recovery hardware apparatus, a computer-readable storage medium, and a program code recovery terminal are provided.
In order to achieve the above object, according to one aspect of the present disclosure, the following technical solutions are provided:
a program code repair method, comprising:
acquiring a log file generated when an application program runs in error; wherein, the log file contains the interface identification and error code of the code segment with error of the application program;
obtaining variables contained in each line of codes in the code segments and the labeling types of the variables according to the interface identifiers; the marking type is a data type of the variable marked in advance;
and repairing the error code or reversely deducing an 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, the following technical solutions are provided:
a program code repair apparatus comprising:
the log file acquisition module is used for acquiring a log file generated when the operation of the application program is wrong; wherein, the log file contains the interface identification and error code of the code segment with error of the application program;
a marking type obtaining module, configured to obtain, according to the interface identifier, a variable included in each line of code in the code fragment and a marking type of the variable; the marking type is a data type of the variable marked in advance;
and the code repairing module is used for repairing the error code or reversely deducing an 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, the following technical solutions are provided:
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 executing implements any of the above program code repair methods.
In order to achieve the above object, according to one aspect of the present disclosure, the following technical solutions are provided:
a computer readable storage medium storing non-transitory computer readable instructions which, when executed by a computer, cause the computer to perform a program code repair method as any one of the above.
In order to achieve the above object, according to still another aspect of the present disclosure, the following technical solutions are also provided:
a program code repair terminal comprises any one of the program code repair devices.
According to the method and the device, the log file generated when the application program runs wrongly is obtained, the variable contained in each line of code in the code segment and the labeling type of the variable are obtained according to the interface identification in the log file, the error code is repaired or the error reason 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 is a summary of the present disclosure, and for the purposes of promoting a clear understanding of the technical means of the present disclosure, the present disclosure may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale.
FIG. 1 is a flow diagram of a method for program code repair 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 diagram 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 are shown in the 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 rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the 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 "include" and variations thereof as used herein are 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". Relevant definitions for other terms will be given in the following description.
Example one
In order to solve the technical problems that in the prior art, a plurality of manual errors are searched, time and labor are consumed for repair, the program code repair speed is low, and the repair efficiency is low, the embodiment of the disclosure provides a program code repair method. As shown in fig. 1, the method for repairing program codes mainly includes the following steps S11 to S13.
Step S11: acquiring a log file generated when an application program runs in error; and the log file comprises the interface identification and the error code of the code segment with the error of the application program.
The application program can be a system self-contained program in a computer or a smart phone, and can also be an installed application program.
Specifically, when an application program runs in an error, a log file is usually generated, and the log file includes an error code, which is a code that sends the error.
For example, when the application program runs on line, the code reports an error, and the interface identifier and the error code of the code segment with the error are reported. Such as: after the interface identifier id1 returns, the front end reports an error after some programs are executed. The interface identifier and the error code of the code segment with the error are uploaded at the moment, and the format is as follows:
Figure BDA0002549834540000051
Figure BDA0002549834540000061
step S12: obtaining variables contained in each line of codes in the code segments and the labeling types of the variables according to the interface identifiers; and the marking type is a data type of the variable marked in advance.
The data types comprise a String, a Number, a Boolean value, an Array, an Object, a Default value Default, an arbitrary value AnyOne and the like.
Specifically, the user may pre-label the data type of the variable included 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 Number of type:Number
Boolean Boolean value type:Boolean
Array Array of elements type:Array
Object Object type:Object
Default Default value type:Default
AnyOne Any one value type:AnyOne
Figure BDA0002549834540000062
Figure BDA0002549834540000071
For the above code fragment, id1 may be defined as an interface identifier of the code fragment, and the following mark type code may be added:
Figure BDA0002549834540000072
Figure BDA0002549834540000081
step S13: and repairing the error code or reversely deducing an error reason according to the variable and the labeling type of the variable.
In this embodiment, a log file generated when an application program runs wrongly is acquired, a variable included in each line of codes in the code fragment and a label type of the variable are acquired according to an interface identifier in the log file, and an error code is repaired or an error cause is reversely inferred according to the variable and the label type of the variable, so that manual processing is not required, and the code repairing speed and the repairing efficiency can be improved.
In an optional embodiment, the method further comprises:
step S14: dividing the code of the application program into at least one code segment, and adding an interface identifier to each code segment.
Specifically, the division may be performed according to sub-functions included in the code, for example, each sub-function is taken as a code segment.
Step S15: and respectively labeling the data types of variables contained in each line of codes in each code segment.
Step S16: and generating a type labeling file according to the interface identifier of each code segment and the data type of the labeled variable.
Correspondingly, step S12 specifically includes:
step S121: and acquiring the type marking file.
Step S122: and acquiring the variables contained in each line of codes in the code segments and the labeling types of the variables from the type labeling file according to the interface identifiers.
In an optional embodiment, step S13 specifically includes:
step S131: and determining an 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 was analyzed to be 21, but not in the enumerated range, based on the comparison of the annotated type of the variable with errorStack. A repair scheme may be generated at this point based on this error addition. Example code for a hypothetical error is as follows:
const useValueAddOne=[1,2,3,4].filter(item=>item===key33)[0]+1
the following repair scenario code may be generated:
const useValueAddOne=[1,2,3,4,21].filter(item=>item===key33)[0]+1
in an optional embodiment, step S13 specifically includes:
step S134: determining a data type of an error variable in the error code.
Step S135: and reversely deducing the error reason according to the data type and the label type of the error variable.
If the reported log file is as follows
Figure BDA0002549834540000101
The data type of key3 can be found to change from Array to String. The list Array is implemented as String in code to infer service provider back from wrong understanding.
It will be appreciated by those skilled in the art that obvious modifications (for example, a superposition of the modes listed) or equivalent substitutions may be made on the basis of the various embodiments described above.
In the above, although the steps in the embodiment of the program code recovery method are described in the above sequence, it should be clear to those skilled in the art that the steps in the embodiment of the present disclosure are not necessarily performed in the above sequence, and may also be performed in other sequences such as reverse, parallel, and cross, and further, on the basis of the above steps, those skilled in the art may also add other steps, and these obvious modifications or equivalents should also be included in the protection scope of the present disclosure, and are not described herein again.
For convenience of description, only the relevant parts of the embodiments of the present disclosure are shown, and details of the specific techniques are not disclosed, please refer to the embodiments of the method of the present disclosure.
Example two
In order to solve the technical problems that in the prior art, a plurality of manual errors are searched, time and labor are consumed for repair, the program code repair speed is low, and the repair efficiency is low, the embodiment of the disclosure provides a program code repair device. The apparatus may perform the steps in the embodiment of the program code recovery method 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 content of the first and second substances,
the log file obtaining module 21 is configured to obtain a log file generated when an operation error occurs in an application program, where the log file includes an interface identifier and an error code of a code segment in which the error occurs in the application program;
the labeling type obtaining module 22 is configured to obtain a variable included in each line of code in the code fragment and a labeling type of the variable according to the interface identifier; the marking type is a data type of the variable marked in advance;
the code repairing module 23 is configured to repair the error code or reversely infer a cause of the error according to the variable and the labeled type of the variable.
Further, the apparatus further comprises: a code segment dividing module 24, a type marking module 25 and a marking file generating module 26; wherein the content of the first and second substances,
the code segment dividing module 24 is configured to divide the code of the application into at least one code segment, and add an interface identifier to each code segment;
the type labeling module 25 is configured to label data types of variables included in each line of code in each code segment;
the label file generating module 26 is configured to generate a type label file according to the interface identifier of each code segment and the data type of the labeled variable;
correspondingly, the annotation type obtaining module 22 is specifically configured to: acquiring the type marking file; and acquiring the variables contained in each line of codes in the code segments and the labeling types of the variables from the type labeling file according to the interface identifiers.
Further, the code recovery 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 recovery module 23 is specifically configured to: determining the data type of an error variable in the error code; and reversely deducing the error reason according to the data type and the label type of the error variable.
For detailed descriptions of the working principle, the technical effect of implementation, and the like of the embodiment of the program code recovery apparatus, reference may be made to the description of the embodiment of the program code recovery method, which is not described herein again.
EXAMPLE III
Referring now to FIG. 3, a block diagram of an electronic device 300 suitable for use in implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 3 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
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 appropriate 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 necessary 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.
Generally, the following devices may be connected to the I/O interface 305: input devices 306 including, for example, a touch screen, touch pad, 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 devices 308 including, for example, magnetic tape, hard disk, etc.; and a communication device 309. The communication means 309 may allow the electronic device 300 to communicate wirelessly or by wire with other devices to exchange data. While fig. 3 illustrates an electronic device 300 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 309, or installed from the storage means 308, or installed from the ROM 302. The computer program, when executed by the processing device 301, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium of the present disclosure can be a computer readable signal medium or a computer readable storage medium or any superposition of the two. A computer readable storage medium may 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 superposition of the foregoing. In the present 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 contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable superposition of the foregoing. 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, optical 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 communications 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 network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled 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; wherein, the log file contains the interface identification and error code of the code segment with error of the application program; obtaining variables contained in each line of codes in the code segments and the labeling types of the variables according to the interface identifiers; the marking type is a data type of the variable marked in advance; and repairing the error code or reversely deducing an error reason according to the variable and the labeling type of the variable.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of 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 a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart 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 described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a unit does not in some cases constitute a limitation of the unit itself, for example, the first retrieving unit may also be described as a "unit for retrieving at least two internet protocol addresses".
The functions described herein above 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: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), 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. A 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 combination of the foregoing. 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 superposition of the foregoing.
According to one or more embodiments of the present disclosure, there is provided a program code repair method including:
acquiring a log file generated when an application program runs in error; wherein, the log file contains the interface identification and error code of the code segment with error of the application program;
obtaining variables contained in each line of codes in the code segments and the labeling types of the variables according to the interface identifiers; the marking type is a data type of the variable marked in advance;
and repairing the error code or reversely deducing an 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;
respectively marking the data types of variables contained in each line of codes in each code segment;
generating a type marking file according to the interface identification of each code segment and the data type of the marked variable;
correspondingly, the obtaining of the variable included in each line of code in the code fragment and the labeled type of the variable according to the interface identifier includes:
acquiring the type marking file;
and acquiring the variables contained in each line of codes in the code segments and the labeling types of the variables from the type labeling file according to the interface identifiers.
Further, the repairing the error code according to the variable and the labeled 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 reversely deducing the error reason according to the variable and the labeling type of the variable comprises:
determining the data type of an error variable in the error code;
and reversely deducing the error reason according to the data type and the label type of the error variable.
According to one or more embodiments of the present disclosure, there is provided a program code repair apparatus including:
the log file acquisition module is used for acquiring a log file generated when the operation of the application program is wrong; wherein, the log file contains the interface identification and error code of the code segment with error of the application program;
a marking type obtaining module, configured to obtain, according to the interface identifier, a variable included in each line of code in the code fragment and a marking type of the variable; the marking type is a data type of the variable marked in advance;
and the code repairing module is used for repairing the error code or reversely deducing an error reason according to the variable and the labeling type of the variable.
Further, the apparatus 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 respectively marking the data types of the variables contained in each line of codes in each code segment;
the label file generating module is used for generating a type label file according to the interface identifier of each code segment and the data type of the labeled variable;
correspondingly, the annotation type obtaining module is specifically configured to: acquiring the type marking file; and acquiring the variables contained in each line of codes in the code segments and the labeling types of the variables from the type labeling file according to the interface identifiers.
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 reversely deducing the error reason according to the data type and the label 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 the processor is used for executing the computer readable instructions, so that the processor realizes the program code repairing method when executing.
According to one or more embodiments of the present disclosure, there is provided a computer-readable storage medium storing non-transitory computer-readable instructions which, when executed by a computer, cause the computer to perform the above-described program code repair method.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular arrangement of features above described which are stacked together, and that other arrangements in which features of the above described type or their equivalents are stacked together as desired without departing from the spirit of the disclosure are also encompassed. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while 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. Under 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 limitations on the scope of the 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 subcombination.
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 disclosed as example forms of implementing the claims.

Claims (7)

1. A method for program code repair, comprising:
acquiring a log file generated when an application program runs in error; wherein, the log file contains the interface identification and error code of the code segment with error of the application program;
obtaining variables contained in each line of codes in the code segments and the labeling types of the variables according to the interface identifiers; the marking type is a data type of the variable marked in advance;
and repairing the error code or reversely deducing an error reason according to the variable and the labeling type of the variable.
2. The method of claim 1, further comprising:
dividing the code of the application program into at least one code segment, and adding an interface identifier to each code segment;
respectively marking the data types of variables contained in each line of codes in each code segment;
generating a type marking file according to the interface identification of each code segment and the data type of the marked variable;
correspondingly, the obtaining of the variable included in each line of code in the code fragment and the labeled type of the variable according to the interface identifier includes:
acquiring the type marking file;
and acquiring the variables contained in each line of codes in the code segments and the labeling types of the variables from the type labeling file according to the interface identifiers.
3. The method according to claim 1 or 2, wherein the repairing the error code according to the variable and the label type 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.
4. The method according to claim 1 or 2, wherein the reversely deducing the error reason according to the variable and the label type of the variable comprises:
determining the data type of an error variable in the error code;
and reversely deducing the error reason according to the data type and the label type of the error variable.
5. A program code recovery apparatus, comprising:
the log file acquisition module is used for acquiring a log file generated when the operation of the application program is wrong; wherein, the log file contains the interface identification and error code of the code segment with error of the application program;
a marking type obtaining module, configured to obtain, according to the interface identifier, a variable included in each line of code in the code fragment and a marking type of the variable; the marking type is a data type of the variable marked in advance;
and the code repairing module is used for repairing the error code or reversely deducing an error reason according to the variable and the labeling type of the variable.
6. 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 executing implements the program code repair method according to any of claims 1-4.
7. 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-4.
CN202010572321.4A 2020-06-22 Program code repairing method and device Active CN111737040B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010572321.4A CN111737040B (en) 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 Program code repairing method and device

Publications (2)

Publication Number Publication Date
CN111737040A true CN111737040A (en) 2020-10-02
CN111737040B CN111737040B (en) 2024-05-28

Family

ID=

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113157256A (en) * 2021-03-25 2021-07-23 北京达佳互联信息技术有限公司 Interface code generation method and device, electronic equipment, storage medium and product

Citations (11)

* Cited by examiner, † Cited by third party
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
US20030126590A1 (en) * 2001-12-28 2003-07-03 Michael Burrows System and method for dynamic data-type checking
US20060156286A1 (en) * 2005-01-11 2006-07-13 Morgan Fabian F Dynamic source code analyzer
US20090138861A1 (en) * 2007-11-27 2009-05-28 Massimo Terpolilli Trace Log Rule Parsing
US20130346806A1 (en) * 2012-06-21 2013-12-26 International Business Machines Corporation Trace value correlation with data field declarations
US20140173356A1 (en) * 2012-12-14 2014-06-19 International Business Machines Corporation Performing diagnostic tracing of an executing application to identify suspicious pointer values
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
US20190196893A1 (en) * 2017-12-26 2019-06-27 Samsung Electronics Co., Ltd. Method and apparatus for managing operation data of appliance for failure prediction
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

Patent Citations (11)

* Cited by examiner, † Cited by third party
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
US20030126590A1 (en) * 2001-12-28 2003-07-03 Michael Burrows System and method for dynamic data-type checking
US20060156286A1 (en) * 2005-01-11 2006-07-13 Morgan Fabian F Dynamic source code analyzer
US20090138861A1 (en) * 2007-11-27 2009-05-28 Massimo Terpolilli Trace Log Rule Parsing
US20130346806A1 (en) * 2012-06-21 2013-12-26 International Business Machines Corporation Trace value correlation with data field declarations
US20140173356A1 (en) * 2012-12-14 2014-06-19 International Business Machines Corporation Performing diagnostic tracing of an executing application to identify suspicious pointer values
US20190196893A1 (en) * 2017-12-26 2019-06-27 Samsung Electronics Co., Ltd. Method and apparatus for managing operation data of appliance for failure prediction
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

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113157256A (en) * 2021-03-25 2021-07-23 北京达佳互联信息技术有限公司 Interface code generation method and device, electronic equipment, storage medium and product
CN113157256B (en) * 2021-03-25 2024-03-19 北京达佳互联信息技术有限公司 Method and device for generating interface code, electronic equipment, storage medium and product

Similar Documents

Publication Publication Date Title
CN110634047B (en) Method and device for recommending house resources, electronic equipment and storage medium
CN112395253B (en) Index file generation method, terminal device, electronic device and medium
CN115757400B (en) Data table processing method, device, electronic equipment and computer readable medium
CN110960855B (en) Communication protocol code updating method and device, electronic equipment and storage medium
CN111950857A (en) Index system management method and device based on service indexes and electronic equipment
CN111800513A (en) Method and device for pushing information and computer readable medium of electronic equipment
CN112115153A (en) Data processing method, device, equipment and storage medium
CN111552640A (en) Code detection method, device, equipment and storage medium
CN113157731A (en) Symbol analysis method, device, equipment and storage medium
CN112099982A (en) Collapse information positioning method, device, medium and electronic equipment
CN111262907B (en) Service instance access method and device and electronic equipment
CN111597107A (en) Information output method and device and electronic equipment
CN111756953A (en) Video processing method, device, equipment and computer readable medium
CN111708680A (en) Error reporting information analysis method and device, electronic equipment and storage medium
CN111737040A (en) Program code repairing method and device
CN111143355B (en) Data processing method and device
CN111737040B (en) Program code repairing method and device
CN112084086B (en) Information collection method, device, medium and electronic equipment
CN112905090A (en) Spreadsheet processing method, device, terminal and storage medium
CN115034175A (en) Table data processing method, device, terminal and storage medium
CN112380476A (en) Information display method and device and electronic equipment
CN111597439A (en) Information processing method and device and electronic equipment
CN110543243A (en) Data processing method, device, equipment and storage medium
CN114040014B (en) Content pushing method, device, electronic equipment and computer readable storage medium
CN111209042B (en) Method, device, medium and electronic equipment for establishing function stack

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