CN117033042A - Fault restoration method and device for application program and electronic equipment - Google Patents

Fault restoration method and device for application program and electronic equipment Download PDF

Info

Publication number
CN117033042A
CN117033042A CN202310877239.6A CN202310877239A CN117033042A CN 117033042 A CN117033042 A CN 117033042A CN 202310877239 A CN202310877239 A CN 202310877239A CN 117033042 A CN117033042 A CN 117033042A
Authority
CN
China
Prior art keywords
program
instruction
binary
memory
source program
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.)
Pending
Application number
CN202310877239.6A
Other languages
Chinese (zh)
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.)
Loongson Technology Corp Ltd
Original Assignee
Loongson Technology Corp 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 Loongson Technology Corp Ltd filed Critical Loongson Technology Corp Ltd
Priority to CN202310877239.6A priority Critical patent/CN117033042A/en
Publication of CN117033042A publication Critical patent/CN117033042A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0706Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment
    • G06F11/0736Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment in functional embedded systems, i.e. in a data processing system designed as a combination of hardware and software dedicated to performing a certain function
    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application provides a fault repairing method and device for an application program and electronic equipment, and relates to the technical field of electronic equipment. The fault repairing method of the application program comprises the following steps: compiling a repair program to generate a binary repair program, wherein the repair program is used for controlling the execution of a correct instruction corresponding to the error instruction when the error code of the application program needs to be executed and the error instruction is compiled; loading the binary repair program into a memory, and running the binary repair program; modifying the binary source program compiled by the application program in the memory by running the binary repair program to obtain a modified binary source program; and running the modified binary source program, and if the error instruction in the binary source program is required to be executed in the process of running the modified binary source program, acquiring the correct instruction corresponding to the error instruction in the memory, and executing the correct instruction. The application effectively ensures the normal operation of the application program which is not allowed to be modified by the source program.

Description

