Program debugging method, intelligent terminal and readable storage medium
By implementing CPU core program debugging at the software level through plug-in programs and JTAG protocol interfaces, the problem of lack of hardware debugging modules is solved, providing a flexible and efficient debugging solution with the same functionality as hardware debugging interfaces, and reducing development costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-22
- Publication Date
- 2026-03-31
AI Technical Summary
In existing technologies, some CPU cores lack hardware debugging modules, making program debugging impossible, especially with insufficient support for hardware breakpoints.
Program debugging is achieved at the software level through plug-in programs. Debugging commands are used to jump to the plug-in program, save register states, obtain breakpoint addresses, and perform debugging operations through the breakpoint maintenance table. Breakpoint setting and restoration are implemented in conjunction with the JTAG protocol interface.
On CPU cores that lack hardware debugging interfaces, a flexible and efficient program debugging mechanism is provided, achieving the same functionality as a hardware debugging interface, making up for hardware dependence, improving debugging efficiency and reducing development costs.
Smart Images

Figure CN119938545B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of chip information technology, and in particular to a program debugging method, a smart terminal, and a readable storage medium. Background Technology
[0002] In the development and testing of electronic products, ensuring the correct operation of chips and systems is crucial. Most modern CPU architectures include a hardware debug module (DAP). The DAP interface is a standard interface for debugging and accessing internal system resources. It supports various debugging functions, including communication between the debugger and the target device, accessing registers and memory, setting breakpoints and trigger conditions, etc.
[0003] However, some CPU cores are not equipped with complete hardware debugging modules, such as modules lacking hardware breakpoint support or integrated DAP modules. Although these CPUs have a TAP (Test Access Port) for JTAG interface communication, they lack the ability to support hardware breakpoints, thus lacking a program debugging mechanism.
[0004] Therefore, there is an urgent need for a program debugging method, a smart terminal, and a readable storage medium to solve the above problems. Summary of the Invention
[0005] The technical problem solved by this invention is to provide a program debugging method, a smart terminal, and a readable storage medium, which can realize program debugging through software when the CPU core does not have a hardware debugging interface.
[0006] The technical problem solved by this invention is achieved by the following technical solution:
[0007] A program debugging method includes: when a debugging instruction is obtained during the execution of the main program, jumping to a plug-in program through the debugging instruction and saving the register state through the plug-in program; obtaining a breakpoint address based on the register state; matching the breakpoint address with a preset address in a breakpoint maintenance table to obtain the original instruction corresponding to the preset address that matches the breakpoint address, and performing corresponding debugging operations, wherein the breakpoint maintenance table includes a breakpoint table and a temporary breakpoint table.
[0008] In a preferred embodiment of the present invention, before the steps of jumping to the plug-in program and saving the register state through the plug-in program when a debugging instruction is obtained during the main program's execution, the method includes: obtaining newly set breakpoint information, generating a maintenance command based on the newly set breakpoint information, and sending it to the maintenance interface, wherein the newly set breakpoint information includes a breakpoint address; replacing the original instruction at the breakpoint address with a specific exception instruction through the maintenance interface, and saving the original instruction and the breakpoint address to the breakpoint table.
[0009] In a preferred embodiment of the present invention, the steps of obtaining newly set breakpoint information, generating maintenance commands based on the newly set breakpoint information, and sending them to the maintenance interface further include: obtaining the newly set breakpoint information, generating debugging commands based on the newly set breakpoint information, and sending them to the command processing program; the command processing program converts the debugging commands into the maintenance commands, and then sends them to the maintenance interface of the target device using the JTAG protocol interface.
[0010] In a preferred embodiment of the present invention, the step of saving the register state through the plug-in program includes: saving the CPU register state and the exception type through the plug-in program, the exception type including maintenance interrupt and specific exception; executing an infinite loop instruction through the plug-in program to enter a waiting state and suspending the main program.
[0011] In a preferred embodiment of the present invention, after the steps of matching the breakpoint address with a preset address in the breakpoint maintenance table to obtain the original instruction corresponding to the preset address that matches the breakpoint address and performing corresponding debugging operations, the method further includes: if the breakpoint address matches a preset address in the temporary breakpoint table, then the original instruction corresponding to the breakpoint address is restored, and the preset address that matches the breakpoint address is deleted from the temporary breakpoint table; if the breakpoint address matches a preset address in the breakpoint table, then the original instruction corresponding to the breakpoint address is restored, and after the original instruction is executed, the original instruction is replaced with the specific exception instruction again.
[0012] In a preferred embodiment of the present invention, after the steps of matching the breakpoint address with a preset address in the breakpoint maintenance table to obtain the original instruction corresponding to the preset address that matches the breakpoint address and performing the corresponding debugging operation, the method further includes: determining / generating the next temporary breakpoint address based on the breakpoint address, and saving the original instruction of the next temporary breakpoint address to the temporary breakpoint table; and replacing the original instruction of the next temporary breakpoint address with the specific exception instruction.
[0013] In a preferred embodiment of the present invention, after the step of replacing the original instruction of the next temporary breakpoint address with the specific exception instruction, the method further includes: replacing the infinite loop instruction in the plug-in program with an empty instruction to continue running the main program; and replacing the empty instruction with the infinite loop instruction again when exiting the plug-in program.
[0014] In a preferred embodiment of the present invention, after the step of matching the breakpoint address with a preset address in the breakpoint maintenance table to obtain the original instruction corresponding to the preset address that matches the breakpoint address and performing corresponding debugging operations, the step further includes: in response to a breakpoint deletion instruction, obtaining the breakpoint to be deleted corresponding to the breakpoint deletion instruction; matching the breakpoint to be deleted with the preset address in the breakpoint table, and deleting the preset address that matches the breakpoint to be deleted and the original instruction corresponding to the preset address in the breakpoint table.
[0015] A smart terminal includes: a memory and a processor, wherein the memory stores a program debugging program, and when the program debugging program is executed by the processor, it implements the steps of the program debugging method as described in any one of the above.
[0016] A readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the program debugging method as described in any one of the preceding descriptions.
[0017] The technical effect achieved by the present invention using the above technical solution is that it enables program debugging for CPU cores that do not have hardware debugging interfaces, making up for the dependence of traditional debugging methods on hardware interfaces, realizing debugging in software, and having the same functions as hardware debugging interfaces.
[0018] 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
[0019] Figure 1 This is a flowchart illustrating a program debugging method according to the present invention.
[0020] Figure 2 This is a schematic diagram of the system structure of a program debugging mechanism according to the present invention.
[0021] Figure 3 This is a schematic diagram of the state transition path of a debugging instruction as shown in this invention.
[0022] Figure 4 This is a schematic diagram illustrating the execution logic of a plug-in program according to the present invention. Detailed Implementation
[0023] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below are merely 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 embodiments of the present invention. Through the description of the specific embodiments, a more in-depth and specific understanding of the technical means and effects adopted by the present invention to achieve its intended purpose can be obtained. Moreover, the accompanying drawings are only provided for reference and illustration and are not intended to limit the present invention.
[0024] This invention aims to solve the problem of how to efficiently debug programs when the CPU core does not have a hardware debugging interface.
[0025] Please see Figure 1 , Figure 1 This is a flowchart illustrating a program debugging method according to the present invention.
[0026] like Figure 1 As shown, a program debugging method provided by one embodiment of the present invention includes the following steps:
[0027] S11: When a debug instruction is obtained during the main program's execution, the program jumps to the plug-in program via the debug instruction and saves the register state through the plug-in program.
[0028] Specifically, debugging instructions include: specific exception instructions. Specific exception instructions are obtained after the main program reaches a breakpoint address; that is, a specific exception instruction is set at the breakpoint address.
[0029] In other implementations, debugging instructions also include maintenance interrupt instructions. Interrupt and exception handling are crucial components of CPU core functionality. They not only ensure the system's timely response to external events and proper handling of internal errors but also maintain system stability and security. A maintenance interrupt is an interrupt event that can be triggered from an external maintenance interface. When a user sends a maintenance interrupt instruction from the maintenance interface, the CPU receives the interrupt signal, pauses the currently executing task, jumps to the interrupt entry point (i.e., the plug-in program), handles the interrupt and exception, and then returns to continue executing the task.
[0030] Specifically, the host computer manages the debugging process, and users can send various debugging commands through the host computer's debugging interface. The main program runs on the target chip being debugged, and the chip's CPU fetches and executes instructions. The main program includes plug-in programs. The program counter (PC) contains the address of the currently executing instruction. Each time an instruction is fetched, the program counter's memory address is incremented. After an instruction is fetched, the program counter sequentially points to the next instruction in the order. In other words, the position of the PC indicates the position of the CPU where it fetches and executes instructions.
[0031] Specifically, the plug-in program is responsible for handling specific exceptions and maintenance interruption events triggered during CPU operation. More complex maintenance functions can be implemented through the plug-in program, such as setting breakpoints, performing single-step debugging, and breakpoint debugging.
[0032] Specifically, the state of registers plays a crucial role in computer systems, not only recording various state information after instruction execution but also directly participating in the decision-making process of program control flow. In this embodiment, the register state includes the breakpoint address of the main program.
[0033] S12: Obtain the breakpoint address based on the register state.
[0034] In programming and debugging, a breakpoint is a signal that instructs the debugger to temporarily suspend program execution at a specific point. When execution is suspended at a breakpoint, the program is in interrupt mode, which helps developers inspect and debug the program.
[0035] Specifically, one or more breakpoints are preset in the program to control its execution. When the program encounters a breakpoint, it pauses and enters debug mode, allowing developers to examine the current program state (such as register values, variables, memory, etc.) and analyze the code execution at the breakpoint.
[0036] S13: Match the breakpoint address with the preset address in the breakpoint maintenance table to obtain the original instruction corresponding to the preset address that matches the breakpoint address, and perform the corresponding debugging operation. The breakpoint maintenance table includes the breakpoint table and the temporary breakpoint table.
[0037] A breakpoint is a permanent breakpoint that pauses program execution every time it reaches the breakpoint, unless manually removed by the user. A temporary breakpoint is a one-time breakpoint that is automatically deleted by the system after being triggered once and will not be triggered again.
[0038] When using a debugger, if you want the program to stop execution at a certain point, you can set a breakpoint at that location, which is the breakpoint address. When the program reaches the breakpoint, it will stop running, allowing you to debug the CPU.
[0039] The above method provides a flexible and efficient program debugging mechanism for CPU cores that do not have a hardware debugging interface, making up for the dependence of traditional debugging methods on hardware interfaces, realizing debugging in software, and having the same functions as hardware debugging interfaces.
[0040] Optionally, before the steps of jumping to the plug-in program and saving the register state through the plug-in program when a debugging instruction is obtained during the main program's execution, the process includes: obtaining newly set breakpoint information, generating a maintenance command based on the newly set breakpoint information, and sending it to the maintenance interface. The newly set breakpoint information includes the breakpoint address. The original instruction at the breakpoint address is replaced with a specific exception instruction through the maintenance interface, and the original instruction and the breakpoint address are saved to the breakpoint table.
[0041] Optionally, the steps of obtaining newly set breakpoint information, generating maintenance commands based on the newly set breakpoint information, and sending them to the maintenance interface further include: obtaining newly set breakpoint information, generating debugging commands based on the newly set breakpoint information, and sending them to the command processing program; the command processing program converts the debugging commands into maintenance commands and then sends them to the maintenance interface of the target device using the JTAG protocol interface.
[0042] Specifically, breakpoint debugging is the most common function in the debugging process. Users can set breakpoints through the host computer and obtain the CPU core status when the program pauses execution at the breakpoint.
[0043] The command handler converts debugging commands sent from the host computer into maintenance commands, which are then sent to the maintenance interface of the target device via the JTAG protocol interface. These maintenance commands enable reading and writing of the target device's I / O registers and memory.
[0044] For example, the user first specifies the location / line number (break xxx) of the breakpoint to be set on the main program via the host computer software. The host computer software internally parses the instruction address (i.e., breakpoint address) in the corresponding code segment based on the ELF file, and then generates a breakpoint setting command (also known as a debugging command / instruction) containing the breakpoint address. This breakpoint setting command is then sent to the command handler. After converting the debugging command into a maintenance command sequence, the command handler uses the JTAG protocol interface to send it to the maintenance interface of the target device (see [reference]). Figure 2 (The user program in the diagram is the main program).
[0045] Specifically, after receiving a maintenance command, the maintenance interface replaces the original instruction at the corresponding breakpoint address in the main program's memory with a specific exception instruction, and saves the original instruction at the breakpoint address to the breakpoint table on the host computer. In subsequent processes, when the main program reaches the breakpoint address, the specific exception instruction is executed by the main program, thus jumping to the plug-in program through a specific exception entry point, while the main program suspends.
[0046] Optionally, the step of saving the register state through the plug-in program includes: saving the CPU register state through the plug-in program and saving the exception type, which includes maintenance interrupt and specific exception; executing an infinite loop instruction through the plug-in program to enter a waiting state and suspend the main program.
[0047] Specifically, the plug-in program first saves the current register state, and then the main program running on the target chip stops at a fixed position (i.e., a breakpoint) and enters a waiting state. At this time, the user can send a command (reg) to retrieve the register state through the host computer. The maintenance interface will return the saved breakpoint context information to the host computer, allowing the user to view the program's execution at the breakpoint and perform corresponding debugging operations.
[0048] Optionally, after matching the breakpoint address with a preset address in the breakpoint maintenance table to obtain the original instruction corresponding to the preset address that matches the breakpoint address and performing the corresponding debugging operation, the process includes: if the breakpoint address matches a preset address in the temporary breakpoint table, restoring the original instruction corresponding to the breakpoint address and deleting the preset address that matches the breakpoint address from the temporary breakpoint table; if the breakpoint address matches a preset address in the breakpoint table, restoring the original instruction corresponding to the breakpoint address and replacing the original instruction with a specific exception instruction again after the original instruction has been executed.
[0049] Specifically, when the main program executes to a breakpoint and triggers a specific exception, it first obtains the current CPU register state through the host computer, including the address that triggered the exception (i.e., the breakpoint address). The host computer then matches the breakpoint address in the saved breakpoint table and the temporary breakpoint table to find the original instruction corresponding to that breakpoint address.
[0050] If it is a temporary breakpoint, the original instruction corresponding to the temporary breakpoint in the temporary breakpoint table is written back to the address of the temporary breakpoint in the main program memory to restore the original instruction, and the record in the temporary breakpoint table is deleted.
[0051] If it's a breakpoint, the specific exception instruction at the breakpoint address is restored to the original instruction. After the CPU fetches and executes the original instruction, it replaces the original instruction at the breakpoint address with the specific exception instruction again. At this point, the main program has already run to the next instruction after the breakpoint, so the breakpoint will not be triggered. The breakpoint will only be triggered again when the main program runs to this breakpoint again.
[0052] It should be noted that since breakpoints are set by the user, the main program cannot delete them during its execution; a breakpoint will only be deleted when the user sends a delete command. Temporary breakpoints, on the other hand, are generated automatically by the main program based on its logic during runtime, and therefore must be actively and promptly deleted by the main program.
[0053] Optionally, after matching the breakpoint address with a preset address in the breakpoint maintenance table to obtain the original instruction corresponding to the preset address that matches the breakpoint address and performing the corresponding debugging operation, the method further includes: determining / generating the next temporary breakpoint address based on the breakpoint address, saving the original instruction of the next temporary breakpoint address to the temporary breakpoint table; and replacing the original instruction of the next temporary breakpoint address with a specific exception instruction.
[0054] Specifically, during single-step debugging, temporary breakpoints need to be set. The host computer determines the address of the next instruction (i.e., the address of the next temporary breakpoint, which is 4 times the address of the original breakpoint) based on the current breakpoint address, and saves the original instruction at the next temporary breakpoint address to the temporary breakpoint table. Then, the host computer replaces the original instruction at the temporary breakpoint address with a specific exception instruction to ensure that when the main program executes to the next temporary breakpoint address from its current breakpoint, an exception is triggered, and the program jumps to the plug-in program for debugging, while the main program suspends.
[0055] Optionally, after replacing the original instruction at the next temporary breakpoint address with a specific exception instruction, the method further includes: replacing the infinite loop instruction in the plug-in program with a null instruction to continue running the main program; and replacing the null instruction with the infinite loop instruction again when exiting the plug-in program.
[0056] After debugging at a breakpoint, it's necessary to resume main program execution. Since the PC is still stuck at a fixed position within the plug-in program, the host computer needs to actively allow the main program to continue execution. This means the host computer replaces the infinite loop instruction in the plug-in program with a null instruction, allowing the CPU to continue fetching and executing instructions. Before finally exiting the plug-in program, the host computer must replace the null instruction back with the infinite loop instruction to ensure that the program can hang when the next breakpoint is triggered and the program jumps back to the previous one.
[0057] After the main program exits the aforementioned breakpoint, it continues to execute program instructions. When the main program executes to the newly set temporary breakpoint address, it triggers the temporary breakpoint again and jumps back into the plug-in program through the specific exception instruction of the temporary breakpoint.
[0058] Using the above method, the process pauses at a newly set temporary breakpoint after each step, thus enabling single-step debugging.
[0059] In one implementation, when a user sends a pause debugging command via a host computer, execution should be immediately halted regardless of the current state of the main program running on the target chip. The host computer can issue a maintenance interrupt to the CPU core via a maintenance command to pause the main program and allow the PC to jump to the maintenance interrupt entry point.
[0060] The host computer sends a maintenance command, triggering a maintenance interrupt. The system jumps to the plug-in program through the maintenance interrupt entry point. The plug-in program saves the current register state, and then the PC stays at a fixed position, entering a waiting state. At this time, the user sends a command to retrieve the register state through the host computer, and the maintenance interface returns the saved state information to the host computer.
[0061] It should be noted that when a maintenance interruption or a specific exception (breakpoint, specific exception instruction) occurs, the plugin program will jump to the maintenance interrupt entry point or the specific exception entry point respectively to execute the processing logic. For maintenance interruptions and specific exceptions, the processing logic of the plugin program is the same, except for the entry point.
[0062] Specifically, the processing logic of the plug-in program (see...) Figure 4 The process is as follows: First, the program saves the CPU register state (current context) to a specific area in memory, including the exception type. Then, it executes an infinite loop instruction, entering a wait state where the program counter (PC) remains. When the host computer replaces this loop instruction with a null instruction, the PC continues normal execution. Before exiting the plug-in program, the loop instruction that was replaced with a null instruction is restored to its original state to ensure the correctness of subsequent debugging procedures. When another exception occurs and the PC jumps back into the plug-in program, it can loop and hang again.
[0063] After completing breakpoint debugging and single-step debugging, it is necessary to restore the CPU to normal operation. Replace the infinite loop jump instructions in the plug-in program with null instructions so that the PC can execute the main program normally. Before exiting the plug-in program, replace the null instructions back with infinite loop jump instructions to ensure the correctness of subsequent debugging procedures.
[0064] Please see Figure 3 , Figure 3This diagram illustrates a state transition path for debugging instructions according to the present invention. The `Step` command is used to single-step through the program during debugging. The `Go` command continues program execution until a certain condition is met or the program terminates; unlike the `Step` command, the `Go` command executes the program at full speed and does not single-step through each instruction. The `Go` command is commonly used to continue program execution, especially during debugging, skipping the single-step execution phase and directly running to the next breakpoint or program termination. The `Halt` command stops CPU execution; during debugging, the `halt` command can pause program execution, allowing developers to check the current state or perform debugging.
[0065] The program debugging method in this embodiment utilizes the JTAG interface protocol and a debugging system mechanism composed of a host computer, command processor, and plug-in programs to achieve debugging functions such as accessing registers and memory, setting and clearing breakpoints, and single-step debugging. By maintaining the interface, this invention implements the main debugging functions of the DAP interface, such as breakpoint debugging, single-step debugging, and register access, without increasing additional hardware complexity, thereby improving system debugging efficiency and reducing development costs.
[0066] The present invention also provides a smart terminal, comprising: a memory and a processor, wherein the memory stores a program debugging program, and when the program debugging program is executed by the processor, it implements the steps of the program debugging method as described in any one of the above.
[0067] The present invention also provides a readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the program debugging method as described in any one of the above descriptions.
[0068] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the accompanying drawings may include multiple sub-steps or multiple stages, which are not necessarily completed at the same time, but may be executed at different times, and their execution order is not necessarily sequential, but may be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0069] Through the above description of the embodiments, those skilled in the art can clearly understand that the embodiments of the present invention can be implemented in hardware or by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions of the embodiments of the present invention can be embodied in the form of a software product. This software product can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, mobile hard drive, etc.) and includes several instructions to cause a computer device (such as a personal computer, server, or network device, etc.) to execute the methods described in the various implementation scenarios of the embodiments of the present invention.
[0070] The preferred embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the specific details of the above embodiments. The above embodiments and accompanying drawings are exemplary. The modules or processes in the accompanying drawings are not necessarily necessary for implementing the embodiments of the present invention and should not be construed as limiting the present invention. Within the scope of the technical concept of the present invention, various simple modifications and combinations can be made to the technical solutions of the present invention, and these simple modifications and combinations all fall within the protection scope of the present invention.
Claims
1. A program debugging method characterized by comprising: The method comprises the following steps: when a debugging instruction is acquired during the running of the main program, jumping to the plug-in program through the debugging instruction to handle specific exception and maintenance interrupt event, the debugging instruction comprising specific exception instruction and maintenance interrupt instruction; saving the register state and exception type of the CPU to the target area in the memory through the plug-in program, the exception type comprising maintenance interrupt and specific exception; executing the dead loop instruction through the plug-in program to enter the waiting state and suspend the main program; acquiring the breakpoint address according to the register state; matching the breakpoint address with the preset address in the breakpoint maintenance table to acquire the original instruction corresponding to the preset address matched with the breakpoint address, and executing breakpoint debugging or single-step debugging according to the matching result, the breakpoint maintenance table comprising breakpoint table and temporary breakpoint table.
2. The program debugging method according to Claim 1, wherein Before the step of jumping to the plug-in program when the debugging instruction is acquired during the running of the main program, and saving the register state of the CPU to the target area in the memory through the plug-in program, the method comprises the following steps: acquiring new breakpoint information, and generating a maintenance command based on the new breakpoint information and sending it to the maintenance interface, the new breakpoint information comprising breakpoint address; replacing the original instruction of the breakpoint address with specific exception instruction through the maintenance interface, and saving the original instruction and the breakpoint address to the breakpoint table.
3. The program debugging method according to Claim 2, wherein The step of acquiring new breakpoint information and generating a maintenance command based on the new breakpoint information and sending it to the maintenance interface further comprises: acquiring the new breakpoint information, and generating a debugging command according to the new breakpoint information and sending it to the command processing program; after the debugging command is converted into the maintenance command by the command processing program, the maintenance command is sent to the maintenance interface of the target device using the JTAG protocol interface.
4. The program debugging method according to Claim 2, wherein After the step of matching the breakpoint address with the preset address in the breakpoint maintenance table to acquire the original instruction corresponding to the preset address matched with the breakpoint address, and executing breakpoint debugging or single-step debugging according to the matching result, the method further comprises the following steps: if the breakpoint address matches the preset address in the temporary breakpoint table, the original instruction corresponding to the breakpoint address is restored, and the preset address matched with the breakpoint address is deleted in the temporary breakpoint table; if the breakpoint address matches the preset address in the breakpoint table, the original instruction corresponding to the breakpoint address is restored, and after the execution of the original instruction is completed, the original instruction is replaced with the specific exception instruction again.
5. The program debugging method according to Claim 4, wherein After the step of matching the breakpoint address with the preset address in the breakpoint maintenance table to acquire the original instruction corresponding to the preset address matched with the breakpoint address, and executing breakpoint debugging or single-step debugging according to the matching result, the method further comprises the following steps: determining / generating the next temporary breakpoint address according to the breakpoint address, and saving the original instruction of the next temporary breakpoint address to the temporary breakpoint table; replacing the original instruction of the next temporary breakpoint address with the specific exception instruction.
6. The program debugging method according to Claim 5, wherein After the step of replacing the original instruction of the next temporary breakpoint address with the specific exception instruction, the method further comprises the following steps: The loop instruction in the plug-in program is replaced with a null instruction to continue running the main program; and the null instruction is replaced with the loop instruction again when the plug-in program exits.
7. The program debugging method according to Claim 4, wherein The step of matching the breakpoint address with preset addresses in a breakpoint maintenance table, obtaining original instructions corresponding to the preset addresses matched with the breakpoint address, and performing breakpoint debugging or single-step debugging according to the matching result, further comprises: In response to a breakpoint deletion instruction, obtaining a to-be-deleted breakpoint corresponding to the breakpoint deletion instruction; Matching the to-be-deleted breakpoint with the preset addresses in the breakpoint table, and deleting the preset addresses matched with the to-be-deleted breakpoint and original instructions corresponding to the preset addresses in the breakpoint table.
8. A smart terminal, characterized by The intelligent terminal comprises a memory and a processor, wherein the memory stores a program debugging program, and the program debugging program, when executed by the processor, implements the steps of the program debugging method according to any one of claims 1 to 7.
9. A readable storage medium, characterized by, The readable storage medium stores a computer program, and the computer program, when executed by the processor, implements the steps of the program debugging method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Program debugging method and microcontroller
CN115269403A
Method and device for performing single-step operation on virtual machine by using Hypervisor, medium and product
CN118939565A