Hardware-driven call stack attribution
Apparatuses, systems, and techniques for hardware-driven call stack attribution. The apparatuses, systems, and techniques include generating and updating call stacks within a processing device during execution of an application. In particular, a branch identifier associated with an instruction being executed by an execution thread is determined. A call stack identifier of the execution thread executing the instruction is identified. The call stack identifier of the execution thread is updated based on the identified call stack identifier of the execution thread and the branch identifier.
1 . A method comprising:
determining, by a processing circuit, a branch identifier associated with an instruction of an application being executed by an execution thread;
identifying a call stack identifier of the execution thread executing the instruction; and
updating the call stack identifier of the execution thread with a new value of the call stack identifier of the execution thread, the updating comprising:
identifying, based on the identified call stack identifier of the execution thread and the branch identifier, a record of a state transition data structure associated with the application, wherein the record comprises the new value of the call stack identifier of the execution thread;
obtaining the new value of the call stack identifier of the execution thread from the identified record; and
setting the call stack identifier of the execution thread to the obtained new value of the call stack identifier of the execution thread.
2 . The method of claim 1 , wherein the new value of the call stack identifier is a numeral representation of a call stack after the execution of the instruction by the execution thread.
3 . The method of claim 1 , wherein the call stack identifier of the execution thread is a numerical representation of a call stack.
4 . The method of claim 1 , wherein the branch identifier is a numerical representation of a branch between functions.
5 . The method of claim 1 , wherein updating the call stack identifier of the execution thread to the new value of the call stack identifier comprises determining whether a type of the instruction is a branch type instruction.
6 . The method of claim 1 , wherein updating the call stack identifier of the execution thread further comprises:
identifying, based on the identified call stack identifier of the execution thread, the branch identifier and a branch taken value, the record of the state transition data structure associated with the application, wherein the branch taken value is a boolean value indicating whether a branch is taken or not.
7 . The method of claim 1 , wherein updating the call stack identifier of the execution thread is performed responsive to determining that an update call stack flag associated with the instruction being executed by the execution thread is equal to a first predefined value.
8 . The method of claim 1 , wherein the call stack identifier of the execution thread is stored in a hardware register associated with the execution thread.
9 . The method of claim 1 , further comprising:
outputting, via a program counter (PC) sampler, the call stack identifier of the execution thread.
10 . The method of claim 1 , further comprising:
in response to updating the call stack identifier, updating a register of a performance monitor of the processing circuit in view of a bit flag associated with the register.
11 . The method of claim 1 , further comprising:
configuring the call stack identifier to be written into at least one of: a data register or memory.
12 . A system comprising:
a memory device; and
a processing circuit coupled to the memory device, wherein the processing circuit is to perform operations comprising:
determining a branch identifier associated with an instruction of an application being executed by an execution thread;
identifying a call stack identifier of the execution thread executing the instruction; and
updating the call stack identifier of the execution thread with a new value of the call stack identifier of the execution thread, the updating comprising:
identifying, based on the identified call stack identifier of the execution thread and the branch identifier, a record of a state transition data structure associated with the application, wherein the record comprises the new value of the call stack identifier of the execution thread;
obtaining the new value of the call stack identifier of the execution thread from the identified record; and
setting the call stack identifier of the execution thread to the obtained new value of the call stack identifier of the execution thread.
13 . The system of claim 12 , wherein the new value of the call stack identifier is a numeral representation of a call stack after the execution of the instruction by the execution thread.
14 . The system of claim 12 , wherein the call stack identifier of the execution thread is a numerical representation of a call stack.
15 . The system of claim 12 , wherein the branch identifier is a numerical representation of a branch between functions.
16 . The system of claim 12 , wherein updating the call stack identifier of the execution thread to the new value of the call stack identifier comprises determining whether a type of the instruction is a branch type instruction.
17 . The system of claim 12 , wherein updating the call stack identifier of the execution thread further comprises:
identifying, based on the identified call stack identifier of the execution thread, the branch identifier and a branch taken value, the record of the state transition data structure associated with the application, wherein the branch taken value is a boolean value indicating whether a branch is taken or not.
18 . The system of claim 12 , wherein updating the call stack identifier of the execution thread is performed responsive to determining that an update call stack flag associated with the instruction being executed by the execution thread is equal to a first predefined value.
19 . The system of claim 12 , wherein the call stack identifier of the execution thread is stored in a hardware register associated with the execution thread.
20 . A non-transitory computer-readable medium comprising instructions that, responsive to execution by a processing circuit, cause the processing circuit to perform operations comprising:
receiving a state transition data structure associated with an application to be executed;
encoding a plurality of instructions associated with the application with a branch identifier; and
responsive to execution of an instruction of the plurality of instructions by an execution thread, updating a call stack identifier of the execution thread with a new value of the call stack identifier of the execution thread, the updating comprising:
identifying, based on the call stack identifier of the execution thread and the branch identifier, a record of the state transition data structure, wherein the record comprises the new value of the call stack identifier of the execution thread;
obtaining the new value of the call stack identifier of the execution thread from the identified record; and
setting the call stack identifier of the execution thread to the obtained new value of the call stack identifier of the execution thread.
21 . The non-transitory computer-readable medium of claim 20 , wherein the new value of the call stack identifier is a numerical representation of a call stack after the execution of the instruction by the execution thread.