Fault restoration method and device for application program and electronic equipment
Technical Field
The present application relates to the field of electronic devices, and in particular, to a method and an apparatus for repairing a fault of an application program, and an electronic device.
Background
The embedded device may implement the functionality supported by different applications by running different applications. The embedded device may be configured to carry different types of operating systems or different versions of the same type of operating system, and the same application program may have a problem of running errors when running on different types of operating systems or different versions of the same type of operating system. At this time, the error code in the source program of the application program can be modified, so that the application program is adapted to the corresponding operating system, and the normal running of the application program on the embedded device can be ensured.
However, there is a class of applications whose source is not allowed to be modified. How to ensure the normal operation of the application program when the application program is in error operation becomes a problem to be solved urgently.
Disclosure of Invention
In view of the foregoing, embodiments of the present application have been made to provide a method, an apparatus, and an electronic device for repairing a failure of an application program that overcomes or at least partially solves the foregoing problems, where a source program does not allow normal operation of such an application program that is modified.
In order to solve the above problems, an embodiment of the present application discloses a method for repairing a fault of an application program, the method comprising:
acquiring a binary repair program after compiling the repair program; the repairing program is used for replacing and executing a correct instruction corresponding to the error instruction when the error code of the application program is executed and the error instruction is compiled;
loading the binary repair program into a memory, and running the binary repair program;
modifying the binary source program compiled by the application program in the memory by running the binary repair program to obtain a modified binary source program, wherein the modified binary source program is used for replacing and executing a correct instruction corresponding to the error instruction in the memory when the error instruction in the binary source program is executed so as to enable the application program to run normally after being repaired;
and running the modified binary source program.
The embodiment of the application also discloses a fault repairing device of the application program, which comprises:
the acquisition module is used for acquiring the binary repair program after the repair program is compiled; the repairing program is used for replacing and executing a correct instruction corresponding to the error instruction when the error code of the application program is executed and the error instruction is compiled;
The operation module is used for loading the binary repair program into a memory and operating the binary repair program;
the modification module is used for modifying the binary source program compiled by the application program in the memory by running the binary repair program to obtain a modified binary source program, and the modified binary source program is used for replacing and executing a correct instruction corresponding to the error instruction in the memory when the error instruction in the binary source program is executed so as to enable the application program to run normally after being repaired;
the operation module is also used for operating the modified binary source program.
The embodiment of the application also discloses an electronic device, which comprises: a processor, a memory and a computer program stored on the memory and executable on the processor, which when executed by the processor, implements the steps of the method for repairing a fault in an application as described in any of the preceding first aspects.
The embodiment of the application also discloses a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program realizes the steps of the fault restoration method of the application program in any one of the first aspect when being executed by a processor.
The embodiment of the application has the following advantages:
in the embodiment of the application, the binary source program after compiling the application program in the memory is modified by running the binary repair program generated by compiling the repair program, so as to obtain the modified binary source program. Since the repair program can be used to replace the correct instruction corresponding to the execution error instruction when the error code of the application program is executed and compiled into the error instruction. Therefore, the modified binary source program can be used for replacing the correct instruction corresponding to the error instruction in the execution memory when the error instruction in the binary source program is executed, so that the application program can normally run after being repaired. According to the technical scheme, the binary source program compiled by the application program is modified, so that the application program can directly execute the correct instruction corresponding to the error code during operation, the execution of the error instruction corresponding to the error code is avoided, and the normal operation of the application program is ensured. Particularly, for the application program of the type which is not allowed to be modified by the source program, the normal operation of the application program can be ensured by modifying the binary source program compiled by the source program on the premise of not modifying the source program of the application program.
Drawings
FIG. 1 is a schematic diagram illustrating the operation of an application and an operating system according to an embodiment of the present application;
FIG. 2 is a flowchart of a method for repairing a failure of an application according to an embodiment of the present application;
FIG. 3 is a flowchart of another method for repairing a failure of an application according to an embodiment of the present application;
FIG. 4 is a flowchart of a method for repairing a failure of an application according to another embodiment of the present application;
FIG. 5 is a schematic diagram of a fault repair process provided by an embodiment of the present application;
FIG. 6 is a flow chart illustrating another method for repairing a failure of an application according to another embodiment of the present application;
FIG. 7 shows a block diagram of an application fault resilient device provided by an embodiment of the present application;
fig. 8 shows a block diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order that the above-recited objects, features and advantages of the present application will become more readily apparent, a more particular description of the application will be rendered by reference to the appended drawings and appended detailed description.
The embedded device may implement the functionality supported by different applications by running different applications. The embedded device may have different operating systems, and the same application program may run on different operating systems, which may have a problem of running error. At this time, the error code in the source program of the application program can be modified, so that the application program is adapted to the operating system, and the normal running of the application program on the embedded device is ensured. The developer can write correct codes for repairing the running error problem of the application program on the operating system. When the error code which is used for generating the running error problem in the application program is executed, the correct code is replaced and executed, so that the application program can normally run on the operating system, and the problem of the adaptation of the application program to the operating system is solved.
For example, an embedded device may be running an embedded operating system. Referring to fig. 1, a schematic diagram of an application program and an operating system according to an embodiment of the application is shown. As shown in fig. 1, the embedded integrated development environment may compile relevant source codes of an application program to be run on the embedded device, a software system of the embedded operating system, a driver, and relevant source codes of a processor architecture, to obtain a binary source program of the application program, a software system of the embedded operating system, a driver, and a binary source program of the processor architecture. The application program, the software system of the embedded operating system, the driver and the binary source program of the processor architecture are loaded to the memory of the embedded device, so that the binary source program of the application program runs on the embedded operating system, and the embedded device is endowed with the function supported by the application program. Wherein the embedded integrated development environment supports two compilers. Typically, the relevant source code of an application may be compiled using either of these two compilers. The related source code of the embedded operating system needs to follow the set rules and adopt different kinds of compilers for compiling. In one application environment, an embedded device is loaded with a chip, with both its embedded operating system and application programs running on top of the chip running environment provided by the chip.
In an alternative implementation, the embedded integrated development environment may create established IDE engineering files for managing and building application modules of the system kernel. The application module may run and debug applications on devices with embedded operating systems and dynamically load, unload, and reload applications.
However, there is a class of applications, the source of which is not allowed to be modified. How to ensure the normal operation of the application program when the application program is in error operation becomes a problem to be solved urgently.
Referring to fig. 2, a flowchart of a fault repairing method for an application program according to an embodiment of the application is shown. The fault repairing method can be applied to the embedded device and the embedded integrated development environment shown in fig. 1 and is executed by the embedded device. As shown in fig. 2, the fault repairing method includes:
step 201, obtaining a binary repair program after compiling the repair program. The repair program is used for replacing correct instructions corresponding to the execution error instructions when the error codes of the application program are executed to compile the error instructions.
Alternatively, the embedded device may obtain a binary fix program generated by compiling the fix program by the embedded integrated development environment. The repair program is used for replacing correct instructions corresponding to the execution error instructions when the error codes of the application program are executed to compile the error instructions. The correct instruction is a binary instruction generated by compiling correct code corresponding to the error code of the application program by the embedded integrated development environment. The correct code may be a correct code written by a person based on the cause of the error code running error. The embedded integrated development environment can compile correct codes by adopting a target compiler to ensure consistency of the error codes and the compiling modes of the correct codes, thereby ensuring normal operation of binary source programs after replacing correct instructions. The target compiler is a compiler that compiles the application.
In an alternative implementation, the repairing program is used for replacing the error instruction in the binary source program compiled by the application program with the correct instruction, so that the correct instruction corresponding to the error instruction is executed when the error instruction compiled by the error code of the application program needs to be executed. In another alternative implementation, the repair program is configured to add a call instruction before the error instruction in the binary source program, so that the correct instruction corresponding to the error instruction is executed when the error instruction of the application program is required to be executed after the error code is compiled. The call instruction is used to call the correct instruction in the memory.
For example, the embedded integrated development environment may compile a fix program using a target compiler. The target compiler is a compiler that compiles the application. That is, the embedded integrated development environment may be compiled into a binary repair program using the same compiler as the application. This makes it possible to try to avoid running errors in the program interworking that may be caused by using different compilers.
Step 202, loading the binary repair program into the memory, and running the binary repair program.
In some embodiments of the present application, the embedded device loads the binary repair program to the memory through the running embedded operating system, and runs the binary repair program.
And 203, modifying the binary source program compiled by the application program in the memory by running the binary repair program to obtain a modified binary source program.
In the embodiment of the application, after acquiring the binary source program compiled by the application program, the embedded device loads the binary source program into the memory. And modifying the binary source program in the memory by running the binary repair program. The modified binary source program is used for replacing the correct instruction corresponding to the error instruction in the execution memory when the error instruction in the binary source program is executed, so that the application program can normally run after being repaired.
In an alternative implementation, the repair program is used to replace the error instructions in the binary source program after the application program has been compiled with the correct instructions.
Specifically, the process of modifying the binary source program compiled from the application program in the memory to obtain the modified binary source program may include the following steps 2031A to 2032A.
In step 2031A, the correct instruction in memory corresponding to the incorrect instruction is fetched.
Optionally, the embedded device may obtain the correct instruction compiled by the embedded integrated development environment, load the correct instruction into the memory, and record the memory address where the correct instruction is stored. The embedded device obtains the correct instruction in the memory based on the memory address by running the binary repair program. Or the embedded device can acquire the correct instruction compiled by the embedded integrated development environment and load the correct instruction to a preset fixed position in the memory. The embedded device obtains the correct instruction in the memory based on the memory address of the preset fixed position by running the binary repair program.
In step 2032A, the error instruction in the in-memory binary source program is replaced with the correct instruction, resulting in a modified binary source program.
Optionally, the embedded device may obtain a target address corresponding to a wrong instruction in the binary source program in the memory, and replace an instruction stored in the target address with a correct instruction, so as to obtain a modified binary source program. In an alternative implementation, the repair program records the function name of the objective function where the error code is located and the address offset corresponding to the error code, respectively. The address offset is an offset of a storage address in the memory of the erroneous instruction compared to the first address. The first address is the first address of the memory block storing the function instruction corresponding to the target function.
Based on this, the implementation process of obtaining the target address corresponding to the error instruction in the binary source program in the memory may include: and searching the first address in the memory according to the function name. And calculating a target address corresponding to the error instruction according to the head address and the address offset.
The embedded device may call an address lookup function to lookup the first address in memory based on the function name. The target address is calculated from the head address and the address offset. The address searching function is used for searching the memory block of the target function indicated by the function name in the memory and outputting the first address of the memory block.
Further alternatively, the embedded device may call a data copy function to overwrite copies the correct instruction into the target address to replace the erroneous instruction stored in the target address.
For example, as shown in fig. 3, by running the binary repair program, the function name of the objective function x where the error code recorded in the binary repair program is located is obtained. The address lookup function is called to find the target function x. It is determined whether the objective function x is found. And when the objective function x is not found, outputting repair failure information. The repair failure information may indicate that no error code was found. When the target function x is found, the head address of the target function is obtained, and the target address is calculated based on the head address and the address offset corresponding to the error code recorded by the binary repair program. And calling a data copying function to replace the error instruction in the target address with the correct instruction, and outputting the repairing success information.
It should be noted that, in some embodiments, by running the binary repair program, the function instruction of the objective function where the error instruction is located may be replaced by the correct function instruction as a whole. The correct function instruction comprises a correct instruction corresponding to the error instruction. Therefore, when the occupation of the error instruction in the function instruction is larger, the whole replacement of the function instruction can more effectively ensure the correct operation of the replaced function instruction compared with the replacement of a plurality of single instructions.
In another alternative implementation, the fix-up program is used to add a call instruction before the erroneous instruction in the binary source program.
Specifically, the process of modifying the binary source program compiled from the application program in the memory to obtain the modified binary source program may include the following step 2031B.
In step 2031B, a call instruction is added before the error instruction in the binary source program, resulting in a modified binary source program.
Optionally, the embedded device may obtain the correct instruction and the call instruction compiled by the embedded integrated development environment, load the correct instruction and the call instruction into the memory, and record the memory address where the call instruction is stored. And the embedded equipment acquires the calling instruction in the memory based on the memory address by running the binary repair program. Or the embedded device can acquire the correct instruction and the call instruction compiled by the embedded integrated development environment, and load the correct instruction and the call instruction to a preset fixed position in the memory. And the embedded equipment acquires the calling instruction in the memory based on the memory address of the preset fixed position by running the binary repair program.
In some embodiments of the present application, by running a binary repair program, a target address corresponding to an erroneous instruction in a memory may be obtained, and a call instruction is added before the erroneous instruction in a binary source program based on the target address. Wherein the embedded device may call a data addition function to add the call instruction to the target address. It should be noted that, the manner of acquiring the target address corresponding to the error instruction may refer to the manner of acquiring the target address in the previous implementation, which is not described herein.
Step 204, running the modified binary source program.
In the embodiment of the application, after the binary source program compiled by the application program in the memory is modified, the embedded device can run the modified binary source program so as to normally run the application program.
In summary, according to the fault repairing method for the application program provided by the embodiment of the application, the binary repairing program generated by compiling the repairing program is operated to modify the binary source program compiled by the application program in the memory, so as to obtain the modified binary source program. Since the repair program can be used to replace the correct instruction corresponding to the execution error instruction when the error code of the application program is executed and compiled into the error instruction. Therefore, the modified binary source program can be used for replacing the correct instruction corresponding to the error instruction in the execution memory when the error instruction in the binary source program is executed, so that the application program can normally run after being repaired. According to the technical scheme, the binary source program compiled by the application program is modified, so that the application program can directly execute the correct instruction corresponding to the error code during operation, the execution of the error instruction corresponding to the error code is avoided, and the normal operation of the application program is ensured. Particularly, for the application program of the type which is not allowed to be modified by the source program, the normal operation of the application program can be ensured by modifying the binary source program compiled by the source program on the premise of not modifying the source program of the application program.
Referring to fig. 4, a flowchart of a fault repairing method for an application program according to an embodiment of the present application is shown. The fault repairing method can be applied to the embedded device and the embedded integrated development environment shown in fig. 1 and is executed by the embedded device. As shown in fig. 4, the fault repairing method includes:
step 401, obtaining a correct code compiled by a target compiler, and obtaining a correct instruction. The target compiler is a compiler that compiles the application.
In the embodiment of the application, the embedded device can acquire the correct instruction generated by compiling the correct code corresponding to the error code of the application program by the target compiler in the embedded integrated development environment. The embedded integrated development environment can compile correct codes by adopting a target compiler to ensure consistency of the error codes and the compiling modes of the correct codes, thereby ensuring normal operation of binary source programs after replacing correct instructions.
Step 402, load the correct instruction into the memory.
Alternatively, the embedded device may load the correct instruction into memory and record the memory address where the correct instruction is stored. Alternatively, the embedded device may load the correct instruction into a predetermined fixed location in memory. For example, the embedded device loads the correct instruction to a preset fixed location in the memory through the running embedded operating system.
Step 403, obtaining the binary repair program after compiling the repair program. The repair program is used for controlling the correct instruction corresponding to the execution error instruction when the error code of the application program is required to be executed and the error instruction is compiled.
Alternatively, the embedded device may obtain a binary fix program generated by compiling the fix program by the embedded integrated development environment. In an alternative implementation, the repairing program is used for replacing the error instruction in the binary source program compiled by the application program with the correct instruction, so that the correct instruction corresponding to the error instruction is executed when the error instruction compiled by the error code of the application program needs to be executed. In another alternative implementation, the repair program is configured to add a call instruction before the error instruction in the binary source program, so that the correct instruction corresponding to the error instruction is executed when the error instruction of the application program is required to be executed after the error code is compiled. The call instruction is used to call the correct instruction in the memory.
For example, the embedded integrated development environment may compile a fix program using a target compiler. The target compiler is a compiler that compiles the application. That is, the embedded integrated development environment may be compiled into a binary repair program using the same compiler as the application. This makes it possible to try to avoid running errors in the program interworking that may be caused by using different compilers.
Step 404, loading the binary repair program into the memory, and running the binary repair program.
In some embodiments of the present application, the embedded device loads the binary repair program to the memory through the running embedded operating system, and runs the binary repair program.
And 405, modifying the binary source program compiled by the application program in the memory by running the binary repair program to obtain a modified binary source program.
The explanation and implementation of this step may refer to the explanation and implementation of step 203, which is not described in detail in the embodiments of the present application.
Step 406, running the modified binary source program.
In the embodiment of the application, after the binary source program compiled by the application program in the memory is modified, the embedded device can run the modified binary source program so as to normally run the application program.
It should be noted that, in the case where the repair program is used to replace the error instruction in the binary source program compiled by the application program with the correct instruction, the embedded device may further perform the step of unloading the binary repair program and the correct instruction before performing step 307, so as to delete the redundant instruction in the memory after the binary source program is completed by modifying the binary repair program and the correct code, and it is determined that the binary repair program and the correct instruction are not useful.
In one alternative implementation, the embedded integrated development environment and embedded device may run applications as well as repair programs. Before executing step 401, the embedded device obtains a binary source program compiled by a source program of the application program under the condition of executing a loading instruction corresponding to the application program, and loads the binary source program into the memory.
Correspondingly, under the condition that the embedded device executes the loading instruction corresponding to the repair program, executing the steps 401 to 403 to obtain the binary repair program compiled by the repair program, and loading the correct instruction into the memory. And acquiring the binary repair program after compiling the repair program, and loading the binary repair program into the memory. The embedded device runs the binary repair program under the condition of executing the running instruction of the repair program.
And correspondingly, under the condition that the embedded device executes the operation instruction corresponding to the application program, executing step 407 to operate the modified binary source program.
Optionally, the embedded device may execute a target instruction set, where the target instruction set includes a load instruction corresponding to the application program, a load instruction corresponding to the repair program, an operation instruction of the repair program, and an operation instruction corresponding to the application program, which are sequentially arranged. The target instruction set may be an instruction set pre-written by a user. Alternatively, the target instruction set may be an instruction set sequentially input by the user according to the repair process of the application program. In the embodiment of the application, the instructions for running the application program comprise two instructions, namely a loading instruction and a running instruction. Therefore, the loading instruction and the running instruction corresponding to the repairing program can be simply added between the loading instruction and the running instruction corresponding to the application program, so that the running process of the repairing program is added after the binary source program of the application program is loaded into the memory and before the binary source program is run, the modification of the error code of the application program is realized, and the normal running of the application program is ensured.
In the embodiment of the application, the binary source program compiled by the application program is modified, so that the application program can directly execute the correct instruction corresponding to the error code during operation, thereby avoiding executing the error instruction corresponding to the error code and ensuring the normal operation of the application program. Particularly for the solidification application program, the normal operation of the application program can be ensured by modifying the binary source program compiled by the source program on the premise of not modifying the source program of the application program.
For easy understanding, the technical solutions of the present application are further schematically described with the following examples. As shown in fig. 5 and 6, the embedded integrated development environment loads the artificially written fix program and the correct code xFix. And compiling the repair program and the correct code xFix by adopting a target editor to obtain a binary repair program and a correct instruction. And the embedded device loads the binary repair program and the correct instruction into the memory and runs the repair program. And modifying the binary source program compiled by the application program to obtain a modified binary source program so as to repair the application program. Unloading the binary repair program and the correct instruction, and running the modified binary source program, namely running the repaired application program. The operation repair program can realize the repair of the application program by replacing the error instruction in the memory with the correct instruction.
In summary, according to the fault repairing method for the application program provided by the embodiment of the application, the binary repairing program generated by compiling the repairing program is operated to modify the binary source program compiled by the application program in the memory, so as to obtain the modified binary source program. Since the repair program can be used to replace the correct instruction corresponding to the execution error instruction when the error code of the application program is executed and compiled into the error instruction. Therefore, the modified binary source program can be used for replacing the correct instruction corresponding to the error instruction in the execution memory when the error instruction in the binary source program is executed, so that the application program can normally run after being repaired. According to the technical scheme, the binary source program compiled by the application program is modified, so that the application program can directly execute the correct instruction corresponding to the error code during operation, the execution of the error instruction corresponding to the error code is avoided, and the normal operation of the application program is ensured. Particularly, for the application program of the type which is not allowed to be modified by the source program, the normal operation of the application program can be ensured by modifying the binary source program compiled by the source program on the premise of not modifying the source program of the application program.
Referring to fig. 7, a block diagram of a fault repairing apparatus for an application according to an embodiment of the present application is shown. As shown in fig. 7, the failure recovery apparatus 700 of the application program includes: an acquisition module 701, a running module 702 and a modification module 703.
An obtaining module 701, configured to obtain a binary repair program after compiling the repair program; the repairing program is used for replacing and executing a correct instruction corresponding to the error instruction when the error code of the application program is executed and the error instruction is compiled;
an operation module 702, configured to load the binary repair program into a memory, and operate the binary repair program;
the modifying module 703 is configured to modify the binary source program compiled by the application program in the memory by running the binary repair program, so as to obtain a modified binary source program, where the modified binary source program is configured to replace and execute a correct instruction corresponding to the error instruction in the memory when the error instruction in the binary source program is executed, so that the application program is normally run after being repaired;
the running module 702 is further configured to run the modified binary source program.
Optionally, the modifying module 703 is further configured to:
acquiring a correct instruction corresponding to the error instruction in the memory;
and replacing the error instruction in the binary source program in the memory with the correct instruction to obtain the modified binary source program.
Optionally, the repairing program records the function name of the objective function where the error code is located and the address offset corresponding to the error code, wherein the address offset is the offset of the storage address corresponding to the error instruction in the memory compared with the first address, and the first address is the first address of the memory block of the function instruction corresponding to the storage objective function;
the modification module 703 is further configured to:
searching a first address in a memory according to the function name;
calculating a target address corresponding to the error instruction according to the first address and the address offset;
and replacing the instruction stored in the target address with the correct instruction to obtain the modified binary source program.
Optionally, the modifying module 703 is further configured to: adding a calling instruction before an error instruction in the binary source program to obtain a modified binary source program; the call instruction is used to call the correct instruction in the memory.
Optionally, the obtaining module 701 is further configured to obtain a correct code compiled by the target compiler, to obtain a correct instruction; the target compiler is a compiler for compiling error codes of the application program;
The execution module 702 is further configured to load the correct instruction into the memory.
Optionally, the fault repairing apparatus 700 of the application program further includes: and the unloading module is also used for unloading the binary repair program and the correct instruction.
Optionally, the obtaining module 701 is further configured to obtain a binary source program of the compiled source program of the application program under the condition that a load instruction corresponding to the application program is executed;
the operation module 702 is further configured to load the binary source program into the memory;
the obtaining module 701 is further configured to obtain a binary repair program after compiling the repair program under the condition that a loading instruction and an operating instruction corresponding to the repair program are executed;
the operation module 702 is further configured to operate the modified binary source program when an operation instruction corresponding to the application program is executed.
In summary, according to the fault repairing method for the application program provided by the embodiment of the application, the binary repairing program generated by compiling the repairing program is operated to modify the binary source program compiled by the application program in the memory, so as to obtain the modified binary source program. Since the repair program can be used to replace the correct instruction corresponding to the execution error instruction when the error code of the application program is executed and compiled into the error instruction. Therefore, the modified binary source program can be used for replacing the correct instruction corresponding to the error instruction in the execution memory when the error instruction in the binary source program is executed, so that the application program can normally run after being repaired. According to the technical scheme, the binary source program compiled by the application program is modified, so that the application program can directly execute the correct instruction corresponding to the error code during operation, the execution of the error instruction corresponding to the error code is avoided, and the normal operation of the application program is ensured. Particularly, for the application program of the type which is not allowed to be modified by the source program, the normal operation of the application program can be ensured by modifying the binary source program compiled by the source program on the premise of not modifying the source program of the application program.
Fig. 8 is a block diagram illustrating a configuration of an electronic device according to an exemplary embodiment. For example, electronic device 800 may be a mobile phone, computer, digital broadcast terminal, messaging device, game console, tablet device, medical device, exercise device, personal digital assistant, or the like.
Referring to fig. 8, an electronic device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input/output (I/O) interface 812, a sensor component 814, and a communication component 816.
The processing component 802 generally controls overall operation of the electronic device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing element 802 may include one or more processors 920 to execute instructions to perform all or part of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interactions between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operations at the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
The power supply component 806 provides power to the various components of the electronic device 800. The power components 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the electronic device 800.
The multimedia component 808 includes a screen between the electronic device 800 and the user that provides an output interface. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and/or a rear camera. When the electronic device 800 is in an operational mode, such as a shooting mode or a video mode, the front camera and/or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 further includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be a keyboard, click wheel, buttons, etc. These buttons may include, but are not limited to: homepage button, volume button, start button, and lock button.
The sensor assembly 814 includes one or more sensors for providing status assessment of various aspects of the electronic device 800. For example, the sensor assembly 814 may detect an on/off state of the electronic device 800, a relative positioning of the components, such as a display and keypad of the electronic device 800, the sensor assembly 814 may also detect a change in position of the electronic device 800 or a component of the electronic device 800, the presence or absence of a user's contact with the electronic device 800, an orientation or acceleration/deceleration of the electronic device 800, and a change in temperature of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscopic sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communication between the electronic device 800 and other devices, either wired or wireless. The electronic device 800 may access a wireless network based on a communication standard, such as WiFi,2G, or 3G, or a combination thereof. In one exemplary embodiment, the communication component 816 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 800 can be implemented by one or more Application Specific Integrated Circuits (ASICs), digital signal processing circuits (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic elements.
In this embodiment, the electronic device further includes a chip provided by the embodiment of the present application.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
It will be apparent to those skilled in the art that embodiments of the present application may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the application may take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the scope of the embodiments of the application.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or terminal device comprising the element.
The foregoing has described in detail a current source module and apparatus, an electronic device and a storage medium according to the present application, and specific examples have been provided herein to illustrate the principles and embodiments of the present application, the above examples being provided only to assist in understanding the method of the present application and its core ideas; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.

