]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - libctf/testsuite/libctf-lookup/enum-symbol.c
8 main (int argc
, char *argv
[])
11 ctf_dict_t
*fp
, *tmp_fp
;
20 fprintf (stderr
, "Syntax: %s PROGRAM\n", argv
[0]);
24 if ((ctf
= ctf_open (argv
[1], NULL
, &err
)) == NULL
)
27 /* Fish out the enumerator, then fish out all its enumerand/value pairs. */
29 if ((fp
= ctf_arc_lookup_symbol_name (ctf
, "primary1", &type
, &err
)) == NULL
)
32 while ((name
= ctf_enum_next (fp
, type
, &i
, &val
)) != NULL
)
34 printf ("%s has value %i\n", name
, val
);
36 if (ctf_errno (fp
) != ECTF_NEXT_END
)
39 /* Fish it out again to check the caching layer. */
40 if (((tmp_fp
= ctf_arc_lookup_symbol_name (ctf
, "primary1", &tmp
, &err
)) != fp
)
44 ctf_dict_close (tmp_fp
);
51 fprintf (stderr
, "%s: cannot open: %s\n", argv
[0], ctf_errmsg (err
));
54 fprintf (stderr
, "%s: Symbol lookup error: %s\n", argv
[0], ctf_errmsg (err
));
57 fprintf (stderr
, "%s: Symbol re-lookup error (caching bug): %s\n", argv
[0],
61 fprintf (stderr
, "Lookup failed: %s\n", ctf_errmsg (ctf_errno (fp
)));
64 fprintf (stderr
, "iteration failed: %s\n", ctf_errmsg (ctf_errno (fp
)));