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