a method , apparatus , and a computer program product are disclosed for selectively activating a trace function in a computer program in response to a call of a predetermined trigger code element so that trace data is produced only for those subroutines that call the trigger code element or are called by the trigger code element . the computer program product provides one or more trace code elements for one or more selected subroutines of the computer program stored on internal memory of a digital computer . the trace code elements provide trace data for said selected subroutines . the computer program product also selects a subroutine as a trigger code element , processes the computer program , monitors the call stack for the trigger code element , and enables the trace code elements for each selected subroutine simultaneously present in the call stack if the trigger code element is identified in the call stack .