Patent ID: 8245195

Claim:
A system for debugging a computer program executed by a processor, the system comprising a debugging unit and a storage system, the debugging unit comprising: a setting module configured for setting a trap flag of a flag register of the processor, so as to generate a software interrupt after an instruction of the computer program is executed by the processor, wherein the instruction is stored in the storage system; a protecting module configured for pushing values of a plurality of registers of the processor into a stack to protect the plurality of registers when the software interrupt is generated, wherein the values of the plurality of registers comprise a return address of the software interrupt, and the return address comprises a segment address INT_CS and an effective address INT_IP; a retrieving module configured for retrieving an operation code of a next instruction following a current instruction of the computer program from the storage system, wherein the operation code determines a type of the next instruction; a first processing module configured for performing a bitwise OR operation between the top of the stack and a value “0100h” upon condition that the next instruction is a pop flags (POPF) instruction; a second processing module configured for calculating a jump-from address and a jump-to address upon condition that the next instruction is a jump instruction and causes a jump to take place, and storing the jump-from address and the jump-to address into the storage system, wherein the jump-from address is INT_CS*10h+INT_IP and the jump-to address is INT_CS*10h+(INT_IP+(rel8+2) &FFh) upon condition that the next instruction is a short conditional jump instruction and a corresponding jump condition is met, wherein the “rel8” is an 8-bit address offset between a next instruction of the short conditional jump instruction and the jump-to address; and a restoring module configured for restoring the values of the plurality of registers from the stack, and returning to the computer program.