]>
Commit | Line | Data |
---|---|---|
d8a62882 | 1 | /* { dg-do run { target *-*-linux* *-*-gnu* } } */ |
9124bbe1 SH |
2 | /* { dg-options "-fprofile-arcs -fprofile-info-section" } */ |
3 | ||
4 | #define assert(expr) \ | |
5 | ((expr) \ | |
6 | ? (void)0 \ | |
7 | : (__builtin_printf ("%s:%i: Assertion `%s' failed.\n", \ | |
8 | __FILE__, __LINE__, #expr), \ | |
9 | __builtin_abort ())) | |
10 | ||
11 | struct gcov_info; | |
12 | ||
13 | extern void | |
14 | __gcov_info_to_gcda (const struct gcov_info *__info, | |
15 | void (*__filename_fn) (const char *, void *), | |
16 | void (*__dump_fn) (const void *, unsigned, void *), | |
17 | void *(*__allocate_fn) (unsigned, void *), | |
18 | void *__arg); | |
19 | ||
20 | extern const struct gcov_info *my_info; | |
21 | ||
22 | static unsigned counter; | |
23 | ||
24 | static void | |
25 | filename (const char *f, void *arg) | |
26 | { | |
27 | assert (arg == &counter); | |
28 | assert (__builtin_strstr (f, "gcov-info-to-gcda.c") == 0); | |
29 | } | |
30 | ||
31 | static void | |
32 | dump (const void *d, unsigned n, void *arg) | |
33 | { | |
34 | unsigned *m = (unsigned *)arg; | |
35 | assert (arg == &counter); | |
36 | ||
37 | if (*m == 0) | |
38 | { | |
39 | const unsigned *u = d; | |
40 | assert (*u == 0x67636461); | |
41 | } | |
42 | ||
43 | *m += n; | |
44 | } | |
45 | ||
46 | static void * | |
47 | allocate (unsigned length, void *arg) | |
48 | { | |
49 | assert (arg == &counter); | |
50 | return __builtin_malloc (length); | |
51 | } | |
52 | ||
53 | int main() | |
54 | { | |
55 | __asm__ volatile (".set my_info, .LPBX2"); | |
56 | __gcov_info_to_gcda (my_info, filename, dump, allocate, &counter); | |
57 | assert (counter > 4); | |
58 | return 0; | |
59 | } |