It is a vulgarized contraction for the expression "son of a machine", which is usually surrounded by exclamation points and can be a compliment (such as "son of a tiger") or a euphemistic imprecation (such as "son of a bad mother"); It all depends on the interpretation we make of "machine".