Commit | Line | Data |
---|---|---|
3d6c6501 SEF |
1 | /* |
2 | * Copyright (c) 1983 Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
6 | * provided that: (1) source distributions retain this entire copyright | |
7 | * notice and comment, and (2) distributions including binaries display | |
8 | * the following acknowledgement: ``This product includes software | |
9 | * developed by the University of California, Berkeley and its contributors'' | |
10 | * in the documentation or other materials provided with the distribution | |
11 | * and in all advertising materials mentioning features or use of this | |
12 | * software. Neither the name of the University nor the names of its | |
13 | * contributors may be used to endorse or promote products derived | |
14 | * from this software without specific prior written permission. | |
15 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
18 | */ | |
5489fcc3 KR |
19 | #include "getopt.h" |
20 | #include "libiberty.h" | |
21 | #include "gprof.h" | |
22 | #include "basic_blocks.h" | |
23 | #include "call_graph.h" | |
24 | #include "cg_arcs.h" | |
25 | #include "cg_print.h" | |
26 | #include "core.h" | |
27 | #include "gmon_io.h" | |
28 | #include "hertz.h" | |
29 | #include "hist.h" | |
30 | #include "source.h" | |
31 | #include "sym_ids.h" | |
32 | ||
5489fcc3 | 33 | const char *whoami; |
64c50fc5 | 34 | const char *function_mapping_file; |
5489fcc3 KR |
35 | const char *a_out_name = A_OUTNAME; |
36 | long hz = HZ_WRONG; | |
3d6c6501 | 37 | |
5489fcc3 KR |
38 | /* |
39 | * Default options values: | |
40 | */ | |
41 | int debug_level = 0; | |
42 | int output_style = 0; | |
43 | int output_width = 80; | |
44 | bool bsd_style_output = FALSE; | |
e4dee78c | 45 | bool demangle = TRUE; |
5489fcc3 KR |
46 | bool discard_underscores = TRUE; |
47 | bool ignore_direct_calls = FALSE; | |
48 | bool ignore_static_funcs = FALSE; | |
49 | bool ignore_zeros = TRUE; | |
50 | bool line_granularity = FALSE; | |
51 | bool print_descriptions = TRUE; | |
52 | bool print_path = FALSE; | |
32843f94 | 53 | bool ignore_non_functions = FALSE; |
5489fcc3 KR |
54 | File_Format file_format = FF_AUTO; |
55 | ||
56 | bool first_output = TRUE; | |
b4f476e9 | 57 | |
3d6c6501 SEF |
58 | char copyright[] = |
59 | "@(#) Copyright (c) 1983 Regents of the University of California.\n\ | |
60 | All rights reserved.\n"; | |
3d6c6501 | 61 | |
12516a37 | 62 | static char *gmon_name = GMONNAME; /* profile filename */ |
c06e55d9 | 63 | |
12516a37 | 64 | bfd *abfd; |
77c9b2c3 | 65 | |
5489fcc3 KR |
66 | /* |
67 | * Functions that get excluded by default: | |
68 | */ | |
12516a37 KR |
69 | static char *default_excluded_list[] = |
70 | { | |
c3de2a19 ILT |
71 | "_gprof_mcount", "mcount", "_mcount", "__mcount", "__mcount_internal", |
72 | "__mcleanup", | |
12516a37 KR |
73 | "<locore>", "<hicore>", |
74 | 0 | |
5489fcc3 | 75 | }; |
3d6c6501 | 76 | |
e4dee78c ILT |
77 | /* Codes used for the long options with no short synonyms. 150 isn't |
78 | special; it's just an arbitrary non-ASCII char value. */ | |
79 | ||
80 | #define OPTION_DEMANGLE (150) | |
81 | #define OPTION_NO_DEMANGLE (OPTION_DEMANGLE + 1) | |
82 | ||
5489fcc3 KR |
83 | static struct option long_options[] = |
84 | { | |
12516a37 KR |
85 | {"line", no_argument, 0, 'l'}, |
86 | {"no-static", no_argument, 0, 'a'}, | |
32843f94 | 87 | {"ignore-non-functions", no_argument, 0, 'D'}, |
5489fcc3 KR |
88 | |
89 | /* output styles: */ | |
90 | ||
12516a37 KR |
91 | {"annotated-source", optional_argument, 0, 'A'}, |
92 | {"no-annotated-source", optional_argument, 0, 'J'}, | |
93 | {"flat-profile", optional_argument, 0, 'p'}, | |
94 | {"no-flat-profile", optional_argument, 0, 'P'}, | |
95 | {"graph", optional_argument, 0, 'q'}, | |
96 | {"no-graph", optional_argument, 0, 'Q'}, | |
97 | {"exec-counts", optional_argument, 0, 'C'}, | |
98 | {"no-exec-counts", optional_argument, 0, 'Z'}, | |
64c50fc5 JL |
99 | {"function-ordering", no_argument, 0, 'r'}, |
100 | {"file-ordering", required_argument, 0, 'R'}, | |
12516a37 KR |
101 | {"file-info", no_argument, 0, 'i'}, |
102 | {"sum", no_argument, 0, 's'}, | |
5489fcc3 KR |
103 | |
104 | /* various options to affect output: */ | |
105 | ||
12516a37 | 106 | {"all-lines", no_argument, 0, 'x'}, |
e4dee78c ILT |
107 | {"demangle", no_argument, 0, OPTION_DEMANGLE}, |
108 | {"no-demangle", no_argument, 0, OPTION_NO_DEMANGLE}, | |
12516a37 KR |
109 | {"directory-path", required_argument, 0, 'I'}, |
110 | {"display-unused-functions", no_argument, 0, 'z'}, | |
111 | {"min-count", required_argument, 0, 'm'}, | |
112 | {"print-path", no_argument, 0, 'L'}, | |
113 | {"separate-files", no_argument, 0, 'y'}, | |
114 | {"static-call-graph", no_argument, 0, 'c'}, | |
115 | {"table-length", required_argument, 0, 't'}, | |
116 | {"time", required_argument, 0, 'n'}, | |
117 | {"no-time", required_argument, 0, 'N'}, | |
118 | {"width", required_argument, 0, 'w'}, | |
3d6c6501 | 119 | /* |
5489fcc3 KR |
120 | * These are for backwards-compatibility only. Their functionality |
121 | * is provided by the output style options already: | |
3d6c6501 | 122 | */ |
12516a37 KR |
123 | {"", required_argument, 0, 'e'}, |
124 | {"", required_argument, 0, 'E'}, | |
125 | {"", required_argument, 0, 'f'}, | |
126 | {"", required_argument, 0, 'F'}, | |
127 | {"", required_argument, 0, 'k'}, | |
5489fcc3 KR |
128 | |
129 | /* miscellaneous: */ | |
130 | ||
12516a37 KR |
131 | {"brief", no_argument, 0, 'b'}, |
132 | {"debug", optional_argument, 0, 'd'}, | |
133 | {"help", no_argument, 0, 'h'}, | |
134 | {"file-format", required_argument, 0, 'O'}, | |
135 | {"traditional", no_argument, 0, 'T'}, | |
136 | {"version", no_argument, 0, 'v'}, | |
137 | {0, no_argument, 0, 0} | |
5489fcc3 KR |
138 | }; |
139 | ||
140 | ||
141 | static void | |
12516a37 | 142 | DEFUN (usage, (stream, status), FILE * stream AND int status) |
5489fcc3 | 143 | { |
12516a37 | 144 | fprintf (stream, "\ |
32843f94 | 145 | Usage: %s [-[abcDhilLsTvwxyz]] [-[ACeEfFJnNOpPqQZ][name]] [-I dirs]\n\ |
5489fcc3 KR |
146 | [-d[num]] [-k from/to] [-m min-count] [-t table-length]\n\ |
147 | [--[no-]annotated-source[=name]] [--[no-]exec-counts[=name]]\n\ | |
148 | [--[no-]flat-profile[=name]] [--[no-]graph[=name]]\n\ | |
149 | [--[no-]time=name] [--all-lines] [--brief] [--debug[=level]]\n\ | |
64c50fc5 | 150 | [--function-ordering] [--file-ordering]\n\ |
5489fcc3 KR |
151 | [--directory-path=dirs] [--display-unused-functions]\n\ |
152 | [--file-format=name] [--file-info] [--help] [--line] [--min-count=n]\n\ | |
153 | [--no-static] [--print-path] [--separate-files]\n\ | |
154 | [--static-call-graph] [--sum] [--table-length=len] [--traditional]\n\ | |
32843f94 | 155 | [--version] [--width=n] [--ignore-non-functions]\n\ |
e4dee78c | 156 | [--demangle] [--no-demangle]\n\ |
5489fcc3 | 157 | [image-file] [profile-file...]\n", |
12516a37 | 158 | whoami); |
50622dea | 159 | if (status == 0) |
6590e0d5 | 160 | fprintf (stream, "Report bugs to bug-gnu-utils@gnu.org\n"); |
12516a37 | 161 | done (status); |
03c35bcb | 162 | } |
5489fcc3 KR |
163 | |
164 | ||
165 | int | |
12516a37 | 166 | DEFUN (main, (argc, argv), int argc AND char **argv) |
3d6c6501 | 167 | { |
12516a37 KR |
168 | char **sp, *str; |
169 | Sym **cg = 0; | |
170 | int ch, user_specified = 0; | |
3d6c6501 | 171 | |
12516a37 KR |
172 | whoami = argv[0]; |
173 | xmalloc_set_program_name (whoami); | |
5489fcc3 | 174 | |
12516a37 | 175 | while ((ch = getopt_long (argc, argv, |
32843f94 | 176 | "aA::bBcCdD::e:E:f:F:hiI:J::k:lLm:n::N::O:p::P::q::Q::st:Tvw:xyzZ::", |
12516a37 KR |
177 | long_options, 0)) |
178 | != EOF) | |
5489fcc3 | 179 | { |
12516a37 KR |
180 | switch (ch) |
181 | { | |
182 | case 'a': | |
183 | ignore_static_funcs = TRUE; | |
184 | break; | |
185 | case 'A': | |
186 | if (optarg) | |
187 | { | |
188 | sym_id_add (optarg, INCL_ANNO); | |
03c35bcb | 189 | } |
12516a37 KR |
190 | output_style |= STYLE_ANNOTATED_SOURCE; |
191 | user_specified |= STYLE_ANNOTATED_SOURCE; | |
192 | break; | |
193 | case 'b': | |
194 | print_descriptions = FALSE; | |
195 | break; | |
196 | case 'B': | |
197 | output_style |= STYLE_CALL_GRAPH; | |
198 | user_specified |= STYLE_CALL_GRAPH; | |
199 | break; | |
200 | case 'c': | |
201 | ignore_direct_calls = TRUE; | |
202 | break; | |
203 | case 'C': | |
204 | if (optarg) | |
205 | { | |
206 | sym_id_add (optarg, INCL_EXEC); | |
03c35bcb | 207 | } |
12516a37 KR |
208 | output_style |= STYLE_EXEC_COUNTS; |
209 | user_specified |= STYLE_EXEC_COUNTS; | |
210 | break; | |
211 | case 'd': | |
212 | if (optarg) | |
213 | { | |
214 | debug_level |= atoi (optarg); | |
215 | debug_level |= ANYDEBUG; | |
216 | } | |
217 | else | |
218 | { | |
219 | debug_level = ~0; | |
03c35bcb | 220 | } |
12516a37 | 221 | DBG (ANYDEBUG, printf ("[main] debug-level=0x%x\n", debug_level)); |
5489fcc3 | 222 | #ifndef DEBUG |
12516a37 KR |
223 | printf ("%s: debugging not supported; -d ignored\n", whoami); |
224 | #endif /* DEBUG */ | |
225 | break; | |
32843f94 JL |
226 | case 'D': |
227 | ignore_non_functions = TRUE; | |
228 | break; | |
12516a37 KR |
229 | case 'E': |
230 | sym_id_add (optarg, EXCL_TIME); | |
231 | case 'e': | |
232 | sym_id_add (optarg, EXCL_GRAPH); | |
233 | break; | |
234 | case 'F': | |
235 | sym_id_add (optarg, INCL_TIME); | |
236 | case 'f': | |
237 | sym_id_add (optarg, INCL_GRAPH); | |
238 | break; | |
239 | case 'g': | |
240 | sym_id_add (optarg, EXCL_FLAT); | |
241 | break; | |
242 | case 'G': | |
243 | sym_id_add (optarg, INCL_FLAT); | |
244 | break; | |
245 | case 'h': | |
246 | usage (stdout, 0); | |
247 | case 'i': | |
248 | output_style |= STYLE_GMON_INFO; | |
249 | user_specified |= STYLE_GMON_INFO; | |
250 | break; | |
251 | case 'I': | |
252 | search_list_append (&src_search_list, optarg); | |
253 | break; | |
254 | case 'J': | |
255 | if (optarg) | |
256 | { | |
257 | sym_id_add (optarg, EXCL_ANNO); | |
258 | output_style |= STYLE_ANNOTATED_SOURCE; | |
259 | } | |
260 | else | |
261 | { | |
262 | output_style &= ~STYLE_ANNOTATED_SOURCE; | |
03c35bcb | 263 | } |
12516a37 KR |
264 | user_specified |= STYLE_ANNOTATED_SOURCE; |
265 | break; | |
266 | case 'k': | |
267 | sym_id_add (optarg, EXCL_ARCS); | |
268 | break; | |
269 | case 'l': | |
270 | line_granularity = TRUE; | |
271 | break; | |
272 | case 'L': | |
273 | print_path = TRUE; | |
274 | break; | |
275 | case 'm': | |
276 | bb_min_calls = atoi (optarg); | |
277 | break; | |
278 | case 'n': | |
279 | sym_id_add (optarg, INCL_TIME); | |
280 | break; | |
281 | case 'N': | |
282 | sym_id_add (optarg, EXCL_TIME); | |
283 | break; | |
284 | case 'O': | |
285 | switch (optarg[0]) | |
286 | { | |
287 | case 'a': | |
288 | file_format = FF_AUTO; | |
289 | break; | |
290 | case 'm': | |
291 | file_format = FF_MAGIC; | |
292 | break; | |
293 | case 'b': | |
294 | file_format = FF_BSD; | |
295 | break; | |
296 | case 'p': | |
297 | file_format = FF_PROF; | |
298 | break; | |
299 | default: | |
300 | fprintf (stderr, "%s: unknown file format %s\n", | |
301 | optarg, whoami); | |
302 | done (1); | |
03c35bcb | 303 | } |
12516a37 KR |
304 | break; |
305 | case 'p': | |
306 | if (optarg) | |
307 | { | |
308 | sym_id_add (optarg, INCL_FLAT); | |
03c35bcb | 309 | } |
12516a37 KR |
310 | output_style |= STYLE_FLAT_PROFILE; |
311 | user_specified |= STYLE_FLAT_PROFILE; | |
312 | break; | |
313 | case 'P': | |
314 | if (optarg) | |
315 | { | |
316 | sym_id_add (optarg, EXCL_FLAT); | |
317 | output_style |= STYLE_FLAT_PROFILE; | |
318 | } | |
319 | else | |
320 | { | |
321 | output_style &= ~STYLE_FLAT_PROFILE; | |
03c35bcb | 322 | } |
12516a37 KR |
323 | user_specified |= STYLE_FLAT_PROFILE; |
324 | break; | |
325 | case 'q': | |
326 | if (optarg) | |
327 | { | |
328 | if (strchr (optarg, '/')) | |
329 | { | |
330 | sym_id_add (optarg, INCL_ARCS); | |
331 | } | |
332 | else | |
333 | { | |
334 | sym_id_add (optarg, INCL_GRAPH); | |
03c35bcb KR |
335 | } |
336 | } | |
12516a37 KR |
337 | output_style |= STYLE_CALL_GRAPH; |
338 | user_specified |= STYLE_CALL_GRAPH; | |
339 | break; | |
64c50fc5 JL |
340 | case 'r': |
341 | output_style |= STYLE_FUNCTION_ORDER; | |
342 | user_specified |= STYLE_FUNCTION_ORDER; | |
343 | break; | |
344 | case 'R': | |
345 | output_style |= STYLE_FILE_ORDER; | |
346 | user_specified |= STYLE_FILE_ORDER; | |
347 | function_mapping_file = optarg; | |
348 | break; | |
12516a37 KR |
349 | case 'Q': |
350 | if (optarg) | |
351 | { | |
352 | if (strchr (optarg, '/')) | |
353 | { | |
354 | sym_id_add (optarg, EXCL_ARCS); | |
355 | } | |
356 | else | |
357 | { | |
358 | sym_id_add (optarg, EXCL_GRAPH); | |
03c35bcb | 359 | } |
12516a37 KR |
360 | output_style |= STYLE_CALL_GRAPH; |
361 | } | |
362 | else | |
363 | { | |
364 | output_style &= ~STYLE_CALL_GRAPH; | |
03c35bcb | 365 | } |
12516a37 KR |
366 | user_specified |= STYLE_CALL_GRAPH; |
367 | break; | |
368 | case 's': | |
369 | output_style |= STYLE_SUMMARY_FILE; | |
370 | user_specified |= STYLE_SUMMARY_FILE; | |
371 | break; | |
372 | case 't': | |
373 | bb_table_length = atoi (optarg); | |
374 | if (bb_table_length < 0) | |
375 | { | |
376 | bb_table_length = 0; | |
03c35bcb | 377 | } |
12516a37 KR |
378 | break; |
379 | case 'T': | |
380 | bsd_style_output = TRUE; | |
381 | break; | |
382 | case 'v': | |
50622dea ILT |
383 | /* This output is intended to follow the GNU standards document. */ |
384 | printf ("GNU gprof %s\n", VERSION); | |
d2ee1370 | 385 | printf ("Based on BSD gprof, copyright 1983 Regents of the University of California.\n"); |
50622dea | 386 | printf ("\ |
d2ee1370 | 387 | This program is free software. This program has absolutely no warranty.\n"); |
12516a37 KR |
388 | done (0); |
389 | case 'w': | |
390 | output_width = atoi (optarg); | |
391 | if (output_width < 1) | |
392 | { | |
393 | output_width = 1; | |
03c35bcb | 394 | } |
12516a37 KR |
395 | break; |
396 | case 'x': | |
397 | bb_annotate_all_lines = TRUE; | |
398 | break; | |
399 | case 'y': | |
400 | create_annotation_files = TRUE; | |
401 | break; | |
402 | case 'z': | |
403 | ignore_zeros = FALSE; | |
404 | break; | |
405 | case 'Z': | |
406 | if (optarg) | |
407 | { | |
408 | sym_id_add (optarg, EXCL_EXEC); | |
409 | output_style |= STYLE_EXEC_COUNTS; | |
410 | } | |
411 | else | |
412 | { | |
413 | output_style &= ~STYLE_EXEC_COUNTS; | |
03c35bcb | 414 | } |
12516a37 KR |
415 | user_specified |= STYLE_ANNOTATED_SOURCE; |
416 | break; | |
e4dee78c ILT |
417 | case OPTION_DEMANGLE: |
418 | demangle = TRUE; | |
419 | break; | |
420 | case OPTION_NO_DEMANGLE: | |
421 | demangle = FALSE; | |
422 | break; | |
12516a37 KR |
423 | default: |
424 | usage (stderr, 1); | |
03c35bcb KR |
425 | } |
426 | } | |
12516a37 | 427 | |
64c50fc5 JL |
428 | /* Don't allow both ordering options, they modify the arc data in-place. */ |
429 | if ((user_specified & STYLE_FUNCTION_ORDER) | |
430 | && (user_specified & STYLE_FILE_ORDER)) | |
431 | { | |
432 | fprintf (stderr,"\ | |
433 | %s: Only one of --function-ordering and --file-ordering may be specified.\n", | |
434 | whoami); | |
435 | done (1); | |
436 | } | |
437 | ||
7862d7d0 ILT |
438 | /* --sum implies --line, otherwise we'd lose b-b counts in gmon.sum */ |
439 | if (output_style & STYLE_SUMMARY_FILE) | |
440 | { | |
441 | line_granularity = 1; | |
442 | } | |
443 | ||
12516a37 | 444 | /* append value of GPROF_PATH to source search list if set: */ |
31af2d7e | 445 | str = (char *) getenv ("GPROF_PATH"); |
12516a37 KR |
446 | if (str) |
447 | { | |
448 | search_list_append (&src_search_list, str); | |
03c35bcb | 449 | } |
3d6c6501 | 450 | |
12516a37 KR |
451 | if (optind < argc) |
452 | { | |
453 | a_out_name = argv[optind++]; | |
03c35bcb | 454 | } |
12516a37 KR |
455 | if (optind < argc) |
456 | { | |
457 | gmon_name = argv[optind++]; | |
03c35bcb | 458 | } |
12516a37 KR |
459 | |
460 | /* | |
461 | * Turn off default functions: | |
462 | */ | |
463 | for (sp = &default_excluded_list[0]; *sp; sp++) | |
464 | { | |
465 | sym_id_add (*sp, EXCL_TIME); | |
466 | sym_id_add (*sp, EXCL_GRAPH); | |
0f579087 | 467 | #ifdef __alpha__ |
12516a37 | 468 | sym_id_add (*sp, EXCL_FLAT); |
5489fcc3 | 469 | #endif |
03c35bcb | 470 | } |
5489fcc3 | 471 | |
12516a37 KR |
472 | /* |
473 | * For line-by-line profiling, also want to keep those | |
474 | * functions off the flat profile: | |
475 | */ | |
476 | if (line_granularity) | |
477 | { | |
478 | for (sp = &default_excluded_list[0]; *sp; sp++) | |
479 | { | |
480 | sym_id_add (*sp, EXCL_FLAT); | |
03c35bcb KR |
481 | } |
482 | } | |
12516a37 KR |
483 | |
484 | /* | |
485 | * Read symbol table from core file: | |
486 | */ | |
487 | core_init (a_out_name); | |
488 | ||
489 | /* | |
490 | * If we should ignore direct function calls, we need to load | |
491 | * to core's text-space: | |
492 | */ | |
493 | if (ignore_direct_calls) | |
494 | { | |
495 | core_get_text_space (core_bfd); | |
03c35bcb | 496 | } |
3d6c6501 | 497 | |
12516a37 KR |
498 | /* |
499 | * Create symbols from core image: | |
500 | */ | |
501 | if (line_granularity) | |
502 | { | |
503 | core_create_line_syms (core_bfd); | |
504 | } | |
505 | else | |
506 | { | |
507 | core_create_function_syms (core_bfd); | |
03c35bcb | 508 | } |
3d6c6501 | 509 | |
12516a37 KR |
510 | /* |
511 | * Translate sym specs into syms: | |
512 | */ | |
513 | sym_id_parse (); | |
3d6c6501 | 514 | |
12516a37 KR |
515 | if (file_format == FF_PROF) |
516 | { | |
5489fcc3 | 517 | #ifdef PROF_SUPPORT_IMPLEMENTED |
12516a37 KR |
518 | /* |
519 | * Get information about mon.out file(s): | |
520 | */ | |
521 | do | |
522 | { | |
523 | mon_out_read (gmon_name); | |
524 | if (optind < argc) | |
525 | { | |
526 | gmon_name = argv[optind]; | |
03c35bcb | 527 | } |
12516a37 KR |
528 | } |
529 | while (optind++ < argc); | |
5489fcc3 | 530 | #else |
12516a37 KR |
531 | fprintf (stderr, |
532 | "%s: sorry, file format `prof' is not yet supported\n", | |
533 | whoami); | |
534 | done (1); | |
811e3c6a | 535 | #endif |
12516a37 KR |
536 | } |
537 | else | |
538 | { | |
539 | /* | |
540 | * Get information about gmon.out file(s): | |
541 | */ | |
542 | do | |
543 | { | |
544 | gmon_out_read (gmon_name); | |
545 | if (optind < argc) | |
546 | { | |
547 | gmon_name = argv[optind]; | |
03c35bcb | 548 | } |
12516a37 KR |
549 | } |
550 | while (optind++ < argc); | |
03c35bcb | 551 | } |
12516a37 KR |
552 | |
553 | /* | |
554 | * If user did not specify output style, try to guess something | |
555 | * reasonable: | |
556 | */ | |
557 | if (output_style == 0) | |
558 | { | |
559 | if (gmon_input & (INPUT_HISTOGRAM | INPUT_CALL_GRAPH)) | |
560 | { | |
561 | output_style = STYLE_FLAT_PROFILE | STYLE_CALL_GRAPH; | |
562 | } | |
563 | else | |
564 | { | |
565 | output_style = STYLE_EXEC_COUNTS; | |
03c35bcb | 566 | } |
12516a37 | 567 | output_style &= ~user_specified; |
03c35bcb | 568 | } |
12516a37 KR |
569 | |
570 | /* | |
571 | * Dump a gmon.sum file if requested (before any other processing!): | |
572 | */ | |
573 | if (output_style & STYLE_SUMMARY_FILE) | |
574 | { | |
575 | gmon_out_write (GMONSUM); | |
03c35bcb | 576 | } |
4b8250bd | 577 | |
12516a37 KR |
578 | if (gmon_input & INPUT_HISTOGRAM) |
579 | { | |
580 | hist_assign_samples (); | |
03c35bcb | 581 | } |
2ea5f325 | 582 | |
12516a37 KR |
583 | if (gmon_input & INPUT_CALL_GRAPH) |
584 | { | |
585 | cg = cg_assemble (); | |
03c35bcb | 586 | } |
12516a37 KR |
587 | |
588 | /* do some simple sanity checks: */ | |
589 | ||
590 | if ((output_style & STYLE_FLAT_PROFILE) | |
591 | && !(gmon_input & INPUT_HISTOGRAM)) | |
592 | { | |
593 | fprintf (stderr, "%s: gmon.out file is missing histogram\n", whoami); | |
594 | done (1); | |
03c35bcb | 595 | } |
5489fcc3 | 596 | |
12516a37 KR |
597 | if ((output_style & STYLE_CALL_GRAPH) && !(gmon_input & INPUT_CALL_GRAPH)) |
598 | { | |
599 | fprintf (stderr, | |
600 | "%s: gmon.out file is missing call-graph data\n", whoami); | |
601 | done (1); | |
03c35bcb | 602 | } |
5489fcc3 | 603 | |
12516a37 | 604 | /* output whatever user whishes to see: */ |
5489fcc3 | 605 | |
12516a37 KR |
606 | if (cg && (output_style & STYLE_CALL_GRAPH) && bsd_style_output) |
607 | { | |
608 | cg_print (cg); /* print the dynamic profile */ | |
03c35bcb | 609 | } |
5489fcc3 | 610 | |
12516a37 KR |
611 | if (output_style & STYLE_FLAT_PROFILE) |
612 | { | |
613 | hist_print (); /* print the flat profile */ | |
03c35bcb | 614 | } |
12516a37 KR |
615 | |
616 | if (cg && (output_style & STYLE_CALL_GRAPH)) | |
617 | { | |
618 | if (!bsd_style_output) | |
619 | { | |
620 | cg_print (cg); /* print the dynamic profile */ | |
03c35bcb | 621 | } |
12516a37 | 622 | cg_print_index (); |
03c35bcb | 623 | } |
12516a37 KR |
624 | |
625 | if (output_style & STYLE_EXEC_COUNTS) | |
5489fcc3 | 626 | { |
12516a37 | 627 | print_exec_counts (); |
03c35bcb | 628 | } |
5489fcc3 | 629 | |
12516a37 | 630 | if (output_style & STYLE_ANNOTATED_SOURCE) |
5489fcc3 | 631 | { |
12516a37 | 632 | print_annotated_source (); |
03c35bcb | 633 | } |
64c50fc5 JL |
634 | if (output_style & STYLE_FUNCTION_ORDER) |
635 | { | |
636 | cg_print_function_ordering (); | |
637 | } | |
638 | if (output_style & STYLE_FILE_ORDER) | |
639 | { | |
640 | cg_print_file_ordering (); | |
641 | } | |
12516a37 | 642 | return 0; |
3d6c6501 SEF |
643 | } |
644 | ||
5489fcc3 KR |
645 | void |
646 | done (status) | |
647 | int status; | |
3d6c6501 | 648 | { |
12516a37 | 649 | exit (status); |
3d6c6501 | 650 | } |