1// -*- C++ -*- 2 3// Copyright (C) 2004 Free Software Foundation, Inc. 4 5// This library is free software; you can redistribute it and/or 6// modify it under the terms of the GNU General Public License as 7// published by the Free Software Foundation; either version 2, or (at 8// your option) any later version. 9 10// This library is distributed in the hope that it will be useful, but 11// WITHOUT ANY WARRANTY; without even the implied warranty of 12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13// General Public License for more details. 14 15// You should have received a copy of the GNU General Public License 16// along with this library; see the file COPYING. If not, write to 17// the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 18// MA 02110-1301, USA. 19 20// As a special exception, you may use this file as part of a free 21// software library without restriction. Specifically, if other files 22// instantiate templates or use macros or inline functions from this 23// file, or you compile this file and link it with other files to 24// produce an executable, this file does not by itself cause the 25// resulting executable to be covered by the GNU General Public 26// License. This exception does not however invalidate any other 27// reasons why the executable file might be covered by the GNU General 28// Public License. 29 30// Benjamin Kosnik <bkoz@redhat.com> 31// Blame subsequent hacks on Loren J. Rittle <ljrittle@acm.org>, Phil 32// Edwards <pme@gcc.gnu.org>, and a cast of dozens at libstdc++@gcc.gnu.org. 33 34#include "testsuite_abi.h" 35#include <iostream> 36#include <unistd.h> // for access(2) 37 38int 39main(int argc, char** argv) 40{ 41 using namespace std; 42 43 // Get arguments. (Heading towards getopt_long, I can feel it.) 44 string argv1 = argc > 1 ? argv[1] : ""; 45 if (argv1 == "--help" || argc < 4) 46 { 47 cerr << "usage: abi_check --check current baseline\n" 48 " --check-verbose current baseline\n" 49 " --examine symbol current\n" 50 " --help\n" 51 "\n" 52 "All arguments are string literals.\n" 53 "CURRENT is a file generated byextract_symvers.\n" 54 "BASELINE is a file from config/abi.\n" 55 "SYMBOL is a mangled name.\n" 56 << endl; 57 exit(1); 58 } 59 60 if (argv1.find("--check") != string::npos) 61 { 62 bool verbose = false; 63 if (argv1 == "--check-verbose") 64 verbose = true; 65 66 // Quick sanity/setup check for arguments. 67 const char* test_file = argv[2]; 68 const char* baseline_file = argv[3]; 69 if (access(test_file, R_OK) != 0) 70 { 71 cerr << "Cannot read symbols file " << test_file 72 << ", did you forget to build first?" << endl; 73 exit(1); 74 } 75 if (access(baseline_file, R_OK) != 0) 76 { 77 cerr << "Cannot read baseline file " << baseline_file << endl; 78 exit(1); 79 } 80 if (!compare_symbols(baseline_file, test_file, verbose)) 81 exit (1); 82 } 83 84 if (argv1 == "--examine") 85 { 86 const char* file = argv[3]; 87 if (access(file, R_OK) != 0) 88 { 89 cerr << "Cannot read symbol file " << file << endl; 90 exit(1); 91 } 92 examine_symbol(argv[2], file); 93 } 94 return 0; 95} 96