IP Library Granted Patent US 9,785,536
Granted Patent B2
US 9,785,536 · App. 15/036,234 · Granted Oct 10, 2017

Code injection for conditional breakpoints

Inventors: Mihail-Marian Nistor (Bucharest, RO); Dragos Miloiu (Banesti, RO)
Assignee: NXP USA, INC.
G06F11/362G06F8/30G06F8/41G06F11/3644
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 9,785,536
App. No.
15/036,234
Granted
Oct 10, 2017
Kind
B2
Abstract

An apparatus for debugging operational code of a target program comprises a memory storing the operational code and a set of instructions representing a debugger program for debugging the operational code. A microprocessor is configured to execute the operational code and the debugger program. The debugger program can inject a jump to a breakpoint handling routine into the operational code and let a compiler program create code pieces for the breakpoint handling routine.

Claims (83)

1. A method of debugging operational code of a target program, where a jump to an breakpoint handling routine is injected into the operational code, the method comprising:

receiving a command to set a conditional breakpoint, the command comprising a breakpoint position and a condition;

computing an address of the breakpoint and an address of a next valid instruction within the operational code, the next valid instruction being the first next instruction not affected by the injection of the jump to the breakpoint handling routine;

saving a part of the operational code starting from the address of the breakpoint until the address of the next valid instruction, to obtain a saved code part;

translating the condition into a compiler program language to obtain a translated condition;

calling a compiler program with information comprising the address of the breakpoint, the address of the next valid instruction, the saved code part and the translated condition, to let the compiler program create code pieces for a breakpoint handling routine, the code pieces comprising:

a context save block comprising instructions to temporarily save context data;

a condition evaluation code block comprising instructions to evaluate the condition that the debugger program received;

a context restore block comprising instructions to restore the context data;

the translated opcode, and

a jump to the next valid instruction;

the method further comprising:

receiving the code pieces and one or more debugger program hooks from the compiler program;

computing a routine memory address where the breakpoint handling routine will be inserted;

inserting the breakpoint handling routine at the routine memory address, and

injecting the jump to the breakpoint handling routine into the operational code at the address of the breakpoint.

2. A method of debugging operational code according to claim 1 , the method further comprising:

checking the validity of the condition;

stopping the method if the condition is found to be invalid;

reporting, for example to a user, that the condition is invalid.

3. A method of debugging operational code according to claim 1 , the method further comprising:

receiving an instruction to remove the conditional breakpoint;

restoring the saved code part at the address of the breakpoint;

marking as free an area of the program memory where the breakpoint handling routine was inserted.

4. A method of debugging operational code according to claim 1 , wherein the debugger program hooks comprise an offset and size of the context restore block within the breakpoint handling routine, the method further comprising:

detecting that the conditional breakpoint is hit, and putting the target program in debug mode;

restoring the saved code part at the address of the breakpoint;

setting a program counter to the start of the context restore block using the offset;

performing single instruction steps in debug mode until the program counter gets to an end of the context restore block;

setting the program counter to the address of the breakpoint.

5. A method of debugging operational code according to claim 1 , the method further comprising:

receiving a request to resume execution of the target program after the conditional breakpoint was hit;

performing one or more single instruction steps to exit the memory area where the jump will be reinserted;

reinserting the jump to breakpoint handling routine at the address of the breakpoint, and

resuming the target program.

6. A method of debugging operational code according to claim 1 , the method further comprising:

receiving a request to execute step operation;

performing a single step operation;

if a next instruction is valid: reinserting the jump to breakpoint handling routine at the address of the breakpoint, and executing the step as requested;

if the next instruction is not valid and if user operation requires more steps: return to the action of performing a single step operation.

7. A method of generating code for a breakpoint handling routine, the method comprising:

receiving information from a debugger program, the information comprising an address of a breakpoint, an address of a next valid instruction, a saved code part of an operational code and a translated condition;

generating code to save context information including register data affected by the breakpoint handling routine to obtain a context save block;

generating code to evaluate the translated condition, to obtain a condition evaluation code block;

generating code to restore the context information so as to revert any changes done by the breakpoint handling routine, to obtain a context restore block;

generating code to execute the saved code part of the operational code;

generating code to jump to the address of the next valid instruction in the operational code.

8. A method of generating code according to claim 7 , the method further comprising:

computing an offset and a size of the context restore block;

computing an offset of a first instruction within the condition evaluation code block that is to be executed if the translated condition is met;

sending the offset and the size of the context restore instruction block to the debugger program;

sending the offset of the first instruction to the debugger program.

