A software debugging method

By constructing an online CPU behavior database and combining it with database retrieval to achieve backtracking debugging, the problem of low efficiency in existing software debugging is solved, and efficient pre-chip tape-out verification and embedded software debugging are realized.

CN116775444BActive Publication Date: 2026-07-31SHANGHAI UNIVISTA IND SOFTWARE GRP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANGHAI UNIVISTA IND SOFTWARE GRP CO LTD
Filing Date
2022-03-10
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing software debugging methods are inefficient and cannot perform backtracking debugging efficiently in the pre-chip tape-out verification stage. Furthermore, existing backtracking debuggers are not suitable for embedded software development.

Method used

By collecting CPU behavior information through online forward execution and building a database, backtracking debugging can be achieved. Combined with target database key-value retrieval and offline debugging engine, forward and backtracking debugging can be performed simultaneously in a single run. The database is used to find CPU behavior information to improve efficiency.

Benefits of technology

It enables simultaneous forward and backward debugging in a single run, greatly saving software debugging iteration time and improving debugging efficiency and performance. It is suitable for the verification stage before chip tape-out.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116775444B_ABST
    Figure CN116775444B_ABST
Patent Text Reader

Abstract

This invention relates to a software debugging method, comprising the following steps: Step S1: Running and debugging the software program to be debugged online in a forward direction, collecting CPU behavior information using a preset real-time information acquisition component, and constructing a database in real time based on the CPU behavior information; Step S2: When a backtracking debugging request is received, pausing the software program to be debugged at the current debugging point, obtaining the target jump function input by the user, and translating the target jump function into a target database key value; Step S3: Retrieving the database based on the target database key value, obtaining the CPU behavior information corresponding to the target database key value, and performing backtracking debugging; after the backtracking debugging is completed, executing Step S4; Step S4: Resuming the forward running and debugging of the software program to be debugged from the current debugging point. This invention improves the efficiency and performance of software debugging.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software debugging technology, and in particular to a software debugging method. Background Technology

[0002] Most existing software debugging methods employ unidirectional, intrusive, and online approaches. Unidirectional debugging only allows debugging forward over time, not backward. Intrusive methods involve the debugger altering processor behavior to achieve the debugging objective, thus changing the program's execution and interrupting its operation. In such cases, it may be impossible to reproduce the previously encountered error upon subsequent debugging. Online debugging refers to debugging during program execution, not offline. Therefore, existing software debugging methods require restarting the program to revert to a previous point in time, often requiring multiple restarts to pinpoint the problem, resulting in very low debugging efficiency.

[0003] Existing software debuggers offer backtracking capabilities, but these are designed for general-purpose applications and suffer from performance issues. Furthermore, the existing backtracking debugging software is irrelevant to embedded chip software development, and is particularly unsuitable for the pre-tape-out verification stage. Therefore, providing an efficient, high-performance software debugging method applicable to the pre-tape-out verification stage is a pressing technical problem. Summary of the Invention

[0004] The purpose of this invention is to provide a software debugging method that improves the efficiency and performance of software debugging.

[0005] According to a first aspect of the present invention, a software debugging method is provided, comprising:

[0006] Step S1: Run and debug the software program to be debugged online in a forward direction, collect CPU behavior information using a preset real-time information acquisition component, and build a database in real time based on the CPU behavior information;

[0007] Step S2: When a backtracking debugging request is received, the software program to be debugged is paused at the current debugging point, the target jump function input by the user is obtained, and the target jump function is translated into the target database key value;

[0008] Step S3: Based on the target database key value, retrieve the database and obtain the CPU behavior information corresponding to the target database key value for backtracking and debugging. After the backtracking and debugging is completed, execute step S4.

[0009] Step S4: Continue running and debugging the software program to be debugged from the current debugging point.

[0010] According to a second aspect of the present invention, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being configured to perform the method described in the first aspect of the present invention.

[0011] According to a third aspect of the present invention, a computer-readable storage medium is provided, wherein the computer instructions are configured to perform the method described in the first aspect of the present invention.

[0012] Compared with existing technologies, this invention has significant advantages and beneficial effects. Through the above technical solution, the software debugging method provided by this invention achieves considerable technological advancement and practicality, and has broad industrial application value. It possesses at least the following advantages:

