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 | 149 | if (status == 0) |
6590e0d5 | 150 | fprintf (stream, "Report bugs to bug-gnu-utils@gnu.org\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 | ||
7862d7d0 ILT |
422 | /* --sum implies --line, otherwise we'd lose b-b counts in gmon.sum */ |
423 | if (output_style & STYLE_SUMMARY_FILE) | |
424 | { | |
425 | line_granularity = 1; | |
426 | } | |
427 | ||
12516a37 | 428 | /* append value of GPROF_PATH to source search list if set: */ |
31af2d7e | 429 | str = (char *) getenv ("GPROF_PATH"); |
12516a37 KR |
430 | if (str) |
431 | { | |
432 | search_list_append (&src_search_list, str); | |
03c35bcb | 433 | } |
3d6c6501 | 434 | |
12516a37 KR |
435 | if (optind < argc) |
436 | { | |
437 | a_out_name = argv[optind++]; | |
03c35bcb | 438 | } |
12516a37 KR |
439 | if (optind < argc) |
440 | { | |
441 | gmon_name = argv[optind++]; | |
03c35bcb | 442 | } |
12516a37 KR |
443 | |
444 | /* | |
445 | * Turn off default functions: | |
446 | */ | |
447 | for (sp = &default_excluded_list[0]; *sp; sp++) | |
448 | { | |
449 | sym_id_add (*sp, EXCL_TIME); | |
450 | sym_id_add (*sp, EXCL_GRAPH); | |
0f579087 | 451 | #ifdef __alpha__ |
12516a37 | 452 | sym_id_add (*sp, EXCL_FLAT); |
5489fcc3 | 453 | #endif |
03c35bcb | 454 | } |
5489fcc3 | 455 | |
12516a37 KR |
456 | /* |
457 | * For line-by-line profiling, also want to keep those | |
458 | * functions off the flat profile: | |
459 | */ | |
460 | if (line_granularity) | |
461 | { | |
462 | for (sp = &default_excluded_list[0]; *sp; sp++) | |
463 | { | |
464 | sym_id_add (*sp, EXCL_FLAT); | |
03c35bcb KR |
465 | } |
466 | } | |
12516a37 KR |
467 | |
468 | /* | |
469 | * Read symbol table from core file: | |
470 | */ | |
471 | core_init (a_out_name); | |
472 | ||
473 | /* | |
474 | * If we should ignore direct function calls, we need to load | |
475 | * to core's text-space: | |
476 | */ | |
477 | if (ignore_direct_calls) | |
478 | { | |
479 | core_get_text_space (core_bfd); | |
03c35bcb | 480 | } |
3d6c6501 | 481 | |
12516a37 KR |
482 | /* |
483 | * Create symbols from core image: | |
484 | */ | |
485 | if (line_granularity) | |
486 | { | |
487 | core_create_line_syms (core_bfd); | |
488 | } | |
489 | else | |
490 | { | |
491 | core_create_function_syms (core_bfd); | |
03c35bcb | 492 | } |
3d6c6501 | 493 | |
12516a37 KR |
494 | /* |
495 | * Translate sym specs into syms: | |
496 | */ | |
497 | sym_id_parse (); | |
3d6c6501 | 498 | |
12516a37 KR |
499 | if (file_format == FF_PROF) |
500 | { | |
5489fcc3 | 501 | #ifdef PROF_SUPPORT_IMPLEMENTED |
12516a37 KR |
502 | /* |
503 | * Get information about mon.out file(s): | |
504 | */ | |
505 | do | |
506 | { | |
507 | mon_out_read (gmon_name); | |
508 | if (optind < argc) | |
509 | { | |
510 | gmon_name = argv[optind]; | |
03c35bcb | 511 | } |
12516a37 KR |
512 | } |
513 | while (optind++ < argc); | |
5489fcc3 | 514 | #else |
12516a37 KR |
515 | fprintf (stderr, |
516 | "%s: sorry, file format `prof' is not yet supported\n", | |
517 | whoami); | |
518 | done (1); | |
811e3c6a | 519 | #endif |
12516a37 KR |
520 | } |
521 | else | |
522 | { | |
523 | /* | |
524 | * Get information about gmon.out file(s): | |
525 | */ | |
526 | do | |
527 | { | |
528 | gmon_out_read (gmon_name); | |
529 | if (optind < argc) | |
530 | { | |
531 | gmon_name = argv[optind]; | |
03c35bcb | 532 | } |
12516a37 KR |
533 | } |
534 | while (optind++ < argc); | |
03c35bcb | 535 | } |
12516a37 KR |
536 | |
537 | /* | |
538 | * If user did not specify output style, try to guess something | |
539 | * reasonable: | |
540 | */ | |
541 | if (output_style == 0) | |
542 | { | |
543 | if (gmon_input & (INPUT_HISTOGRAM | INPUT_CALL_GRAPH)) | |
544 | { | |
545 | output_style = STYLE_FLAT_PROFILE | STYLE_CALL_GRAPH; | |
546 | } | |
547 | else | |
548 | { | |
549 | output_style = STYLE_EXEC_COUNTS; | |
03c35bcb | 550 | } |
12516a37 | 551 | output_style &= ~user_specified; |
03c35bcb | 552 | } |
12516a37 KR |
553 | |
554 | /* | |
555 | * Dump a gmon.sum file if requested (before any other processing!): | |
556 | */ | |
557 | if (output_style & STYLE_SUMMARY_FILE) | |
558 | { | |
559 | gmon_out_write (GMONSUM); | |
03c35bcb | 560 | } |
4b8250bd | 561 | |
12516a37 KR |
562 | if (gmon_input & INPUT_HISTOGRAM) |
563 | { | |
564 | hist_assign_samples (); | |
03c35bcb | 565 | } |
2ea5f325 | 566 | |
12516a37 KR |
567 | if (gmon_input & INPUT_CALL_GRAPH) |
568 | { | |
569 | cg = cg_assemble (); | |
03c35bcb | 570 | } |
12516a37 KR |
571 | |
572 | /* do some simple sanity checks: */ | |
573 | ||
574 | if ((output_style & STYLE_FLAT_PROFILE) | |
575 | && !(gmon_input & INPUT_HISTOGRAM)) | |
576 | { | |
577 | fprintf (stderr, "%s: gmon.out file is missing histogram\n", whoami); | |
578 | done (1); | |
03c35bcb | 579 | } |
5489fcc3 | 580 | |
12516a37 KR |
581 | if ((output_style & STYLE_CALL_GRAPH) && !(gmon_input & INPUT_CALL_GRAPH)) |
582 | { | |
583 | fprintf (stderr, | |
584 | "%s: gmon.out file is missing call-graph data\n", whoami); | |
585 | done (1); | |
03c35bcb | 586 | } |
5489fcc3 | 587 | |
12516a37 | 588 | /* output whatever user whishes to see: */ |
5489fcc3 | 589 | |
12516a37 KR |
590 | if (cg && (output_style & STYLE_CALL_GRAPH) && bsd_style_output) |
591 | { | |
592 | cg_print (cg); /* print the dynamic profile */ | |
03c35bcb | 593 | } |
5489fcc3 | 594 | |
12516a37 KR |
595 | if (output_style & STYLE_FLAT_PROFILE) |
596 | { | |
597 | hist_print (); /* print the flat profile */ | |
03c35bcb | 598 | } |
12516a37 KR |
599 | |
600 | if (cg && (output_style & STYLE_CALL_GRAPH)) | |
601 | { | |
602 | if (!bsd_style_output) | |
603 | { | |
604 | cg_print (cg); /* print the dynamic profile */ | |
03c35bcb | 605 | } |
12516a37 | 606 | cg_print_index (); |
03c35bcb | 607 | } |
12516a37 KR |
608 | |
609 | if (output_style & STYLE_EXEC_COUNTS) | |
5489fcc3 | 610 | { |
12516a37 | 611 | print_exec_counts (); |
03c35bcb | 612 | } |
5489fcc3 | 613 | |
12516a37 | 614 | if (output_style & STYLE_ANNOTATED_SOURCE) |
5489fcc3 | 615 | { |
12516a37 | 616 | print_annotated_source (); |
03c35bcb | 617 | } |
64c50fc5 JL |
618 | if (output_style & STYLE_FUNCTION_ORDER) |
619 | { | |
620 | cg_print_function_ordering (); | |
621 | } | |
622 | if (output_style & STYLE_FILE_ORDER) | |
623 | { | |
624 | cg_print_file_ordering (); | |
625 | } | |
12516a37 | 626 | return 0; |
3d6c6501 SEF |
627 | } |
628 | ||
5489fcc3 KR |
629 | void |
630 | done (status) | |
631 | int status; | |
3d6c6501 | 632 | { |
12516a37 | 633 | exit (status); |
3d6c6501 | 634 | } |