3 // Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
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 3, or (at
8 // your option) any later version.
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.
15 // You should have received a copy of the GNU General Public License
16 // along with this library; see the file COPYING3. If not see
17 // <http://www.gnu.org/licenses/>.
20 // Benjamin Kosnik <bkoz@redhat.com>
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.
24 #include "testsuite_abi.h"
27 #include <unistd.h> // for access(2)
30 main(int argc
, char** argv
)
34 // Get arguments. (Heading towards getopt_long, I can feel it.)
35 string argv1
= argc
> 1 ? argv
[1] : "";
36 if (argv1
== "--help" || argc
< 4)
38 cerr
<< "usage: abi_check --check current baseline\n"
39 " --check-verbose current baseline\n"
40 " --examine symbol current\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"
51 if (argv1
.find("--check") != string::npos
)
54 if (argv1
== "--check-verbose")
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)
62 cerr
<< "Cannot read symbols file " << test_file
63 << ", did you forget to build first?" << endl
;
66 if (access(baseline_file
, R_OK
) != 0)
68 cerr
<< "Cannot read baseline file " << baseline_file
<< endl
;
71 if (!compare_symbols(baseline_file
, test_file
, verbose
))
75 if (argv1
== "--examine")
77 const char* file
= argv
[3];
78 if (access(file
, R_OK
) != 0)
80 cerr
<< "Cannot read symbol file " << file
<< endl
;
83 examine_symbol(argv
[2], file
);