[0013] This invention enables simultaneous forward and backward debugging during a single run of the software program to be debugged, and allows users to continue running the program after backward debugging is complete. This invention significantly reduces software debugging iteration time and improves debugging efficiency and performance.

[0014] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0015] Figure 1 A flowchart of a software debugging method provided in an embodiment of the present invention. Detailed Implementation

[0016] To further illustrate the technical means and effects adopted by the present invention to achieve the intended purpose, the following detailed description of the specific implementation method and its effects of a software debugging method proposed according to the present invention, in conjunction with the accompanying drawings and preferred embodiments, is provided below.

[0017] This invention provides a software debugging method, such as... Figure 1 As shown, it includes:

[0018] Step S1: Run and debug the software program to be debugged online in a forward direction, collect CPU behavior information using a preset real-time information acquisition component, and build a database in real time based on the CPU behavior information;

[0019] Among them, online forward running and debugging of the software program to be debugged means forward debugging the program by advancing the time backward. During this process, the CPU behavior can be changed in an intrusive manner according to the debugging requirements.

[0020] Step S2: When a backtracking debugging request is received, the software program to be debugged is paused at the current debugging point, the target jump function input by the user is obtained, and the target jump function is translated into the target database key value;

[0021] Among them, through database-based backtracking debugging, in the online debugging task, it is possible to freely backtrack to any time before the current simulation time point for debugging. Specifically, an online debugging engine can be set up to execute the online forward running and debugging of the software program to be debugged, and an offline debugging engine can be set up to execute the backtracking debugging process based on the database. In the background, the online debugging engine and the offline debugging engine can be freely switched according to the debugging needs. In the forward or backtracking debugging mode, the user front-end control remains highly consistent in different modes, and the user interface and debugging experience remain highly consistent.

[0022] Step S3: Based on the target database key value, retrieve the database and obtain the CPU behavior information corresponding to the target database key value for backtracking and debugging. After the backtracking and debugging is completed, execute step S4.

[0023] Step S4: Continue running and debugging the software program to be debugged from the current debugging point.

[0024] As an example, in step S1, the software program to be debugged can be a general application program or a software program used in the verification stage before chip tape-out for embedded development and debugging. If the software program to be debugged is a software program in the verification stage before chip tape-out, it can be run on a pre-set simulation platform to simulate the chip. Of course, a real chip can also be used to run the software program to be debugged.

[0025] This invention enables simultaneous forward and backward debugging during a single run of the software program to be debugged, and allows users to continue running the program after backward debugging is complete. This invention significantly reduces software debugging iteration time and improves debugging efficiency and performance.

[0026] As one embodiment, in step S1, the online forward running and debugging of the software program to be debugged includes:

[0027] Step S11: Set the branch execution behavior of the software program to be debugged in an intrusive manner, so that the software program to be debugged runs according to the set branch behavior.

[0028] It should be noted that in some debugging scenarios, the program is originally running in one direction, but due to debugging needs, it is necessary to change the CPU behavior and try another branch. By using the online forward running and debugging method of the software program to be debugged in step S1, the CPU behavior can be changed and new running branches can be explored without recompiling or rebuilding the debug. The debugging process is flexible and can adapt to various debugging needs in the software development process. Moreover, the entire running process will be recorded by the database for subsequent backtracking and debugging.

[0029] As one embodiment, in step S1, the online forward running and debugging of the software program to be debugged includes:

[0030] Step S12: Debug the software program to be debugged online by executing step by step backward.

[0031] Among them, the single-step backward execution method is used for debugging, which means that after each step is executed, the result of the execution of the step is checked to see if it is consistent with the expectation, so as to whether the current execution point is the target problem point.

[0032] As one embodiment, in step S1, the online forward running and debugging of the software program to be debugged includes:

[0033] Step S12: Debug the software program to be debugged online by setting breakpoints.

[0034] Understandably, one or more breakpoints can be set for online debugging based on debugging needs.

