Error target capture file based on embedded operating system and method for generating the same
Patent Information
- Application Number
- CN202211593236.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-13
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2042-12-13
AI Technical Summary
[0005]本发明的目的就在于为了解决上述嵌入式软件发生错误导致软件失常或崩溃时,传统的核心转储文件占用系统内存空间大、生成时间长等问题而提供一种基于嵌入式操作系统的错误目标捕获文件及其生成方法
[0028]本发明的有益效果是:运行在嵌入式操作系统上的软件某一任务发生错误时,触发处理器异常,嵌入式操作系统中止调度,执行异常响应程序;异常响应程序保存异常现场信息,执行异常处理程序;异常处理程序捕获错误目标信息,生成错误目标捕获文件,删除发生错误的任务;嵌入式操作系统退出异常处理程序和异常响应程序,恢复调度。本发明提出的错误目标捕获文件生成方法能够快速高效地收集分析错误目标的必要信息,生成的错误目标捕获文件占用内存空间小,能够辅助软件开发人员准确、快速地定位错误目标。
Smart Images

Figure CN115964209B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to an error target capture file, specifically an error target capture file based on an embedded operating system and its generation method, belonging to the field of embedded operating system technology. Background Technology
[0002] With the rapid development of embedded operating systems, various devices based on embedded operating systems have been widely used in important fields such as aerospace, national defense, industrial control, consumer electronics, communications, and automobiles.
[0003] Although embedded systems are becoming increasingly secure and reliable, unpredictable errors inevitably occur during embedded software operation, leading to software malfunctions or even crashes. The common practice for locating such errors is to collect all context information at the time of the error and generate a core dump file for debugger analysis. The core dump file is of type ELF Core, including the ELF header, Program headers, PT_NOTE segment, and PT_LOAD segment. The PT_NOTE segment stores thread state information and register information at the time of the exception, while the PT_LOAD segment stores the mapped memory and code segments of the process.
[0004] Because core dump files record a lot of on-site information, their generation time is long and they consume a large amount of memory. However, for embedded systems with extremely limited size and resources, overly complex and lengthy core dump file formats consume excessive memory. Therefore, how to quickly and efficiently collect and analyze the necessary information of the erroneous target while minimizing system memory usage, and assist software developers in accurately and quickly locating the erroneous target, has become an urgent problem to be solved. Summary of the Invention
[0005] The purpose of this invention is to provide an error target capture file and its generation method based on an embedded operating system to solve the problems of large system memory space occupation and long generation time of traditional core dump files when embedded software malfunctions or crashes due to errors.
[0006] The present invention achieves the above objectives through the following technical solution: an error target capture file based on an embedded operating system, comprising an error target capture file, wherein the error target capture file is used to record error target information captured by the embedded operating system when a software error occurs, the error target capture file includes file information, exception information, task stack information and function call address table, wherein the software is a user application running on the embedded operating system, and the error is a serious error that causes the software to terminate abnormally or crash;
[0007] The file information includes file type, processor type, and operating system version name; the exception information includes exception type, the task ID of the exception, the name of the task that caused the exception, and the general register information of the exception context; the task stack information is the stack information of the task that caused the error, including task stack length, task stack base address, and task stack content; the function call address table includes the function call level number of the exception and the function call address information of the exception.
[0008] As a further aspect of the present invention: the error is a serious error that causes the software to terminate abnormally or crash, including address access out of bounds, division by zero exception, illegal pointer, undefined instruction, memory overflow and other errors that can trigger processor exceptions.
[0009] A method for generating error target capture files based on an embedded operating system, the method comprising the following steps:
[0010] Step 1: When an error occurs in a task of the software running on the embedded operating system, a processor exception is triggered. The embedded operating system then stops scheduling and executes the exception response program.
[0011] Step 2: The exception response procedure saves the exception situation information and executes the exception handling procedure;
[0012] Step 3: The exception handler captures error target information, generates an error target capture file, and deletes the task that caused the error;
[0013] Step 4: The embedded operating system exits the exception handler and exception response routine and resumes scheduling.
[0014] As a further aspect of the present invention: in step two, the process by which the abnormal response program saves the abnormal situation information is as follows:
[0015] ① Enter the exception stack and save the exception stack information, including the stack frame register, stack base register, and link register information;
[0016] ② Switch from the exception stack to the task stack using a dedicated register and save all general-purpose register information of the exception context;
[0017] ③ Restore the exception stack based on the exception stack information saved in ②.
[0018] As a further aspect of the present invention: the process by which the exception handler generates the error target capture file is as follows:
[0019] ① Allocate memory space for the error target capture file;
[0020] ② Write the file type, processor type, and operating system version name to the error target capture file;
[0021] ③ Obtain the exception type, the task ID of the exception, the name of the task that caused the exception, and the general register information of the exception context, and write them to the error target capture file;
[0022] ④ Obtain the stack length, stack base address, and stack contents of the task that caused the error, and write them to the error target capture file;
[0023] ⑤ Obtain the function call address table and write it to the error target capture file.
[0024] As a further aspect of the present invention: the process of obtaining the function call address table is as follows:
[0025] ①Based on the general-purpose register information saved in the exception handler, analyze the information of the stack frame register, stack base register, and link register to obtain the address of the target function where the error occurred;
[0026] ②Based on the task stack information saved in the exception handler, the function call relationship and the target function call address are analyzed layer by layer for the target function call address where the error occurred;
[0027] ③ Record the number of function call levels and output the function call address table.
[0028] The beneficial effects of this invention are as follows: When an error occurs in a task of software running on an embedded operating system, a processor exception is triggered. The embedded operating system aborts scheduling and executes an exception response program. The exception response program saves the exception context information and executes an exception handling program. The exception handling program captures the error target information, generates an error target capture file, and deletes the task that caused the error. The embedded operating system exits the exception handling program and the exception response program and resumes scheduling. The error target capture file generation method proposed in this invention can quickly and efficiently collect and analyze the necessary information of the error target. The generated error target capture file occupies little memory space and can assist software developers in accurately and quickly locating the error target. Attached Figure Description
[0029] Figure 1 This is a diagram showing the file format for capturing erroneous targets in this invention.
[0030] Figure 2 This is a schematic diagram of the error target capture file generation method of the present invention;
[0031] Figure 3 This is a schematic diagram of the abnormal scene information saving process of the present invention;
[0032] Figure 4 This is a schematic diagram of the error target file saving process of the present invention.
[0033] Figure 5 This is a schematic diagram of the stack backtracking process of the present invention. Detailed Implementation
[0034] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0035] Example 1
[0036] This embodiment is implemented on an embedded ARM architecture processor FT-1500A / 4, which runs an embedded real-time operating system.
[0037] like Figure 1 As shown, an error target capture file based on an embedded operating system includes an error target capture file, which is used to record error target information captured by the embedded operating system when a software error occurs. The error target capture file includes file information, exception information, task stack information and function call address table. The software is a user application running on the embedded operating system, and the error is a serious error that causes the software to terminate abnormally or crash.
[0038] The file information includes file type, processor type, and operating system version name; the exception information includes exception type, the task ID of the exception, the name of the task that caused the exception, and the general-purpose register information of the exception context; the task stack information is the stack information of the task that caused the error, including the task stack length, the task stack base address, and the task stack content; the function call address table includes the function call level number of the exception and the function call address information of the exception.
[0039] An error is a serious error that causes the software to terminate or crash abnormally, including out-of-bounds address access, division by zero exception, illegal pointer, undefined instruction, memory overflow, and other errors that can trigger processor exceptions.
[0040] Exception types include undefined instruction exception, instruction prefetch abort exception, data access abort exception, and software interrupt exception.
[0041] The general-purpose registers for the abnormal situation include registers r0 to r14, pc, and cpsr.
[0042] Example 2
[0043] This embodiment is implemented on an embedded ARM architecture processor FT-1500A / 4, which runs an embedded real-time operating system. After the user loads the application onto the FT-1500 / 4 processor, an undefined instruction error occurs during application runtime, triggering an undefined instruction exception.
[0044] like Figures 2 to 5 As shown, a method for generating an error target capture file based on an embedded operating system includes the following steps:
[0045] Step 1: When an error occurs in a task of the software running on the embedded operating system, a processor exception is triggered. The embedded operating system then stops scheduling and executes the exception response program.
[0046] Step 2: The exception response procedure saves the exception situation information and executes the exception handling procedure;
[0047] Step 3: The exception handler captures error target information, generates an error target capture file, and deletes the task that caused the error;
[0048] Step 4: The embedded operating system exits the exception handler and exception response routine and resumes scheduling.
[0049] Example 3
[0050] like Figures 2 to 5 As shown, in addition to all the technical features included in Embodiment 2, this embodiment also includes:
[0051] In step two, the process for the exception response program to save the exception scene information is as follows:
[0052] ① Enter the exception stack and save the exception stack information, including the stack frame register, stack base register, and link register information;
[0053] ② Switch from the exception stack to the task stack using a dedicated register and save all register information of the exception context;
[0054] ③ Restore the exception stack based on the exception stack information saved in ②.
[0055] The stack frame register is register r13, the stack base register is register r11, and the link register is register r14; the special-purpose register is register cpsr.
[0056] Example 4
[0057] like Figures 2 to 5 As shown, in addition to all the technical features included in Embodiment 2, this embodiment also includes:
[0058] In step three, the process by which the exception handler saves the error target capture file is as follows:
[0059] ① Allocate memory space for the error target capture file;
[0060] ② Write the file type, processor type, and operating system version name to the error target capture file;
[0061] ③ Obtain the exception type, the task ID of the exception, the name of the task that caused the exception, and the general register information of the exception context, and write them to the error target capture file;
[0062] ④ Obtain the stack length, stack base address, and stack contents of the task that caused the error, and write them to the error target capture file;
[0063] ⑤ Obtain the function call address table and write it to the error target capture file.
[0064] Example 5
[0065] like Figures 2 to 5 As shown, in addition to all the technical features included in Embodiment 4, this embodiment also includes: the process of obtaining the function call address table is as follows:
[0066] ①Based on the general-purpose register information saved in the exception handler, analyze the information of the stack frame register, stack base register, and link register to obtain the address of the target function where the error occurred;
[0067] ②Based on the task stack information saved in the exception handler, the function call relationship and the target function call address are analyzed layer by layer for the target function call address where the error occurred;
[0068] ③ Record the number of function call levels and output the function call address table.
[0069] Working principle: When an error occurs during system operation, causing an anomaly, the system captures the error target, quickly and efficiently collects and analyzes the necessary information of the error target, and generates an error target capture file that occupies little system memory space, making it easy to save, copy and use the error target capture file.
[0070] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.
[0071] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A method for generating error target capture files based on an embedded operating system, characterized in that: The error target capture file based on the embedded operating system includes An error target capture file is used to record error target information captured by the embedded operating system when a software error occurs. The error target capture file includes file information, exception information, task stack information, and function call address table. The file information includes file type, processor type, and operating system version name; The exception information includes the exception type, the ID of the task that caused the exception, the name of the task that caused the exception, and the general register information of the exception scene. The task stack information is the stack information of the task that encountered the error, including the task stack length, task stack base address, and task stack content; The function call address table includes the function call level number where the exception occurred and the function call address information where the exception occurred; The generation method includes the following steps: Step 1: When an error occurs in a task of the software running on the embedded operating system, a processor exception is triggered. The embedded operating system then stops scheduling and executes the exception response program. Step 2: The exception response procedure saves the exception situation information and executes the exception handling procedure; In step two, the process of the exception response program saving the exception scene information is as follows: ① Enter the exception stack and save the exception stack information, including the stack frame register, stack base register, and link register information; ② Switch from the exception stack to the task stack using a dedicated register and save all general-purpose register information of the exception context; ③ Restore the exception stack based on the exception stack information saved in ②; Step 3: The exception handler captures error target information, generates an error target capture file, and deletes the task that caused the error; The process of generating the error target capture file in step three is as follows: ① Allocate memory space for the error target capture file; ② Write the file type, processor type, and operating system version name to the error target capture file; ③ Obtain the exception type, the task ID of the exception, the name of the task that caused the exception, and the general register information of the exception context, and write them to the error target capture file; ④ Obtain the stack length, stack base address, and stack contents of the task that caused the error, and write them to the error target capture file; ⑤ Obtain the function call address table and write it to the error target capture file; Step 4: The embedded operating system exits the exception handler and exception response routine and resumes scheduling.
2. The generation method according to claim 1, characterized in that: The error is a serious error that causes the software to terminate or crash abnormally, including out-of-bounds address access, division by zero exception, illegal pointer, undefined instruction, memory overflow, and other errors that can trigger processor exceptions.
3. The generation method according to claim 1, characterized in that: The process of obtaining the function call address table is as follows: ①Based on the general-purpose register information saved in the exception handler, analyze the information of the stack frame register, stack base register, and link register to obtain the address of the target function where the error occurred; ②Based on the task stack information saved in the exception handler, the function call relationship and the target function call address are analyzed layer by layer for the target function call address where the error occurred; ③ Record the number of function call levels and output the function call address table.
Citation Information
Patent Citations
A system for catching embedded operating system anomalies
CN109376030A