1. A method for selectively tracing program execution, the method comprising: executing a first module on a processor, the processor operably coupled to a memory storing the first module and at least one branch module; detecting execution of an instruction of the first module to execute a branch module; in response to detecting execution of the instruction, turning on a debugging mode to generate traces of branch modules subsequently executed by the processor; detecting return of execution by the processor to the first module, wherein detecting the return of execution by the processor comprises detecting equality of a value stored in a status register and a return address of the first module, the status register indicating an address of an instruction currently executed by the processor; and in response to detecting return of execution to the first module, turning off the debugging mode to terminate the generation of traces.