Abnormality processing method and device, computer equipment and storage medium
By obtaining and reconstructing the context information of abnormal moments in the software processor core and building control flow data, the problem of inaccurate software crash analysis under the watchdog reset mode is solved, efficient and accurate abnormal analysis is achieved, and cost is reduced and complexity.
Patent Information
- Application Number
- CN202410949123.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2024-11-08
AI Technical Summary
In the prior art, the abnormality of software crash cannot be accurately analyzed by the watchdog reset method, and the crash condition on the vehicle is complicated in the laboratory environment, resulting in high analysis cost and low accuracy.
When an exception is detected for the software processor core task, the address information of the previous context information register is obtained, and the context area address reconstruction is performed N times, the function address before the exception moment is determined, and the control flow data is constructed to analyze the software exception location. .
It improves the accuracy and efficiency of abnormal analysis, avoids the need for recurrence of crashes in laboratory environments, reduces analysis costs, and simplifies the handling of complex working conditions on the vehicle.
Smart Images

Figure CN118916196A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of intelligent driving technology, and in particular to an exception handling method, apparatus, computer equipment and storage medium. Background Art
[0002] AUTOSAR (Automotive Open System ARchitecture) software is used in the development of automotive electronic systems to improve the development efficiency, maintainability, scalability and separation of software and hardware. In the field of new energy vehicles, AUTOSAR software is increasingly widely used. A large number of software are running on test vehicles and mass-produced vehicles. When software freezes, a watchdog is usually used to reset the system so that the system can continue to run. However, the watchdog reset method cannot be used to perform abnormal analysis on software freezes.
[0003] In order to solve the problem that software crashes cannot be analyzed by watchdog reset, the traditional technology uses a debugger to reproduce the crash condition in a laboratory environment, and performs an exception analysis based on the reproduced crash condition, which results in inaccurate exception analysis. Summary of the invention
[0004] Based on this, it is necessary to provide an exception handling method, apparatus, computer equipment, computer-readable storage medium and computer program product that can improve the accuracy of software exception analysis in response to the above technical problems.
[0005] In a first aspect, the present application provides an exception handling method, comprising:
[0006] When detecting that a task in the software processor core is running abnormally, determining the abnormal time when the task is running abnormally;
[0007] Acquire address information of a previous context information register of the software processor core stored at the abnormal time;
[0008] Perform N context area address reconstructions according to the address information to obtain N function addresses before the abnormal moment;
[0009] Control flow data for determining a software exception location is determined based on the N function addresses.
[0010] In one embodiment, performing N context area address reconstructions according to the address information to obtain N function addresses before the abnormal moment includes:
[0011] Performing a first context area address reconstruction according to the address information to reconstruct the function address stored in the context area before the abnormal moment;
[0012] Starting from the second context area address reconstruction, for each context area address reconstruction, obtaining link information stored in the context area determined by the previous address reconstruction;
[0013] Reconstruct the address according to the link information to obtain the address of the current context area;
[0014] The function address stored in the current context area is obtained according to the address, until the Nth context area address reconstruction is completed, and the N function addresses before the abnormal moment are obtained.
[0015] In one embodiment, the first context area address reconstruction is performed according to the address information to reconstruct the function address stored in the context area before the abnormal moment, including:
[0016] Parsing the address information to obtain segment data and offset data of the address information;
[0017] Performing an encoding operation on the segment data and the offset data to reconstruct an address of a context area reconstructed for the first time before the abnormal moment;
[0018] According to the address of the first reconstructed context area, a function address is determined from the first reconstructed context area.
[0019] In one embodiment, encoding the segment data and the offset data to reconstruct the function address stored in the context area before the abnormal moment includes:
[0020] extracting first target bit data from the segment data, and extracting second target bit data from the offset data;
[0021] The first target bit data is placed at a first target position of a corresponding context area address space, and the second target bit data is placed at a second target position of the context area address space, to reconstruct the address of the context area reconstructed for the first time before the abnormal moment.
[0022] In one embodiment, the method further comprises:
[0023] When abnormal operation of a task in a software processor core is detected, a reconstruction trigger event is generated;
[0024] In response to the reconstruction triggering event, determining the abnormality type of the task running abnormality;
[0025] Determine a corresponding reconstruction entry path according to the abnormality type, perform reconstruction based on the reconstruction entry path, and execute the step of determining the abnormal time when the task runs abnormally.
[0026] In one embodiment, determining the control flow data for determining the location of the software exception according to the N function addresses includes:
[0027] Determining a core identification of the software processor core;
[0028] The function address obtained by each context area address reconstruction in N context area address reconstructions is spliced into the control flow cache area corresponding to the core identifier to obtain control flow data for determining the software abnormality location, and the control flow data is stored in a storage medium.
[0029] In one embodiment, before storing the control flow data in a storage medium, the method further includes:
[0030] If the core identifier is not a preset core identifier, sending the control flow data to the target processor core where the preset core identifier is located;
[0031] The control flow data is stored in a storage medium through the target processor core.
[0032] In one embodiment, the method further comprises:
[0033] In response to the abnormal analysis instruction, the storage medium acquires corresponding target control flow data;
[0034] Determine, according to all function addresses in the target control flow data, a target function corresponding to each function address;
[0035] Determining abnormal functions from the objective functions according to the execution order between the objective functions;
[0036] The abnormal position of the software is determined according to the abnormal function.
[0037] In a second aspect, the present application also provides an exception handling device, including:
[0038] A data determination module, for determining the abnormal time when the task is abnormally executed when an abnormal task is detected in the software processor core;
[0039] An address information acquisition module, used to acquire address information stored in a previous context information register of the software processor core at the abnormal moment;
[0040] A reconstruction module, used to perform N context area address reconstructions according to the address information to obtain N function addresses before the abnormal moment;
[0041] The storage module is used to determine the control flow data used to determine the location of the software exception according to the N function addresses.
[0042] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0043] When detecting that a task in the software processor core is running abnormally, determining the abnormal time when the task is running abnormally;
[0044] Acquire address information of a previous context information register of the software processor core stored at the abnormal time;
[0045] Perform N context area address reconstructions according to the address information to obtain N function addresses before the abnormal moment;
[0046] Control flow data for determining a software exception location is determined based on the N function addresses.
[0047] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0048] When detecting that a task in the software processor core is running abnormally, determining the abnormal time when the task is running abnormally;
[0049] Acquire address information of a previous context information register of the software processor core stored at the abnormal time;
[0050] Perform N context area address reconstructions according to the address information to obtain N function addresses before the abnormal moment;
[0051] Control flow data for determining a software exception location is determined based on the N function addresses.
[0052] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0053] When detecting that a task in the software processor core is running abnormally, determining the abnormal time when the task is running abnormally;
[0054] Acquire address information of a previous context information register of the software processor core stored at the abnormal time;
[0055] Perform N context area address reconstructions according to the address information to obtain N function addresses before the abnormal moment;
[0056] Control flow data for determining a software exception location is determined based on the N function addresses.
[0057] The above-mentioned exception handling method, device, computer equipment, storage medium and computer program product, when detecting an abnormal task operation in the software processor core, determine the abnormal time when the task operation is abnormal, obtain the address information stored in the previous context information register at this abnormal time, perform N context area address reconstructions based on the address information, obtain N function addresses before this abnormal time, and determine the control flow data used to determine the location of the software abnormality based on the N function addresses. In the case of an abnormality, all control flow data where the abnormality occurs can be collected, and exception analysis can be performed based on the control flow data, thereby avoiding the problem of being unable to analyze the exception when the software fault is reset, and there is no need to reproduce the crash condition through a laboratory environment, thereby avoiding the situation where the vehicle working conditions are complex and difficult to reproduce, reducing the cost of exception analysis and improving the accuracy of exception analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0059] Figure 1 A schematic diagram of a flow chart of an exception handling method in an embodiment;
[0060] Figure 2 is a schematic flow chart of step 103 in one embodiment;
[0061] Figure 3 A schematic diagram of reconstruction of segment data and offset data in one embodiment;
[0062] Figure 4 A schematic diagram of a process of reconstructing a context area address in one embodiment;
[0063] Figure 5 is a flow chart of a method for determining a reconstructed entry path in one embodiment;
[0064] Figure 6 A schematic diagram of reconstructing an entry path in one embodiment;
[0065] Figure 7 A schematic diagram of a flow chart of a fault location method based on control flow data in one embodiment;
[0066] Figure 8is a structural block diagram of an exception handling device in an embodiment;
[0067] Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0069] AUTOSAR software is an automotive electronic software architecture standard, namely the automotive open system architecture. It is an alliance jointly established by global automobile manufacturers, component suppliers and other electronic, semiconductor and software system companies to develop an open and standardized software architecture for the automotive industry. In the face of increasingly complex automotive ECU software challenges, standardized platforms are used to reduce design complexity, improve flexibility and development efficiency.
[0070] In the field of new energy vehicles, AUTOSAR software is increasingly widely used. A large number of software are running on test vehicles and mass-produced vehicles. When the software crashes, a watchdog is usually used to reset it so that the system can continue to run. However, although the watchdog reset method improves the robustness of the system, the problem of software crashes still exists. The existing solution is to use a debugger to reproduce the crash condition in a laboratory environment. Due to the complex working conditions on the vehicle, few signals can be obtained, and the difficulty of reproduction is great. A lot of manpower and time resources will be invested. In addition, when a crash occurs on the vehicle, it may be reset by the watchdog, hiding the crash situation, resulting in low accuracy of abnormal analysis.
[0071] To address this technical problem, an exception handling method is proposed. When a task operation exception is detected in the software processor core, the control flow data during the task operation exception is automatically reconstructed, and the location of the software exception is determined based on the control flow data. This reduces the time and labor costs of exception analysis, and there is no need to reproduce the working conditions on the vehicle, thereby ensuring the accuracy of exception analysis.
[0072] In an exemplary embodiment, Figure 1 As shown, an exception handling method is provided. This embodiment uses the method applied to a terminal as an example. It can be understood that the terminal can be a terminal of different types. For example, the terminal can be a terminal of different types. The method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes steps 101 to 104, wherein:
[0073] Step 101 : when it is detected that a task in a software processor core is running abnormally, determine the abnormal time when the task is running abnormally.
[0074] The software may be AUTOSAR multi-core software, including multiple processor cores, each of which has a corresponding core identifier. In a multi-core system, each core runs independently. Task operation exceptions may be any one or both of Trap faults and ErrKernelPanic faults. Trap faults may be a program error exception detected by the processor, including Null Pointer Exception, Division by Zero Exception, Memory Access Violation, Illegal Instruction, and hardware faults. Null Pointer Exception: When a program attempts to access a null pointer (uninitialized or invalid memory address), the processor triggers a Null Pointer Exception. This may be caused by a programming error, such as an unchecked pointer dereference. Division by Zero Exception: When a program attempts to perform a division by zero operation, the processor triggers a Division by Zero Exception. This is usually caused by an arithmetic error or a logic error. Memory Access Violation: When a program attempts to access unallocated memory or access a protected memory area, the processor will cause a memory access exception. This may be caused by a pointer error, out-of-bounds access, or unauthorized memory access. Illegal Instruction: When the processor attempts to execute an undefined or unsupported instruction, an illegal instruction exception is caused. This may be caused by hardware or software compatibility issues. Hardware Failure: When the processor or other hardware component fails, it may cause an interrupt or exception. For example, a memory unit is damaged or a communication bus error.
[0075] ErrKernelPanic faults can be understood as operating system-level errors, including: Deadlock: When two or more processes or threads are waiting for each other to release resources and cannot continue to execute, the system may be deadlocked. This situation usually needs to be resolved by forcibly terminating certain processes or threads. Kernel Error: When the operating system kernel encounters a serious error or inconsistent state, it may cause the kernel to crash or be unable to continue running. This situation may be caused by vulnerabilities in the operating system code, hardware failures, or system resource exhaustion. Out of Memory: When the system cannot allocate enough memory to meet the needs of the process or operating system, it may cause a memory exhaustion error. This usually causes the operating system to be unable to continue to perform important system tasks or services. Critical Service Interruption: When certain critical system services or processes fail or stop responding, it may cause the system's ErrKernelPanic faults. This may have a serious impact on the stability and reliability of the system.
[0076] Exemplarily, when it is detected that a task in the software processor core is running abnormally, the control flow reconstruction function is called to determine the abnormal time when the task is running abnormally.
[0077] Step 102: Acquire address information stored in a previous context information register of the software processor core at the abnormal time.
[0078] Among them, the previous context information register, namely Previous Context Information, PCXI, can be understood as a register used by the processor to save the current execution context when an exception or interrupt occurs. The previous context information register can only store information at the time of the exception or interrupt, including but not limited to address values. The value type of PCXI depends on the specific implementation and context. For example, if PCXI is used to store the value of the program counter, then it can be an address value, indicating the location of the code being executed when the task was interrupted.
[0079] Exemplarily, based on UDS (Unified Diagnostic Services), a function is called to read the information stored in the previous context information register of the software processor core at the abnormal time, and according to the convention of the architecture and the operating system, the information stored in the previous context information register at the abnormal time is parsed to obtain the address information stored at the abnormal time. It should be noted that the parsing method can be implemented by existing methods, which will not be described in detail here.
[0080] Step 103 , performing N times of context area address reconstruction according to the address information to obtain N function addresses before the abnormal moment.
[0081] It should be noted that the address information stored in the previous context information register at the abnormal moment cannot directly determine the address of the context area (Context Switching Area, CSA) before that, and the context area address reconstruction is required to obtain the address of the corresponding area. Address reconstruction can be understood as reconstructing the address of the context area. Context area address reconstruction can be to determine the address of the context area from a preset mapping table based on the address information, or to determine the corresponding identifier based on the address information, and to search and manage the address of the context area based on the ID. Context area address reconstruction can also be determined by encoding a specified part of the data in the address information to restore the actual address of the context area. N is a positive integer, and the value of N is determined according to the actual application scenario. For example, N can be 12.
[0082] When performing each context area address reconstruction, for example, in the process of performing N context area address reconstructions based on the address information, for the first context address reconstruction before the abnormal moment, the address of the context area of the first reconstruction is obtained by encoding a specified portion of data in the address information, and the corresponding function address and the value of the previous context information register stored in the context area are determined from the corresponding context area according to the address. A second context address reconstruction is performed according to the value of the previous context information register to obtain the function address stored in the second context area. The address reconstruction method for the third to N times is the same as the second method to obtain N function addresses before the abnormal moment.
[0083] Step 104: Determine control flow data for determining the location of software exceptions based on the N function addresses.
[0084] Among them, the control flow can be understood as the order of execution of the control program logic, and the control flow data can be understood as the data related to the order of execution of the control logic before the abnormal moment of the abnormal operation when the task in the software processor core runs abnormally. The data can be the function address stored in the context area.
[0085] It should be noted that multi-core software includes multiple processor cores. The abnormal operation of a task in a software processor core may be that multiple cores have task abnormalities at the same time, or that only one core has task abnormalities. For ease of understanding, in this example, the abnormal operation of a task in one processor core is taken as an example.
[0086] Exemplarily, by performing N context area address reconstructions based on address information, N function addresses before the exception moment are obtained, the core identifier of the processor core corresponding to the N function addresses is determined, and by calling a write function, the N function addresses are written into the control flow cache area corresponding to the core identifier, thereby obtaining control flow data for determining the location of the software exception.
[0087] The above-mentioned exception handling method, when detecting an abnormal task operation in the software processor core, determines the abnormal time when the task runs abnormally, obtains the address information stored in the previous context information register at this abnormal time, performs N context area address reconstructions based on the address information, obtains N function addresses before this abnormal time, and determines the control flow data used to determine the location of the software exception based on the N function addresses. In the case of an exception, all control flow data where the exception occurs can be collected, and exception analysis can be performed based on the control flow data, thereby avoiding the problem of being unable to analyze the exception when the software fault is reset, and there is no need to reproduce the crash condition through a laboratory environment, thereby avoiding the situation where the vehicle conditions are complex and difficult to reproduce, reducing the cost of exception analysis and improving the accuracy of exception analysis.
[0088] In order to implement software exception analysis, control flow reconstruction is very important. The following provides a method for reconstructing the address of the context area. In an exemplary embodiment, Figure 2 As shown, step 103 includes steps 201 to 203. Among them:
[0089] Step 201 : Perform a first context area address reconstruction based on the address information to reconstruct the function address stored in the context area before the abnormal moment.
[0090] The address information includes segment data and offset data for memory addressing. The context area address reconstruction may be encoding the segment data and offset data into the context area address to obtain the address of the context area, and based on the address of the context area, reading the stored function address from the context area. Encoding the segment data and offset data into the context area address may be encoding into a specified position, for example, Figure 3 As shown, it is a schematic diagram of the reconstruction of segment data and offset data in an exemplary embodiment, in which the segment data of bits 16 to 19 are placed at bits 28 to 31 of the CSA address, and the offset data of bits 0 to 15 are placed at bits 6 to 21 of the CSA address, and the remaining positions can be filled with 0.
[0091] In an exemplary embodiment, the address of the first context area is reconstructed based on the address information to reconstruct the function address stored in the context area before the abnormal moment, including: parsing the address information to obtain the segment data and offset data in the address information; encoding the segment data and the offset data to reconstruct the address of the first reconstructed context area before the abnormal moment; and determining the function address from the first reconstructed context area based on the address of the first reconstructed context area. It should be noted that the parsing method of the address information can be implemented by existing methods, which will not be described in detail here. The encoding operation can be to place the segment data and the offset data in specified locations respectively. The address of the first reconstructed context area can be reconstructed by this encoding method, and the stored function address can be read from the first reconstructed context area based on the address.
[0092] Furthermore, in an exemplary embodiment, encoding the segment data and the offset data to reconstruct the address of the first reconstructed context area before the abnormal moment includes:
[0093] Extract the first target bit data from the segment data, and extract the second target bit data from the offset data; place the first target bit data at the first target position of the corresponding context area address space, and place the second target bit data at the second target position of the context area address space, and reconstruct the address of the context area reconstructed for the first time before the abnormal moment.
[0094] Among them, the first target bit data and the second target bit data can be determined according to actual needs, and the first target bit data and the second target bit data constitute the complete address of the upper and lower area addresses. The first target position and the second target position of the context area address space can be predetermined. By reconstructing the context area address, it is helpful to locate the root cause of the abnormality and facilitate fault analysis and repair. For example, the first target bit data is the segment data of 16 to 19 bits, which is placed in the first target position of the CSA address, that is, 28 to 31 bits; the second target bit data is the offset data of 0 to 15 bits, and the offset data of 0 to 15 bits is placed in the second target position of the CSA address, that is, 6 to 21 bits.
[0095] Step 202 , starting from the second context area address reconstruction, for each context area address reconstruction, obtain the link information stored in the context area determined in the last address reconstruction.
[0096] The link information may be a link word, which is another form of address information. The link information also includes segment data and offset data.
[0097] Step 203, reconstruct the address according to the link information to obtain the address of the current context area, and obtain the function address stored in the current context area according to the address, until the Nth reconstruction of the context area address is completed, and obtain the N function addresses before the abnormal moment.
[0098] Optionally, starting from the second reconstruction of the context area address, for each reconstruction of the context area address, according to the address of the context area reconstructed last time, the value of the previous context information register stored in the context area reconstructed last time, i.e., the link information, is read, the segment data and the offset data in the link information are encoded, and the address of the context area reconstructed for the second time is obtained. Based on the address of the second context area, the function address stored in the context area reconstructed for the second time and the value of the previous context information register in the context area reconstructed for the second time are read. For each reconstruction from the third to the Nth reconstruction, the implementation method of each reconstruction is the same as the second reconstruction method, until the Nth reconstruction of the context area address is completed, and the N function addresses before the abnormal moment are obtained. For example, when the N-1th reconstruction of the context area address is completed, when the Nth reconstruction of the context area address is required, according to the address determined by the N-1th reconstruction of the context area address, the link information of the previous context information register is read from the N-1th context area, the segment data and the offset data in the link information are encoded, and the address of the context area reconstructed for the Nth time is obtained. Based on the address of the Nth context area, the function address stored in the Nth reconstruction of the context area is read.
[0099] It should be noted that the context area address reconstruction implementation method based on link information can be implemented by address information reconstruction, which will not be described in detail here.
[0100] like Figure 4 As shown, it is a flowchart of context area address reconstruction in an exemplary embodiment, the core identifier of the processor core corresponding to the task running abnormally is determined, and for each processor core running abnormally, when performing the first reconstruction, the address information stored in the previous context information register at the abnormal time is used, and the segment data and offset data in the address information are reconstructed using the CSA address reconstruction algorithm to obtain the CSA address, and the link information and function address are obtained from the corresponding CSA based on the CSA address. For the second reconstruction to the Nth reconstruction, the CSA address reconstruction algorithm is used to reconstruct the address of the link information obtained last time to obtain the CSA address, and the link information and function address are obtained from the corresponding CSA based on the CSA address until N reconstructions are completed, and according to the core identifier, the obtained function address is written to the control flow cache area ram corresponding to the core identifier.
[0101] In this embodiment, by reconstructing the segment data and the offset data, N function addresses before the abnormal moment are obtained, so that fault analysis and tracing of the task operation abnormality can be performed.
[0102] The above-described embodiments provide a method for reconstructing context addresses. It is understandable that in multi-core software, the reconstructed entry paths are different for different types of task operation exceptions. In an exemplary embodiment, Figure 5 As shown, a method for determining a reconstructed entry path is provided, including steps 501 to 503, wherein:
[0103] Step 501: When a task in a software processor core is detected to be running abnormally, a reconstruction trigger event is generated.
[0104] Step 502: In response to the reconstruction triggering event, determine the abnormality type of the task running abnormality.
[0105] Step 503: determine the corresponding reconstruction entry path according to the exception type, and perform reconstruction based on the reconstruction entry path.
[0106] It should be noted that for different exception types, the corresponding reconstruction entry paths are predetermined. Figure 6 As shown, for software processor core 1, software processor core 2, and software processor core 3, task 1, task 2, and task 3 are run respectively. If the exception type is a Trap type fault, the corresponding reconstruction entry path is os_trap→ErrorHook→CtrflowRecons. If the exception type is an ErrKernelPanic type fault, the corresponding reconstruction entry path is os_ErrKernelPanic→CoreFreeze→CtrflowRecons. In other words, for known exception types, the system will call the predefined error handling function (ErrorHook) corresponding to the exception type or trigger the core freezing mechanism (CoreFreeze) for reconstruction.
[0107] Exemplarily, when a task operation exception is detected in a software processor core, a reconstruction trigger event is generated. In response to the reconstruction trigger event, the exception type of the task operation exception is determined, the corresponding reconstruction entry path is determined according to the exception type, and reconstruction is performed based on the reconstruction entry path.
[0108] In the above embodiment, by determining the corresponding reconstruction entry path according to the abnormality type and performing reconstruction based on the reconstruction entry path, the system can adapt to various abnormal situations and accelerate the response speed of the system.
[0109] The control flow data is obtained by address reconstruction. The following provides a storage method for the control flow data. In an exemplary embodiment, the control flow data used to determine the location of the software exception is determined according to N function addresses, including:
[0110] Determine the core identifier of the software processor core; splice the function address obtained by each context area address reconstruction in N context area address reconstructions into the control flow cache area corresponding to the core identifier, obtain control flow data for determining the software abnormality location, and store the control flow data in a storage medium.
[0111] Among them, writing the control flow data to the storage medium can be storing the control flow data in the non-volatile random access memory NvmRam, executing the NvM_WriteAll write function, requesting to copy the configured RAM blocks to the associated NVblocks (Non-Volatile (NV) Blocks, non-volatile storage blocks), and then looping to support Fls_17_Dmu_MainFunction, Fee_MainFunction and non-volatile memory (NvM__MainFunction) main functions to implement storage operations until the storage is completed.
[0112] It should be noted that the codes stored in the multi-core software are all executed by the main core, because they cannot cross cores, so they need to be executed by the main core, that is, when the control flow data is stored, it is necessary to determine whether the core is the main core. In an exemplary embodiment, before storing the control flow data in the storage medium, the method also includes: if the core identifier is not a preset core identifier, the control flow data is sent to the target processor core where the preset core identifier is located; and the control flow data is stored in the storage medium through the target processor core. Among them, the preset core identifier can be the main core identifier. This method avoids cross-core processing by judging the core before writing, thereby ensuring the reliability of storage.
[0113] It can be understood that, based on the reconstructed control flow data, the software fault can be located based on the control flow data. In an exemplary embodiment, a fault location method based on control flow data is provided, including steps 701 to 704, wherein:
[0114] Step 701, in response to an exception analysis instruction, obtain corresponding target control flow data from a storage medium.
[0115] Exemplarily, in response to the exception analysis instruction, corresponding target control flow data is acquired from a storage medium according to a core identifier carried by the exception analysis instruction.
[0116] Step 702: Determine the target function corresponding to each function address according to all function addresses in the target control flow data.
[0117] It is understandable that each function address has a corresponding target function, and the corresponding target function can be obtained based on the known function address. In other words, the order of the target functions appearing in the control program can be known based on the order of the function addresses in the target control flow data.
[0118] Step 703: determine abnormal functions from the target functions according to the execution order of the target functions.
[0119] Among them, the function and use of the function are predetermined, and the execution status of the control program during the execution process can be determined according to the execution order between the target functions. For example, the target functions determined according to function address 1, function address 2, and function address 3 are Os_Task_os_1ms_Task_Core0(), IdcEstm(), and Os_TrapIsrEpiloque(), respectively. Since Os_TrapIsrEpiloque() appears, it can be determined that there are abnormalities in the two functions Os_Task_os_1ms_Task_Core0() and IdcEstm(), that is, the abnormal location can be determined.
[0120] Step 704, determining the abnormal location of the software according to the abnormal function.
[0121] In the above embodiment, the target function corresponding to each function address is determined according to all function addresses in the target control flow data, and the abnormal function is determined from the target function according to the execution order between the target functions; the abnormal position of the software is determined according to the abnormal function, and there is no need to reproduce the crash condition in the laboratory environment. The software anomaly can be located, and the situation where the watchdog hides the crash can be avoided.
[0122] In an exemplary embodiment, an exception handling method is provided, which generates a reconstruction trigger event when a task operation exception is detected in a software processor core; determines the exception type of the task operation exception in response to the reconstruction trigger event; determines the corresponding reconstruction entry path according to the exception type, and performs reconstruction based on the reconstruction entry path.
[0123] Determine the abnormal time when the task runs abnormally; obtain the address information stored in the previous context information register of the software processor core at the abnormal time; perform the first context area address reconstruction according to the address information, and reconstruct the function address stored in the context area before the abnormal time; starting from the second context area address reconstruction, for each context area address reconstruction, obtain the link information stored in the context area determined by the previous address reconstruction; perform address reconstruction according to the link information to obtain the address of the current context area, and obtain the function address stored in the current context area according to the address, until the Nth context area address reconstruction is completed, and obtain the N function addresses before the abnormal time.
[0124] Determine the core identifier of the software processor core; splice the function address obtained by each reconstruction of the context area address in N context area address reconstructions to the control flow cache area corresponding to the core identifier, obtain the control flow data for determining the abnormal position of the software, and store the control flow data in the storage medium. If the core identifier is not the preset core identifier, send the control flow data to the target processor core where the preset core identifier is located; store the control flow data in the storage medium through the target processor core. In response to the abnormal analysis instruction, obtain the corresponding target control flow data from the storage medium; determine the target function corresponding to each function address according to all function addresses in the target control flow data; determine the abnormal function from the target function according to the execution order between the target functions; determine the abnormal position of the software according to the abnormal function. For example, the following is an analysis based on the above method, adding a dead loop to the main core core0 2ms task, so that the main core core0 1ms task will wait until timeout, and the system will enter a fault. As shown in Table 1, ControlFlowData is the control flow reconstruction data. After ControlFlowData is stored in dFlash, it is read through DID (E487). After reading the DID (E487) through the UDS22 service, the data in dFlash matches the ControlFlowData and debugger Call Stack.
[0125] Table 1
[0126]
[0127] It should be noted that the specific implementation of this embodiment can be achieved in the manner defined in the above embodiment, which will not be elaborated here.
[0128] In this way, by calling the entry selection, control flow reconstruction, and control flow information storage of the control flow reconstruction function, the control flow data in the crash process can be automatically reconstructed and stored, and fault data can be easily obtained without investing a lot of manpower and time resources, nor is it necessary to reproduce the crash condition in a laboratory environment. This avoids the problems of complex vehicle conditions, few obtainable signals, and difficulty in reproduction. When a crash occurs on the vehicle, the watchdog is reset, which hides the crash situation and improves the accuracy and reliability of abnormality analysis.
[0129] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0130] Based on the same inventive concept, the embodiment of the present application also provides an exception handling device for implementing the above-mentioned exception handling method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more exception handling device embodiments provided below can refer to the limitations on the exception handling method above, and will not be repeated here.
[0131] In an exemplary embodiment, Figure 8 As shown, an exception handling device is provided, including: a data determination module 801, an address information acquisition module 802, a reconstruction module 803 and a storage module 804, wherein:
[0132] The data determination module 801 is used to determine the abnormal time when the task is abnormally executed when the task is detected to be abnormal in the software processor core.
[0133] The address information acquisition module 802 is used to acquire the address information stored in the previous context information register of the software processor core at the abnormal time.
[0134] A reconstruction module 803 is used to perform N context area address reconstructions according to the address information to obtain N function addresses before the abnormal moment;
[0135] The storage module 804 is used to determine the control flow data used to determine the abnormal position of the software according to the N function addresses.
[0136] The above-mentioned exception handling method, device, computer equipment, storage medium and computer program product, when detecting an abnormal task operation in the software processor core, determine the abnormal time when the task operation is abnormal, obtain the address information stored in the previous context information register at this abnormal time, perform N context area address reconstructions based on the address information, obtain N function addresses before this abnormal time, and determine the control flow data used to determine the location of the software abnormality based on the N function addresses. In the case of an abnormality, all control flow data where the abnormality occurs can be collected, and exception analysis can be performed based on the control flow data, thereby avoiding the problem of being unable to analyze the exception when the software fault is reset, and there is no need to reproduce the crash condition through a laboratory environment, thereby avoiding the situation where the vehicle working conditions are complex and difficult to reproduce, reducing the cost of exception analysis and improving the accuracy of exception analysis.
[0137] In an exemplary embodiment, the reconstruction module 803 is further used to perform a first context area address reconstruction according to the address information, and reconstruct the function address stored in the context area before the abnormal moment;
[0138] Starting from the second context area address reconstruction, for each context area address reconstruction, obtaining link information stored in the context area determined by the previous address reconstruction;
[0139] The address is reconstructed according to the link information to obtain the address of the current context area, and the function address stored in the current context area is obtained according to the address, until the Nth context area address reconstruction is completed, and the N function addresses before the abnormal moment are obtained.
[0140] In an exemplary embodiment, the reconstruction module 803 is further used to parse the address information to obtain the middle segment data and the offset data of the address information;
[0141] Performing encoding operation on the segment data and the offset data to reconstruct the address of the context area reconstructed for the first time before the abnormal moment;
[0142] According to the address of the context area of the first reconstruction, the function address is determined from the context area of the first reconstruction.
[0143] In an exemplary embodiment, the reconstruction module 803 is further used to extract the first target bit data from the segment data, and to extract the second target bit data from the offset data;
[0144] The first target bit data is placed at the first target position of the corresponding context area address space, and the second target bit data is placed at the second target position of the context area address space, to reconstruct the address of the context area reconstructed for the first time before the abnormal moment.
[0145] In an exemplary embodiment, the abnormality analysis device further includes a reconstruction entry path determination module, which is used to generate a reconstruction trigger event when an abnormality in the operation of a task in the software processor core is detected;
[0146] In response to the reconstruction triggering event, determining the abnormality type of the task operation abnormality;
[0147] Determine the corresponding reconstruction entry path according to the exception type, perform reconstruction based on the reconstruction entry path, and execute the step of determining the abnormal time when the task runs abnormally.
[0148] In an exemplary embodiment, the anomaly analysis device further includes a storage module, the storage module being used to determine a core identification of a software processor core;
[0149] The function address obtained by each context area address reconstruction in N context area address reconstructions is spliced into the control flow buffer area corresponding to the core identifier to obtain control flow data for determining the software abnormality location, and the control flow data is stored in a storage medium.
[0150] In an exemplary embodiment, the storage module 804 is used to send the control flow data to the target processor core where the preset core identifier is located if the core identifier is not the preset core identifier;
[0151] The control flow data is stored in a storage medium via the target processor core.
[0152] In an exemplary embodiment, the abnormality analysis device further includes an abnormality locating module, the abnormality locating module being used to obtain corresponding target control flow data from a storage medium in response to the abnormality analysis instruction;
[0153] According to all function addresses in the target control flow data, determine the target function corresponding to each function address;
[0154] According to the execution order between the objective functions, the abnormal function is determined from the objective functions;
[0155] Determine the abnormal location of the software based on the abnormal function.
[0156] Each module in the above-mentioned exception handling device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.
[0157] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Fig. 9 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, an exception handling method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0158] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0159] In an exemplary embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0160] In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0161] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0162] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0163] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0164] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0165] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. An exception handling method, It is characterized in that The method comprises: When detecting that a task in the software processor core is running abnormally, determining the abnormal time when the task is running abnormally; Acquire address information of a previous context information register of the software processor core stored at the abnormal time; Perform N context area address reconstructions according to the address information to obtain N function addresses before the abnormal moment; Control flow data for determining a software exception location is determined based on the N function addresses.
2. The method according to claim 1, It is characterized in that The performing N context area address reconstructions according to the address information to obtain N function addresses before the abnormal moment includes: Performing a first context area address reconstruction according to the address information to reconstruct the function address stored in the context area before the abnormal moment; Starting from the second context area address reconstruction, for each context area address reconstruction, obtaining link information stored in the context area determined by the previous address reconstruction; Reconstruct the address according to the link information to obtain the address of the current context area; The function address stored in the current context area is obtained according to the address, until the Nth context area address reconstruction is completed, and the N function addresses before the abnormal moment are obtained.
3. The method according to claim 2, It is characterized in that The first context area address reconstruction is performed according to the address information to reconstruct the function address stored in the context area before the abnormal moment, including: Parsing the address information to obtain segment data and offset data of the address information; Performing an encoding operation on the segment data and the offset data to reconstruct an address of a context area reconstructed for the first time before the abnormal moment; According to the address of the first reconstructed context area, a function address is determined from the first reconstructed context area.
4. The method according to claim 3, It is characterized in that The encoding operation is performed on the segment data and the offset data to reconstruct the address of the first reconstructed context area before the abnormal moment, including: extracting first target bit data from the segment data, and extracting second target bit data from the offset data; The first target bit data is placed at a first target position of the corresponding context area address space, and the second target bit data is placed at a second target position of the context area address space, to reconstruct the address of the context area reconstructed for the first time before the abnormal moment.
5. The method according to claim 1, It is characterized in that The method further comprises: When abnormal operation of a task in a software processor core is detected, a reconstruction trigger event is generated; In response to the reconstruction triggering event, determining the abnormality type of the task running abnormality; Determine a corresponding reconstruction entry path according to the abnormality type, perform reconstruction based on the reconstruction entry path, and execute the step of determining the abnormal time when the task runs abnormally.
6. The method according to any one of claims 1 to 5, It is characterized in that Determining control flow data for determining the software abnormality location according to the N function addresses includes: Determining a core identification of the software processor core; The function address obtained by each context area address reconstruction in N context area address reconstructions is spliced into the control flow cache area corresponding to the core identifier to obtain control flow data for determining the software abnormality location, and the control flow data is stored in a storage medium.
7. The method according to claim 6, It is characterized in that Before storing the control flow data in a storage medium, the method further includes: If the core identifier is not a preset core identifier, sending the control flow data to the target processor core where the preset core identifier is located; The control flow data is stored in a storage medium through the target processor core.
8. The method according to claim 6, It is characterized in that The method further comprises: In response to the abnormal analysis instruction, obtaining corresponding target control flow data from the storage medium; Determine, according to all function addresses in the target control flow data, a target function corresponding to each function address; Determining abnormal functions from the objective functions according to the execution order between the objective functions; The abnormal position of the software is determined according to the abnormal function.
9. An exception handling device, It is characterized in that The device comprises: A data determination module, for determining the abnormal time when the task is abnormally executed when an abnormal task is detected in the software processor core; An address information acquisition module, used to acquire address information stored in a previous context information register of the software processor core at the abnormal moment; A reconstruction module, used to perform N context area address reconstructions according to the address information to obtain N function addresses before the abnormal moment; The storage module is used to determine the control flow data used to determine the location of the software exception according to the N function addresses.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.
Citation Information
Cited By
Analysis method and device for recording abnormal data
CN120104391A
