Print this page
10812 ctf tools shouldn't add blank labels
10813 ctf symbol mapping needs work
Reviewed by: Jerry Jelinek <jerry.jelinek@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 2015 Joyent, Inc.
  14  */
  15 
  16 /*
  17  * Main conversion entry points. This has been designed such that there can be
  18  * any number of different conversion backends. Currently we only have one that
  19  * understands DWARFv2 (and bits of DWARFv4). Each backend should be placed in
  20  * the ctf_converters list and each will be tried in turn.
  21  */
  22 
  23 #include <libctf_impl.h>
  24 #include <gelf.h>
  25 
  26 ctf_convert_f ctf_converters[] = {
  27         ctf_dwarf_convert
  28 };
  29 
  30 #define NCONVERTS       (sizeof (ctf_converters) / sizeof (ctf_convert_f))
  31 
  32 typedef enum ctf_convert_source {
  33         CTFCONV_SOURCE_NONE = 0x0,


 151                 if (cs == CTF_CONV_ERROR) {
 152                         fp = NULL;
 153                         notsup = B_FALSE;
 154                         break;
 155                 }
 156         }
 157 
 158         if (notsup == B_TRUE) {
 159                 if ((flags & CTF_CONVERT_F_IGNNONC) != 0 &&
 160                     (type & CTFCONV_SOURCE_C) == 0) {
 161                         *errp = ECTF_CONVNOCSRC;
 162                         return (NULL);
 163                 }
 164                 *errp = ECTF_NOCONVBKEND;
 165                 return (NULL);
 166         }
 167 
 168         /*
 169          * Succsesful conversion.
 170          */
 171         if (fp != NULL) {
 172                 if (label == NULL)
 173                         label = "";
 174                 if (ctf_add_label(fp, label, fp->ctf_typemax, 0) == CTF_ERR) {
 175                         *errp = ctf_errno(fp);
 176                         ctf_close(fp);
 177                         return (NULL);
 178                 }
 179                 if (ctf_update(fp) == CTF_ERR) {
 180                         *errp = ctf_errno(fp);
 181                         ctf_close(fp);
 182                         return (NULL);
 183                 }
 184         }
 185 
 186         return (fp);
 187 }
 188 
 189 ctf_file_t *
 190 ctf_fdconvert(int fd, const char *label, uint_t nthrs, uint_t flags, int *errp,
 191     char *errbuf, size_t errlen)
 192 {
 193         int err;
   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 2019 Joyent, Inc.
  14  */
  15 
  16 /*
  17  * Main conversion entry points. This has been designed such that there can be
  18  * any number of different conversion backends. Currently we only have one that
  19  * understands DWARFv2 (and bits of DWARFv4). Each backend should be placed in
  20  * the ctf_converters list and each will be tried in turn.
  21  */
  22 
  23 #include <libctf_impl.h>
  24 #include <gelf.h>
  25 
  26 ctf_convert_f ctf_converters[] = {
  27         ctf_dwarf_convert
  28 };
  29 
  30 #define NCONVERTS       (sizeof (ctf_converters) / sizeof (ctf_convert_f))
  31 
  32 typedef enum ctf_convert_source {
  33         CTFCONV_SOURCE_NONE = 0x0,


 151                 if (cs == CTF_CONV_ERROR) {
 152                         fp = NULL;
 153                         notsup = B_FALSE;
 154                         break;
 155                 }
 156         }
 157 
 158         if (notsup == B_TRUE) {
 159                 if ((flags & CTF_CONVERT_F_IGNNONC) != 0 &&
 160                     (type & CTFCONV_SOURCE_C) == 0) {
 161                         *errp = ECTF_CONVNOCSRC;
 162                         return (NULL);
 163                 }
 164                 *errp = ECTF_NOCONVBKEND;
 165                 return (NULL);
 166         }
 167 
 168         /*
 169          * Succsesful conversion.
 170          */
 171         if (fp != NULL && label != NULL) {


 172                 if (ctf_add_label(fp, label, fp->ctf_typemax, 0) == CTF_ERR) {
 173                         *errp = ctf_errno(fp);
 174                         ctf_close(fp);
 175                         return (NULL);
 176                 }
 177                 if (ctf_update(fp) == CTF_ERR) {
 178                         *errp = ctf_errno(fp);
 179                         ctf_close(fp);
 180                         return (NULL);
 181                 }
 182         }
 183 
 184         return (fp);
 185 }
 186 
 187 ctf_file_t *
 188 ctf_fdconvert(int fd, const char *label, uint_t nthrs, uint_t flags, int *errp,
 189     char *errbuf, size_t errlen)
 190 {
 191         int err;