Methods, apparatus and electronic devices for operating system application layer error handling
By obtaining the operating system build status and calling multiple application interfaces to perform error checking and generate an error hook framework, the problem of low efficiency in application layer error handling in existing technologies is solved, achieving efficient and accurate error handling and ensuring the normal operation of applications.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-17
- Publication Date
- 2026-03-10
AI Technical Summary
In existing technologies, application-layer error handling is inefficient and inaccurate, and cannot effectively restore the running state of applications.
By obtaining the operating system's build status, calling multiple application interfaces to perform error checks, generating an error hook framework, enabling error logging, determining error types, and processing application interface information, centralized processing of operating system application layer errors is achieved.
It improves the efficiency and accuracy of error handling at the operating system's application layer, ensuring that applications can run normally.
Smart Images

Figure CN114296974B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically to methods, apparatus, and electronic devices for handling application layer errors in operating systems. Background Technology
[0002] During application-layer development and debugging, errors may occur in the program. These errors can cause the application to enter a state where it cannot recover and continue execution. Detecting these errors is a function of the application itself, but recovering from them requires interaction with the control threads managed by the operating system.
[0003] In summary, there is an urgent need for a method for handling application-level errors in operating systems to address the problems existing in the aforementioned technologies. Summary of the Invention
[0004] In view of the above-mentioned problems with existing methods, the present invention proposes a method, apparatus and electronic device for handling errors at the application layer of an operating system.
[0005] In a first aspect, the present invention provides a method for handling application-layer errors in an operating system, comprising:
[0006] Get the operating system build status;
[0007] Based on the construction status, error checks are performed on the application layer by calling multiple application programming interfaces to obtain error identifiers;
[0008] The error type of the application layer is determined based on the error identifier;
[0009] Determine whether to enable the pre-configured error log based on the error type;
[0010] If so, the error information is obtained by enabling the error log;
[0011] The interface information of the application interface that caused the error during the call is determined based on the error information through a preset interface;
[0012] The operating system application layer errors are handled based on the interface information of the application programming interface.
[0013] Furthermore, the build state includes a standard state and an extended state, and the step of performing error checking on the application layer by calling multiple application programming interfaces based on the build state includes:
[0014] When the construction state is in the standard state, the first set of application programming interfaces is invoked to perform error checking on the application layer.
[0015] When the build state is in the extended state, the second set of application programming interfaces is invoked to perform error checking on the application layer.
[0016] Furthermore, before performing error checking on the application layer by calling multiple application programming interfaces based on the construction state, the method further includes:
[0017] Generate an error hook framework.
[0018] Furthermore, the interface information of the application programming interface (API) includes the name of the API and the parameters for calling the API.
[0019] Furthermore, after obtaining the operating system's build status, the process also includes:
[0020] When the construction state is in the standard state, fault tolerance processing is performed for operating system application layer errors.
[0021] Furthermore, after obtaining the operating system's build status, the process also includes:
[0022] When the construction state is in the extended state, the preset error checking module is enabled to perform error checking on the operating system application layer.
[0023] When the build state switches from extended state to standard state, the preset error checking module is turned off.
[0024] In a second aspect, the present invention provides an apparatus for operating system application layer error handling, comprising:
[0025] The acquisition module is used to obtain the build status of the operating system;
[0026] The processing module is configured to perform error checks on the application layer by calling multiple application programming interfaces (APIs) based on the construction status to obtain error identifiers; determine the error type of the application layer based on the error identifiers; determine whether to enable pre-configured error logs based on the error type; if so, obtain error information by enabling the error logs; determine the interface information of the API that caused the error during the call based on the error information through a preset interface; and process the operating system application layer error based on the interface information of the API.
[0027] Furthermore, the construction state includes a standard state and an extended state, and the processing module is specifically used for:
[0028] When the construction state is in the standard state, the first set of application programming interfaces is invoked to perform error checking on the application layer.
[0029] When the build state is in the extended state, the second set of application programming interfaces is invoked to perform error checking on the application layer.
[0030] Furthermore, the processing module is also used for:
[0031] Before performing error checks on the application layer by calling multiple application interfaces based on the build status, an error hook framework is generated.
[0032] Furthermore, the processing module is specifically used for:
[0033] The interface information of the application programming interface (API) includes the name of the API and the parameters for calling the API.
[0034] Furthermore, the processing module is also used for:
[0035] After obtaining the build status of the operating system, when the build status is in a standard state, fault tolerance processing is performed on the operating system application layer errors.
[0036] Furthermore, the processing module is also used for:
[0037] After obtaining the build status of the operating system, when the build status is in the extended state, a preset error checking module is activated to perform error checking on the operating system application layer.
[0038] When the build state switches from extended state to standard state, the preset error checking module is turned off.
[0039] Thirdly, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the operating system application layer error handling method as described in the first aspect.
[0040] Fourthly, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the operating system application layer error handling method as described in the first aspect.
[0041] As can be seen from the above technical solutions, the method, apparatus and electronic device for handling operating system application layer errors provided by the present invention improve the efficiency and accuracy of operating system application layer error handling by calling multiple application programming interfaces to centrally handle operating system application layer errors. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0043] Figure 1 A flowchart illustrating the operating system application layer error handling method provided by the present invention;
[0044] Figure 2 This is a schematic diagram of the structure of the operating system application layer error handling device provided by the present invention;
[0045] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0046] The specific embodiments of the present invention will be further described below with reference to the accompanying drawings. The following examples are only used to more clearly illustrate the technical solutions of the present invention and should not be construed as limiting the scope of protection of the present invention.
[0047] Figure 1 This is a flowchart illustrating a method for handling operating system application layer errors provided in an embodiment of the present invention, as shown below. Figure 1 As shown, the method includes:
[0048] Step 101: Obtain the build status of the operating system.
[0049] In one possible implementation, the build state includes a standard state and an extended state.
[0050] It should be noted that the construction state can also include other states, such as the closed state, etc., and the embodiments of the present invention do not specifically limit this.
[0051] Step 102: Based on the build status, perform error checks on the application layer by calling multiple application interfaces to obtain error identifiers.
[0052] Specifically, when the build state is in the standard state, the first set of application programming interfaces is invoked to perform error checking on the application layer.
[0053] When the build state is in the extended state, the second set of application interface calls is used to perform error checking on the application layer.
[0054] In this embodiment of the invention, when the operating system is in a standard build state, runtime error checking is performed for the production compilation of the application.
[0055] Furthermore, when the operating system is built in an extended state, extensive extended error checking is employed to check for all reasonable application interface usage errors.
[0056] The above solution improves the efficiency of operating system application layer error handling by calling multiple application interfaces to perform error checks at the application layer based on the build status.
[0057] Step 103: Determine the error type of the application layer based on the error identifier.
[0058] For example, when the operating system is built in a standard state, the following error flags can be detected:
[0059] 1. E_OK: No error detected.
[0060] 2. E_OS_LIMIT: The internal limits of the operating system have been reached.
[0061] For example, try activating a task at a frequency exceeding the configuration's allowed frequency. For instance, the chip's maximum allowed frequency is pre-set to be 500 Hz, while the task is activated at 600 Hz.
[0062] 3. E_OS_NOFUNC: Unable to call
[0063] Specifically, the application interface being called does not exist.
[0064] 4. E_OS_STATE: Cannot be invoked because the object is not in a valid state.
[0065] Specifically, when the operating system is in the standard build state, the application programming interface (API) is called when the operating system is in the extended build state.
[0066] For example, when the operating system is in the extended build state, the following error flags can be detected:
[0067] 1. E_OK: No error detected.
[0068] 2. E_OS_<standard_code> : An error condition predefined by the operating system has occurred.
[0069] 3. E_OS_SYS_<vendor_code> Besides sending E_OS_<standard_code> In addition to the error flags, user-defined error conditions also occurred.
[0070] In this embodiment of the invention, each application interface call will return a different error identifier, depending on the type of error that may occur during the call.
[0071] In a possible implementation, the application program interface calls corresponding to the error identification are found by referring to the AUTOSAR specification, as well as the meaning of each error identification for a specific application program interface.
[0072] Step 104, determine whether to enable a pre-configured error log according to the error type.
[0073] In an embodiment of the present invention, if the detected error identification is not E_OK, the pre-configured error log is enabled.
[0074] In a possible implementation, the pre-configured error log records the name of the application program interface.
[0075] In another possible implementation, the pre-configured error log records the name of the application program interface and the parameters of the application program interface call.
[0076] Step 105, if so, obtain error information by enabling the error log.
[0077] Step 106, determine the interface information of the application program interface that generates an error during the call according to the error information through a preset interface.
[0078] In an embodiment of the present invention, after enabling the error log record, the operating system provides a set of macros for accessing the interface information of the application program interface that causes the error.
[0079] Specifically, the interface information of the application program interface includes the name of the application program interface and the parameters of the application program interface call.
[0080] In an embodiment of the present invention, the OSErrorGetServiceId() macro is used to find the API call that causes the error.
[0081] Further, this macro returns an OSServiceIdType in the form of OSServiceId_<API name>.
[0082] For example, if the ActivateTask() call causes an error, OSErrorGetServiceId will return OSServiceId_ActivateTask.
[0083] In a possible implementation, the parameters of the API call can be obtained using a macro in the following form:
[0084] OSSError_<API name>_<API parameter name>
[0085] For example, OSError_ActivateTask_TaskId will return the TaskId parameter passed to ActivateTask().
[0086] Step 107: Handle operating system application layer errors based on the interface information of the application programming interface.
[0087] In one possible implementation, the corresponding application interface call is deleted based on the interface information of the application interface.
[0088] The above solution improves the efficiency and accuracy of operating system application layer error handling by generating an error hook framework to call multiple application programming interfaces (APIs).
[0089] Furthermore, in this embodiment of the invention, an error hook framework is generated before step 102.
[0090] In this embodiment of the invention, the error hook framework includes checking all types of errors in all application interface calls.
[0091] In one possible implementation, the ErrorHook framework is generated using the following vagonosgen command line:
[0092] vagonosgen--samples:[ErrorHook]MyConfig.xml
[0093] It should be noted that the above command line will generate an error hook in Samples\Hooks\ErrorHook.c for use in the application.
[0094] The above solution addresses the problem that writing ErrorHooks to capture configuration-generated error types is both time-consuming and error-prone by generating a framework for ErrorHooks within the operating system.
[0095] The above-mentioned centralized processing of operating system application layer errors by generating error hooks and enabling error logs can also be used to process operating system application layer errors online.
[0096] Specifically, after obtaining the build status of the operating system, when the build status is in the standard state, fault tolerance processing is performed on the operating system application layer errors.
[0097] It should be noted that fault tolerance refers to the ability to provide appropriate handling or information prompts for runtime errors caused by abnormal factors during application layer operation, so that the application layer can terminate normally.
[0098] The above solution improves the efficiency of operating system application layer error handling by employing fault-tolerant processing at the application layer runtime.
[0099] Furthermore, after obtaining the operating system's build status, the following is also included:
[0100] When the build status is in the extended state, the preset error checking module is enabled to perform error checking on the operating system application layer.
[0101] When the build state switches from extended state to standard state, the default error checking module is turned off.
[0102] For example, the operating system provides two macros that allow error checking modules to be conditionally included or excluded during development.
[0103] Specifically, the macro for standard state can take the following form:
[0104] OS_STANDARD_STATUS is defined when standard status is configured.
[0105] The macro for extended state can take the following form:
[0106] OS_EXTENDED_STATUS is defined when extended status is configured.
[0107] The above solution adds an error checking module to check for runtime errors that only occur in extended state, eliminating the need to manually check the application to remove this module when changing to standard state.
[0108] Based on the same inventive concept Figure 2 An exemplary embodiment of the present invention provides an apparatus for operating system application layer error handling, which can be a flowchart of an operating system application layer error handling method.
[0109] The device includes:
[0110] Module 201 is used to obtain the build status of the operating system;
[0111] The processing module 202 is configured to perform error checks on the application layer by calling multiple application programming interfaces (APIs) based on the construction status to obtain error identifiers; determine the error type of the application layer based on the error identifiers; determine whether to enable a pre-configured error log based on the error type; if so, obtain error information by enabling the error log; determine the interface information of the API that caused the error during the call based on the error information through a preset interface; and process the operating system application layer error based on the interface information of the API.
[0112] Furthermore, the construction state includes a standard state and an extended state, and the processing module 202 is specifically used for:
[0113] When the construction state is in the standard state, the first set of application programming interfaces is invoked to perform error checking on the application layer.
[0114] When the build state is in the extended state, the second set of application programming interfaces is invoked to perform error checking on the application layer.
[0115] Furthermore, the processing module 202 is also used for:
[0116] Before performing error checks on the application layer by calling multiple application interfaces based on the build status, an error hook framework is generated.
[0117] Furthermore, the processing module 202 is specifically used for:
[0118] The interface information of the application programming interface (API) includes the name of the API and the parameters for calling the API.
[0119] Furthermore, the processing module 202 is also used for:
[0120] After obtaining the build status of the operating system, when the build status is in a standard state, fault tolerance processing is performed on the operating system application layer errors.
[0121] Furthermore, the processing module 202 is also used for:
[0122] After obtaining the build status of the operating system, when the build status is in the extended state, a preset error checking module is activated to perform error checking on the operating system application layer.
[0123] When the build state switches from extended state to standard state, the preset error checking module is turned off.
[0124] Based on the same inventive concept, another embodiment of the present invention provides an electronic device, see [link to previous document]. Figure 3The electronic device specifically includes the following components: a processor 301, a memory 302, a communication interface 303, and a communication bus 304.
[0125] The processor 301, memory 302, and communication interface 303 communicate with each other through the communication bus 304; the communication interface 303 is used to realize information transmission between the devices.
[0126] The processor 301 is used to call the computer program in the memory 302. When the processor executes the computer program, it implements all the steps of the above-described operating system application layer error handling method. For example, when the processor executes the computer program, it implements the following steps: obtaining the build status of the operating system; performing error checks on the application layer by calling multiple application programming interfaces (APIs) based on the build status to obtain error identifiers; determining the error type of the application layer based on the error identifiers; determining whether to enable a pre-configured error log based on the error type; if so, obtaining error information by enabling the error log; determining the interface information of the API that caused the error during the call based on the error information through a preset interface; and processing the operating system application layer error based on the interface information of the API.
[0127] Based on the same inventive concept, another embodiment of the present invention provides a non-transitory computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements all the steps of the above-described method for handling application layer errors in an operating system. For example, when the processor executes the computer program, it implements the following steps: obtaining the build status of the operating system; performing error checks on the application layer by calling multiple application programming interfaces (APIs) based on the build status to obtain error identifiers; determining the error type of the application layer based on the error identifiers; determining whether to enable a pre-configured error log based on the error type; if so, obtaining error information by enabling the error log; determining the interface information of the API that caused the error during the call based on the error information through a preset interface; and handling the operating system application layer error based on the interface information of the API.
[0128] Furthermore, when the logical instructions in the aforementioned memory can be implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, an operating system application layer error handling device, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0129] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of the embodiments of the present invention according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0130] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, an operating system application layer error handling device, or a network device, etc.) to execute the operating system application layer error handling method described in various embodiments or some parts of the embodiments.
[0131] Furthermore, in this invention, terms such as "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0132] Furthermore, in this invention, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0133] Furthermore, in the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0134] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method of operating system application layer error handling, the method comprising: The method comprises the following steps: acquiring a build state of an operating system; performing error checking on an application layer by calling a plurality of application program interfaces according to the build state, to obtain an error identifier; the build state comprises a standard state and an extended state, and the error checking on the application layer by calling the plurality of application program interfaces according to the build state comprises: when the build state is the standard state, performing error checking on the application layer by calling a first set of application program interfaces; performing runtime error checking for production compilation of an application program; when the build state is the extended state, performing error checking on the application layer by calling a second set of application program interfaces; performing a plurality of extended error checkings to check all reasonable application program interface usage errors; determining an error type of the application layer according to the error identifier; determining whether to enable a preconfigured error log according to the error type; if yes, obtaining error information by enabling the error log; determining interface information of an application program interface that generates an error at a calling time according to the error information through a preset interface; after the error log is enabled, the operating system provides a set of macros for accessing the interface information of the application program interface that causes the error, the interface information of the application program interface comprises a name of the application program interface and parameters of a call of the application program interface, and an OSErrorGetServiceId() macro is used to find out an API call that causes the error, the macro returns an OSServiceIdType in the form of OSServiceId_<API name>; if an ActivateTask() call causes the error, the OSErrorGetServiceId will return an OSServiceId_ActivateTask; processing an operating system application layer error according to the interface information of the application program interface.
2. The method of claim 1, wherein the system application layer error handling is performed by a system application layer error handler. Before the error checking on the application layer by calling the plurality of application program interfaces according to the build state, the method further comprises: generating an error hook framework.
3. The method of claim 1, wherein the system application layer error handling is performed by a system application layer error handler. the interface information of the application program interface comprises the name of the application program interface and the parameters of the call of the application program interface.
4. The method of claim 1, wherein the system application layer error handling is performed by a system application layer error handler. After the build state of the operating system is acquired, the method further comprises: when the build state is the standard state, performing fault tolerance processing on an operating system application layer error.
5. The method of claim 1, wherein the system application layer error handling is performed by a system application layer error handler. After the build state of the operating system is acquired, the method further comprises: when the build state is the extended state, starting a preset error checking module to perform error checking on an operating system application layer; when the build state is switched from the extended state to the standard state, the preset error checking module is stopped.
6. An apparatus for operating system application layer error handling, the apparatus comprising: The method comprises the following steps: a acquiring module is configured to acquire a build state of an operating system, the build state comprising a standard state and an extended state; a processing module is configured to perform error checking on an application layer by calling a plurality of application program interfaces according to the build state, to obtain an error identifier; determining an error type of the application layer according to the error identifier; determining whether to enable a preconfigured error log according to the error type; if yes, obtaining error information by enabling the error log; determining, according to the error information, interface information of an application program interface that causes an error when invoked through a preset interface; processing an operating system application layer error according to the interface information of the application program interface; the error checking of the application layer by invoking a plurality of application program interfaces according to the build state, including: when the build state is a standard state, invoking a first set of application program interfaces to perform error checking on the application layer; performing runtime error checking for production compilation of an application program; when the build state is an extended state, invoking a second set of application program interfaces to perform error checking on the application layer; and using a plurality of extended error checks to check all reasonable application program interface usage errors; the processing module is specifically configured to: the interface information of the application program interface includes a name of the application program interface and parameters of the application program interface invocation, after enabling error logging, the operating system provides a set of macros for accessing the interface information of the application program interface that causes the error, the interface information of the application program interface includes the name of the application program interface and the parameters of the application program interface invocation, an OSErrorGetServiceId() macro is used to find the API invocation that causes the error, the macro returns an OSServiceIdType in the form of OSServiceId_<API name>; if the ActivateTask() invocation causes the error, the OSErrorGetServiceId will return an OSServiceId_ActivateTask.
7. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, the processor implements the steps of the method according to any one of claims 1 to 5 when executing the program.
8. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, the computer program implements the steps of the method according to any one of claims 1 to 5 when executed by the processor.
Citation Information
Patent Citations
Anomaly processing method and device, computer device and storage medium
CN109766205A