1 /* 2 Copyright (C) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. 3 Portions Copyright (C) 2009-2010 David Anderson. All Rights Reserved. 4 5 This program is free software; you can redistribute it and/or modify it 6 under the terms of version 2.1 of the GNU Lesser General Public License 7 as published by the Free Software Foundation. 8 9 This program is distributed in the hope that it would be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 13 Further, this software is distributed without any warranty that it is 14 free of the rightful claim of any third person regarding infringement 15 or the like. Any license provided herein, whether implied or 16 otherwise, applies only to this software file. Patent licenses, if 17 any, provided herein do not apply to combinations of this program with 18 other software, or any other product whatsoever. 19 20 You should have received a copy of the GNU Lesser General Public 21 License along with this program; if not, write the Free Software 22 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, 23 USA. 24 25 Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, 26 Mountain View, CA 94043, or: 27 28 http://www.sgi.com 29 30 For further information regarding this notice, see: 31 32 http://oss.sgi.com/projects/GenInfo/NoticeExplan 33 34 */ 35 36 37 38 #include "config.h" 39 #include "dwarf_incl.h" 40 #include <stdio.h> 41 #include "dwarf_types.h" 42 #include "dwarf_global.h" 43 44 int 45 dwarf_get_types(Dwarf_Debug dbg, 46 Dwarf_Type ** types, 47 Dwarf_Signed * ret_type_count, Dwarf_Error * error) 48 { 49 int res = _dwarf_load_section(dbg, &dbg->de_debug_typenames,error); 50 if (res != DW_DLV_OK) { 51 return res; 52 } 53 54 return _dwarf_internal_get_pubnames_like_data(dbg, 55 dbg->de_debug_typenames.dss_data, 56 dbg->de_debug_typenames.dss_size, 57 (Dwarf_Global **) types, /* type punning, Dwarf_Type is 58 never a completed type */ 59 ret_type_count, 60 error, 61 DW_DLA_TYPENAME_CONTEXT, 62 DW_DLA_TYPENAME, 63 DW_DLE_DEBUG_TYPENAMES_LENGTH_BAD, 64 DW_DLE_DEBUG_TYPENAMES_VERSION_ERROR); 65 } 66 67 /* Deallocating fully requires deallocating the list 68 and all entries. But some internal data is 69 not exposed, so we need a function with internal knowledge. 70 */ 71 72 void 73 dwarf_types_dealloc(Dwarf_Debug dbg, Dwarf_Type * dwgl, 74 Dwarf_Signed count) 75 { 76 _dwarf_internal_globals_dealloc(dbg, (Dwarf_Global *) dwgl, 77 count, 78 DW_DLA_TYPENAME_CONTEXT, 79 DW_DLA_TYPENAME, DW_DLA_LIST); 80 return; 81 } 82 83 84 int 85 dwarf_typename(Dwarf_Type type_in, char **ret_name, Dwarf_Error * error) 86 { 87 Dwarf_Global type = (Dwarf_Global) type_in; 88 89 if (type == NULL) { 90 _dwarf_error(NULL, error, DW_DLE_TYPE_NULL); 91 return (DW_DLV_ERROR); 92 } 93 94 *ret_name = (char *) (type->gl_name); 95 return DW_DLV_OK; 96 } 97 98 99 int 100 dwarf_type_die_offset(Dwarf_Type type_in, 101 Dwarf_Off * ret_offset, Dwarf_Error * error) 102 { 103 Dwarf_Global type = (Dwarf_Global) type_in; 104 105 return dwarf_global_die_offset(type, ret_offset, error); 106 } 107 108 109 int 110 dwarf_type_cu_offset(Dwarf_Type type_in, 111 Dwarf_Off * ret_offset, Dwarf_Error * error) 112 { 113 Dwarf_Global type = (Dwarf_Global) type_in; 114 115 return dwarf_global_cu_offset(type, ret_offset, error); 116 } 117 118 119 int 120 dwarf_type_name_offsets(Dwarf_Type type_in, 121 char **returned_name, 122 Dwarf_Off * die_offset, 123 Dwarf_Off * cu_die_offset, Dwarf_Error * error) 124 { 125 Dwarf_Global type = (Dwarf_Global) type_in; 126 return dwarf_global_name_offsets(type, 127 returned_name, 128 die_offset, cu_die_offset, error); 129 } 130