A method and apparatus for creating a compressed trace for a program,
wherein events are compressed separately to provide improved compression
and tracing. A sequence of events for a program is selected, and a
sequence of values is then determined for each of the selected events
occurring during an execution of the program. Each sequence of values is
then compressed to generate a compressed sequence of values for each
event. These values are then ordered in accordance with information
stored in selected events (such as for example, branch events), where the
ordered values correspond to the trace.