3 #include <sys/gmon_out.h>
6 #define GMON_SEC "seconds s"
7 uint32_t mineip
= 0xffffffff;
10 /* a hash structure to hold the arc */
18 struct arec
*arc
= NULL
;
20 void note_arc(uint32_t eip
, uint32_t from
)
24 HASH_FIND_INT(arc
, &eip
, s
);
26 s
= malloc(sizeof(struct arec
));
35 HASH_ADD_INT(arc
, eip
, s
);
41 int main(int argc
, char* argv
[])
45 uint32_t eip
, from
, tmp
;
50 fprintf(stderr
, "Please specify the coreboot trace log as parameter\n");
54 f
= fopen(argv
[1], "r");
56 perror("Unable to open the input file");
60 fo
= fopen("gmon.out", "w+");
62 perror("Unable to open the output file");
68 if (fscanf(f
, "~%x(%x)%*[^\n]\n", &eip
, &from
) == 2) {
70 } else if (fscanf(f
, "%*c~%x(%x)%*[^\n]\n", &eip
, &from
) == 2) {
73 /* just drop a line */
74 tmp
= fscanf(f
, "%*[^\n]\n");
78 /* write gprof header */
79 fwrite(GMON_MAGIC
, 1, sizeof(GMON_MAGIC
) - 1, fo
);
81 fwrite(&tmp
, 1, sizeof(tmp
), fo
);
83 fwrite(&tmp
, 1, sizeof(tmp
), fo
);
84 fwrite(&tmp
, 1, sizeof(tmp
), fo
);
85 fwrite(&tmp
, 1, sizeof(tmp
), fo
);
86 /* write fake histogram */
87 tag
= GMON_TAG_TIME_HIST
;
88 fwrite(&tag
, 1, sizeof(tag
), fo
);
89 fwrite(&mineip
, 1, sizeof(mineip
), fo
);
90 fwrite(&maxeip
, 1, sizeof(maxeip
), fo
);
91 /* size of histogram */
93 fwrite(&tmp
, 1, sizeof(tmp
), fo
);
96 fwrite(&tmp
, 1, sizeof(tmp
), fo
);
97 fwrite(GMON_SEC
, 1, sizeof(GMON_SEC
) - 1, fo
);
99 fwrite(&hit
, 1, sizeof(hit
), fo
);
101 /* write call graph data */
102 tag
= GMON_TAG_CG_ARC
;
103 for (s
= arc
; s
!= NULL
; s
= s
->hh
.next
) {
104 fwrite(&tag
, 1, sizeof(tag
), fo
);
105 fwrite(&s
->from
, 1, sizeof(s
->from
), fo
);
106 fwrite(&s
->eip
, 1, sizeof(s
->eip
), fo
);
107 fwrite(&s
->count
, 1, sizeof(s
->count
), fo
);