9. An apparatus for debugging operational code of a target program, the apparatus comprising:

a memory storing the operational code and a set of instructions representing a debugger program for debugging the operational code;

a microprocessor configured to execute the operational code and the debugger program;

the debugger program being arranged to inject a jump to a breakpoint handling routine into the operational code, the debugger program being arranged for:

receiving a command to set a conditional breakpoint, the command comprising a breakpoint position and a condition;

computing an address of the breakpoint and an address of a next valid instruction within the operational code, the next valid instruction being the first next instruction not affected by the injection of the jump to the breakpoint handling routine;

saving a part of the operational code starting from the address of the breakpoint until the address of the next valid instruction, to obtain a saved code part;

translating the condition into a compiler program language to obtain a translated condition;

calling a compiler program with information comprising the address of the breakpoint, the address of the next valid instruction, the saved code part and the translated condition, to let the compiler program create code pieces for a breakpoint handling routine, the code pieces comprising:

a context save block comprising instructions to temporarily save context data;

a condition evaluation code block comprising instructions to evaluate the condition that the debugger program received;

a context restore block comprising instructions to restore the context data;

the translated opcode, and

a jump to the next valid instruction;

the debugger program further being arranged for:

receiving the code pieces and one or more debugger program hooks from the compiler program;

computing a routine memory address where the breakpoint handling routine will be inserted;

inserting the breakpoint handling routine at the routine memory address, and

injecting the jump to the breakpoint handling routine into the operational code at the address of the breakpoint.

10. An apparatus for generating code for a breakpoint handling routine, comprising:

a memory storing a set of instructions representing a compiler program;

a microprocessor configured to execute the compiler program;

an interface for receiving information from a debugger program

the compiler program being arranged for:

receiving information from the debugger program comprising an address of a breakpoint, an address of a next valid instruction, a saved code part of an operational code and a translated condition;

generating code to save context information including register data affected by the breakpoint handling routine to obtain a context save block;

generating code to evaluate the translated condition, to obtain a condition evaluation code block;

generating code to restore the context information so as to revert any changes done by the breakpoint handling routine, to obtain a context restore block;

generating code to execute the saved code part of the operational code;

generating code to jump to the address of the next valid instruction in the operational code.

11. A computer program product stored in a tangible, non-transitory computer readable medium comprising executable instructions for causing a microprocessor system to perform a method according to claim 1 .

Assignments (5)
CORRECTIVE ASSIGNMENT TO CORRECT THE REMOVE APPLICATION 11759915 AND REPLACE IT WITH APPLICATION 11759935 PREVIOUSLY RECORDED ON REEL 040925 FRAME 0001. ASSIGNOR(S) HEREBY CONFIRMS THE RELEASE OF SECURITY INTEREST. Recorded Feb 17, 2020
From: MORGAN STANLEY SENIOR FUNDING, INC.
To: NXP, B.V. F/K/A FREESCALE SEMICONDUCTOR, INC.
Reel/Frame 052917/0001 →
CORRECTIVE ASSIGNMENT TO CORRECT THE REMOVE APPLICATION 11759915 AND REPLACE IT WITH APPLICATION 11759935 PREVIOUSLY RECORDED ON REEL 040928 FRAME 0001. ASSIGNOR(S) HEREBY CONFIRMS THE RELEASE OF SECURITY INTEREST. Recorded Jan 17, 2020
From: MORGAN STANLEY SENIOR FUNDING, INC.
To: NXP B.V.
Reel/Frame 052915/0001 →
CORRECTIVE ASSIGNMENT TO CORRECT THE NATURE OF CONVEYANCE PREVIOUSLY RECORDED AT REEL: 040626 FRAME: 0683. ASSIGNOR(S) HEREBY CONFIRMS THE MERGER AND CHANGE OF NAME EFFECTIVE NOVEMBER 7, 2016. Recorded Jan 12, 2017
From: NXP SEMICONDUCTORS USA, INC. (MERGED INTO); FREESCALE SEMICONDUCTOR, INC. (UNDER)
To: NXP USA, INC.
Reel/Frame 041414/0883 →
CHANGE OF NAME Recorded Nov 16, 2016
From: FREESCALE SEMICONDUCTOR INC.
To: NXP USA, INC.
Reel/Frame 040626/0683 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded May 12, 2016
From: NISTOR, MIHAIL-MARIAN; MILOIU, DRAGOS
To: FREESCALE SEMICONDUCTOR, INC.
Reel/Frame 038567/0279 →
Continuity (1)
Related Publication 20160299828A1 · Oct 13, 2016