Method and apparatus for debugging optimized code
First Claim
1. A computer-implemented method for obtaining information associated with program code, the computer-implemented method comprising:
- adding a segment of code to the program code, the segment of code including a representation associated with a computation, the representation being arranged to be substantially unprocessed;
adding debugging code in proximity to the segment of code;
optimizing the program code;
generating machine code associated with the optimized program code, the machine code including a break point and an associated instruction, the break point being associated with the debugging code; and
replacing the instruction at the break point with a branch instruction, the branch instruction being arranged to cause the debugging code to execute, wherein when the debugging code executes, information associated with the representation is obtained.
2 Assignments
0 Petitions
Accused Products
Abstract
Methods and apparatus for providing a substantially full set of state information to a debugger, without significantly compromising system performance, in order to debug optimized computer program code are disclosed. According to one aspect of the present invention, a method for obtaining information associated with program code includes adding a segment of code, which includes a representation that is effectively not used after it is computed, to the program code. Debugging code is added in proximity to the segment of code, and machine code is generated from the program code. The machine code includes a break point that is associated with the debugging code, and includes an instruction at the breakpoint. Finally, the method includes replacing the instruction at the break point with a branch instruction that is arranged to cause the debugging code to execute.
-
Citations
20 Claims
-
1. A computer-implemented method for obtaining information associated with program code, the computer-implemented method comprising:
-
adding a segment of code to the program code, the segment of code including a representation associated with a computation, the representation being arranged to be substantially unprocessed;
adding debugging code in proximity to the segment of code;
optimizing the program code;
generating machine code associated with the optimized program code, the machine code including a break point and an associated instruction, the break point being associated with the debugging code; and
replacing the instruction at the break point with a branch instruction, the branch instruction being arranged to cause the debugging code to execute, wherein when the debugging code executes, information associated with the representation is obtained. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10)
converting the program code into an internal representation, wherein generating the machine code associated with the program code includes generating the machine code from the internal representation.
-
-
8. A computer-implemented method as recited in claim 1 wherein generating the machine code associated with the program code includes generating machine code associated with the representation.
-
9. A computer-implemented method as recited in claim 8 further including:
executing the debugging code, wherein executing the debugging code is arranged to provide information associated with the representation.
-
10. A computer-implemented method as recited in claim 9 wherein the debugging code is executed by one of a debugger and a deoptimizer.
-
11. A computer apparatus for obtaining information associated with program code, the computer apparatus comprising:
-
a programming interface arranged to add a segment of code to the program code, the segment of code including a representation associated with a computation, the representation being arranged to be substantially unprocessed, the programming interface further being arranged to add debugging code in proximity to the segment of code;
an optimizer arranged to optimize the program code;
a machine code generator arranged to generate machine code associated with the optimized program code, the machine code including a break point, the break point being associated with the debugging code, wherein the machine code further includes a instruction at the break point location; and
a decompiler arranged to replace the instruction with a branch instruction, wherein the branch instruction is arranged to cause the debugging code to execute. - View Dependent Claims (12, 13, 14, 15, 16)
a code converter arranged to convert the program code into an internal representation, wherein the machine code generator is arranged to generate the machine code from the internal representation.
-
-
15. A computer apparatus according to claim 14 further including:
a debugger arranged to execute the debugging code, wherein executing the debugging code is arranged to provide information associated with the representation.
-
16. A computer apparatus according to claim 14 further including:
a deoptimizer arranged to execute the debugging code, wherein executing the debugging code is arranged to provide information associated with the program representation.
-
17. A computer program product for obtaining information associated with a particular set of instructions, the computer program product comprising:
-
computer code that includes a representation associated with a computation, the representation being arranged to be substantially unprocessed, wherein the computer code includes debugging code;
computer code for generating machine code associated with the computer code that includes the representation and the debugging code, the machine code including a break point, the break point being associated with the debugging code, wherein the machine code further includes a instruction;
computer code for replacing the instruction with a branch instruction, the branch instruction being arranged to cause the debugging code to execute, wherein causing the debugging code to execute provides information associated with the representation; and
a computer-readable medium that stores the program codes. - View Dependent Claims (18)
-
-
19. A computer-implemented method for obtaining information associated with program code, the computer-implemented method comprising:
-
adding a call to a subroutine, the subroutine being associated with the program code, the call to the subroutine including a plurality of arguments, wherein at least one of the plurality of arguments is a reference to a representation associated with a computation, the representation being unused with respect to the program code and the subroutine; and
generating machine code associated with the program code, wherein generating the machine code includes substantially transforming the call to the subroutine into debugging code.
-
-
20. A computer-implemented method for debugging optimized code, the computer-implemented method comprising:
-
generating a higher-level program representation, the higher-level program representation including a loop section, the loop section having an associated counter value, wherein the loop section includes a segment of break point code;
optimizing the higher-level program representation, wherein optimizing the higher-level program representation includes converting the higher-level program representation into lower-level code, the lower-level code including a section associated with the debugging code and a instruction;
replacing the instruction with a branch instruction, branch instruction being arranged to cause the section associated with the debugging code to execute; and
executing the branch instruction, wherein executing branch instruction causes the section associated with the debugging code to execute and to provide information associated with the counter value.
-
Specification