Print this page
10822 ctfdump -c should include non-root types
Reviewed by: Robert Mustacchi <rm@joyent.com>
   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright (c) 2018, Joyent, Inc.
  14  */
  15 
  16 /*
  17  * Dump information about CTF containers.
  18  */
  19 
  20 #include <stdio.h>
  21 #include <unistd.h>
  22 #include <libctf.h>
  23 #include <libgen.h>
  24 #include <stdarg.h>
  25 #include <stdlib.h>
  26 #include <stddef.h>
  27 #include <sys/sysmacros.h>
  28 #include <sys/types.h>
  29 #include <sys/stat.h>
  30 #include <sys/note.h>
  31 #include <fcntl.h>
  32 #include <errno.h>
  33 #include <string.h>


 965 idname_compare(const void *lhs, const void *rhs)
 966 {
 967         return (strcmp(((ctf_idname_t *)lhs)->ci_name,
 968             ((ctf_idname_t *)rhs)->ci_name));
 969 }
 970 
 971 static void
 972 ctfdump_source(void)
 973 {
 974         ulong_t nr_syms = ctf_nr_syms(g_fp);
 975         ctf_id_t max_id = ctf_max_id(g_fp);
 976         size_t count = 0;
 977 
 978         (void) printf("/* Types */\n\n");
 979 
 980         if ((idnames = calloc(max_id + 1, sizeof (idnames[0]))) == NULL) {
 981                 ctfdump_fatal("failed to alloc idnames: %s\n",
 982                     strerror(errno));
 983         }
 984 
 985         if (ctf_type_iter(g_fp, B_FALSE, ctfsrc_collect_types_cb,
 986             idnames) == CTF_ERR) {
 987                 warnx("failed to collect types: %s",
 988                     ctf_errmsg(ctf_errno(g_fp)));
 989                 g_exit = 1;
 990         }
 991 
 992         qsort(idnames, max_id, sizeof (ctf_idname_t), idname_compare);
 993 
 994         for (size_t i = 0; i < max_id; i++) {
 995                 if (idnames[i].ci_id != 0)
 996                         ctfsrc_type(idnames[i].ci_id, idnames[i].ci_name);
 997         }
 998 
 999         free(idnames);
1000 
1001         (void) printf("\n\n/* Data Objects */\n\n");
1002 
1003         if ((idnames = calloc(nr_syms, sizeof (idnames[0]))) == NULL) {
1004                 ctfdump_fatal("failed to alloc idnames: %s\n",
1005                     strerror(errno));


   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright (c) 2019, Joyent, Inc.
  14  */
  15 
  16 /*
  17  * Dump information about CTF containers.
  18  */
  19 
  20 #include <stdio.h>
  21 #include <unistd.h>
  22 #include <libctf.h>
  23 #include <libgen.h>
  24 #include <stdarg.h>
  25 #include <stdlib.h>
  26 #include <stddef.h>
  27 #include <sys/sysmacros.h>
  28 #include <sys/types.h>
  29 #include <sys/stat.h>
  30 #include <sys/note.h>
  31 #include <fcntl.h>
  32 #include <errno.h>
  33 #include <string.h>


 965 idname_compare(const void *lhs, const void *rhs)
 966 {
 967         return (strcmp(((ctf_idname_t *)lhs)->ci_name,
 968             ((ctf_idname_t *)rhs)->ci_name));
 969 }
 970 
 971 static void
 972 ctfdump_source(void)
 973 {
 974         ulong_t nr_syms = ctf_nr_syms(g_fp);
 975         ctf_id_t max_id = ctf_max_id(g_fp);
 976         size_t count = 0;
 977 
 978         (void) printf("/* Types */\n\n");
 979 
 980         if ((idnames = calloc(max_id + 1, sizeof (idnames[0]))) == NULL) {
 981                 ctfdump_fatal("failed to alloc idnames: %s\n",
 982                     strerror(errno));
 983         }
 984 
 985         if (ctf_type_iter(g_fp, B_TRUE, ctfsrc_collect_types_cb,
 986             idnames) == CTF_ERR) {
 987                 warnx("failed to collect types: %s",
 988                     ctf_errmsg(ctf_errno(g_fp)));
 989                 g_exit = 1;
 990         }
 991 
 992         qsort(idnames, max_id, sizeof (ctf_idname_t), idname_compare);
 993 
 994         for (size_t i = 0; i < max_id; i++) {
 995                 if (idnames[i].ci_id != 0)
 996                         ctfsrc_type(idnames[i].ci_id, idnames[i].ci_name);
 997         }
 998 
 999         free(idnames);
1000 
1001         (void) printf("\n\n/* Data Objects */\n\n");
1002 
1003         if ((idnames = calloc(nr_syms, sizeof (idnames[0]))) == NULL) {
1004                 ctfdump_fatal("failed to alloc idnames: %s\n",
1005                     strerror(errno));