3 // Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston,
18 // MA 02111-1307, 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"
36 #include <unistd.h> // for access(2)
39 main(int argc
, char** argv
)
43 // Get arguments. (Heading towards getopt_long, I can feel it.)
44 string argv1
= argc
> 1 ? argv
[1] : "";
45 if (argv1
== "--help" || argc
< 4)
47 cerr
<< "usage: abi_check --check current baseline\n"
48 " --check-verbose current baseline\n"
49 " --examine symbol current\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"
60 if (argv1
.find("--check") != string::npos
)
63 if (argv1
== "--check-verbose")
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)
71 cerr
<< "Cannot read symbols file " << test_file
72 << ", did you forget to build first?" << endl
;
75 if (access(baseline_file
, R_OK
) != 0)
77 cerr
<< "Cannot read baseline file " << baseline_file
<< endl
;
80 compare_symbols(baseline_file
, test_file
, verbose
);
83 if (argv1
== "--examine")
85 const char* file
= argv
[3];
86 if (access(file
, R_OK
) != 0)
88 cerr
<< "Cannot read symbol file " << file
<< endl
;
91 examine_symbol(argv
[2], file
);