In the eyes of the law, debugging my source code and tracking every place your car drives on public roads (non intrusively without attaching a GPS device) are exactly the same: legal.
But previous articles posted to HN have had arguments by law professors that at least some of what the NSA is doing is actually illegal, even aside from questions of constitutionality.