Officially, these are supposed to be sniffing for explosive and chemical residue. However, I have heard that they are also being used to detect narcotics as well.
I would imagine it is fairly easy to train these devices to detect any type of chemical residue by just calibrating the sensors with whatever chemical "fingerprint" you're interested in detecting.