[0035] As one embodiment, the CPU behavior information includes program count information, preset critical register change information, memory access information, and CPU event information. Each step of the software program to be debugged generates a corresponding program count. During the execution of the software program to be debugged, multiple registers are set; only the registers related to the debugging task need to be set as preset critical registers, and every change to these critical registers is recorded. Memory access information includes heap memory read and write information. CPU event information includes reset events and restart events, etc.

[0036] As one embodiment, in step S1, the preset information acquisition component can be an existing trace capture component for capturing CPU behavior. The trace capture component captures multiple CPU behavior information, each with a corresponding timestamp. It should be noted that the CPU behavior information directly collected by the trace capture component contains a lot of redundant information, occupying a large amount of space. Therefore, by parsing the CPU behavior information extracted by the trace capture component, the program counter value, along with the corresponding key register status, memory access status, and CPU event information, can be extracted. The program counter value can be used as a key to construct a database. The database includes all records of the software program to be debugged, and each record includes a program counter value field, a key register status field, a memory access status field, and a CPU event information field.

[0037] As one embodiment, in step S1, the preset information acquisition component can also be a pre-set acquisition component that is only used to collect key register status, memory access status and CPU event information, and directly collect key register status, memory access status and CPU event information to construct the database.

[0038] In addition, data can be compressed using techniques such as data compression to reduce the size of the database. This ensures that the database size will not become too large, even when running long programs.

[0039] By building a database to record key behavior information of each step of CPU execution, the process of controlling CPU behavior during backtracking and debugging is transformed into database lookup behavior. This significantly improves the speed of obtaining CPU information compared to controlling CPU behavior, thereby increasing backtracking and debugging efficiency.

[0040] It should be noted that the debugging user only knows the target jump function of the software program to be debugged, but does not know the corresponding target database key. During the database construction process, a mapping relationship between the database key and the jump function is established simultaneously. As one embodiment, step S1, in the process of constructing the database, further includes:

[0041] Step S10: Establish the mapping relationship between database key values ​​and jump functions.

[0042] In step S2, translating the target jump function into a target database key value includes:

[0043] Step S21: Based on the mapping relationship between the database key-value pairs and the jump functions, translate the target jump function into the target database key-value pairs. This can be achieved through an offline debugging engine.

[0044] As one embodiment, step S3 includes:

[0045] Step S31: Retrieve the database based on the target database key value to obtain the key register status, memory access status and CPU event information corresponding to the target database key value;

[0046] Step S32: If the key register state, memory access state, or CPU event information corresponding to the target database key value is inconsistent with the preset key register state, preset memory access state, or preset CPU event information corresponding to the target database key value, then the program execution point corresponding to the target database key value is determined as the target problem point.

[0047] It should be noted that the preset critical register states, preset memory access states, or preset CPU event information are the expected values ​​for the normal operation of the software program to be debugged. When all are consistent, it means that the program has no problems at this execution point and before this execution point. If there is a discrepancy in one value, it means that this execution point is the target problem point.

[0048] However, it is usually difficult to pinpoint the target problem point directly in one go, so repeated debugging is required. As an example, in step S32, if the key register status, memory access status, and CPU event information corresponding to the target database key value are consistent with the preset key register status, preset memory access status, and preset CPU event information corresponding to the target database key value, then execute:

[0049] Step S32: Return to step S2, retrieve the target jump function re-entered by the user, translate the re-entered target jump function into the target database key value, and execute step S3.

[0050] It should be noted that once it is confirmed that the program execution point corresponding to the previous target jump function is not the target problem execution point, the target problem execution point is located after this program execution point. The user can then re-enter the target jump function corresponding to this program execution point. Step S32 allows for multiple specification of backtracking points, backtracking to the specified backtracking point, and checking whether the backtracking point is the target problem point.

[0051] As one embodiment, when a backtracking point is specified, and this backtracking point is not the target problem point, the problem point can be located by using the backtracking point as the starting point and employing single-step or multi-step backward debugging. In step S31, if the key register state, memory access state, and CPU event information corresponding to the target database key value are consistent with the preset key register state, preset memory access state, and preset CPU event information corresponding to the target database key value, then the following is executed:

[0052] Step S33: Control the database key value to jump backward from the target database key value according to the preset key value step size, obtain the key register status, memory access status and CPU event information corresponding to each database key value, and compare it with the preset key register status, preset memory access status and preset CPU event information corresponding to each database key value. If they are consistent, determine that the program running point corresponding to the current database key value is the target problem point.

