8 main (int argc, char *argv[])
11 ctf_dict_t *a_fp, *ignore1_fp, *b_fp, *ignore2_fp, *tmp_fp;
13 ctf_id_t a, b, ignore1, ignore2, tmp;
18 fprintf (stderr, "Syntax: %s PROGRAM\n", argv[0]);
22 if ((ctf = ctf_open (argv[1], NULL, &err)) == NULL)
25 /* Fish out each symbol in turn: also try to fish out a nonexistent one. */
27 if ((a_fp = ctf_arc_lookup_symbol_name (ctf, "a", &a, &err)) == NULL)
29 printf ("Type of a is %s\n", foo = ctf_type_aname (a_fp, a));
31 if ((b_fp = ctf_arc_lookup_symbol_name (ctf, "b", &b, &err)) == NULL)
33 printf ("Type of b is %s\n", foo = ctf_type_aname (b_fp, b));
35 if ((ignore1_fp = ctf_arc_lookup_symbol_name (ctf, "ignore1", &ignore1, &err)) == NULL)
37 printf ("Type of ignore1 is %s\n", foo = ctf_type_aname (ignore1_fp, ignore1));
39 if ((ignore2_fp = ctf_arc_lookup_symbol_name (ctf, "ignore2", &ignore2, &err)) == NULL)
41 printf ("Type of ignore2 is %s\n", foo = ctf_type_aname (ignore2_fp, ignore1));
43 /* Try a call in just-get-the-dict mode and make sure it doesn't fail. */
44 if ((tmp_fp = ctf_arc_lookup_symbol_name (ctf, "ignore2", NULL, &err)) == NULL)
46 ctf_dict_close (tmp_fp);
48 /* Make sure failures fail. */
49 if ((ctf_arc_lookup_symbol_name (ctf, "nonexistent", NULL, &err) != NULL)
50 || err != ECTF_NOTYPEDAT)
53 /* Fish them out again to check the caching layer. */
54 if (((tmp_fp = ctf_arc_lookup_symbol_name (ctf, "a", &tmp, &err)) != a_fp)
57 ctf_dict_close (tmp_fp);
59 if (((tmp_fp = ctf_arc_lookup_symbol_name (ctf, "b", &tmp, &err)) != b_fp)
62 ctf_dict_close (tmp_fp);
64 if (((tmp_fp = ctf_arc_lookup_symbol_name (ctf, "ignore1", &tmp, &err)) != ignore1_fp)
67 ctf_dict_close (tmp_fp);
69 if (((tmp_fp = ctf_arc_lookup_symbol_name (ctf, "ignore2", &tmp, &err)) != ignore2_fp)
72 ctf_dict_close (tmp_fp);
74 ctf_dict_close (a_fp);
75 ctf_dict_close (b_fp);
76 ctf_dict_close (ignore1_fp);
77 ctf_dict_close (ignore2_fp);
83 fprintf (stderr, "%s: cannot open: %s\n", argv[0], ctf_errmsg (err));
86 fprintf (stderr, "%s: Symbol lookup error: %s\n", argv[0], ctf_errmsg (err));
89 fprintf (stderr, "%s: Nonexistent symbol lookup unexpected error: %s\n", argv[0],
93 fprintf (stderr, "%s: Symbol re-lookup error (caching bug): %s\n", argv[0],