Commit | Line | Data |
---|---|---|
ef368dac NC |
1 | /* gmon_io.c - Input and output from/to gmon.out files. |
2 | ||
0eee5820 | 3 | Copyright 2000, 2001 Free Software Foundation, Inc. |
ef368dac NC |
4 | |
5 | This file is part of GNU Binutils. | |
6 | ||
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 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
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. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
20 | 02111-1307, USA. */ | |
21 | \f | |
252b5132 RH |
22 | #include "cg_arcs.h" |
23 | #include "basic_blocks.h" | |
24 | #include "bfd.h" | |
25 | #include "corefile.h" | |
26 | #include "call_graph.h" | |
27 | #include "gmon_io.h" | |
28 | #include "gmon_out.h" | |
ef368dac | 29 | #include "gmon.h" /* Fetch header for old format. */ |
252b5132 RH |
30 | #include "gprof.h" |
31 | #include "hertz.h" | |
32 | #include "hist.h" | |
33 | #include "libiberty.h" | |
34 | ||
35 | int gmon_input = 0; | |
ef368dac NC |
36 | int gmon_file_version = 0; /* 0 == old (non-versioned) file format. */ |
37 | ||
0eee5820 AM |
38 | int |
39 | DEFUN (gmon_io_read_vma, (ifp, valp), FILE * ifp AND bfd_vma *valp) | |
40 | { | |
41 | char buf[8]; | |
42 | bfd_vma val; | |
43 | ||
44 | switch (GMON_PTR_SIZE) | |
45 | { | |
46 | case 4: | |
47 | if (fread (buf, 1, 4, ifp) != 4) | |
48 | return 1; | |
49 | val = bfd_get_32 (core_bfd, buf); | |
50 | break; | |
51 | ||
52 | case 8: | |
53 | if (fread (buf, 1, 8, ifp) != 8) | |
54 | return 1; | |
55 | val = bfd_get_64 (core_bfd, buf); | |
56 | break; | |
57 | ||
58 | default: | |
59 | fprintf (stderr, _("%s: GMON_PTR_SIZE has unexpected value of %u\n"), | |
60 | whoami, GMON_PTR_SIZE); | |
61 | done (1); | |
62 | } | |
63 | *valp = val; | |
64 | return 0; | |
65 | } | |
252b5132 | 66 | |
0eee5820 AM |
67 | int |
68 | DEFUN (gmon_io_read_32, (ifp, valp), FILE * ifp AND unsigned int *valp) | |
69 | { | |
70 | char buf[4]; | |
71 | ||
72 | if (fread (buf, 1, 4, ifp) != 4) | |
73 | return 1; | |
74 | *valp = bfd_get_32 (core_bfd, buf); | |
75 | return 0; | |
76 | } | |
77 | ||
78 | int | |
7ee44f74 | 79 | DEFUN (gmon_io_read, (ifp, buf, n), FILE * ifp AND char *buf AND size_t n) |
0eee5820 AM |
80 | { |
81 | if (fread (buf, 1, n, ifp) != n) | |
82 | return 1; | |
83 | return 0; | |
84 | } | |
85 | ||
86 | int | |
7ee44f74 | 87 | DEFUN (gmon_io_write_vma, (ofp, val), FILE * ofp AND bfd_vma val) |
0eee5820 AM |
88 | { |
89 | char buf[8]; | |
90 | ||
91 | switch (GMON_PTR_SIZE) | |
92 | { | |
93 | case 4: | |
94 | bfd_put_32 (core_bfd, val, buf); | |
95 | if (fwrite (buf, 1, 4, ofp) != 4) | |
96 | return 1; | |
97 | break; | |
98 | ||
99 | case 8: | |
100 | bfd_put_64 (core_bfd, val, buf); | |
101 | if (fwrite (buf, 1, 8, ofp) != 8) | |
102 | return 1; | |
103 | break; | |
104 | ||
105 | default: | |
106 | fprintf (stderr, _("%s: GMON_PTR_SIZE has unexpected value of %u\n"), | |
107 | whoami, GMON_PTR_SIZE); | |
108 | done (1); | |
109 | } | |
110 | return 0; | |
111 | } | |
112 | ||
113 | int | |
7ee44f74 | 114 | DEFUN (gmon_io_write_32, (ofp, val), FILE * ofp AND unsigned int val) |
0eee5820 AM |
115 | { |
116 | char buf[4]; | |
117 | ||
118 | bfd_put_32 (core_bfd, val, buf); | |
119 | if (fwrite (buf, 1, 4, ofp) != 4) | |
120 | return 1; | |
121 | return 0; | |
122 | } | |
123 | ||
124 | int | |
7ee44f74 | 125 | DEFUN (gmon_io_write_8, (ofp, val), FILE * ofp AND unsigned char val) |
0eee5820 AM |
126 | { |
127 | char buf[1]; | |
128 | ||
129 | bfd_put_8 (core_bfd, val, buf); | |
130 | if (fwrite (buf, 1, 1, ofp) != 1) | |
131 | return 1; | |
132 | return 0; | |
133 | } | |
134 | ||
135 | int | |
7ee44f74 | 136 | DEFUN (gmon_io_write, (ofp, buf, n), FILE * ofp AND char *buf AND size_t n) |
0eee5820 AM |
137 | { |
138 | if (fwrite (buf, 1, n, ofp) != n) | |
139 | return 1; | |
140 | return 0; | |
141 | } | |
142 | ||
143 | /* get_vma and put_vma are for backwards compatibility only */ | |
144 | static bfd_vma | |
252b5132 RH |
145 | DEFUN (get_vma, (abfd, addr), bfd * abfd AND bfd_byte * addr) |
146 | { | |
147 | switch (sizeof (char*)) | |
148 | { | |
149 | case 4: | |
150 | return bfd_get_32 (abfd, addr); | |
151 | case 8: | |
152 | return bfd_get_64 (abfd, addr); | |
153 | default: | |
154 | fprintf (stderr, _("%s: bfd_vma has unexpected size of %ld bytes\n"), | |
155 | whoami, (long) sizeof (char*)); | |
156 | done (1); | |
157 | } | |
158 | } | |
159 | ||
0eee5820 | 160 | static void |
252b5132 RH |
161 | DEFUN (put_vma, (abfd, val, addr), bfd * abfd AND bfd_vma val AND bfd_byte * addr) |
162 | { | |
163 | switch (sizeof (char*)) | |
164 | { | |
165 | case 4: | |
166 | bfd_put_32 (abfd, val, addr); | |
167 | break; | |
168 | case 8: | |
169 | bfd_put_64 (abfd, val, addr); | |
170 | break; | |
171 | default: | |
172 | fprintf (stderr, _("%s: bfd_vma has unexpected size of %ld bytes\n"), | |
173 | whoami, (long) sizeof (char*)); | |
174 | done (1); | |
175 | } | |
176 | } | |
177 | ||
252b5132 RH |
178 | void |
179 | DEFUN (gmon_out_read, (filename), const char *filename) | |
180 | { | |
181 | FILE *ifp; | |
182 | struct gmon_hdr ghdr; | |
183 | unsigned char tag; | |
184 | int nhist = 0, narcs = 0, nbbs = 0; | |
185 | ||
ef368dac | 186 | /* Open gmon.out file. */ |
252b5132 RH |
187 | if (strcmp (filename, "-") == 0) |
188 | { | |
189 | ifp = stdin; | |
5af11cab AM |
190 | #ifdef SET_BINARY |
191 | SET_BINARY (fileno (stdin)); | |
192 | #endif | |
252b5132 RH |
193 | } |
194 | else | |
195 | { | |
196 | ifp = fopen (filename, FOPEN_RB); | |
0eee5820 | 197 | |
252b5132 RH |
198 | if (!ifp) |
199 | { | |
200 | perror (filename); | |
201 | done (1); | |
202 | } | |
203 | } | |
0eee5820 | 204 | |
252b5132 RH |
205 | if (fread (&ghdr, sizeof (struct gmon_hdr), 1, ifp) != 1) |
206 | { | |
207 | fprintf (stderr, _("%s: file too short to be a gmon file\n"), | |
208 | filename); | |
209 | done (1); | |
210 | } | |
211 | ||
0eee5820 AM |
212 | if ((file_format == FF_MAGIC) |
213 | || (file_format == FF_AUTO && !strncmp (&ghdr.cookie[0], GMON_MAGIC, 4))) | |
252b5132 RH |
214 | { |
215 | if (file_format == FF_MAGIC && strncmp (&ghdr.cookie[0], GMON_MAGIC, 4)) | |
216 | { | |
217 | fprintf (stderr, _("%s: file `%s' has bad magic cookie\n"), | |
218 | whoami, filename); | |
219 | done (1); | |
220 | } | |
221 | ||
ef368dac | 222 | /* Right magic, so it's probably really a new gmon.out file. */ |
252b5132 | 223 | gmon_file_version = bfd_get_32 (core_bfd, (bfd_byte *) ghdr.version); |
0eee5820 | 224 | |
252b5132 RH |
225 | if (gmon_file_version != GMON_VERSION && gmon_file_version != 0) |
226 | { | |
227 | fprintf (stderr, | |
228 | _("%s: file `%s' has unsupported version %d\n"), | |
229 | whoami, filename, gmon_file_version); | |
230 | done (1); | |
231 | } | |
232 | ||
ef368dac | 233 | /* Read in all the records. */ |
252b5132 RH |
234 | while (fread (&tag, sizeof (tag), 1, ifp) == 1) |
235 | { | |
236 | switch (tag) | |
237 | { | |
238 | case GMON_TAG_TIME_HIST: | |
239 | ++nhist; | |
240 | gmon_input |= INPUT_HISTOGRAM; | |
241 | hist_read_rec (ifp, filename); | |
242 | break; | |
243 | ||
244 | case GMON_TAG_CG_ARC: | |
245 | ++narcs; | |
246 | gmon_input |= INPUT_CALL_GRAPH; | |
247 | cg_read_rec (ifp, filename); | |
248 | break; | |
249 | ||
250 | case GMON_TAG_BB_COUNT: | |
251 | ++nbbs; | |
252 | gmon_input |= INPUT_BB_COUNTS; | |
253 | bb_read_rec (ifp, filename); | |
254 | break; | |
255 | ||
256 | default: | |
257 | fprintf (stderr, | |
258 | _("%s: %s: found bad tag %d (file corrupted?)\n"), | |
259 | whoami, filename, tag); | |
260 | done (1); | |
261 | } | |
262 | } | |
263 | } | |
264 | else if (file_format == FF_AUTO | |
265 | || file_format == FF_BSD | |
266 | || file_format == FF_BSD44) | |
267 | { | |
268 | struct hdr | |
269 | { | |
270 | bfd_vma low_pc; | |
271 | bfd_vma high_pc; | |
272 | int ncnt; | |
273 | }; | |
274 | int i, samp_bytes, header_size; | |
275 | unsigned long count; | |
276 | bfd_vma from_pc, self_pc; | |
277 | struct raw_arc raw_arc; | |
278 | struct raw_phdr raw; | |
279 | static struct hdr h; | |
280 | UNIT raw_bin_count; | |
281 | struct hdr tmp; | |
282 | ||
ef368dac | 283 | /* Information from a gmon.out file is in two parts: an array of |
0eee5820 | 284 | sampling hits within pc ranges, and the arcs. */ |
252b5132 RH |
285 | gmon_input = INPUT_HISTOGRAM | INPUT_CALL_GRAPH; |
286 | ||
ef368dac | 287 | /* This fseek() ought to work even on stdin as long as it's |
0eee5820 AM |
288 | not an interactive device (heck, is there anybody who would |
289 | want to type in a gmon.out at the terminal?). */ | |
252b5132 RH |
290 | if (fseek (ifp, 0, SEEK_SET) < 0) |
291 | { | |
292 | perror (filename); | |
293 | done (1); | |
294 | } | |
0eee5820 | 295 | |
252b5132 RH |
296 | if (fread (&raw, 1, sizeof (struct raw_phdr), ifp) |
297 | != sizeof (struct raw_phdr)) | |
298 | { | |
299 | fprintf (stderr, _("%s: file too short to be a gmon file\n"), | |
300 | filename); | |
301 | done (1); | |
302 | } | |
0eee5820 | 303 | |
252b5132 RH |
304 | tmp.low_pc = get_vma (core_bfd, (bfd_byte *) &raw.low_pc[0]); |
305 | tmp.high_pc = get_vma (core_bfd, (bfd_byte *) &raw.high_pc[0]); | |
306 | tmp.ncnt = bfd_get_32 (core_bfd, (bfd_byte *) &raw.ncnt[0]); | |
307 | ||
308 | if (bfd_get_32 (core_bfd, (bfd_byte *) &raw.version[0]) | |
309 | == GMONVERSION) | |
310 | { | |
311 | int profrate; | |
312 | ||
313 | /* 4.4BSD format header. */ | |
252b5132 | 314 | profrate = bfd_get_32 (core_bfd, (bfd_byte *) &raw.profrate[0]); |
0eee5820 | 315 | |
252b5132 RH |
316 | if (!s_highpc) |
317 | hz = profrate; | |
318 | else if (hz != profrate) | |
319 | { | |
320 | fprintf (stderr, | |
321 | _("%s: profiling rate incompatible with first gmon file\n"), | |
322 | filename); | |
323 | done (1); | |
324 | } | |
325 | ||
326 | header_size = sizeof (struct raw_phdr); | |
327 | } | |
328 | else | |
329 | { | |
ef368dac | 330 | /* Old style BSD format. */ |
252b5132 RH |
331 | if (file_format == FF_BSD44) |
332 | { | |
333 | fprintf (stderr, _("%s: file `%s' has bad magic cookie\n"), | |
334 | whoami, filename); | |
335 | done (1); | |
336 | } | |
337 | ||
338 | if (fseek (ifp, sizeof (struct old_raw_phdr), SEEK_SET) < 0) | |
339 | { | |
340 | perror (filename); | |
341 | done (1); | |
342 | } | |
343 | ||
344 | header_size = sizeof (struct old_raw_phdr); | |
345 | } | |
346 | ||
0eee5820 AM |
347 | if (s_highpc && (tmp.low_pc != h.low_pc |
348 | || tmp.high_pc != h.high_pc || tmp.ncnt != h.ncnt)) | |
252b5132 RH |
349 | { |
350 | fprintf (stderr, _("%s: incompatible with first gmon file\n"), | |
351 | filename); | |
352 | done (1); | |
353 | } | |
0eee5820 | 354 | |
252b5132 RH |
355 | h = tmp; |
356 | s_lowpc = (bfd_vma) h.low_pc; | |
357 | s_highpc = (bfd_vma) h.high_pc; | |
358 | lowpc = (bfd_vma) h.low_pc / sizeof (UNIT); | |
359 | highpc = (bfd_vma) h.high_pc / sizeof (UNIT); | |
360 | samp_bytes = h.ncnt - header_size; | |
361 | hist_num_bins = samp_bytes / sizeof (UNIT); | |
0eee5820 | 362 | |
252b5132 RH |
363 | DBG (SAMPLEDEBUG, |
364 | printf ("[gmon_out_read] lowpc 0x%lx highpc 0x%lx ncnt %d\n", | |
fdcf7d43 ILT |
365 | (unsigned long) h.low_pc, (unsigned long) h.high_pc, |
366 | h.ncnt); | |
252b5132 | 367 | printf ("[gmon_out_read] s_lowpc 0x%lx s_highpc 0x%lx\n", |
fdcf7d43 | 368 | (unsigned long) s_lowpc, (unsigned long) s_highpc); |
252b5132 | 369 | printf ("[gmon_out_read] lowpc 0x%lx highpc 0x%lx\n", |
fdcf7d43 | 370 | (unsigned long) lowpc, (unsigned long) highpc); |
252b5132 RH |
371 | printf ("[gmon_out_read] samp_bytes %d hist_num_bins %d\n", |
372 | samp_bytes, hist_num_bins)); | |
373 | ||
2d35e9f6 NC |
374 | /* Make sure that we have sensible values. */ |
375 | if (samp_bytes < 0 || lowpc > highpc) | |
0eee5820 AM |
376 | { |
377 | fprintf (stderr, | |
2d35e9f6 NC |
378 | _("%s: file '%s' does not appear to be in gmon.out format\n"), |
379 | whoami, filename); | |
0eee5820 AM |
380 | done (1); |
381 | } | |
2d35e9f6 | 382 | |
252b5132 | 383 | if (hist_num_bins) |
ef368dac | 384 | ++nhist; |
252b5132 RH |
385 | |
386 | if (!hist_sample) | |
387 | { | |
388 | hist_sample = | |
389 | (int *) xmalloc (hist_num_bins * sizeof (hist_sample[0])); | |
0eee5820 | 390 | |
252b5132 RH |
391 | memset (hist_sample, 0, hist_num_bins * sizeof (hist_sample[0])); |
392 | } | |
393 | ||
394 | for (i = 0; i < hist_num_bins; ++i) | |
395 | { | |
396 | if (fread (raw_bin_count, sizeof (raw_bin_count), 1, ifp) != 1) | |
397 | { | |
398 | fprintf (stderr, | |
399 | _("%s: unexpected EOF after reading %d/%d bins\n"), | |
400 | whoami, --i, hist_num_bins); | |
401 | done (1); | |
402 | } | |
0eee5820 | 403 | |
252b5132 RH |
404 | hist_sample[i] += bfd_get_16 (core_bfd, (bfd_byte *) raw_bin_count); |
405 | } | |
406 | ||
ef368dac NC |
407 | /* The rest of the file consists of a bunch of |
408 | <from,self,count> tuples. */ | |
252b5132 RH |
409 | while (fread (&raw_arc, sizeof (raw_arc), 1, ifp) == 1) |
410 | { | |
411 | ++narcs; | |
412 | from_pc = get_vma (core_bfd, (bfd_byte *) raw_arc.from_pc); | |
413 | self_pc = get_vma (core_bfd, (bfd_byte *) raw_arc.self_pc); | |
414 | count = bfd_get_32 (core_bfd, (bfd_byte *) raw_arc.count); | |
0eee5820 | 415 | |
252b5132 RH |
416 | DBG (SAMPLEDEBUG, |
417 | printf ("[gmon_out_read] frompc 0x%lx selfpc 0x%lx count %lu\n", | |
fdcf7d43 | 418 | (unsigned long) from_pc, (unsigned long) self_pc, count)); |
0eee5820 | 419 | |
ef368dac | 420 | /* Add this arc. */ |
252b5132 RH |
421 | cg_tally (from_pc, self_pc, count); |
422 | } | |
0eee5820 | 423 | |
252b5132 RH |
424 | fclose (ifp); |
425 | ||
426 | if (hz == HZ_WRONG) | |
427 | { | |
ef368dac NC |
428 | /* How many ticks per second? If we can't tell, report |
429 | time in ticks. */ | |
252b5132 | 430 | hz = hertz (); |
0eee5820 | 431 | |
252b5132 RH |
432 | if (hz == HZ_WRONG) |
433 | { | |
434 | hz = 1; | |
435 | fprintf (stderr, _("time is in ticks, not seconds\n")); | |
436 | } | |
437 | } | |
438 | } | |
439 | else | |
440 | { | |
441 | fprintf (stderr, _("%s: don't know how to deal with file format %d\n"), | |
442 | whoami, file_format); | |
443 | done (1); | |
444 | } | |
445 | ||
446 | if (output_style & STYLE_GMON_INFO) | |
447 | { | |
448 | printf (_("File `%s' (version %d) contains:\n"), | |
449 | filename, gmon_file_version); | |
741247bf NC |
450 | printf (nhist == 1 ? |
451 | _("\t%d histogram record\n") : | |
452 | _("\t%d histogram records\n"), nhist); | |
453 | printf (narcs == 1 ? | |
454 | _("\t%d call-graph record\n") : | |
455 | _("\t%d call-graph records\n"), narcs); | |
456 | printf (nbbs == 1 ? | |
457 | _("\t%d basic-block count record\n") : | |
458 | _("\t%d basic-block count records\n"), nbbs); | |
252b5132 RH |
459 | first_output = FALSE; |
460 | } | |
461 | } | |
462 | ||
463 | ||
464 | void | |
465 | DEFUN (gmon_out_write, (filename), const char *filename) | |
466 | { | |
467 | FILE *ofp; | |
468 | struct gmon_hdr ghdr; | |
469 | ||
470 | ofp = fopen (filename, FOPEN_WB); | |
471 | if (!ofp) | |
472 | { | |
473 | perror (filename); | |
474 | done (1); | |
475 | } | |
476 | ||
477 | if (file_format == FF_AUTO || file_format == FF_MAGIC) | |
478 | { | |
ef368dac | 479 | /* Write gmon header. */ |
252b5132 RH |
480 | |
481 | memcpy (&ghdr.cookie[0], GMON_MAGIC, 4); | |
482 | bfd_put_32 (core_bfd, GMON_VERSION, (bfd_byte *) ghdr.version); | |
0eee5820 | 483 | |
252b5132 RH |
484 | if (fwrite (&ghdr, sizeof (ghdr), 1, ofp) != 1) |
485 | { | |
486 | perror (filename); | |
487 | done (1); | |
488 | } | |
489 | ||
ef368dac | 490 | /* Write execution time histogram if we have one. */ |
252b5132 | 491 | if (gmon_input & INPUT_HISTOGRAM) |
ef368dac | 492 | hist_write_hist (ofp, filename); |
252b5132 | 493 | |
ef368dac | 494 | /* Write call graph arcs if we have any. */ |
252b5132 | 495 | if (gmon_input & INPUT_CALL_GRAPH) |
ef368dac | 496 | cg_write_arcs (ofp, filename); |
252b5132 | 497 | |
ef368dac | 498 | /* Write basic-block info if we have it. */ |
252b5132 | 499 | if (gmon_input & INPUT_BB_COUNTS) |
ef368dac | 500 | bb_write_blocks (ofp, filename); |
252b5132 RH |
501 | } |
502 | else if (file_format == FF_BSD || file_format == FF_BSD44) | |
503 | { | |
504 | struct raw_arc raw_arc; | |
505 | UNIT raw_bin_count; | |
506 | struct raw_phdr h; | |
507 | int i; | |
508 | Arc *arc; | |
509 | Sym *sym; | |
510 | ||
511 | memset (&h, 0, sizeof h); | |
512 | put_vma (core_bfd, s_lowpc, (bfd_byte *) &h.low_pc); | |
513 | put_vma (core_bfd, s_highpc, (bfd_byte *) &h.high_pc); | |
514 | bfd_put_32 (core_bfd, | |
515 | hist_num_bins * sizeof (UNIT) + sizeof (struct raw_phdr), | |
516 | (bfd_byte *) &h.ncnt); | |
517 | ||
518 | /* Write header. Use new style BSD format is explicitly | |
0eee5820 AM |
519 | specified, or if the profiling rate is non-standard; |
520 | otherwise, use the old BSD format. */ | |
252b5132 RH |
521 | if (file_format == FF_BSD44 |
522 | || hz != hertz ()) | |
523 | { | |
524 | bfd_put_32 (core_bfd, GMONVERSION, (bfd_byte *) &h.version); | |
525 | bfd_put_32 (core_bfd, hz, (bfd_byte *) &h.profrate); | |
526 | if (fwrite (&h, sizeof (struct raw_phdr), 1, ofp) != 1) | |
527 | { | |
528 | perror (filename); | |
529 | done (1); | |
530 | } | |
531 | } | |
532 | else | |
533 | { | |
534 | if (fwrite (&h, sizeof (struct old_raw_phdr), 1, ofp) != 1) | |
535 | { | |
536 | perror (filename); | |
537 | done (1); | |
538 | } | |
539 | } | |
540 | ||
ef368dac | 541 | /* Dump the samples. */ |
252b5132 RH |
542 | for (i = 0; i < hist_num_bins; ++i) |
543 | { | |
544 | bfd_put_16 (core_bfd, hist_sample[i], (bfd_byte *) & raw_bin_count[0]); | |
545 | if (fwrite (&raw_bin_count[0], sizeof (raw_bin_count), 1, ofp) != 1) | |
546 | { | |
547 | perror (filename); | |
548 | done (1); | |
549 | } | |
550 | } | |
551 | ||
ef368dac | 552 | /* Dump the normalized raw arc information. */ |
252b5132 RH |
553 | for (sym = symtab.base; sym < symtab.limit; ++sym) |
554 | { | |
555 | for (arc = sym->cg.children; arc; arc = arc->next_child) | |
556 | { | |
557 | put_vma (core_bfd, arc->parent->addr, | |
558 | (bfd_byte *) raw_arc.from_pc); | |
559 | put_vma (core_bfd, arc->child->addr, | |
560 | (bfd_byte *) raw_arc.self_pc); | |
561 | bfd_put_32 (core_bfd, arc->count, (bfd_byte *) raw_arc.count); | |
562 | if (fwrite (&raw_arc, sizeof (raw_arc), 1, ofp) != 1) | |
563 | { | |
564 | perror (filename); | |
565 | done (1); | |
566 | } | |
567 | DBG (SAMPLEDEBUG, | |
568 | printf ("[dumpsum] frompc 0x%lx selfpc 0x%lx count %lu\n", | |
fdcf7d43 ILT |
569 | (unsigned long) arc->parent->addr, |
570 | (unsigned long) arc->child->addr, arc->count)); | |
252b5132 RH |
571 | } |
572 | } | |
0eee5820 | 573 | |
252b5132 RH |
574 | fclose (ofp); |
575 | } | |
576 | else | |
577 | { | |
578 | fprintf (stderr, _("%s: don't know how to deal with file format %d\n"), | |
579 | whoami, file_format); | |
580 | done (1); | |
581 | } | |
582 | } |