static void ctfdump_functions(void) { ctfdump_title(CTFDUMP_FUNCTIONS, "Functions"); if (ctf_function_iter(g_fp, ctfdump_functions_cb, NULL) == CTF_ERR) { ctfdump_warn("failed to dump functions: %s\n", ctf_errmsg(ctf_errno(g_fp))); g_exit = 1; } }
static void ctfdump_source(void) { ulong_t nr_syms = ctf_nr_syms(g_fp); ctf_id_t max_id = ctf_max_id(g_fp); size_t count = 0; (void) printf("/* Types */\n\n"); if ((idnames = calloc(max_id + 1, sizeof (idnames[0]))) == NULL) { ctfdump_fatal("failed to alloc idnames: %s\n", strerror(errno)); } if (ctf_type_iter(g_fp, B_FALSE, ctfsrc_collect_types_cb, idnames) == CTF_ERR) { warnx("failed to collect types: %s", ctf_errmsg(ctf_errno(g_fp))); g_exit = 1; } qsort(idnames, max_id, sizeof (ctf_idname_t), idname_compare); for (size_t i = 0; i < max_id; i++) { if (idnames[i].ci_id != 0) ctfsrc_type(idnames[i].ci_id, idnames[i].ci_name); } free(idnames); (void) printf("\n\n/* Data Objects */\n\n"); if ((idnames = calloc(nr_syms, sizeof (idnames[0]))) == NULL) { ctfdump_fatal("failed to alloc idnames: %s\n", strerror(errno)); } if (ctf_object_iter(g_fp, ctfsrc_collect_objects_cb, &count) == CTF_ERR) { warnx("failed to collect objects: %s", ctf_errmsg(ctf_errno(g_fp))); g_exit = 1; } qsort(idnames, count, sizeof (ctf_idname_t), idname_compare); for (size_t i = 0; i < count; i++) ctfsrc_object(idnames[i].ci_id, idnames[i].ci_name); free(idnames); (void) printf("\n\n/* Functions */\n\n"); if ((idnames = calloc(nr_syms, sizeof (idnames[0]))) == NULL) { ctfdump_fatal("failed to alloc idnames: %s\n", strerror(errno)); } count = 0; if (ctf_function_iter(g_fp, ctfsrc_collect_functions_cb, &count) == CTF_ERR) { warnx("failed to collect functions: %s", ctf_errmsg(ctf_errno(g_fp))); g_exit = 1; } qsort(idnames, count, sizeof (ctf_idname_t), idname_compare); for (size_t i = 0; i < count; i++) ctfsrc_function(&idnames[i]); free(idnames); }