Claims (10)

1. A method for repairing a failure of an application, the method comprising:
acquiring a binary repair program after compiling the repair program; the repairing program is used for replacing and executing a correct instruction corresponding to the error instruction when the error code of the application program is executed and the error instruction is compiled;
loading the binary repair program into a memory, and running the binary repair program;
modifying the binary source program compiled by the application program in the memory by running the binary repair program to obtain a modified binary source program; the modified binary source program is used for replacing and executing a correct instruction corresponding to the error instruction in the memory when the error instruction in the binary source program is executed, so that the application program is normally operated after being repaired;
and running the modified binary source program.
2. The method of claim 1, wherein modifying the compiled binary source program of the application program in the memory to obtain a modified binary source program comprises:
acquiring a correct instruction corresponding to the error instruction in the memory;
And replacing the error instruction in the binary source program in the memory with the correct instruction to obtain the modified binary source program.
3. The method of claim 2, wherein the repair program records a function name of an objective function where the error code is located and an address offset corresponding to the error code; the address offset is the offset of a storage address corresponding to the error instruction in a memory compared with a first address, and the first address is the first address of a memory block storing a function instruction corresponding to the objective function;
the modifying the binary source program compiled by the application program in the memory to obtain a modified binary source program, and the method further comprises:
searching the first address in the memory according to the function name;
calculating a target address corresponding to the error instruction according to the head address and the address offset;
the replacing the error instruction in the binary source program in the memory with the correct instruction to obtain the modified binary source program comprises the following steps:
and replacing the instruction stored in the target address with the correct instruction to obtain the modified binary source program.
4. The method of claim 1, wherein modifying the compiled binary source program of the application program in the memory to obtain a modified binary source program comprises:
adding a calling instruction before the error instruction in the binary source program to obtain the modified binary source program; the call instruction is used for calling the correct instruction in the memory.
5. The method according to claim 1, wherein the method further comprises:
acquiring the correct code compiled by the target compiler to obtain the correct instruction; the target compiler is a compiler for compiling the application program;
and loading the correct instruction to the memory.
6. The method of claim 5, wherein prior to said running said modified binary source program, said method further comprises:
unloading the binary fix program and the correct instruction.
7. The method according to claim 1, wherein the method further comprises:
under the condition of executing a loading instruction corresponding to the application program, acquiring the binary source program compiled by the source program of the application program and loading the binary source program into a memory;
The binary repair program compiled by the acquisition repair program comprises the following components: under the condition of executing a loading instruction and an operating instruction corresponding to the repair program, acquiring a binary repair program compiled by the repair program;
the running the modified binary source program includes: and under the condition of executing the operation instruction corresponding to the application program, operating the modified binary source program.
8. A fault resilient device for an application, the device comprising:
the acquisition module is used for acquiring the binary repair program after the repair program is compiled; the repairing program is used for replacing and executing a correct instruction corresponding to the error instruction when the error code of the application program is executed and the error instruction is compiled;
the operation module is used for loading the binary repair program into a memory and operating the binary repair program;
the modification module is used for modifying the binary source program compiled by the application program in the memory by running the binary repair program to obtain a modified binary source program, and the modified binary source program is used for replacing and executing a correct instruction corresponding to the error instruction in the memory when the error instruction in the binary source program is executed so as to enable the application program to run normally after being repaired;
The operation module is also used for operating the modified binary source program.
9. An electronic device, comprising: a processor, a memory and a computer program stored on the memory and executable on the processor, which when executed by the processor, implements the steps of the method for fault restoration of an application as claimed in any one of claims 1 to 7.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the method for fault restoration of an application program according to any of claims 1 to 7.
CN202310877239.6A 2023-07-17 2023-07-17 Fault restoration method and device for application program and electronic equipment Pending CN117033042A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310877239.6A CN117033042A (en) 2023-07-17 2023-07-17 Fault restoration method and device for application program and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310877239.6A CN117033042A (en) 2023-07-17 2023-07-17 Fault restoration method and device for application program and electronic equipment

