A computer debugging method, device, equipment and system
By installing a debugging agent in the Option ROM of the motherboard firmware debugging device, the problem of the existing technology being unable to perform real host debugging of motherboard UEFI BIOS is solved, real debugging of motherboard and external storage media eFi files is realized, and breakpoints are provided. Open prompts and debugging support for subsequent code.
Patent Information
- Application Number
- CN202111056067.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-09
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2041-09-09
AI Technical Summary
The existing technology cannot realize real host debugging of the motherboard's UEFI BIOS, resulting in the lack of real host debugging tools when writing efi files and Option ROM code in the external access device.
Install the debugging agent in the debugging device Option ROM of the motherboard firmware. The debugging agent is suspended based on the preset breakpoint position, and the debugging agent sends debugging commands to invoke the debugging function of the target host for debugging.
Real host debugging of the motherboard UEFI BIOS is implemented, solving the problem of not being able to debug the Option ROM and the eFi files in the external storage media, providing a sound prompt when the breakpoint is disconnected, and supporting debugging of all subsequent codes.
Smart Images

Figure CN113722168B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer debugging, and in particular to a computer debugging method, device, equipment and system. Background Art
[0002] In existing desktop computers, in the process of designing and modifying the UEFI BIOS of the motherboard, a special debugging tool is required to debug it, and the motherboard has a special connection structure and debugging tool for connection. When the research and development is completed and mass production is carried out, most of the motherboards produced will remove the connection structure used in the debugging stage, so that they can no longer be connected to the debugging tool, and thus the real machine host debugging of the motherboard UEFI BIOS can no longer be performed.
[0003] Alternatively, in some other types of desktop computers, the corresponding processor of the motherboard is not provided with an emulation adapter, and the motherboard lacks a connection structure connected to the hardware emulator, so it is impossible to perform real machine host debugging on the UEFI BIOS of the motherboard.
[0004] The inability to perform real-machine host debugging on the motherboard's UEFI BIOS will further lead to the lack of a real-machine host debugging tool when subsequently writing efi files in external access devices and writing Option ROM (referred to as debugged Option ROM in this article) codes in newly developed devices. Summary of the invention
[0005] In view of this, the embodiments of the present invention provide a computer debugging method, apparatus, device and system to solve the problem that the prior art cannot perform real machine host debugging.
[0006] According to a first aspect, an embodiment of the present invention provides a computer debugging method, comprising: installing a debugging agent in an Option ROM of a debugging device executed by a mainboard firmware; pausing the running of a debugged object of a target host based on a preset breakpoint position, and entering the running of the debugging agent; sending a debugging command to the debugging agent to call the debugging function of the target host to debug the debugged object.
[0007] Optionally, pausing the debugged object of the target host based on a preset breakpoint position includes: when the preset breakpoint position is executed, triggering the breakpoint to suspend the debugged object of the target host.
[0008] Optionally, before installing the debugging agent in the debugging device Option ROM executed by the mainboard of the target host, the method further comprises: obtaining a display function switching instruction; when the display function switching instruction is to start the display function, driving the display of information indicating that the debugging device Option ROM is successfully running.
[0009] Furthermore, the method further comprises: when the display function switching instruction is to turn off the display function, executing the step of installing the debugging agent in the debugging device Option ROM executed by the mainboard of the target host.
[0010] According to a second aspect, an embodiment of the present invention provides a computer debugging device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer debugging method as described in any embodiment of the first aspect by executing the computer instructions.
[0011] According to a third aspect, an embodiment of the present invention provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the computer debugging method as described in any implementation of the first aspect.
[0012] According to a fourth aspect, an embodiment of the present invention provides a computer debugging device, comprising: a storage circuit for storing a debugging device Option ROM, wherein the debugging device Option ROM is used to install a debugging agent; a microcontroller module for receiving a ring command sent by the debugging agent, and sending a first debugging command to the debugging agent to obtain common data corresponding to the first debugging command; and receiving a second debugging command sent by a debugging host, forwarding the common data to the debugging host based on the second debugging command, or obtaining specific data corresponding to the second debugging command; and an FPGA module for driving a buzzer for prompting when the ring command is obtained.
[0013] Optionally, the computer debugging device also includes: a gold finger, which is used to connect to the interface of the target host for data communication; a bus processing circuit, which is respectively connected to the read-write circuit, the storage circuit, and the gold finger, and is used to transmit data between the microcontroller module and the storage circuit, the gold finger and the read-write circuit.
[0014] Optionally, the computer debugging device also includes: a display / debugging function switching switch, used to switch between a display function and a debugging function, wherein the display function is used to indicate the switch state of the display function of the computer debugging device; the debugging function is used to indicate the switch state of the debugging function of the computer debugging device; a switch quantity acquisition circuit, used to acquire the switch state of the display / debugging function switching switch, and can also acquire the switch state of the system breakpoint enable / disable switching switch, and transmit it to the FPGA module.
[0015] Optionally, the computer debugging device also includes: a system breakpoint enable / disable switch, used to switch the system breakpoint enable and system breakpoint disable functions; the switch quantity acquisition circuit is also used to collect the switch state of the system breakpoint enable / disable switch and transmit it to the FPGA module.
[0016] Optionally, the computer debugging device further includes: a main power switch for providing power to the computer debugging device; and a lighting switch connected to the lighting device for controlling the switch of the lighting device when the main power switch is turned on.
[0017] Optionally, the computer debugging device further comprises: a communication interface connected to the microcontroller module, and the microcontroller obtains instructions transmitted by the debugging host through the communication interface.
[0018] Optionally, the microcontroller module is specifically used to: receive a CmdBeep command sent by the debugging agent, and then send a CmdX command to the debugging agent to obtain common data corresponding to the CmdX command; after the data is successfully obtained, receive a CmdY command sent by the debugging host, and then determine whether the common data satisfies the CmdY command; if so, send the common data to the debugging host; if not, forward the CmdY command to the debugging agent; if the debugging agent sends specific data corresponding to the CmdY command after executing the CmdY command, receive the specific data, and then send the specific data to the debugging host.
[0019] Furthermore, the microcontroller module is also used to execute the following process: determine whether the command sent by the debugging host is a command for the debugging host to obtain the microcontroller status; when the command sent by the debugging host is not a command for the debugging host to obtain the processor status, if the current status of the microcontroller is busy, the busy status is sent to the debugging host.
[0020] Optionally, when a status acquisition instruction is received from the debugging host, the current status is sent to the debugging host.
[0021] According to a fifth aspect, an embodiment of the present invention provides a computer debugging system, comprising: a target host, a computer debugging device and a debugging host connected in sequence, wherein the computer debugging device comprises: a storage circuit for storing a debugging device Option ROM, and the debugging device Option ROM is used to install a debugging agent; a microcontroller module for receiving a ring command sent by the debugging agent, and sending a first debugging command to the debugging agent to obtain common data corresponding to the first debugging command; and receiving a second debugging command sent by the debugging host, forwarding the common data to the debugging host based on the second debugging command, or obtaining specific data corresponding to the second debugging command; an FPGA module for driving a buzzer for prompting when the ring command is obtained; and the debugging host is used to send a debugging command to the debugging agent to call the debugging function of the target host to debug the debugged object.
[0022] Optionally, the microcontroller module is specifically used to: receive a CmdBeep command sent by the debugging agent, and then send a CmdX command to the debugging agent to obtain common data corresponding to the CmdX command; after the data is successfully obtained, receive a CmdY command sent by the debugging host, and then determine whether the common data satisfies the CmdY command; if so, send the common data to the debugging host; if not, forward the CmdY command to the debugging agent; if the debugging agent sends specific data corresponding to the CmdY command after executing the CmdY command, receive the specific data, and then send the specific data to the debugging host.
[0023] Optionally, the microcontroller module is also used to perform the following process: determine whether the command sent by the debugging host is a command for the debugging host to obtain the microcontroller status; when the command sent by the debugging host is not a command for the debugging host to obtain the processor status, if the current status of the microcontroller is busy, send the busy status to the debugging host.
[0024] Furthermore, when the state of the microcontroller is not idle, after the debugging host delays for a preset period of time, the debugging host returns to execute the step of receiving the state data returned by the microcontroller module based on the state acquisition command.
[0025] The beneficial effect of the embodiment of the present invention is that a sound prompt can be realized when a breakpoint is disconnected. At the same time, all codes running subsequently can be debugged starting from the system breakpoint set by the Option ROM in the device of the present invention (referred to herein as the debugging device Option ROM). All codes running subsequently include but are not limited to: all debugged objects mentioned in the present invention, the operating system code running subsequently, and the code of all software running on the operating system. Through the present invention, the problem that the debugged Option ROM cannot be debugged by a real machine host in the prior art is effectively solved, and the problem that the efi file in various external storage media such as hard disks and USB flash drives cannot be debugged by a real machine host in the prior art is also solved.
[0026] This application plan mainly includes:
[0027] Solution 1. A computer debugging method, comprising:
[0028] Installing a debugging agent in the debugging device OptionROM executed by the motherboard firmware;
[0029] Based on a preset breakpoint position, the debugged object of the target host is suspended from running, and the debugger enters the running of the debugging agent;
[0030] A debugging command is sent to the debugging agent to call the debugging function of the target host to debug the debugged object.
[0031] Solution 2. According to the computer debugging method of Solution 1, pausing the running of the debugged object of the target host based on a preset breakpoint position comprises:
[0032] When the preset breakpoint position is reached, the breakpoint is triggered, so that the debugged object of the target host is suspended.
[0033] Solution 3. According to the computer debugging method of Solution 1, before installing the debugging agent in the debugging device OptionROM executed by the mainboard firmware of the target host, the method further includes:
[0034] Get the display function switching instruction;
[0035] When the display function switching instruction is to start the display function, the driver displays the information that the debugging device OptionROM is successfully running.
[0036] Solution 4. The computer debugging method according to Solution 3 further includes: when the display function switching instruction is to turn off the display function, executing the step of installing a debugging agent in the debugging device OptionROM executed by the motherboard of the target host.
[0037] Solution 5. A computer debugging device, comprising:
[0038] A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer debugging method as described in any one of Schemes 1-4 by executing the computer instructions.
[0039] Solution 6. A computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the computer debugging method as described in any one of Solutions 1-4.
[0040] Solution 7. A computer debugging device, comprising:
[0041] A storage circuit, used for storing a debugging device OptionROM, wherein the debugging device OptionROM is used for installing a debugging agent;
[0042] a microcontroller module, configured to receive a ring command sent by the debugging agent, and send a first debugging command to the debugging agent to obtain common data corresponding to the first debugging command; and receive a second debugging command sent by a debugging host, and forward the common data to the debugging host based on the second debugging command, or obtain specific data corresponding to the second debugging command;
[0043] The FPGA module is used to drive the buzzer to give a prompt when the ringing command is obtained.
[0044] Solution 8. The computer debugging device according to Solution 7 further comprises:
[0045] A gold finger is used to connect to the interface of the target host for data communication;
[0046] The bus processing circuit is connected to the read-write circuit, the storage circuit and the gold finger respectively, and is used for transmitting data between the microcontroller module and the storage circuit, the gold finger and the read-write circuit.
[0047] Solution 9. The computer debugging device according to Solution 7 further comprises:
[0048] A display / debugging function switching switch, used to switch between a display function and a debugging function, wherein the display function is used to indicate the switch state of the display function of the computer debugging device; and the debugging function is used to indicate the switch state of the debugging function of the computer debugging device;
[0049] The switch quantity acquisition circuit is used to acquire the switch state of the display / debugging function switching switch and transmit it to the FPGA module.
[0050] Solution 10. The computer debugging device according to Solution 7 further comprises:
[0051] The system breakpoint enable / disable switch is used to switch the system breakpoint start and the system breakpoint disable functions; the switch quantity acquisition circuit is also used to collect the switch state of the system breakpoint enable / disable switch and transmit it to the FPGA module.
[0052] Solution 11. The computer debugging device according to Solution 7 further comprises:
[0053] The buzzer power switch is connected to the buzzer and is used to power on or off the buzzer separately.
[0054] Solution 12. The computer debugging device according to Solution 7 further comprises:
[0055] A main power switch, used to provide power to the computer debugging device;
[0056] The lighting switch is connected to the lighting device and is used to control the switch of the lighting device under the premise that the main power switch is turned on.
[0057] Solution 13. The computer debugging device according to Solution 7 further comprises:
[0058] The communication interface is connected to the microcontroller module, and the microcontroller performs bidirectional transmission of commands and data with the debugging host through the communication interface.
[0059] Solution 14. According to the computer debugging device described in any one of Solutions 7 to 13, the microcontroller module is specifically used for:
[0060] Receive the CmdBeep command sent by the debugging agent, and then send the CmdX command to the debugging agent to obtain the common data corresponding to the CmdX command; after the data is successfully obtained, receive the CmdY command sent by the debugging host, and then determine whether the common data satisfies the CmdY command; if so, send the common data to the debugging host; if not, forward the CmdY command to the debugging agent; if the debugging agent sends specific data corresponding to the CmdY command after executing the CmdY command, receive the specific data, and then send the specific data to the debugging host.
[0061] Solution 15. According to the computer debugging device of Solution 14, the microcontroller module is also used to perform the following process:
[0062] Determine whether the command sent by the debugging host is a command for the debugging host to obtain the microcontroller status;
[0063] When the command sent by the debugging host is not a command for the debugging host to obtain the processor status, if the current status of the microcontroller is busy, the busy status is sent to the debugging host.
[0064] Solution 16. According to Solution 15, the computer debugging device sends the current status to the debugging host when receiving the obtain status instruction from the debugging host.
[0065] Solution 17. A computer debugging system, comprising: a target host, a computer debugging device and a debugging host connected in sequence, wherein:
[0066] The computer debugging device comprises:
[0067] A storage circuit, used for storing a debugging device OptionROM, wherein the debugging device OptionROM is used for installing a debugging agent;
[0068] a microcontroller module, configured to receive a ring command sent by the debugging agent, and send a first debugging command to the debugging agent to obtain common data corresponding to the first debugging command; and receive a second debugging command sent by a debugging host, and forward the common data to the debugging host based on the second debugging command, or obtain specific data corresponding to the second debugging command;
[0069] The FPGA module is used to drive the buzzer to give a prompt when the ringing command is obtained;
[0070] The debugging host is used to send a debugging command to the debugging agent to call the debugging function of the target host to debug the debugged object.
[0071] Solution 18. According to the computer debugging system of Solution 17, the microcontroller module is specifically used for:
[0072] Receive the CmdBeep command sent by the debugging agent, and then send the CmdX command to the debugging agent to obtain the common data corresponding to the CmdX command; after the data is successfully obtained, receive the CmdY command sent by the debugging host, and then determine whether the common data satisfies the CmdY command; if so, send the common data to the debugging host; if not, forward the CmdY command to the debugging agent; if the debugging agent sends specific data corresponding to the CmdY command after executing the CmdY command, receive the specific data, and then send the specific data to the debugging host.
[0073] Solution 19. According to the computer debugging system of Solution 18, the microcontroller module is also used to perform the following process:
[0074] Determine whether the received Cyyy command is a get status instruction sent by the debugging host;
[0075] When the received Cyyy command is not the acquisition status instruction of the debugging host, if the current status is busy, the busy status is sent to the debugging host.
[0076] Solution 20. According to Solution 19, the computer debugging system sends the current status to the debugging host when receiving the obtain status instruction from the debugging host.
[0077] Solution 21. The computer debugging system according to Solution 18, wherein the debugging host is used to perform the following process:
[0078] Sending a status acquisition command to the microcontroller module;
[0079] Receiving status data returned by the microcontroller module based on the status acquisition command;
[0080] determining a state of the microcontroller based on the state data;
[0081] When the state of the microcontroller is idle, the CmdY command is sent to the microcontroller.
[0082] Solution 22. According to the computer debugging system described in Solution 21, when the state of the microcontroller is not idle, the debugging host delays for a preset time period, and then the debugging host returns to execute the step of receiving the state data returned by the microcontroller module based on the state acquisition command. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] The features and advantages of the present invention will be more clearly understood by referring to the accompanying drawings, which are schematic and should not be construed as limiting the present invention in any way. In the accompanying drawings:
[0084] Figure 1A A schematic diagram showing a flow chart of a computer debugging method according to an embodiment of the present invention;
[0085] Figure 1B-Figure 1E A flowchart showing different implementations of the computer debugging method according to an embodiment of the present invention is shown;
[0086] Figure 2 A schematic diagram showing the structure of a computer debugging device according to an embodiment of the present invention is shown;
[0087] Figure 3A A schematic diagram showing the structure of a computer debugging device according to another embodiment of the present invention is shown;
[0088] Figure 3BA schematic diagram showing the structure of a computer debugging device according to another embodiment of the present invention is shown;
[0089] Figure 4 A schematic diagram showing a display flow of Option ROM of a debugging device of a computer debugging device according to an embodiment of the present invention is shown;
[0090] Figure 5 A schematic diagram of a debugging process of Option ROM of a debugging device of a computer debugging device according to an embodiment of the present invention is shown;
[0091] Figure 6 A schematic diagram showing a debugging process of installing Option ROM of a computer debugging device in an embodiment of the present invention into a debugging agent in a memory;
[0092] Figure 7 A schematic flow chart showing a debugging process implemented by a main program of a microcontroller module of a computer debugging device according to an embodiment of the present invention;
[0093] Figure 8 A schematic flow chart showing a process of receiving an interrupt program via a serial port in a microcontroller module of a computer debugging device according to an embodiment of the present invention;
[0094] Fig. 9 A schematic flow chart showing a debugging process of a computer debugging device according to another embodiment of the present invention;
[0095] Fig.10 A schematic diagram showing the structure of a computer debugging system according to an embodiment of the present invention is shown;
[0096] Fig.11 A schematic flow chart showing the execution process of the debugging host communication core program according to an embodiment of the present invention;
[0097] Fig.12 A schematic structural diagram of a computer debugging device according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0098] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0099] In addition, for ease of understanding, the special terms involved in this application document are explained below.
[0100] (1) Explanation of Option ROM. The Option ROM mentioned in this application document includes two types: the first type is the Option ROM of the current device, which can also be called: debugging device Option ROM. The second type is the debugged Option ROM, which is one of the debugged objects. Specifically, in the target host, after the mainboard firmware executes the debugging device Option ROM, all subsequent Option ROMs are executed. Therefore, the debugging device Option ROM can debug the debugged Option ROM. The installation of the debugging agent mentioned in this application material refers to the installation in the debugging device Option ROM. As for the debugged Option ROM, the debugging agent cannot be installed. If the debugged Option ROM also needs to install the debugging agent, it must not affect the debugging agent installed by the debugging device Option ROM. Otherwise, the debugging device Option ROM successfully installs the debugging agent, but the agent is destroyed by the subsequent program and cannot be debugged.
[0101] (2) Explain the debugged object. In a motherboard based on UEFI BIOS, the debugged object refers to: all programs running in the period from the system breakpoint set by the Option ROM in the device of the present invention (i.e., the debugging device Option ROM) to the time before the operating system runs are called the debugged object. At this time, the debugged object has three forms: ①, efi files on external media such as USB flash drives, hard disks, and SSD hard disks [can be referred to as debugged efi files]; ②, all subsequent Option ROMs that run after the debugging device Option ROM runs [can be referred to as debugged Option ROM]; ③, the entire code from the system breakpoint set by the Option ROM in the device of the present invention (i.e., the debugging device Option ROM) to the time when the first efi file in the hard disk efi partition is loaded. This entire code belongs to the code in the motherboard firmware [can be referred to as debugged motherboard firmware]. In a motherboard based on Legacy BIOS, the debugged object refers to: ① all Option ROMs that are subsequently run after the debugger Option ROM is run [can be referred to as debugged Option ROM]; ② MBR boot sector code [can be referred to as debugged MBR sector].
[0102] (3) Explain the real machine host debugging. The details are as follows:
[0103] A. A real machine refers to a real computer. Specifically, it is a physical computer assembled from real physical parts. It is an actual object. Its antonym is a virtual machine. A virtual machine is a computer simulated by software.
[0104] B. The meaning of the word debugging in this article is the same as the word debugging in computer science.
[0105] C. Host. This concept is very important in this article. Host has a special meaning in this article. Host describes the relationship between a program and a computer. If a program can be loaded and run in a computer, and the computer has the software resources and hardware resources required for the program to run, and the computer is the computer that the designer of the program wants to run. If these three conditions are met at the same time, the computer can be called the host computer of the program. Debugging the program in the computer can be called host debugging of the program.
[0106] (4) Explain commonly used data: For example,
[0107] Assume that after the preset breakpoint P1 is disconnected, the debugging host needs to obtain the values of registers RIP and RAX;
[0108] Assume that after the preset breakpoint P2 is disconnected, the debugging host needs to obtain the values of registers RIP and RAX;
[0109] Assume that after the preset breakpoint P3 is disconnected, the debugging host needs to obtain the value of the register RIP;
[0110] Then RIP and RAX are commonly used data.
[0111] As can be seen from the above, after all breakpoints are disconnected one by one, the data that the debugging host needs to obtain (for example: the above RIP), and after most breakpoints are disconnected, the data that the debugging host needs to obtain (for example: the above RAX), these two types of data are collectively referred to as: common data in this article.
[0112] Commonly used data is used to improve the execution efficiency of the program. For example:
[0113] Assuming that the preset breakpoint P1 is disconnected, the debugging host sends a command to the microcontroller module, the microcontroller module then forwards the command to the debugging agent, the debugging agent returns data to the microcontroller module, and the microcontroller module then sends the data to the debugging host.
[0114] At this time, that is, after the preset breakpoint P1 is disconnected, assume that the debugging host wants to send 100 different types of commands to obtain 100 different types of data. In this process, the microcontroller module will forward 100 commands to the debugging agent.
[0115] If the mechanism of commonly used data is adopted, or assuming that the debugging host wants to send 100 different types of commands, at this time, the microcontroller module does not need to forward 100 times, because the microcontroller module extracts the frequently used commands from these 100 commands in advance, and then merges them into one or a few commands, which are collectively called CmdX commands. In this way, the microcontroller module only needs to send CmdX commands, and a large amount of frequently used data will be received. The beneficial effect is that the microcontroller module does not need to send 100 times to the debugging agent, but only needs to send once or a few times, thereby improving the execution efficiency of the program.
[0116] In this article, the microcontroller module receives common data by sending CmdX commands.
[0117] (5) Explanation of specific data: The debugging host sends a CmdY command to the microcontroller module. After receiving the CmdY command, the microcontroller module finds that the common data cannot satisfy the CmdY command. Therefore, the microcontroller module forwards the CmdY command to the debugging agent. The debugging agent executes the CmdY command, and the debugging agent needs to return data to the debugging host. Such data is called specific data. In short, specific data is data returned by the debugging agent when the common data cannot satisfy it. Specific data is defined to distinguish it from common data.
[0118] (6) Explanation of the first debugging command: The first debugging command is: CmdX command.
[0119] (7) Explanation of the second debugging command: The second debugging command is: CmdY command.
[0120] (8) To make it easier to understand the content of this article, the following are the commands used in this article:
[0121] 01. The command distribution table is as follows:
[0122]
[0123]
[0124] Note: In the above table, the left column indicates where the command appears, and the right column indicates the specific command that appears.
[0125] 02. The commands are explained as follows:
[0126] CmdBeep Command:
[0127] ●It only indicates a fixed command, which is also called the ringing command;
[0128] ● As soon as the debug agent is entered, the debug agent immediately sends the CmdBeep command to indicate that the breakpoint has been disconnected;
[0129] ●When the MCU main program is powered on, it will receive CmdBeep commands cyclically, which means:
[0130] Once the MCU is powered on, in addition to completing the necessary initialization work, it will keep looping and waiting for the preset breakpoint to disconnect;
[0131] ●FPGA will receive this CmdBeep command. After receiving it, it will apply a driving signal to the buzzer for a very short period of time (for example: 500ms). If the buzzer power switch is closed at this time, the buzzer will emit a very short sound, realizing the sound prompt function of the breakpoint disconnection.
[0132] Cxxx commands:
[0133] ●It is not a command, but a command set consisting of many commands;
[0134] ● Specifically: all commands received by the debugging agent are collectively referred to as: Cxxx commands;
[0135] ●The debugging agent needs to determine whether the current Cxxx command is a CmdH command. If it is, it needs to perform a recovery action.
[0136] CmdH command:
[0137] ●It only expresses a fixed command;
[0138] ●This fixed command is also called the restore command. That is, restore the code that is overwritten by 0xCC at the current breakpoint, and do some necessary on-site recovery. For example: the saved RIP is decremented by 1;
[0139] ●The CmdH command is sent in the debugging host, and one byte of data is sent at the same time. This byte of data is the 1-byte code previously overwritten by 0xCC.
[0140] CmdExitAgent command:
[0141] ●It only expresses a fixed command;
[0142] ●As long as the debug agent is about to exit, the debug agent will immediately send the CmdExitAgent command before exiting, indicating that the debug agent is about to exit;
[0143] ●The MCU main program will receive the CmdExitAgent command in a loop. Once the MCU main program receives this command, it will return to the initial state.
[0144] CmdX Commands:
[0145] ●It is not a command, but a command set consisting of many commands;
[0146] ●CmdX commands are sent by the MCU main program;
[0147] ● Specifically, after the MCU is powered on, it will receive CmdBeep commands cyclically. In other words, after the MCU is powered on, it will wait for the breakpoint to be disconnected. After the breakpoint is disconnected (i.e., receiving the CmdBeep command indicates that the breakpoint has been disconnected), it will send various commands to the debugging agent to receive common data. Here, the various commands sent by the MCU to obtain common data are collectively referred to as CmdX commands.
[0148] CmdT command:
[0149] ●It only expresses a fixed command;
[0150] ●In the entire communication process, the debugging agent has the highest priority. In other words: if the breakpoint is not disconnected, the debugging agent, MCU main program, MCU interrupt program, and debugging host will not have much effect. Once disconnected, the debugging agent will first take the initiative of the program. Therefore, the debugging agent has the highest priority. The second priority is the MCU. Because the MCU must first send CmdX to obtain common data, only when this common data is successfully obtained, the control is handed over to the debugging host. Therefore, the debugging host belongs to the third priority;
[0151] ●Because the debugging host has a lower priority than the MCU main program, the debugging host sends the CmdT command to the MCU interrupt program. The MCU interrupt program will immediately return the status of the MCU main program (busy, idle) to the debugging host;
[0152] ● Simply put: before sending a formal command, the debugging host must wait until the MCU main program is in an idle state to be effective. If the MCU main program is very busy, then even if the debugging host sends a normal command, it will be useless;
[0153] ●Summary: The debugging host sends the CmdT command to obtain the status of the MCU main program.
[0154] In the end, is it: busy or: free?
[0155] CmdY Command:
[0156] ●It is not a command, but a command set consisting of many commands;
[0157] ●CmdY command is sent by the debugging host;
[0158] ● Specifically, in addition to sending CmdT commands, the commands sent by the debugging host are collectively called CmdY commands. That is, CmdY commands do not include CmdT commands;
[0159] ●CmdY commands include: CmdH commands, set breakpoints, delete breakpoints, step in, step over, run, etc.;
[0160] ●The MCU interrupt program will determine whether the existing data satisfies the CmdY command. If not, the MCU main program will forward the CmdY command to the debug agent.
[0161] Cyyy command:
[0162] ●It is not a command, but a command set consisting of many commands;
[0163] ● Specifically: all commands received by the MCU interrupt program are collectively referred to as: Cyyy commands;
[0164] ●The MCU interrupt program needs to determine whether the current Cyyy command is a CmdT command. If so, it needs to return the status.
[0165] The embodiment of the present invention provides a computer debugging method, such as Figure 1A As shown, the computer debugging method mainly includes:
[0166] Step S1: installing a debugging agent in the debugging device Option ROM executed by the mainboard firmware;
[0167] Step S2: based on the preset breakpoint position, suspend the running of the debugged object of the target host, and enter the debugging agent to run.
[0168] The subsequent code of the preset breakpoint happens to be only the last processor instruction of the debugging device Option ROM. When the processor encounters this breakpoint during normal program execution, the breakpoint function will not be triggered immediately. Instead, the breakpoint function will be triggered after the next processor instruction of the breakpoint is executed, so that the debugged object of the target host is suspended. The debugged object at this time refers to: after the last processor instruction of the debugging device Option ROM is executed, it will return to the mainboard firmware. The code starting from the address returned to the mainboard firmware is the debugged object at this time.
[0169] Optionally, in some implementations of this embodiment, the preset breakpoint position may be set in the following ways:
[0170] 1. The system breakpoint can be set to an enable / disable switch, which is used to turn on or off the breakpoint function. The position of the system breakpoint can be set outside the Option ROM (i.e., the debugging device Option ROM) code range of the device of the present invention. Specifically, the methods for implementing the breakpoint may include: (1) setting the INT3 instruction to implement the breakpoint; (2) setting the single-step debugging mode to implement the breakpoint; (3) using the CPU to directly break a specific address, for example, writing the address to be executed into DR0, DR1, DR2, DR3, or just writing one of them; (4) using the memory read-write method to implement the breakpoint; (5) other preset breakpoint methods supported by the processor.
[0171] 2. The location of the system breakpoint is within the code range of the Option ROM (i.e., the debugging device Option ROM) of this device; specifically, the methods for implementing the breakpoint may include: (1) setting the INT3 instruction to implement the breakpoint; (2) setting the single-step debugging mode to implement the breakpoint; (3) using the CPU to directly break a specific address, for example, writing the address to be executed into DR0, DR1, DR2, DR3, or just writing one of them; (4) using the memory read-write method to implement the breakpoint; (5) other preset breakpoint methods supported by the processor.
[0172] The following describes the main process of setting the INT3 instruction to implement a breakpoint with several examples:
[0173] Example 1:
[0174] For example, during the initialization phase of the Option ROM main program of the debugging device, the entry address of the UEFI system table is saved in a global variable. When any breakpoint is triggered, the debugging agent is executed. At this time, the debugging agent can find the entry addresses of all functions in the system table based on the system table, so breakpoints can be set at the entry of all functions in the system table. In the system table, breakpoints are often set for functions such as SystemTable->BootServices->LoadImage() and SystemTable->BootServices->StartImage(). The loading and execution of Option ROM (referring to the debugging device Option ROM and the debugged Option ROM) are implemented by these two functions. Therefore, setting breakpoints for these two functions is helpful for debugging the debugged Option ROM that is subsequently run by this debugging device, and can also be used to debug other boards using this device.
[0175] Example 2:
[0176] During the initialization phase, the main program of the debugging device Option ROM obtains the instance address of EFI_DISK_IO_PROTOCOL and saves this instance address to a global variable. When any breakpoint is triggered, it switches to executing the debugging agent. At this time, the debugging agent can set breakpoints for all functions in the instance based on this global variable, that is, based on the instance address of EFI_DISK_IO_PROTOCOL. According to UEFI specification 2.3.1, there are two functions ReadDisk() and WriteDisk() in this instance. After setting breakpoints for these two functions, the subsequent running efi files and the running debugged OptionROM will be immediately disconnected as long as ReadDisk() or WriteDisk() is called. Similarly, breakpoints can also be set for functions in other PROTOCOL instances in the UEFI system.
[0177] Example 3:
[0178] In case of power failure, turn the system breakpoint enable / disable switch of the debugging device to the enable position, and then correctly install the debugging device in the target computer. Then correctly set the firmware in the target computer so that the target computer can load and execute the debugging device Option ROM. At this time, restart the target computer, or shut down and then restart the target computer. Then, the system breakpoint is triggered and the debugging agent runs. The debugging host can send commands to the debugging agent to obtain the binary machine code of the subsequent program. After receiving these binary machine codes, the debugging host disassembles them and obtains the entry addresses of a large number of instructions. When the debugger wants to set a breakpoint at a certain address, he asks the debugging host to send this address to the debugging agent. At this time, the debugging agent can use the principle of INT3 instruction breakpoint to set a breakpoint at the specified address. The machine code of INT3 instruction is 0xCC. Using the principle of setting breakpoints with INT3 instruction, breakpoints can be set for all debugged objects for debugging.
[0179] 3. In the system, set breakpoints according to whether the efi file has source code and whether the debugged Option ROM has source code:
[0180] (1) If the EFI file being debugged has source code, insert the int3 instruction at the appropriate location of the source code to set a breakpoint, then recompile and generate the EFI file, and use this new EFI file to replace the old EFI file being debugged. All subsequent debugging is done on the new EFI file, and the old EFI file is no longer debugged.
[0181] (2) If the debugged Option ROM has source code, insert the int3 instruction at the appropriate position of the source code to set a breakpoint, then recompile and download it to the PCI device or PCIE device to overwrite the old debugged Option ROM code. The new debugged Option ROM code will be debugged later, and the old debugged Option ROM code will no longer be debugged.
[0182] (3) If the EFI file being debugged does not have source code, then read out the first byte entry code at the entry point of the EFI file being debugged, assuming it is 0xE8, and then use 0xCC to overwrite the first byte entry code 0xE8 of the EFI file being debugged. In other words: after the overwriting is successful, the first byte code of the EFI file being debugged changes from 0xE8 to 0xCC. Note: 0xCC is the machine code of the int3 instruction. Note: Here, you can also not overwrite the first byte code of the code entry in the file, but overwrite the first byte of a certain instruction in the middle of the code in the file, which must also be read out in advance, assuming it is 0xE9. Generally speaking, only one of 0xE8 and 0xE9 needs to be overwritten. There is no need to overwrite both at the same time, because overwriting two or more at the same time is very easy to make mistakes. That is: once the program is disconnected, is it disconnected at 0xE8 or 0xE9? This order is easy to judge incorrectly. Therefore, it is best to overwrite only one, which is not easy to make mistakes. If you must set multiple breakpoints, you can first set a breakpoint according to this method. After the breakpoint is successfully disconnected, you can then send a command to set a new breakpoint in the debugging host to set other breakpoints.
[0183] (4) If the debugged Option ROM does not have source code, but there is a binary image file corresponding to the debugged Option ROM, this image file can be downloaded to the debugged Option ROM of the PCI device or PCIE device. At this time, the same method as step (3) above is used to set a breakpoint in this binary image file (i.e., the first byte of the entry of the code in the file, or the first byte of a certain instruction in the middle of the code in the file is overwritten by 0xCC), and then the binary image file after the breakpoint is set is downloaded to the debugged Option ROM of the PCI device or PCIE device to overwrite the old debugged Option ROM code.
[0184] 4. In another implementation, if the debugged efi file has no source code, or the debugged Option ROM has no source code, but has a corresponding image file, this image file can be downloaded to the debugged Option ROM. In this case, the automatic recovery debugging method can be used:
[0185] (1) Find a 1-byte free space in the file header of this efi file.
[0186] (2) Copy the first byte code of the code entry in the efi file and store it in the empty space in the previous step.
[0187] (3) Use 0xCC to overwrite the first byte code of the code entry in the efi file.
[0188] (4) Then, run this efi file and the breakpoint will be disconnected.
[0189] (5) The debug agent automatically searches the file header, finds the previously free byte position, reads out the 1-byte code at that position, and uses this 1-byte code to perform a recovery operation [RIP is decremented by 1, and the read 1-byte code overwrites 0xCC].
[0190] (6) If the Option ROM being debugged does not have source code but has a corresponding image file, the debugging method is similar to (1) to (5) above.
[0191] (7) Summary: If INT3 is used to preset breakpoints, it can be divided into manual recovery debugging method and automatic recovery debugging method. The manual recovery debugging method is: use INT3 to preset breakpoints, wait until the preset breakpoint is broken, and then use the debugging host to send the 1-byte code originally overwritten by INT3 to the microcontroller module, and finally reach the debugging agent, and the debugging agent performs the recovery action. The automatic recovery debugging method is: use INT3 to preset breakpoints, and at the same time put the 1-byte code overwritten by INT3 in the empty space of the file header. After the file is loaded and executed, the 1-byte code in the file header is in the memory. When the breakpoint is broken, the debugging agent directly searches for the original 1-byte from the file header in the memory and then performs the recovery action.
[0192] 5. In another embodiment, if the debugged Option ROM has no source code and no corresponding image file, in this case, the debugging method is: first enable the system breakpoint function of the debugging device, and then find the loading function of the debugged Option ROM according to the firmware specification of the motherboard after disconnection. Set a breakpoint for this function, and after successful disconnection, gradually find the timing of the debug Option ROM being loaded according to the function, so as to locate the entry code of the debugged Option ROM, and then set a breakpoint at this entry code, so that subsequent debugging is easy.
[0193] Step S3: Sending a debugging command to the debugging agent to call the debugging function of the target host to debug the debugged object.
[0194] In this embodiment, the computer debugging process can be performed in two computers. In specific implementation, the debugging device of this embodiment can be inserted into the debugged computer. The debugging management program is run in the host computer. The debugged computer and the host computer are connected by a communication line, or wirelessly. The host computer sends various debugging commands by wire or wirelessly, and the debugged computer will eventually make various responses.
[0195] In some optional implementations of this embodiment, such as Figure 1B As shown, the implementation process of the computer debugging method of this embodiment mainly includes:
[0196] SM-1, start;
[0197] SM-2, motherboard firmware loading and debugging device Option ROM;
[0198] SM-3. Install the debugging agent while the mainboard firmware is executing the debugging device Option ROM loaded in the previous step;
[0199] SM-4, determine whether any preset breakpoint is encountered, if yes, execute step SM-5; if no, execute SM-8;
[0200] SM-5, enter the debugging agent;
[0201] SM-6, perform debugging actions;
[0202] SM-7, exit the debugging agent;
[0203] SM-8. Continue to execute. After completing this step, return to step SM-4.
[0204] In some optional implementations of this embodiment, such as Figure 1C As shown, when the preset breakpoint is located in the middle of the debugging device Option ROM, and the working process after the breakpoint is triggered, the specific implementation process of the computer debugging method mainly includes:
[0205] S3-1: The debugging device Option Rom code of this embodiment starts to execute;
[0206] S3-2: Install the debugging agent;
[0207] S3-3: A breakpoint is generated immediately at the current position;
[0208] S3-4: Enter the debugging agent;
[0209] S3-5: The debugging agent communicates with another debugging host through an interface;
[0210] S3-6: Exit the debugging agent;
[0211] S3-7: The Option ROM code of the debugging device of this embodiment ends.
[0212] In some optional implementations of this embodiment, the debugging method of this embodiment can be applied to the UEFI BIOS of a computer system. In this case, the arrangement process is as follows: Figure 1D As shown, including:
[0213] S4-1: power on or hot start;
[0214] S4-2: Run the UEFI BIOS code in the motherboard firmware;
[0215] S4-3: UEFI BIOS loads the Option ROM of this debugging device;
[0216] S4-4: UEFI BIOS executes Option ROM of this debugging device;
[0217] S4-5: Continue to run the UEFI BIOS code in the motherboard firmware;
[0218] S4-6: UEFI BIOS loads the debugged Option ROM;
[0219] S4-7: UEFI BIOS executes the debugged Option ROM;
[0220] S4-8: Continue to run the UEFI BIOS code in the motherboard firmware;
[0221] S4-9: UEFI BIOS loads the first efi file in the external memory;
[0222] S4-10: UEFI BIOS executes the first efi file in the external memory;
[0223] S4-11: Load the second efi file from the external memory;
[0224] S4-12: Execute the second efi file in the external memory;
[0225] S4-13: Enter the operating system;
[0226] S4-14: Power off.
[0227] In some optional implementations of this embodiment, when the preset breakpoint is located at the time when the debugging device Option ROM is executed and is about to return to the mainboard firmware, and the working process after the breakpoint is triggered, such as Figure 1E As shown, including:
[0228] S5-1, the Option ROM code of this debugging device starts;
[0229] S5-2, install the debugging agent;
[0230] S5-3, setting a breakpoint at the current position (at this time, the breakpoint will not be disconnected immediately); and after the step is completed, the preset breakpoint will not be disconnected immediately;
[0231] S5-4, the Option ROM code of the debugging device ends (this end code has only one instruction, and after the execution of this instruction, the breakpoint in the above S5-3 is triggered to achieve disconnection); and after this step is executed, the breakpoint preset in step S5-3 will be disconnected immediately;
[0232] S5-5, enter the debugging agent;
[0233] S5-6, the debugging agent communicates with another debugging host through an interface;
[0234] S5-7, exit the debugging agent;
[0235] S5-8. Return to the UEFI BIOS code in the motherboard firmware.
[0236] In some optional implementations of this embodiment, the method can be applied to Figure 2 In the device shown, the device includes: a PCIE gold finger 3, a PCIE bus processing circuit 2 and a storage circuit 1 for storing the debugging device Option ROM.
[0237] The PCIE golden finger 3 is electrically connected to the PCIE bus processing circuit 2, and the PCIE bus processing circuit 2 is electrically connected to the storage circuit 1 storing the Option ROM of the debugging device. The PCIE golden finger 3 is used to connect to the PCIE slot of the motherboard for bidirectional data communication. The PCIE bus processing circuit 2 is used for bidirectional data transmission between the PCIE bus and the storage circuit 1 storing the Option ROM of the debugging device. The storage circuit 1 storing the Option ROM of the debugging device is used to store the code of the Option ROM of the debugging device.
[0238] In this embodiment, the preset breakpoint position is within the Option ROM code range of the debugging device. In specific implementation, the breakpoint can be implemented in the following ways:
[0239] 01) Place the INT3 instruction directly.
[0240] 02) Set to enter single-step debugging mode.
[0241] 03) Write the address to be executed into DR0, DR1, DR2, DR3, just one of them. That is: use the CPU to directly disconnect the specific address.
[0242] 04) Use memory read and write to disconnect.
[0243] 05) Other preset breakpoint methods supported by the processor.
[0244] In some optional implementations of this embodiment, the main process of the computer debugging method can be applied to the following Figure 2 The difference between the devices shown is that Figure 2 The device shown is a device based on a PCIE bus interface. In this embodiment, the computer debugging method can be applied to a device based on a PCI bus interface. Except for the different bus interface types, the other implementation processes of these two devices are the same and will not be repeated here.
[0245] In some optional implementations of the present invention, step S2, the process of pausing the debugged object of the target host based on the preset breakpoint position, may include the following implementation process:
[0246] In this implementation, the breakpoint position can be set outside the Option ROM code range of the debugging device. When the execution of the code in the Option ROM of the debugging device ends, the breakpoint is triggered to suspend the operation of the debugged object of the target host.
[0247] In this implementation, the breakpoint will not be disconnected immediately, and another instruction needs to be executed before it can be disconnected. This instruction is the last instruction of the Option ROM code of this debugging device. In other words, the above-mentioned breakpoint setting action is completed before the last instruction of this device, and the breakpoint disconnection will be triggered only when the last instruction of this device is executed. It should be noted that the above-mentioned breakpoint position setting and implementation process is only one of the implementation methods of setting the breakpoint, and is not used to limit the setting method of the breakpoint position described in the embodiment of the present invention.
[0248] Optionally, before installing the debugging agent in the debugging device Option ROM executed by the mainboard of the target host, the computer debugging method further includes:
[0249] Obtain a switching instruction of a display function / debugging function switching switch; when the switching instruction of the display function / debugging function switching switch is to start the display function, drive and display information indicating that the debugging device Option ROM is successfully running; when the switching instruction of the display function / debugging function switching switch is to execute the debugging function, execute the step of installing a debugging agent in the debugging device Option ROM executed by the mainboard of the target host.
[0250] The embodiment of the present invention also provides a computer debugging device, such as Figure 3A As shown, the device mainly includes:
[0251] The storage circuit 31 is used to store the debugging device OptionROM, and the debugging device OptionROM is used to install the debugging agent;
[0252] The microcontroller module 32 is configured to receive a ring command sent by the debugging agent, and send a first debugging command to the debugging agent to obtain common data corresponding to the first debugging command; and receive a second debugging command sent by the debugging host, and forward the common data to the debugging host based on the second debugging command, or obtain specific data corresponding to the second debugging command;
[0253] The FPGA module 33 is used to drive the buzzer 115 to give a prompt when the ringing command is obtained.
[0254] In some optional implementations of this embodiment, such as Figure 3B As shown, the device also includes:
[0255] The golden finger 102 is used to connect to the interface of the target host for data communication and provide power input to the main power switch 103;
[0256] The bus processing circuit 107 is respectively connected to the read / write circuit 109, the storage circuit 108 storing the debugging device Option ROM, and the gold finger 102, and is used for data transmission between the microcontroller module 32 (MCU) and the storage circuit 108, the gold finger 102 and the read / write circuit 109.
[0257] In some optional implementations of this embodiment, such as Figure 3B As shown, the device also includes:
[0258] The display / debugging function switching switch 110 is used to switch between the display function and the debugging function. The display function is used to indicate the switch state of the display function of the computer debugging device; the debugging function is used to indicate the switch state of the debugging function of the computer debugging device. Specifically, when the display / debugging function switching switch 110 is in the "display function" position, the computer debugging device performs the display function. Conversely, when the display / debugging function switching switch 110 is in the "debugging function" position, the computer debugging device performs the debugging function.
[0259] The system breakpoint enable / disable switch 112 is used to switch the system breakpoint enable and system breakpoint disable functions; the switch quantity acquisition circuit 111 is also used to collect the switch state of the system breakpoint enable / disable switch 112 and transmit it to the FPGA module.
[0260] In some optional implementations of this embodiment, the display process of the debugging device Option ROM is as follows: Figure 4 As shown, it mainly includes:
[0261] SB-1, debug device Option ROM code starts;
[0262] SB-2. Get the status of the display function / debugging function switch;
[0263] SB-3, determine whether the display function / debugging function switch is in the "display function" position; if so, execute step SB-4, otherwise execute step SB-6;
[0264] SB-4, Displays the information that the UEFI debugging device Option ROM is running successfully;
[0265] SB-5, junk code (purpose: to construct an infinite loop to facilitate observation of the display information of step SB-4);
[0266] SB-6. Execute the Option ROM debugging process of the debugging device.
[0267] In some optional implementations of this embodiment, the debugging process of the debugging device Option ROM is as follows: Figure 5 As shown, it mainly includes:
[0268] SC-1. The display function / debugging function switch is not in the "display function" position (i.e., in the "debugging function" position);
[0269] SC-2. Get relevant system information and save it to various global variables. Note: The debugging host can send a command to set breakpoints. After receiving the command, the debugging agent can directly or indirectly set various breakpoints based on these global variables. For example, the entry address of the UEFI system table is saved in a global variable. The debugging agent can find the entry addresses of all functions in the table based on the system table, so breakpoints can be set at the entry of all functions in the system table. In the system table, there are functions that often need to set breakpoints, such as SystemTable->BootServices->LoadImage() and SystemTable->BootServices->StartImage(). The loading and execution of Option ROM are implemented by these two functions, so setting breakpoints on these two functions is helpful for debugging the debugged Option ROM. Another example: Call the UEFI system function to obtain the instance address of EFI_DISK_IO_PROTOCOL (this is a mature existing technology), save this instance address in a global variable, and the debugging agent can set breakpoints for all functions in the instance based on this global variable, that is, based on the instance address of EFI_DISK_IO_PROTOCOL. According to UEFI specification 2.3.1, there are two functions ReadDisk() and WriteDisk() in this instance. After setting breakpoints for these two functions, the subsequent running efi files and debugged Option ROM will be immediately disconnected as long as they call ReadDisk() or WriteDisk(). Similarly, breakpoints can also be set for functions in other PROTOCOL instances in the UEFI system.
[0270] SC-3, install and debug agent;
[0271] SC-4, whether the system breakpoint enable / disable switch 112 is in the "enable" position; if so, execute step SC-5, otherwise execute the code in step SC-6, and execute step SC-10;
[0272] SC-5, set a breakpoint at the current position (at this time, the breakpoint will not be disconnected immediately); and after this step is completed, the preset breakpoint will not be disconnected immediately;
[0273] SC-6, the Option ROM code of this debugging device ends (this ending code has only one instruction. After the execution of this instruction, the breakpoint in the above SC-5 is triggered to achieve disconnection); and after this step is executed, the breakpoint preset in the SC-5 step will be disconnected immediately;
[0274] SC-7, enter the debugging agent;
[0275] SC-8, the debugging agent communicates with the debugging host through the interface;
[0276] SC-9, exit the debugging agent;
[0277] SC-10. Return to the UEFI BIOS code in the motherboard firmware.
[0278] The switch quantity acquisition circuit 111 is used to acquire the switch status of the display / debug function switching switch 110 , and can also acquire the switch status of the system breakpoint enable / disable switching switch 112 , and transmit them to the FPGA module 33 .
[0279] In some optional implementations of this embodiment, such as Figure 3B As shown, the device also includes:
[0280] The buzzer power switch 114 is connected to the buzzer 115 and is used to power on the buzzer 115 alone or to power off the buzzer 115 alone. The main functions of the buzzer power switch 114 and the buzzer 115 include:
[0281] 01) After the breakpoint is disconnected, a sound prompt can be given.
[0282] 02) You can also press the buzzer power switch 114 to disconnect the power of the buzzer 115.
[0283] 03) FPGA cannot directly control the buzzer 115, and there is a buzzer power switch 114 in the middle. Only when the buzzer power switch 114 is turned on, can the FPGA effectively control the buzzer 115 through the buzzer drive circuit 120.
[0284] 04) The function of adding a sound prompt after the breakpoint is disconnected is mainly for the purpose of improving the convenience of use. For example: in the target host, after the device is inserted and turned on, a sound is heard, indicating that the program of the target host has been disconnected. Clearly reflect the current working status of the target host. You can imagine this: suppose there is no sound prompt function for this breakpoint, after the debugging host and the debugging device in the target host are connected with a serial port cable, and the system breakpoint is enabled, the target host is powered on, but the debugging host has no response. Under normal circumstances, the debugging host should receive various on-site information at the breakpoint (for example: the values of various registers, the values in the stack, the values in the memory, and the code starting at the breakpoint). Now the debugging host cannot receive this information. Then the problem may be with the debugging host, or the communication line, or the target host, or the communication line is not in good contact. The specific cause is difficult to find out. If the target host has a sound prompt function for the breakpoint, then after the target host is powered on, pay attention to whether the target host has a breakpoint prompt sound. If so, the target host is working normally. At this time, you can focus on checking the communication line and the debugging host. If there is no sound after the target host is powered on, it means that the program of the target host has not been disconnected. At this time, you can focus on checking the target host. In this way, the sound prompt provides great convenience for troubleshooting the location of the fault.
[0285] In some optional implementations of this embodiment, such as Figure 3B As shown, the device also includes:
[0286] The main power switch 103 is used to provide power to the computer debugging device; and a main power indicator light 104 can also be set to indicate the power supply status of the device. If it is on, it means that the power supply of the device is normal. If it is not on, it is necessary to determine whether the device is not plugged in properly or the main power switch 103 is not turned on. If these are all correct, but the main power indicator light 104 is still off, it means that there may be a problem with the device and the circuit needs to be checked.
[0287] The lighting switch 105 is connected to the lighting device and is used to control the lighting device on and off when the main power switch 103 is turned on. By turning on the lighting switch 105, the lighting lamp on the debugging device lights up to illuminate the environment in the chassis. The lighting device can be, for example, a lighting lamp 106 in the chassis.
[0288] In some optional implementations of this embodiment, such as Figure 3B As shown, the device also includes:
[0289] The communication interface 119 is connected to the microcontroller module 32 (MCU), and the microcontroller performs bidirectional transmission of commands and data with the debugging host via the communication interface 119 .
[0290] In actual application, the golden finger 102 is electrically connected to the bus processing circuit 107. The bus processing circuit 107 is electrically connected to the storage circuit 108 storing the Option ROM of the debugging device. The bus processing circuit 107 is electrically connected to the read-write circuit 109. The read-write circuit 109 is electrically connected to the FPGA module 33. The FPGA module 33 is electrically connected to the microcontroller module 32 (MCU). The MCU is electrically connected to the communication interface 119. Specifically, the functions of the above components mainly include:
[0291] The gold finger 102 is used to connect to the slot of the mainboard for two-way data communication. The bus processing circuit 107 is used for two-way data transmission between the bus and the storage circuit 108 storing the Option ROM of the debugging device. At the same time, the bus processing circuit 107 is also used for two-way data communication with the read-write circuit.
[0292] The read / write circuit is used to realize bidirectional communication between FPGA and bus processing circuit 107. FPGA is used for bidirectional communication between MCU and read / write circuit. MCU is used for bidirectional communication between communication interface 119 and FPGA. Communication interface 119 needs to be connected to the debugging host, and is connected in a wired or wireless manner. Communication interface 119 is used for bidirectional communication between the debugging host and MCU.
[0293] In this embodiment, the communication interface 119 is implemented in a serial port manner. In actual implementation, it is not limited to a serial port, but may also adopt various interface forms, such as a USB interface, a 1394 interface, a network port, or a wireless interface, etc., but the present invention is not limited thereto.
[0294] In some optional implementations of this embodiment, such as Figure 6 As shown, in the computer debugging device, the debugging process of the debugging agent mainly includes:
[0295] SD-1: Enter the debug agent;
[0296] SD-2: Issue command CmdBeep (this command sends a very short drive signal to the buzzer drive circuit. If the buzzer power switch 114 is in the "on" position, the buzzer will emit a very short beep: "beep", indicating that the program has been disconnected);
[0297] SD-3: Receives command Cxxx from MCU, and the command is received successfully;
[0298] SD-4: Determine whether the Cxxx command is a legal command; if so, execute step SD-6; otherwise, execute step SD-5;
[0299] SD-5: Feedback error processing to MCU; then return to step SD-3;
[0300] SD-6: Determine whether the Cxxx command is a CmdH recovery command; if so, execute step SD-7; otherwise, execute step SD-8;
[0301] SD-7: Use the 1-byte data carried by the CmdH command to perform the recovery action, and then make necessary adjustments to the site; then return to step SD-3;
[0302] SD-8: Determine whether the Cxxx command requires on-site operation; if so, execute step SD-9, otherwise execute step SD-10;
[0303] SD-9: perform on-site operations (for example, set breakpoints, clear breakpoints, obtain specified register values, obtain specified memory area values, obtain specified stack values, modify specified register values, modify specified memory values, modify specified stack values, etc.); then execute step SD-10;
[0304] SD-10: Determine whether command Cxxx requires a response; if yes, execute step SD-11, otherwise execute step SD-12;
[0305] SD-11: Response information (in this step, the response information sent back to the MCU includes various field data, such as register values, values in a certain memory area, and values in the stack, if necessary) is sent back to the MCU; then step SD-12 is executed;
[0306] SD-12: Determine whether command Cxxx needs to be exited; if yes, execute step SD-13, otherwise return to execute step SD-3;
[0307] SD-13: Send the debug agent exit command CmdExitAgent to MCU;
[0308] SD-14: The code in the debugger ends.
[0309] In some optional implementations of this embodiment, the microcontroller module is specifically used to: receive the CmdBeep command sent by the debugging agent, and then send the CmdX command to the debugging agent to obtain the common data corresponding to the CmdX command; after the data is successfully obtained, receive the CmdY command sent by the debugging host, and then determine whether the common data satisfies the CmdY command; if so, send the common data to the debugging host; if not, forward the CmdY command to the debugging agent; if the debugging agent sends specific data corresponding to the CmdY command after executing the CmdY command, receive the specific data, and then send the specific data to the debugging host. Figure 7 As shown, the debugging process implemented by the main program of the microcontroller module of the computer debugging device specifically includes:
[0310] SE-1, MCU main program starts;
[0311] SE-2, MCU status St1 is initialized to: busy (the debugging host will read the MCU status St1 by querying);
[0312] SE-3, the forwarding command flag Fg1 is initialized to: do not forward;
[0313] SE-4. MCU receives the CmdBeep command sent by the debugging agent (if the MCU successfully receives the command, it means that a new breakpoint has been successfully disconnected);
[0314] SE-5. Determine whether step SE-4 is received successfully. If yes, execute step SE-6; otherwise, return to execute step SE-4;
[0315] SE-6, MCU sends a response to FPGA (indicates: MCU successfully receives the CmdBeep command);
[0316] SE-7, MCU sends CmdX command to the debugging agent to receive various frequently used common data, and then stores these common data in the MCU on-chip memory and the large-capacity memory 118;
[0317] SE-8, MCU state St1 is set to: idle;
[0318] SE-9, read the forwarding command flag Fg1 (the serial port receiving interrupt program will set this flag to: forward);
[0319] SE-10, determine whether the forwarding command flag Fg1 is to be forwarded, if yes, execute step SE-11; otherwise, return to execute step SE-9;
[0320] SE-11, MCU state St1 is set to: busy (because MCU is ready for busy communication and data transmission, the state needs to be set to busy);
[0321] SE-12. Forward the command CmdY sent by the debugging host and which must be forwarded to the debugging agent to the debugging agent;
[0322] SE-13. Determine whether the debugging agent is to return specific data for the CmdY command. If so, execute step SE-14; otherwise, execute step SE-17;
[0323] SE-14. MCU receives the specific data for the CmdY command returned by the debug agent (i.e., the data returned by the debug agent executing CmdY);
[0324] SE-15, determine whether step SE-14 is received successfully, if yes, execute step SE-16; otherwise, return to execute step SE-14;
[0325] SE-16, send the received data as the response data of the command to the debugging host;
[0326] SE-17, determine whether the command CmdY is to cause the debug agent to exit, if so, execute step SE-19; otherwise, execute step SE-18;
[0327] SE-18, the forwarding command flag Fg1 is restored to the initial value: not forwarded, and then step SE-8 is executed;
[0328] SE-19, MCU receives the CmdExitAgent command sent by the debug agent;
[0329] SE-20. Determine whether step SE-19 is received successfully. If so, execute step SE-2; otherwise, execute step SE-19.
[0330] In some optional implementations of this embodiment, such as Figure 8 As shown, the process of receiving the interrupt program of the serial port in the microcontroller module of the computer debugging device includes:
[0331] SF-1, the serial port receiving interrupt program in MCU starts;
[0332] SF-2, MCU successfully receives the command Cyyy sent by the debugging host;
[0333] SF-3. Determine whether the command Cyyy is CmdT. If yes, execute step SF-4; otherwise, execute step SF-5;
[0334] SF-4, the MCU status St1 is sent to the debugging host (because the CmdT command is to obtain the status); then execute step SF-11;
[0335] SF-5. Determine whether the MCU status St1 is busy. If yes, execute step SF-6; otherwise, execute step SF-7;
[0336] SF-6, the MCU status St1 is sent to the debugging host (at this time, the main program is "busy", so the currently received command Cyyy is not processed, and only the status St1 is sent to the debugging host); then execute step SF-11;
[0337] SF-7, determine whether the common data obtained in step SE-7 can satisfy the command CmdY; if yes, execute step SF-8; otherwise, execute step SF-9;
[0338] SF-8, the data required by command CmdY is sent to the debugging host; then step SF-11 is executed;
[0339] SF-9. Send the message "Forwarding command CmdY" to the debugging host (at this time, the command Cyyy must be CmdY. Because: the debugging host only sends CmdT and CmdY commands. In addition, the debugging process is briefly described as follows: first, the breakpoint is disconnected, so the debugging agent obtains the program control of the target computer. Then the MCU obtains frequently used data from the debugging agent and saves this data locally in the MCU. Next, the MCU sets its own status to "idle". Next, the debugging host sends CmdT to obtain the status of the MCU, and on the premise that it is "idle", it sends the debugging command CmdY to the MCU. Next, the MCU first determines whether the local data satisfies the CmdY command. If not, the CmdY command is forwarded to the debugging agent, and the debugging agent processes the command).
[0340] SF-10, the forwarding command flag Fg1 is set to: forward (if the CmdY command needs to send the data obtained from the debugging agent to the debugging host, it will be sent in the MCU main program. At this time, this interrupt receiving program does not do this sending because it is executed by the MCU main program);
[0341] SF-11, the serial port receiving interrupt program in MCU ends.
[0342] In some optional implementations of this embodiment, such as Fig. 9 As shown, when the debugged Option ROM is disconnected, or the debugged efi file is disconnected, the specific implementation process of the computer debugging method mainly includes:
[0343] S7-1. A breakpoint is preset in the debugged object, and then the breakpoint is successfully disconnected;
[0344] S7-2, the debugging host sends a debugging command;
[0345] S7-3, communication interface 119 transmits to MCU;
[0346] S7-4, MCU transmits to FPGA;
[0347] S7-5, FPGA transmits to the debugging agent in the computer memory (this debugging agent is installed in the memory after the debugging device OptionROM is executed by the mainboard firmware. In this embodiment, the debugging device has two working modes, that is, two sets of programs. In these two sets of programs, the loading, execution, and installation of the debugging agent of OptionROM are the same);
[0348] S7-6, the above debugging agent determines whether: a legal debugging command is received; if yes, execute step S7-7, otherwise execute step S7-8;
[0349] S7-7, the above debugging agent responds normally; execute step S7-9;
[0350] S7-8, the above-mentioned debugging agent performs error processing; execute step S7-9;
[0351] S7-9, the debugging agent in the computer memory is transmitted to the FPGA (this debugging agent is the same as the debugging agent described in step S7-5);
[0352] S7-10, FPGA to MCU;
[0353] S7-11, MCU transmits to communication interface 119;
[0354] S7-12, the communication interface 119 transmits it to the debugging host, and then executes step S7-2.
[0355] The above debugging process is the second working mode inside the debugging device of this embodiment. The hardware of this debugging remains unchanged, but there are two sets of programs. The purpose of these two sets of programs is the same. The workflows inside these two sets of programs are different. In the second working mode, there is no CmdX command. All debugging commands are sent by the debugging host, and then passed step by step until they are transmitted to the debugging agent. The debugging agent makes different responses. If this response needs to return data, then the data will be returned step by step until it is returned to the debugging host. Therefore, the second working mode is only different in the way of communication, and the rest is the same as the first working mode. In addition, the first working mode and the second working mode are both based on Figure 3BThe debugging device shown in the figure. The working modes mentioned in this article in which the microcontroller module sends CmdX commands all belong to the first working mode.
[0356] Based on the contents described in the above embodiments, the functions of the FPGA module of this embodiment are summarized as follows: FPGA collects the first state value of the "display function / debugging function switch" through the switch quantity acquisition circuit 111, and at the same time, collects the second state value of the "system breakpoint enable / disable switch 112", and then transmits the first state value and the second state value to the debugging device Option ROM running in the memory of the target host, so that the Option ROM can make different responses according to the different states of the two switches. Then, after receiving the ringing command from the debugging agent, the FPGA sends a driving signal to the buzzer. At the same time, the FPGA also plays the role of a communication bridge between the debugging agent and the microprocessor module, realizing two-way communication between the debugging agent and the microprocessor module.
[0357] The embodiment of the present invention also provides a computer debugging system, such as Fig.10 As shown, the computer debugging system mainly includes: a target host 41, a computer debugging device 42 and a debugging host 43 which are connected in sequence.
[0358] Wherein, the computer debugging device 42 comprises:
[0359] A storage circuit for storing a debugging device Option ROM, wherein the debugging device Option ROM is used to install a debugging agent; a microcontroller module for receiving a ringing command sent by the debugging agent, and sending a first debugging command to the debugging agent to obtain common data corresponding to the first debugging command; and receiving a second debugging command sent by a debugging host 43, forwarding the common data to the debugging host based on the second debugging command, or obtaining specific data corresponding to the second debugging command; an FPGA module for driving a buzzer to give a prompt when the ringing command is obtained; and the debugging host 43 is used to send a debugging command to the debugging agent to call the debugging function of the target host 41 to debug the debugged object. For details, please refer to the relevant description of the computer debugging device 42 of any of the above embodiments, which will not be repeated here.
[0360] In some optional implementations of this embodiment, such as Fig.11 As shown, the execution process of the debugging host 43 communication core program mainly includes:
[0361] SG-1: Debug host program starts;
[0362] SG-2: The debugging host sends the command CmdT to obtain the MCU status St1;
[0363] SG-3: The debug host receives the data returned by the command CmdT, that is, the state St1 of the MCU;
[0364] SG-4: Determine whether the debugging host successfully receives the data returned by the CmdT command. If yes, execute step SG-5; otherwise, return to execute step SG-3;
[0365] SG-5: Determine whether the received state St1 is idle; if it is idle, execute step SG-7, otherwise execute step SG-6;
[0366] SG-6: Delay for a period of time (e.g., 100 ms), and then return to execute step SG-2;
[0367] SG-7: The debugging host sends the debugging command CmdY (including: CmdH command, set breakpoint, delete breakpoint, step, step over, run, etc.) to the MCU. At the same time, the command may be sent with data or not. The following is an explanation: because sending the CmdY command is actually a data frame. For example: a data frame has a length, a command identifier, the data carried (this data is optional), a checksum, and may have other parts. So many components are sent together as a complete data frame. Once the receiver receives the CmdY command, the data carried in the CmdY command will also be received. Special note: If the current CmdY command is the CmdH command (this CmdH command is called: recovery command), then for some embodiments, this CmdH command must carry 1 byte of data when it is sent. This 1 byte of data is the 1 byte code that was previously overwritten by int3. This CmdH command and the 1-byte code sent will eventually be received by the debugging agent, and then the debugging agent will perform recovery actions on the disconnected int3, specifically, recovering the 1-byte code overwritten by int3, and making necessary on-site adjustments (for example: the original RIP will be decremented by 1). If it is not recovered, garbled characters will be displayed. Only after recovery can the correct assembly code be displayed (supplementary note: as long as the MCU is in the "idle" state, it means that the target computer must be in the "breakpoint has been disconnected state". Otherwise, the MCU may be receiving the CmdBeep command of the debugging agent in a loop, and at this time, the MCU is in the "busy" state. Alternatively, the MCU may also be forwarding commands and also in the "busy" state);
[0368] SG-8: Determine whether the command CmdY is a CmdH command; if so, return to step SG-2, otherwise, go to step SG-9;
[0369] SG-9: Determine whether the command CmdY indicates that data needs to be returned; if so, execute step SG-10; otherwise, return to execute step SG-2;
[0370] SG-10: The debug host receives the data returned by the command CmdY;
[0371] SG-11: Determine whether the data is received successfully; if so, return to step SG-2; otherwise, return to step SG-10.
[0372] In some optional implementations of this embodiment, the debugging device may be a PCIE board.
[0373] The connection between the target host 41 to be debugged and the debugging device may include the following two modes:
[0374] The first connection mode is built-in connection. The characteristic is that the debugging device is placed inside the chassis of the target host 41 to be debugged. Specifically, the debugging device can be directly plugged into the PCIE slot on the motherboard of the target host 41 to be debugged. Alternatively, a very short PCIE extension cable is used, one end of which is plugged into the PCIE slot on the motherboard of the target host 41 to be debugged, and the other end of the extension cable is plugged into the debugging device.
[0375] The second connection method is: external connection. The characteristic is that the debugging device is placed outside the chassis of the target host 41 to be debugged. Specifically, the debugging device can be connected to the PCIE slot on the motherboard of the target host 41 to be debugged with a very long PCIE extension cable. It is also possible to use a very short PCIE extension cable and a baffle to connect the PCIE slot on the motherboard of the target host 41 to be debugged to the baffle, and then use a very long PCIE extension cable to connect the debugging device to the baffle on the chassis of the target host 41 to be debugged (note: this baffle is just installed and has a PCIE connector).
[0376] The embodiment of the present invention also provides a computer debugging device, such as Fig.12 As shown, the computer debugging device may include a processor 51, a memory 521, and a memory 522, wherein the processor 51, the memory 521, and the memory 522 may be connected via a bus or other means. Fig.12 The example of connecting through bus is taken in the following.
[0377] The processor 51 may be a central processing unit (CPU). The processor 51 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.
[0378] The memory 521, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as program instructions / modules corresponding to the computer debugging method in the embodiment of the present invention. The processor 51 executes various functional applications and data processing of the processor by running the non-transitory software programs, instructions and modules stored in the memory 521, that is, implements the computer debugging method in the above method embodiment. In this embodiment, the code stored in the memory 521 is the Option ROM of the computer debugging device of this embodiment, which is executed by the central processing unit of the target computer.
[0379] The memory 522 is a non-transitory computer-readable storage medium that can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as program instructions / modules corresponding to the computer debugging method in the embodiment of the present invention. The processor 51 executes various functional applications and data processing of the processor by running the non-transitory software programs, instructions and modules stored in the memory 522, that is, implementing the computer debugging method in the above method embodiment.
[0380] The memory 521 and the memory 522 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required by at least one function; the data storage area may store data created by the processor 51, etc. In addition, the memory 521 and the memory 522 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 521 and the memory 522 may optionally include a memory remotely arranged relative to the processor 51, and these remote memories may be connected to the processor 51 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0381] The one or more modules are stored in the memory 521 and the memory 522, and when executed by the processor 51, the following is performed: Figure 1A-Figure 11 The computer debugging method in the illustrated embodiment.
[0382] For details of the above computer debugging equipment, please refer to Figures 1A to 11 The corresponding related descriptions and effects in the illustrated embodiments can be understood and will not be repeated here.
[0383] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above-mentioned types of memory.
[0384] In addition, in this embodiment, the following description is required:
[0385] 01) Depending on the type of motherboard firmware, this embodiment can be implemented on either Legacy BIOS or UEFI BIOS.
[0386] 02) If classified according to different interface types, the embodiments of the present invention may have the following forms: based on PCI interface, based on PCIE interface, based on Mini PCIE interface, based on Thunderbolt interface, based on ISA, based on EISA, etc.
[0387] 03) If classified according to different function types, the embodiments of the present invention can have the following forms: single function and combined function. Regarding single function, for example: a separate debugging function. Regarding combined function, for example: a combination of debugging function and display function (the structural diagram of the combined form, see Figure 3A-3B. The display function refers to the function performed by the debugging device when the "display function / debugging function switch" is in the "display function" position). Another example: combining the debugging function and the graphics card will result in: a graphics card with a debugging function. Therefore, it is easy to think of: a sound card with a debugging function, a network card with a debugging function, an X card with a debugging function (where X represents a function name), and these combinations are all embodiments of the present invention. Because according to the technical details of the present invention, professional and technical personnel can easily implement the design of this combination.
[0388] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A computer debugging method, characterized in that: include: Installing a debugging agent in the debugging device Option ROM executed by the mainboard firmware of the target host; Based on a preset breakpoint position, the debugged object of the target host is suspended from running, and the debugger enters the running of the debugging agent; The debugging host sends a debugging command to the debugging agent to call the debugging function of the target host to debug the debugged object; The method for setting the preset breakpoint position includes: The breakpoint is set by using the free space in the file header of the executable file to store the first byte code of the file code entry of the executable file; The system breakpoint is set using the system breakpoint enable / disable switch.
2. The computer debugging method according to claim 1, characterized in that: The step of pausing the debugged object of the target host based on a preset breakpoint position includes: When the preset breakpoint position is reached, the breakpoint is triggered, so that the debugged object of the target host is suspended.
3. The computer debugging method according to claim 1, characterized in that: Before installing the debugging agent in the debugging device Option ROM executed by the mainboard firmware of the target host, the method further includes: Get the display function switching instruction; When the display function switching instruction is to start the display function, the driver displays the information that the Option ROM of the debugging device is successfully running.
4. The computer debugging method according to claim 3, characterized in that: The computer debugging method further comprises: when the display function switching instruction is to turn off the display function, executing the step of installing a debugging agent in the debugging device Option ROM executed by the mainboard firmware of the target host.
5. A computer debugging device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer debugging method according to any one of claims 1 to 4 by executing the computer instructions.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the computer debugging method according to any one of claims 1 to 4.
7. A computer debugging device, characterized in that: include: A storage circuit, used for storing a debugging device Option ROM, wherein the debugging device Option ROM is used for installing a debugging agent; a microcontroller module, configured to receive a ring command sent by the debugging agent, and send a first debugging command to the debugging agent to obtain common data corresponding to the first debugging command; and receiving a second debugging command sent by the debugging host, forwarding the common data to the debugging host based on the second debugging command, or acquiring specific data corresponding to the second debugging command; wherein the common data refers to data that the debugging host needs to acquire after all breakpoints are disconnected one by one and data that the debugging host needs to acquire after most breakpoints are disconnected; the debugging host sends a CmdY command to the microcontroller module, and after the microcontroller module receives the CmdY command, it finds that the common data cannot satisfy the CmdY command, so the microcontroller module forwards the CmdY command to the debugging agent, the debugging agent executes the CmdY command, and the debugging agent needs to return data to the debugging host, and the returned data is called specific data; The FPGA module is used to drive the buzzer to give a prompt when the ringing command is obtained; The debugging process of the debugging agent includes: Based on a preset breakpoint position, the debugged object of the target host is suspended from running, and the debugger enters the running of the debugging agent; The debugging host sends a debugging command to the debugging agent to call the debugging function of the target host to debug the debugged object; The method for setting the preset breakpoint position includes: The breakpoint is set by using the free space in the file header of the executable file to store the first byte code of the file code entry of the executable file; The system breakpoint is set using the system breakpoint enable / disable switch.
8. The computer debugging device according to claim 7, characterized in that: Also includes: Read and write circuits; A gold finger is used to connect to the interface of the target host for data communication; The bus processing circuit is connected to the read-write circuit, the storage circuit and the gold finger respectively, and is used for data transmission between the microcontroller module and the storage circuit, the gold finger and the read-write circuit.
9. The computer debugging device according to claim 7, characterized in that: The computer debugging device also includes: A display / debugging function switching switch, used to switch between a display function and a debugging function, wherein the display function is used to indicate the switch state of the display function of the computer debugging device; and the debugging function is used to indicate the switch state of the debugging function of the computer debugging device; The switch quantity acquisition circuit is used to acquire the switch state of the display / debugging function switching switch and transmit it to the FPGA module.
10. The computer debugging device according to claim 9, characterized in that: The computer debugging device also includes: The system breakpoint enable / disable switch is used to switch the system breakpoint start and the system breakpoint disable functions; the switch quantity acquisition circuit is also used to collect the switch state of the system breakpoint enable / disable switch and transmit it to the FPGA module.
11. The computer debugging device according to claim 7, characterized in that: The computer debugging device also includes: The buzzer power switch is connected to the buzzer and is used to power on or off the buzzer separately.
12. The computer debugging device according to claim 7, characterized in that: The computer debugging device also includes: A main power switch, used to provide power to the computer debugging device; The lighting switch is connected to the lighting device and is used to control the lighting device under the premise that the main power switch is turned on.
13. The computer debugging device according to claim 7, characterized in that: The computer debugging device also includes: The communication interface is connected to the microcontroller module, and the microcontroller performs bidirectional transmission of commands and data with the debugging host through the communication interface.
14. The computer debugging device according to any one of claims 7 to 13, characterized in that: The microcontroller module is specifically used for: Receive the CmdBeep command sent by the debugging agent, and then send the CmdX command to the debugging agent to obtain the common data corresponding to the CmdX command; after the data is successfully obtained, receive the CmdY command sent by the debugging host, and then determine whether the common data satisfies the CmdY command; if so, send the common data to the debugging host; if not, forward the CmdY command to the debugging agent; If the debugging agent sends specific data corresponding to the CmdY command after executing the CmdY command, the specific data is received and then sent to the debugging host.
15. The computer debugging device according to claim 14, characterized in that: The microcontroller module is also used to perform the following processes: Determine whether the command sent by the debugging host is a command for the debugging host to obtain the status of the microcontroller module; When the command sent by the debugging host is not a command for the debugging host to obtain the status of the microcontroller module, if the current status of the microcontroller module is busy, the busy status is sent to the debugging host.
16. The computer debugging device according to claim 15, characterized in that: When receiving the state acquisition instruction from the debugging host, the current state is sent to the debugging host.
17. A computer debugging system, characterized in that: include: The target host, the computer debugging device and the debugging host are connected in sequence, wherein: The computer debugging device comprises: The storage circuit is used to store the debugging device Option ROM, and the debugging device Option ROM is used to install the debugging agent; the debugging process of the debugging agent includes: Based on a preset breakpoint position, the debugged object of the target host is suspended from running, and the debugger enters the running of the debugging agent; Sending a debugging command to the debugging agent to call the debugging function of the target host to debug the debugged object; The microcontroller module is used to receive the ring command sent by the debugging agent, and send a first debugging command to the debugging agent to obtain common data corresponding to the first debugging command; and receive a second debugging command sent by the debugging host, and forward the common data to the debugging host based on the second debugging command, or obtain specific data corresponding to the second debugging command; wherein the common data refers to the data that the debugging host needs to obtain after all breakpoints are disconnected one by one and the data that the debugging host needs to obtain after most breakpoints are disconnected; the debugging host sends a CmdY command to the microcontroller module, and after receiving the CmdY command, the microcontroller module finds that the common data cannot satisfy the CmdY command, so the microcontroller module forwards the CmdY command to the debugging agent, the debugging agent executes the CmdY command, and the debugging agent needs to return data to the debugging host, and the returned data is called specific data; The FPGA module is used to drive the buzzer to give a prompt when the ringing command is obtained; the debugging host is used to send a debugging command to the debugging agent to call the debugging function of the target host to debug the debugged object; The method for setting the preset breakpoint position includes: The breakpoint is set by using the free space in the file header of the executable file to store the first byte code of the file code entry of the executable file; The system breakpoint is set using the system breakpoint enable / disable switch.
18. The computer debugging system according to claim 17, characterized in that: The microcontroller module is specifically used for: Receive the CmdBeep command sent by the debugging agent, and then send the CmdX command to the debugging agent to obtain the common data corresponding to the CmdX command; after the data is successfully obtained, receive the CmdY command sent by the debugging host, and then determine whether the common data satisfies the CmdY command; if so, send the common data to the debugging host; if not, forward the CmdY command to the debugging agent; If the debugging agent sends specific data corresponding to the CmdY command after executing the CmdY command, the specific data is received and then sent to the debugging host.
19. The computer debugging system according to claim 18, characterized in that: The microcontroller module is also used to perform the following processes: Determine whether the received Cyyy command is a get status instruction sent by the debugging host; When the received Cyyy command is not the acquisition status instruction of the debugging host, if the current status is busy, the busy status is sent to the debugging host.
20. The computer debugging system according to claim 19, characterized in that: When receiving the state acquisition instruction from the debugging host, the current state is sent to the debugging host.
21. The computer debugging system according to claim 18, characterized in that: The debugging host is used to perform the following processes: Sending a status acquisition command to the microcontroller module; Receiving status data returned by the microcontroller module based on the status acquisition command; determining a state of the microcontroller module based on the state data; When the state of the microcontroller module is idle, the CmdY command is sent to the microcontroller module.
22. The computer debugging system according to claim 21, characterized in that: When the state of the microcontroller module is not idle, the debugging host delays for a preset period of time, and then the debugging host returns to execute the step of receiving the state data returned by the microcontroller module based on the state acquisition command.
