A replay debugging device and method based on erroneous target capture files
Patent Information
- Application Number
- CN202211593220.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-13
- Publication Date
- 2026-09-01
- Estimated Expiration
- 2042-12-13
AI Technical Summary
传统的调试是通过对软件行为的多次重现从而定位以及找出错误目标,这需要不断重复软件的运行与关闭,耗费软件调试人员大量的时间和精力,而且对于某些错误行为也不能重现真实的错误场景
Smart Images

Figure CN115878468B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a replay debugging method and apparatus, specifically a replay debugging apparatus and method based on erroneous target capture files, belonging to the field of software debugging and R&D technology. Background Technology
[0002] Debugging is a crucial part of software development. With the rapid development of embedded devices, efficient debugging of embedded software has become increasingly important. Errors such as array out-of-bounds errors, memory overflows, and illegal pointers that occur during embedded software operation, leading to software malfunctions or crashes, are characterized by their high degree of concealment and unpredictability. These errors need to be analyzed and located through software debugging. Accurately reproducing the error target is the most critical step in the entire debugging process. Traditional debugging involves repeatedly reproducing the software behavior to locate and find the error target. This requires repeatedly running and shutting down the software, consuming a significant amount of time and energy for software debuggers. Moreover, it cannot reproduce the actual error scenario for some erroneous behaviors.
[0003] Therefore, how to quickly and accurately locate and replay errors, reduce software debugging and development costs, and effectively shorten the software development cycle has become an urgent problem to be solved. Based on this, this application proposes a replay debugging device and method based on error target capture files. Summary of the Invention
[0004] The purpose of this invention is to provide a replay debugging apparatus and method based on erroneous target capture files in order to solve at least one of the above-mentioned technical problems.
[0005] This invention achieves the above objective through the following technical solution: a replay debugging device based on an error target capture file, which captures the error target and generates an error target capture file when a software error occurs, thereby realizing error replay debugging, specifically including:
[0006] Error target capture component, deployed on the target machine, includes an exception handling module and a communication proxy module;
[0007] The replay debugging component, deployed on the host machine, includes a replay plugin, a debugging plugin, a disassembler, and a communication management plugin;
[0008] The error target capture component, when an error occurs, captures the error target through the exception handling module, generates an error target capture file, and then sends the error target capture file to the replay debugging component through the communication proxy module.
[0009] The error target capture file is used to record error target information captured by the embedded operating system when software errors occur, including file information, exception information, task stack information, and function call address table;
[0010] The software is a user application running on an embedded operating system.
[0011] 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.
[0012] As a further aspect of the present invention: the file information includes the file type, processor type, and operating system version name; the exception information includes the exception type, the task ID of the exception, the name of the exception, and the general-purpose register information of the exception context; the task stack information is the stack information of the task that encountered 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.
[0013] A replay debugging method based on error target capture files includes the following steps:
[0014] S1) The replay debugging component starts debug mode and obtains the error target capture file through the communication management plugin;
[0015] S2) The disassembler parses the executable file of the software that has encountered an error and generates a disassembled file;
[0016] S3) The debugging plugin obtains the software function information recorded in the disassembly file, analyzes the error target capture file, matches the function call addresses saved in the error target capture file with the function information in the disassembly file, and generates a function information file;
[0017] S4) The replay plugin reads information recorded in the function information file and the error target capture file, and replays the error scene.
[0018] As a further aspect of the present invention: in step S2), the function information includes the function name, function address, the source code file name corresponding to the function, the source code corresponding to the function, and the source code line number corresponding to the function.
[0019] As a further aspect of the present invention: in step S3), the process of generating the function information file is as follows:
[0020] ① Retrieve the address of the first-level function recorded in the function call address table of the error target capture file;
[0021] ② Search and record the source code, source code file name, and source code line number of the first-level function address in the disassembled file, and record the function name and source code closest to the source code line;
[0022] ③ Repeat ①~② to match the n-level function addresses recorded in the function call address table of the error target capture file with the corresponding function information.
[0023] ④ Save the function information recorded in ③ as a function information file.
[0024] As a further aspect of the present invention: In step S4), replaying the error scene means replaying the scene information at the moment the error occurred to the software debugger through the replay plugin. This mainly includes the exception type corresponding to the error, the source code file name where the error occurred, the source code and source code line number, the name and task ID of the task where the error occurred, the general register information when the error occurred, and the function call relationship and function information when the error occurred.
[0025] The beneficial effects of the present invention are as follows: the replay debugging method apparatus includes an error target capture component and a replay debugging component. When an error occurs in the application software, the error target capture component captures the error target, generates an error target capture file, and sends it to the replay debugging component. The replay debugging component, in conjunction with the disassembled file of the software executable file, replays the error scene, which can help software debuggers accurately and quickly locate and replay the error, reduce software debugging and development costs, and shorten the software development cycle. Attached Figure Description
[0026] Figure 1 This is a block diagram of the playback debugging device of the present invention;
[0027] Figure 2 This is a block diagram of the playback debugging method of the present invention;
[0028] Figure 3 This is a flowchart illustrating the generation process of the function information file for this invention. Detailed Implementation
[0029] 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.
[0030] Example 1
[0031] This embodiment is implemented on an embedded ARM architecture processor FT-1500A / 4 and a PC.
[0032] like Figure 1As shown, a replay debugging device based on an error target capture file is disclosed. This device captures the error target when a software error occurs, generates an error target capture file, and implements error replay debugging. Specifically, it includes:
[0033] The error target capture component, deployed on the FT-1500A / 4 processor, includes an exception handling module and a communication agent module;
[0034] The replay debugging component, deployed on a PC, includes a replay plugin, a debugging plugin, a disassembler, and a communication management plugin.
[0035] The error target capture component, when an error occurs, captures the error target through the exception handling module, generates an error target capture file, and then sends the error target capture file to the replay debugging component through the communication proxy module.
[0036] The error target capture file is used to record error target information captured by the embedded operating system when software errors occur, including file information, exception information, task stack information, and function call address table;
[0037] The software is a user application running on an embedded operating system.
[0038] Example 2
[0039] like Figure 1 As shown, in addition to all the technical features included in Embodiment 1, this embodiment also includes:
[0040] 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.
[0041] File information includes file type, processor type, and operating system version name; exception information includes exception type, task ID of the exception, task name of the exception, and general-purpose register information of the exception context; task stack information is the stack information of the task that encountered the error, including task stack length, task stack base address, and task stack contents; function call address table includes the function call level of the exception and the function call address information of the exception.
[0042] The processor type is ARM, and the general-purpose registers for the abnormal environment include r0 to r14, pc, and cpsr registers.
[0043] Example 2
[0044] This embodiment is implemented on an embedded ARM architecture processor FT-1500A / 4. An error target capture component is deployed on the FT-1500A / 4 processor; a replay debugging component is deployed on the PC. 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. The error target capture component generates an error target capture file. The replay debugging component performs replay debugging, such as... Figures 1 to 3 As shown, a replay debugging method based on an error target capture file includes the following steps:
[0045] S1) The replay debugging component starts debug mode and obtains the error target capture file through the communication management plugin;
[0046] S2) The disassembler parses the executable file of the software that has encountered an error and generates a disassembled file;
[0047] S3) The debugging plugin obtains the software function information recorded in the disassembly file, analyzes the error target capture file, matches the function call addresses saved in the error target capture file with the function information in the disassembly file, and generates a function information file;
[0048] S4) The replay plugin reads information recorded in the function information file and the error target capture file, and replays the error scene.
[0049] Example 4
[0050] like Figures 1 to 3 As shown, in addition to all the technical features included in Embodiment 3, this embodiment also includes:
[0051] In step S3), the function information includes the function name, function address, the name of the source code file corresponding to the function, the source code corresponding to the function, and the line number of the source code corresponding to the function.
[0052] In step S3), the process of generating the function information file is as follows:
[0053] ① Retrieve the address of the first-level function recorded in the function call address table of the error target capture file;
[0054] ② Search and record the source code, source code file name, and source code line number of the first-level function address in the disassembled file, and record the function name and source code closest to the source code line;
[0055] ③ Repeat ①~② to match the n-level function addresses recorded in the function call address table of the error target capture file with the corresponding function information.
[0056] ④ Save the function information recorded in ③ as a function information file.
[0057] In step S4), replaying the error scene means replaying the scene information at the moment the error occurred to the software debugger through the replay plugin. This mainly includes the exception type corresponding to the error, the source code file name where the error occurred, the source code and source code line number, the name and task ID of the task where the error occurred, the general register information at the time of the error, and the function call relationship and function information at the time of the error.
[0058] Working principle: When an error occurs in the application software, the error target capture component captures the error target, generates an error target capture file, and sends it to the replay debugging component; the replay debugging component combines the disassembled file of the software executable file to replay the error scene.
[0059] The present invention proposes a replay debugging device and method based on error target capture files, which can help software debuggers accurately and quickly locate and replay errors, reduce software debugging and development costs, and shorten the software development cycle.
[0060] 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.
[0061] 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 replay debugging method based on a replay debugging device for capturing erroneous targets, characterized in that: When a software error occurs, the replay debugging device captures the error target, generates an error target capture file, and realizes error replay debugging, specifically including: Error target capture component, deployed on the target machine, includes an exception handling module and a communication proxy module; The replay debugging component, deployed on the host machine, includes a replay plugin, a debugging plugin, a disassembler, and a communication management plugin; The error target capture component, when an error occurs, captures the error target through the exception handling module, generates an error target capture file, and then sends the error target capture file to the replay debugging component through the communication proxy module. The error target capture file is used to record error target information captured by the embedded operating system when software errors occur, including file information, exception information, task stack information, and function call address table; The software is a user application running on an embedded operating system; The replay debugging method includes the following steps: S1) The replay debugging component starts debug mode and obtains the error target capture file through the communication management plugin; S2) The disassembler parses the executable file of the software that has encountered an error and generates a disassembled file; S3) The debugging plugin obtains the software function information recorded in the disassembly file, analyzes the error target capture file, matches the function call addresses saved in the error target capture file with the function information in the disassembly file, and generates a function information file; In step S3), the process of generating the function information file is as follows: ① Retrieve the address of the first-level function recorded in the function call address table of the error target capture file; ② Search and record the source code, source code file name, and source code line number of the first-level function address in the disassembled file, and record the function name and source code closest to the source code line; ③ Repeat ①~② to match the n-level function addresses recorded in the function call address table of the error target capture file with the corresponding function information; ④ Save the function information recorded in ③ as a function information file; S4) The replay plugin reads information recorded in the function information file and the error target capture file, and replays the error scene.
2. The playback debugging 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 playback debugging method according to claim 1, characterized in that: 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 exception, and the general register information of the exception context; the task stack information is the stack information of the task that encountered the error, including the task stack length, the task stack base address, and the task stack contents; the function call address table includes the function call level number of the exception and the function call address information of the exception.
4. The playback debugging method according to claim 1, characterized in that: In step S3), the function information includes the function name, function address, the name of the source code file corresponding to the function, the source code corresponding to the function, and the line number of the source code corresponding to the function.
5. The playback debugging method according to claim 1, characterized in that: In step S4), replaying the error scene means replaying the scene information at the moment the error occurred to the software debugger through the replay plugin. This mainly includes the exception type corresponding to the error, the source code file name where the error occurred, the source code and source code line number, the name and task ID of the task where the error occurred, the general register information when the error occurred, and the function call relationship and function information when the error occurred.
Citation Information
Patent Citations
Application program playback method and system
CN104461521A
Embedded software debugging method
CN111352842A