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 #ifndef _MDB_CTF_H 27 #define _MDB_CTF_H 28 29 #include <mdb/mdb_target.h> 30 #include <libctf.h> 31 32 #ifdef _MDB 33 #include <sys/machelf.h> 34 #endif 35 36 /* 37 * The following directive tells the mapfile generator that prototypes and 38 * declarations ending with an "Internal" comment should be excluded from the 39 * mapfile. 40 * 41 * MAPFILE: exclude "Internal" 42 */ 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 48 typedef struct mdb_ctf_id { 49 void *_opaque[2]; 50 } mdb_ctf_id_t; 51 52 typedef struct mdb_ctf_funcinfo { 53 mdb_ctf_id_t mtf_return; /* function return type */ 54 uint_t mtf_argc; /* number of arguments */ 55 uint_t mtf_flags; /* function attributes (see libctf.h) */ 56 uint_t mtf_symidx; /* for ctf_func_args */ 57 } mdb_ctf_funcinfo_t; 58 59 typedef struct mdb_ctf_arinfo { 60 mdb_ctf_id_t mta_contents; /* type of array conents */ 61 mdb_ctf_id_t mta_index; /* type of array index */ 62 uint_t mta_nelems; /* number of elements */ 63 } mdb_ctf_arinfo_t; 64 65 typedef int mdb_ctf_visit_f(const char *, mdb_ctf_id_t, mdb_ctf_id_t, ulong_t, 66 int, void *); 67 typedef int mdb_ctf_member_f(const char *, mdb_ctf_id_t, ulong_t, void *); 68 typedef int mdb_ctf_enum_f(const char *, int, void *); 69 typedef int mdb_ctf_type_f(mdb_ctf_id_t, void *); 70 71 extern int mdb_ctf_enabled_by_object(const char *); 72 73 extern int mdb_ctf_lookup_by_name(const char *, mdb_ctf_id_t *); 74 extern int mdb_ctf_lookup_by_addr(uintptr_t, mdb_ctf_id_t *); 75 76 extern int mdb_ctf_module_lookup(const char *, mdb_ctf_id_t *); 77 78 extern int mdb_ctf_func_info(const GElf_Sym *, const mdb_syminfo_t *, 79 mdb_ctf_funcinfo_t *); 80 extern int mdb_ctf_func_args(const mdb_ctf_funcinfo_t *, uint_t, 81 mdb_ctf_id_t *); 82 83 extern void mdb_ctf_type_invalidate(mdb_ctf_id_t *); 84 extern int mdb_ctf_type_valid(mdb_ctf_id_t); 85 extern int mdb_ctf_type_cmp(mdb_ctf_id_t, mdb_ctf_id_t); 86 87 extern int mdb_ctf_type_resolve(mdb_ctf_id_t, mdb_ctf_id_t *); 88 extern char *mdb_ctf_type_name(mdb_ctf_id_t, char *, size_t); 89 extern ssize_t mdb_ctf_type_size(mdb_ctf_id_t); 90 extern int mdb_ctf_type_kind(mdb_ctf_id_t); 91 extern int mdb_ctf_type_reference(const mdb_ctf_id_t, mdb_ctf_id_t *); 92 extern int mdb_ctf_type_encoding(mdb_ctf_id_t, ctf_encoding_t *); 93 extern int mdb_ctf_type_visit(mdb_ctf_id_t, mdb_ctf_visit_f *, void *); 94 95 extern int mdb_ctf_array_info(mdb_ctf_id_t, mdb_ctf_arinfo_t *); 96 extern const char *mdb_ctf_enum_name(mdb_ctf_id_t, int); 97 98 extern int mdb_ctf_member_iter(mdb_ctf_id_t, mdb_ctf_member_f *, void *); 99 extern int mdb_ctf_enum_iter(mdb_ctf_id_t, mdb_ctf_enum_f *, void *); 100 extern int mdb_ctf_type_iter(const char *, mdb_ctf_type_f *, void *); 101 102 /* utility stuff */ 103 extern ctf_id_t mdb_ctf_type_id(mdb_ctf_id_t); 104 extern ctf_file_t *mdb_ctf_type_file(mdb_ctf_id_t); 105 106 107 extern int mdb_ctf_member_info(mdb_ctf_id_t, const char *, 108 ulong_t *, mdb_ctf_id_t *); 109 extern int mdb_ctf_offsetof(mdb_ctf_id_t, const char *, ulong_t *); 110 extern int mdb_ctf_num_members(mdb_ctf_id_t); 111 112 extern ssize_t mdb_ctf_offset_to_name(mdb_ctf_id_t, ulong_t, char *, size_t, 113 int, mdb_ctf_id_t *, ulong_t *); 114 115 #define MDB_CTF_VREAD_IGNORE_GROW 0x01 116 #define MDB_CTF_VREAD_IGNORE_ABSENT 0x02 117 #define MDB_CTF_VREAD_IGNORE_UNIONS 0x04 118 119 #define MDB_CTF_VREAD_IGNORE_ALL 0x07 120 121 extern int mdb_ctf_vread(void *, const char *, uintptr_t, uint_t); 122 extern int mdb_ctf_readsym(void *, const char *, const char *, uint_t); 123 124 #ifdef _MDB 125 126 extern ctf_file_t *mdb_ctf_open(const char *, int *); /* Internal */ 127 extern ctf_file_t *mdb_ctf_bufopen(const void *, size_t, /* Internal */ 128 const void *, Shdr *, const void *, Shdr *, int *); 129 extern void mdb_ctf_close(ctf_file_t *fp); /* Internal */ 130 131 #endif 132 133 #ifdef __cplusplus 134 } 135 #endif 136 137 #endif /* _MDB_CTF_H */ 138