Brazil's president has survived a vote which could have seen him tried on corruption charges at the Supreme Court, and be suspended from office.