Trace funtction

how does a trace function work, and how would i set one up???