Hardware-assisted program trace collection with selectable call-signature capture
Abstract
Hardware-assisted program tracing is facilitated by a processor that includes a root instruction address register, a program trace signature computation unit and a call signature register. When a program instruction having an address matching the root instruction address register is executed, a program trace signature is captured in the call signature register and capture of branch history is commenced. By accumulating different values of the call signature register, for example in response to an interrupt generated when the root instruction is executed, software that performs program tracing can obtain signatures of all of the multiple execution paths that lead to the root instruction, which is also specified by software in order to set different root instructions for program tracing. In an alternative implementation, a storage for multiple call signatures is provided in the processor and read at once by the software.
Claims
exact text as granted — not AI-modified1 . A method of collecting program trace information of program code executed by a processor, the method comprising:
computing a program call signature at program calls and returns within the program code that uniquely identifies a call and return history extending to a currently executing instruction; specifying a root instruction at which to collect the program call signature by storing an address of the root instruction in a root instruction register of the processor; during execution of the program code, detecting that the execution has reached the root instruction; and responsive to detecting that the execution has reached the root instruction, storing a current value of the program call signature in a call signature register and commencing capture of program trace information in a branch history buffer as execution of the program code proceeds.
2 . The method of claim 1 , further comprising specifying a particular value of the program call signature at which to commence capture of program trace information, wherein the detecting further detects that a current value of the program call signature matches the particular value of the program call signature when the execution has reached the root instruction, and wherein the commencing capture of program trace information is performed responsive to detecting that the execution has reached the root instruction and that the current value of the program call signature matches the particular value of the program call signature.
3 . The method of claim 2 , further comprising selecting a trace capture mode of the processor, and wherein, in a first operating mode, the commencing capture is performed responsive to detecting that the execution has reached the root instruction and that the current value of the program call signature matches the particular value of the program call signature, and wherein in a second operating mode, the commencing capture is performed responsive to detecting that the execution has reached the root instruction independent of the current value of the program call signature.
4 . The method of claim 1 , further comprising responsive to a subsequent execution of the root instruction, interrupting the processor, whereby results of the capturing can be obtained from the branch history buffer.
5 . The method of claim 1 , wherein the storing stores the current value of the program call signature in one of multiple call signature registers forming a call signature buffer, wherein the storing populates the call signature buffer at multiple occurrences of the detecting having detected that the execution has reached the root instruction.
6 . The method of claim 1 , wherein the computing the program call signature comprises hashing addresses of the program calls with current values of the program call signature as the program calls are encountered and un-hashing the current values of the program call signature with addresses of the program calls when the corresponding program returns are encountered.
7 . A processor, comprising:
an instruction fetch unit for fetching program instructions for execution by functional units within the processor; an instruction decoder for decoding the program instructions fetched by the instruction fetch unit; an instruction dispatch unit for dispatching the decoded program instructions to the functional units; a computation unit for computing a program call signature at calls and returns encountered in the program instructions, wherein the program call signature uniquely identifies a call and return history extending to a currently executing instruction; a root instruction register for storing an address of a specified a root instruction at which to collect the program call signature; and control logic that, responsive to execution reaching the root instruction, stores the program call signature in a call signature register of the processor and triggers capture of program trace information in a branch history buffer of the processor.
8 . The processor of claim 7 , wherein the control logic further detects when a current value of the program call signature matches a value of the program call signature stored in the call signature register, and commences triggers capture of the program trace information when the current value of the program call signature matches the value of the program call signature stored in the call signature register and the execution has reached the root instruction.
9 . The processor of claim 8 , wherein the control logic includes a control register for selecting an operating mode the processor, and wherein the control logic, responsive to selecting a first operating mode of the processor, and further responsive to detecting that the execution has reached the root instruction and that the current value of the program call signature matches the value of the program call signature stored in the call signature register, stores the current value of the call signature register and triggers the capture of the program trace information, and wherein the control logic, responsive to selecting a second operating mode of the processor, stores the current value of the call signature register and triggers the capture of the program trace information when the execution has reached the root instruction independent of the current value of the program call signature.
10 . The processor of claim 7 , wherein the control logic generates an interrupt responsive to a subsequent execution of the root instruction to signal a program to collect the program call signature and program trace information from the processor.
11 . The processor of claim 7 , wherein the control logic stores the current value of the program call signature in one of multiple call signature registers forming a call signature buffer and populates the call signature buffer at multiple occurrences of the execution having reached the root instruction.
12 . The processor of claim 7 , wherein the computation unit computes the program call signature by hashing addresses of the program calls with current values of the program call signature as the program calls are encountered and un-hashing the current values of the program call signature with addresses of the program calls when the corresponding program returns are encountered.
13 . A computer system comprising:
a processor for executing program instructions, wherein the processor computes a program call signature at calls and returns encountered in the program instructions, wherein the program call signature uniquely identifies a call and return history extending to a currently executing instruction, and wherein the processor stores the program call signature in a call signature register of the processor and triggers capture of program trace information in a branch history buffer of the processor, when an address of the currently executing instruction matches a root instruction register of the processor; and a memory coupled to the processor for storing the program instructions, wherein the program instructions are program instructions for tracing execution of program code by the processor wherein the program instructions comprising program instructions for specifying the root instruction at which to collect the program trace signature by storing an address of the root instruction in a root instruction register of the processor, and collecting multiple different values of the program call signature during execution of the program code to obtain a complete execution trace for the program code by reading the call signature register of the processor.
14 . The computer system of claim 13 , wherein the processor further detects when a current value of the program call signature matches a value of the program call signature stored in the call signature register, and commences triggers capture of the program trace information when the current value of the program call signature matches the value of the program call signature stored in the call signature register and the execution has reached the root instruction.
15 . The computer system of claim 14 , wherein the processor includes a control register for selecting an operating mode the processor, and wherein the processor, responsive to selecting a first operating mode, and further responsive to detecting that the execution has reached the root instruction and that the current value of the program call signature matches the value of the program call signature stored in the call signature register, stores the current value of the call signature register and triggers the capture of the program trace information, and wherein the processor, responsive to selecting a second operating mode, stores the current value of the call signature register and triggers the capture of the program trace information when the execution has reached the root instruction independent of the current value of the program call signature.
16 . The computer system of claim 13 , wherein the processor generates an interrupt responsive to a subsequent execution of the root instruction to signal a program to collect the program call signature and program trace information from the processor.
17 . The computer system of claim 13 , wherein the processor stores the current value of the program call signature in one of multiple call signature registers forming a call signature buffer and populates the call signature buffer at multiple occurrences of the execution having reached the root instruction.
18 . The computer system of claim 13 , wherein the computation unit computes the program call signature by hashing addresses of the program calls with current values of the program call signature as the program calls are encountered and un-hashing the current values of the program call signature with addresses of the program calls when the corresponding program returns are encountered.
19 . A computer program product comprising computer-readable storage media encoding program instructions for execution by a general-purpose computer system, wherein the program instructions are program instructions for tracing execution of program code by a processor, wherein the program instructions comprising program instructions for:
specifying a root instruction at which to collect the program call signature by storing an address of the root instruction in a root instruction register of the processor, wherein the program call signature uniquely identifies a call and return history extending to a currently executing instruction; and collecting multiple different values of the program call signature and corresponding program trace information during execution of the program code to obtain a program execution trace for the program code by reading a call signature register and branch history buffer of the processor.
20 . The computer program product of claim 19 , wherein the program instructions for collecting reads the call signature register after the program call signature has been captured for multiple occurrences of the capturing, in order to obtain the multiple different values of the program call signature.
21 . The computer program product of claim 20 , wherein the program instructions for collecting form part of an interrupt handler that are executed responsive to the processor capturing a value of the program call signature.
22 . The computer program product of claim 19 , wherein the program instructions for collecting collect multiple difference values of the program call signature from a storage within the processor.
23 . The computer program product of claim 19 , further comprising program instructions for selecting a particular operating mode of the processor, and wherein the processor, responsive to selecting a first operating mode of the processor, and further responsive to detecting that execution of the program code has reached the root instruction and that a current value of the program call signature within the processor matches a value of the program call signature stored in the call signature register, stores the current value of the call signature register and triggers the capture of the program trace information, and wherein the processor, responsive to selecting a second operating mode of the processor, stores the current value of the call signature register and triggers the capture of the program trace information when the execution of the program code has reached the root instruction independent of the current value of the program call signature.
24 . The computer program product of claim 19 , wherein the program call signature is a hash of addresses of the program calls with current values of the program call signature as the program calls are encountered and an un-hash of the current values of the program call signature with addresses of the program calls when the corresponding program returns are encountered.Cited by (0)
No later patents cite this yet.
References (0)
No backward citations on record.