Cost effective dynamic program slicing