3 // Copyright (C) 2004, 2005, 2006, 2007 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 2, 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 COPYING. If not, write to
17 // the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
18 // MA 02110-1301, USA.
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
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.
34 #include "testsuite_abi.h"
37 #include <unistd.h> // for access(2)
40 main(int argc
, char** argv
)
44 // Get arguments. (Heading towards getopt_long, I can feel it.)
45 string argv1
= argc
> 1 ? argv
[1] : "";
46 if (argv1
== "--help" || argc
< 4)
48 cerr
<< "usage: abi_check --check current baseline\n"
49 " --check-verbose current baseline\n"
50 " --examine symbol current\n"
53 "All arguments are string literals.\n"
54 "CURRENT is a file generated byextract_symvers.\n"
55 "BASELINE is a file from config/abi.\n"
56 "SYMBOL is a mangled name.\n"
61 if (argv1
.find("--check") != string::npos
)
64 if (argv1
== "--check-verbose")
67 // Quick sanity/setup check for arguments.
68 const char* test_file
= argv
[2];
69 const char* baseline_file
= argv
[3];
70 if (access(test_file
, R_OK
) != 0)
72 cerr
<< "Cannot read symbols file " << test_file
73 << ", did you forget to build first?" << endl
;
76 if (access(baseline_file
, R_OK
) != 0)
78 cerr
<< "Cannot read baseline file " << baseline_file
<< endl
;
81 if (!compare_symbols(baseline_file
, test_file
, verbose
))
85 if (argv1
== "--examine")
87 const char* file
= argv
[3];
88 if (access(file
, R_OK
) != 0)
90 cerr
<< "Cannot read symbol file " << file
<< endl
;
93 examine_symbol(argv
[2], file
);