1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 /* 26 * Copyright (c) 2013 by Delphix. All rights reserved. 27 */ 28 29 #ifndef _MDB_CTF_H 30 #define _MDB_CTF_H 31 32 #include <mdb/mdb_target.h> 33 #include <libctf.h> 34 35 #ifdef _MDB 36 #include <sys/machelf.h> 37 #endif 38 39 /* 40 * The following directive tells the mapfile generator that prototypes and 41 * declarations ending with an "Internal" comment should be excluded from the 42 * mapfile. 43 * 44 * MAPFILE: exclude "Internal" 45 */ 46 47 #ifdef __cplusplus 48 extern "C" { 49 #endif 50 51 typedef struct mdb_ctf_id { 52 void *_opaque[2]; 53 } mdb_ctf_id_t; 54 55 typedef struct mdb_ctf_funcinfo { 56 mdb_ctf_id_t mtf_return; /* function return type */ 57 uint_t mtf_argc; /* number of arguments */ 58 uint_t mtf_flags; /* function attributes (see libctf.h) */ 59 uint_t mtf_symidx; /* for ctf_func_args */ 60 } mdb_ctf_funcinfo_t; 61 62 typedef struct mdb_ctf_arinfo { 63 mdb_ctf_id_t mta_contents; /* type of array conents */ 64 mdb_ctf_id_t mta_index; /* type of array index */ 65 uint_t mta_nelems; /* number of elements */ 66 } mdb_ctf_arinfo_t; 67 68 typedef int mdb_ctf_visit_f(const char *, mdb_ctf_id_t, mdb_ctf_id_t, ulong_t, 69 int, void *); 70 typedef int mdb_ctf_member_f(const char *, mdb_ctf_id_t, ulong_t, void *); 71 typedef int mdb_ctf_enum_f(const char *, int, void *); 72 typedef int mdb_ctf_type_f(mdb_ctf_id_t, void *); 73 74 extern int mdb_ctf_enabled_by_object(const char *); 75 76 extern int mdb_ctf_lookup_by_name(const char *, mdb_ctf_id_t *); 77 extern int mdb_ctf_lookup_by_addr(uintptr_t, mdb_ctf_id_t *); 78 79 extern int mdb_ctf_module_lookup(const char *, mdb_ctf_id_t *); 80 81 extern int mdb_ctf_func_info(const GElf_Sym *, const mdb_syminfo_t *, 82 mdb_ctf_funcinfo_t *); 83 extern int mdb_ctf_func_args(const mdb_ctf_funcinfo_t *, uint_t, 84 mdb_ctf_id_t *); 85 86 extern void mdb_ctf_type_invalidate(mdb_ctf_id_t *); 87 extern int mdb_ctf_type_valid(mdb_ctf_id_t); 88 extern int mdb_ctf_type_cmp(mdb_ctf_id_t, mdb_ctf_id_t); 89 90 extern int mdb_ctf_type_resolve(mdb_ctf_id_t, mdb_ctf_id_t *); 91 extern char *mdb_ctf_type_name(mdb_ctf_id_t, char *, size_t); 92 extern ssize_t mdb_ctf_type_size(mdb_ctf_id_t); 93 extern int mdb_ctf_type_kind(mdb_ctf_id_t); 94 extern int mdb_ctf_type_reference(const mdb_ctf_id_t, mdb_ctf_id_t *); 95 extern int mdb_ctf_type_encoding(mdb_ctf_id_t, ctf_encoding_t *); 96 extern int mdb_ctf_type_visit(mdb_ctf_id_t, mdb_ctf_visit_f *, void *); 97 98 extern int mdb_ctf_array_info(mdb_ctf_id_t, mdb_ctf_arinfo_t *); 99 extern const char *mdb_ctf_enum_name(mdb_ctf_id_t, int); 100 101 extern int mdb_ctf_member_iter(mdb_ctf_id_t, mdb_ctf_member_f *, void *); 102 extern int mdb_ctf_enum_iter(mdb_ctf_id_t, mdb_ctf_enum_f *, void *); 103 extern int mdb_ctf_type_iter(const char *, mdb_ctf_type_f *, void *); 104 105 /* utility stuff */ 106 extern ctf_id_t mdb_ctf_type_id(mdb_ctf_id_t); 107 extern ctf_file_t *mdb_ctf_type_file(mdb_ctf_id_t); 108 109 110 extern int mdb_ctf_member_info(mdb_ctf_id_t, const char *, 111 ulong_t *, mdb_ctf_id_t *); 112 extern int mdb_ctf_offsetof(mdb_ctf_id_t, const char *, ulong_t *); 113 extern int mdb_ctf_num_members(mdb_ctf_id_t); 114 extern int mdb_ctf_offsetof_by_name(const char *, const char *); 115 116 extern ssize_t mdb_ctf_offset_to_name(mdb_ctf_id_t, ulong_t, char *, size_t, 117 int, mdb_ctf_id_t *, ulong_t *); 118 119 #define MDB_CTF_VREAD_QUIET 0x100 120 121 extern int mdb_ctf_vread(void *, const char *, const char *, 122 uintptr_t, uint_t); 123 extern int mdb_ctf_readsym(void *, const char *, const char *, uint_t); 124 125 #ifdef _MDB 126 127 extern ctf_file_t *mdb_ctf_open(const char *, int *); /* Internal */ 128 extern ctf_file_t *mdb_ctf_bufopen(const void *, size_t, /* Internal */ 129 const void *, Shdr *, const void *, Shdr *, int *); 130 extern void mdb_ctf_close(ctf_file_t *fp); /* Internal */ 131 132 #endif 133 134 #ifdef __cplusplus 135 } 136 #endif 137 138 #endif /* _MDB_CTF_H */ 139