Use of compiler-introduced identifiers to improve debug information pertaining to user variables
AssigneeRed Hat, Inc.
InventorsAndrew MacLeod, Alexandre Oliva
Life of this patent
Estimating the term…
Abstract
A method and system for improving debug information pertaining to user variables using a compiler. The method may include identifying a statement to be removed from its current position in an internal representation of a program by a compiler as part of the compiler optimization, replacing the statement to be removed with a debug annotation, adding references to the debug annotation in subsequent debug expressions referring to the removed statement, and emitting debug location information for a user variable using the debug annotation.
Claims16
A method comprising:
- identifying, by a processing device, a statement to be removed from a current position in an internal representation of a program by a compiler as part of compiler optimization, the statement comprising an assignment of a result of a computation to an internal representation name;
- identifying, by the processing device, the internal representation name in elements in a debug expression of a debug statement, wherein the debug statement describes a variable bound to an expression that represents the variable's value;
- determining, by the processing device, whether the internal representation name is not further used and is assigned to a single operand;
- in response to determining that the internal representation name is not further used and is assigned to the single operand, substituting, by the processing device, the internal representation name with the single operand;
- replacing, by the processing device, the statement to be removed with a compiler- introduced debug annotation, wherein the compiler-introduced debug annotation comprises an artificial variable bound to a value that would have been computed by the removed statement described by an expression of the computation;
- adding, by the processing device, references to the artificial variable in the compiler-introduced debug annotation in the debug expression referring to the internal representation name;
- and
- providing, by the processing device, debug location information for a user variable using a declaration of the compiler-introduced debug annotation, wherein the debug location information comprises the user variable and an expression that, using elements of the compiler-introduced debug annotation, describes a location or a value of the user variable.
A non-transitory computer readable storage medium comprising instruction, which when executed by a processing device, cause the processing device to execute operations comprising:
- identify, by the processing device, a statement to be removed from a current position in an internal representation of a program by a compiler as part of compiler optimization, the statement comprising an assignment of a computation to an internal representation name;
- identify, by the processing device, the internal representation name in elements in a debug expression of a debug statement, wherein the debug statement describes a variable bound to an expression that represents the variable's value;
- determine, by the processing device, whether the internal representation name is not further used and is assigned to a single operand;
- in response to the determination that the internal representation name is not further used and is assigned to the single operand, substitute, by the processing device, the internal representation name with the single operand;
- replace, by the processing device, the statement to be removed with a compiler-introduced debug annotation, wherein the compiler-introduced debug annotation comprises an artificial variable bound to a value that would have been computed by the removed statement described by an expression of the computation;
- add, by the processing device, references to the artificial variable in the compiler-introduced debug annotation in the debug expression referring to the internal representation name;
- and
- provide, by the processing device, debug location information for a user variable using a declaration of the compiler-introduced debug annotation, wherein the debug location information comprises the user variable and expression that, using elements of the compiler-introduced debug annotation, describes a location or a value of the user variable.
A system comprising:
- a memory;
- and
- a processing device, operatively coupled to the memory, to:
- identify a statement to be removed from a current position in an internal representation of a program by a compiler as part of compiler optimization, the statement comprising an assignment of a computation to an internal representation name;
- identify the internal representation name in elements in a debug expression of a debug statement, wherein the debug statement describes a variable bound to an expression that represents the variable's value;
- determine whether the internal representation name is not further used and is assigned to a single operand;
- in response to determine that the internal representation name is not further used and is assigned to the single operand, substitute the internal representation name with the single operand;
- replace the statement to be removed with a compiler-introduced debug annotation, wherein the compiler-introduced debug annotation comprises an artificial variable bound to a value that would have been computed by the removed statement described by an expression of the computation;
- add references to the artificial variable in the compiler-introduced debug annotation in the debug expression referring to the internal representation name;
- and
- provide debug location information for a user variable using a declaration of the compiler-introduced debug annotation, wherein the debug location information comprises the user variable and an expression that, using elements of the compiler-introduced debug annotation, describes a location or a value of the user variable.
Dependencies are inferred from the claim text.