Publications (1)

Publication Number Publication Date
CN117033042A true CN117033042A (en) 2023-11-10

Family

ID=88601379

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310877239.6A Pending CN117033042A (en) 2023-07-17 2023-07-17 Fault restoration method and device for application program and electronic equipment

Country Status (1)

Country Link
CN (1) CN117033042A (en)

Similar Documents

Publication Publication Date Title
KR101770931B1 (en) Method, apparatus, program and computer-readable recording medium of generating communication module firmware and plug-in
CN111736916A (en) Dynamic expansion method and device based on Java language, electronic equipment and storage medium
CN106406956B (en) Application program installation method and device
CN105468410A (en) System upgrading method and device
CN113377370A (en) File processing method and device, electronic equipment and storage medium
CN109426504B (en) Program processing method, program processing device, electronic device and storage medium
CN109901886B (en) Page language switching method, system, device and computer readable storage medium
CN108153540B (en) System upgrading method, device, terminal and storage medium
CN108153488B (en) Data self-adding method and device
CN113010157A (en) Code generation method and device
CN106293683B (en) Project compiling method and device
CN108563487B (en) User interface updating method and device
CN117033042A (en) Fault restoration method and device for application program and electronic equipment
CN112631695B (en) Data verification method and device, electronic equipment and storage medium
CN114661606A (en) Program debugging method and device, electronic equipment and storage medium
CN112445484B (en) Register processing method and device, electronic equipment and storage medium
CN111290882B (en) Data file backup method, data file backup device and electronic equipment
CN113590091A (en) Data processing method and device, electronic equipment and storage medium
CN108427568B (en) User interface updating method and device
CN111459494A (en) Code processing method and device
CN116431579A (en) Vehicle data processing method, device and equipment
CN111596949B (en) Method and device for developing application program
CN113535183B (en) Code processing method, device, electronic equipment and storage medium
CN111625251B (en) Method and device for processing application instance
CN114020693B (en) Header file address acquisition method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination