]>
Commit | Line | Data |
---|---|---|
4b260c20 BK |
1 | // -*- C++ -*- |
2 | ||
748086b7 | 3 | // Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. |
4b260c20 BK |
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 | |
748086b7 | 7 | // published by the Free Software Foundation; either version 3, or (at |
4b260c20 BK |
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 | |
748086b7 JJ |
16 | // along with this library; see the file COPYING3. If not see |
17 | // <http://www.gnu.org/licenses/>. | |
18 | ||
747d0967 BK |
19 | |
20 | // Benjamin Kosnik <bkoz@redhat.com> | |
0e9cab87 PE |
21 | // Blame subsequent hacks on Loren J. Rittle <ljrittle@acm.org>, Phil |
22 | // Edwards <pme@gcc.gnu.org>, and a cast of dozens at libstdc++@gcc.gnu.org. | |
4b260c20 BK |
23 | |
24 | #include "testsuite_abi.h" | |
747d0967 | 25 | #include <iostream> |
4ba851b5 | 26 | #include <cstdlib> |
6ad70bf2 | 27 | #include <unistd.h> // for access(2) |
0e9cab87 PE |
28 | |
29 | int | |
30 | main(int argc, char** argv) | |
747d0967 BK |
31 | { |
32 | using namespace std; | |
33 | ||
0e9cab87 | 34 | // Get arguments. (Heading towards getopt_long, I can feel it.) |
c4c064e7 BK |
35 | string argv1 = argc > 1 ? argv[1] : ""; |
36 | if (argv1 == "--help" || argc < 4) | |
747d0967 | 37 | { |
ac3d7b44 | 38 | cerr << "usage: abi_check --check current baseline\n" |
c4c064e7 | 39 | " --check-verbose current baseline\n" |
4b260c20 BK |
40 | " --examine symbol current\n" |
41 | " --help\n" | |
42 | "\n" | |
43 | "All arguments are string literals.\n" | |
44 | "CURRENT is a file generated byextract_symvers.\n" | |
45 | "BASELINE is a file from config/abi.\n" | |
46 | "SYMBOL is a mangled name.\n" | |
0e9cab87 | 47 | << endl; |
747d0967 BK |
48 | exit(1); |
49 | } | |
4b260c20 BK |
50 | |
51 | if (argv1.find("--check") != string::npos) | |
52 | { | |
53 | bool verbose = false; | |
54 | if (argv1 == "--check-verbose") | |
55 | verbose = true; | |
56 | ||
57 | // Quick sanity/setup check for arguments. | |
58 | const char* test_file = argv[2]; | |
59 | const char* baseline_file = argv[3]; | |
60 | if (access(test_file, R_OK) != 0) | |
747d0967 | 61 | { |
4b260c20 BK |
62 | cerr << "Cannot read symbols file " << test_file |
63 | << ", did you forget to build first?" << endl; | |
64 | exit(1); | |
747d0967 | 65 | } |
4b260c20 BK |
66 | if (access(baseline_file, R_OK) != 0) |
67 | { | |
68 | cerr << "Cannot read baseline file " << baseline_file << endl; | |
69 | exit(1); | |
70 | } | |
fdbba6bc MM |
71 | if (!compare_symbols(baseline_file, test_file, verbose)) |
72 | exit (1); | |
747d0967 | 73 | } |
e7bb3511 | 74 | |
4b260c20 | 75 | if (argv1 == "--examine") |
e7bb3511 | 76 | { |
4b260c20 BK |
77 | const char* file = argv[3]; |
78 | if (access(file, R_OK) != 0) | |
e7bb3511 | 79 | { |
4b260c20 BK |
80 | cerr << "Cannot read symbol file " << file << endl; |
81 | exit(1); | |
e7bb3511 | 82 | } |
4b260c20 | 83 | examine_symbol(argv[2], file); |
e7bb3511 | 84 | } |
747d0967 BK |
85 | return 0; |
86 | } |