3 Copyright (C) 2014-2022 Free Software Foundation, Inc.
5 This file is part of GNU libiberty.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
30 static char *program_name
;
32 #define DEFAULT_MAXCOUNT 7500000
35 print_usage (FILE *fp
, int exit_value
)
37 fprintf (fp
, "Usage: %s [OPTION]...\n", program_name
);
38 fprintf (fp
, "Options:\n");
39 fprintf (fp
, " -h Display this message.\n");
40 fprintf (fp
, " -s SEED Select the random seed to be used.\n");
41 fprintf (fp
, " The default is to base one on the");
42 fprintf (fp
, " current time.\n");
43 fprintf (fp
, " -m MAXCOUNT Exit after MAXCOUNT symbols.\n");
44 fprintf (fp
, " The default is %d.", DEFAULT_MAXCOUNT
);
45 fprintf (fp
, " Set to `-1' for no limit.\n");
51 main (int argc
, char *argv
[])
53 char symbol
[2 + MAXLEN
+ 1] = "_Z";
54 int seed
= -1, seed_set
= 0;
55 int count
= 0, maxcount
= DEFAULT_MAXCOUNT
;
58 program_name
= argv
[0];
62 optchr
= getopt (argc
, argv
, "hs:m:t:");
65 case '?': /* Unrecognized option. */
66 print_usage (stderr
, 1);
70 print_usage (stdout
, 0);
79 maxcount
= atoi (optarg
);
88 printf ("%s: seed = %d\n", program_name
, seed
);
90 while (maxcount
< 0 || count
< maxcount
)
92 char *buffer
= symbol
+ 2;
95 length
= rand () % MAXLEN
;
96 for (i
= 0; i
< length
; i
++)
97 *buffer
++ = (rand () % (ALPMAX
- ALPMIN
)) + ALPMIN
;
101 cplus_demangle (symbol
, DMGL_AUTO
| DMGL_ANSI
| DMGL_PARAMS
);
106 printf ("%s: successfully demangled %d symbols\n", program_name
, count
);