[0053] Most of the preset key-value step sizes can be single-step or multi-step, that is, to traverse the records in the database one by one for debugging, or to read the records at intervals for debugging.

[0054] In some cases, the software program to be debugged may have more than one target problem point during its operation, or there may be a need to backtrack backward. In such cases, a backtracking point can be determined, and then backtracking can be performed to determine the target problem point. As one embodiment, step S3 may further include:

[0055] Step S34: Control the database key value to jump forward from the target database key value according to the preset key value step size, obtain the key register status, memory access status and CPU event information corresponding to each database key value, and compare it with the preset key register status, preset memory access status and preset CPU event information corresponding to each database key value. If they are consistent, determine that the program running point corresponding to the current database key value is the target problem point.

[0056] Most of the preset key-value step sizes can be single-step or multi-step, that is, to traverse the records in the database one by one for debugging, or to read the records at intervals for debugging.

[0057] This invention enables simultaneous forward and backward debugging during a single run of the software program to be debugged, and allows users to continue running the program after backward debugging is complete. This invention significantly reduces software debugging iteration time and improves debugging efficiency and performance.

[0058] It should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the steps as sequential processes, many of these steps can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the steps can be rearranged. A process can be terminated when its operation is complete, but it may also have additional steps not included in the figures. A process can correspond to a method, function, procedure, subroutine, subroutine, etc.

[0059] This invention also provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being configured to perform the method described in this invention.

[0060] This invention also provides a computer-readable storage medium, wherein the computer instructions are used to execute the methods described in this invention.

[0061] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.

Claims

1. A software debugging method characterized by comprising: include: Step S1: Run and debug the software program to be debugged online in a forward direction, collect CPU behavior information using a preset real-time information acquisition component, and build a database in real time based on the CPU behavior information; Step S2: When a backtracking debugging request is received, the software program to be debugged is paused at the current debugging point, the target jump function input by the user is obtained, and the target jump function is translated into the target database key value; Step S3: Based on the target database key value, retrieve the database and obtain the CPU behavior information corresponding to the target database key value for backtracking and debugging. After the backtracking and debugging is completed, execute step S4. Step S4: Continue running forward and debugging the software program to be debugged from the current debugging point; In step S1, the CPU behavior information includes program count information, preset key register change information, memory access information, and CPU event information. The database includes all records of the software program to be debugged, and the records include a program counter value field, a key register status field, a memory access status field, and a CPU event information field. The database key value is the program counter value; In step S1, the process of constructing the database further includes: Step S10: Establish the mapping relationship between database key values ​​and jump functions; In step S2, translating the target jump function into a target database key value includes: Step S21: Based on the mapping relationship between the database key-value and the jump function, translate the target jump function into the target database key-value; Step S3 includes: Step S31: Retrieve the database based on the target database key value to obtain the key register status, memory access status and CPU event information corresponding to the target database key value; Step S32: If the key register state, memory access state, or CPU event information corresponding to the target database key value is inconsistent with the preset key register state, preset memory access state, or preset CPU event information corresponding to the target database key value, then the program execution point corresponding to the target database key value is determined as the target problem point.

2. The method according to claim 1, characterized in that, In step S1, the online forward running and debugging of the software program to be debugged includes: The branch execution behavior of the software program to be debugged is set in an intrusive manner, so that the software program to be debugged runs according to the set branch behavior.

3. The method according to claim 1 or 2, characterized in that, In step S1, the online forward running and debugging of the software program to be debugged includes: The software program to be debugged is debugged online using a step-by-step execution method.

4. The method according to claim 1 or 2, characterized in that, In step S1, the online forward running and debugging of the software program to be debugged includes: The software program to be debugged is debugged online by setting breakpoints.

5. An electronic device, comprising: include: At least one processor; And, a memory communicatively connected to the at least one processor; The memory stores instructions executable by the at least one processor, the instructions being configured to perform the method as described in any one of claims 1-4.

6. A computer readable storage medium characterized by, The device stores computer-executable instructions for performing the method as described in any one of claims 1-4.