1*2de3b87aSKai Wang.\" Copyright (c) 2011 Kai Wang 2*2de3b87aSKai Wang.\" All rights reserved. 3*2de3b87aSKai Wang.\" 4*2de3b87aSKai Wang.\" Redistribution and use in source and binary forms, with or without 5*2de3b87aSKai Wang.\" modification, are permitted provided that the following conditions 6*2de3b87aSKai Wang.\" are met: 7*2de3b87aSKai Wang.\" 1. Redistributions of source code must retain the above copyright 8*2de3b87aSKai Wang.\" notice, this list of conditions and the following disclaimer. 9*2de3b87aSKai Wang.\" 2. Redistributions in binary form must reproduce the above copyright 10*2de3b87aSKai Wang.\" notice, this list of conditions and the following disclaimer in the 11*2de3b87aSKai Wang.\" documentation and/or other materials provided with the distribution. 12*2de3b87aSKai Wang.\" 13*2de3b87aSKai Wang.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14*2de3b87aSKai Wang.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15*2de3b87aSKai Wang.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16*2de3b87aSKai Wang.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17*2de3b87aSKai Wang.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18*2de3b87aSKai Wang.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19*2de3b87aSKai Wang.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20*2de3b87aSKai Wang.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21*2de3b87aSKai Wang.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22*2de3b87aSKai Wang.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23*2de3b87aSKai Wang.\" SUCH DAMAGE. 24*2de3b87aSKai Wang.\" 25*2de3b87aSKai Wang.\" $Id: dwarf_get_abbrev_entry.3 2071 2011-10-27 03:20:00Z jkoshy $ 26*2de3b87aSKai Wang.\" 27*2de3b87aSKai Wang.Dd April 02, 2011 28*2de3b87aSKai Wang.Os 29*2de3b87aSKai Wang.Dt DWARF_GET_ABBREV_ENTRY 3 30*2de3b87aSKai Wang.Sh NAME 31*2de3b87aSKai Wang.Nm dwarf_get_abbrev_entry 32*2de3b87aSKai Wang.Nd retrieve attribute information from an abbreviation descriptor 33*2de3b87aSKai Wang.Sh LIBRARY 34*2de3b87aSKai Wang.Lb libdwarf 35*2de3b87aSKai Wang.Sh SYNOPSIS 36*2de3b87aSKai Wang.In libdwarf.h 37*2de3b87aSKai Wang.Ft int 38*2de3b87aSKai Wang.Fo dwarf_get_abbrev_entry 39*2de3b87aSKai Wang.Fa "Dwarf_Abbrev abbrev" 40*2de3b87aSKai Wang.Fa "Dwarf_Signed ndx" 41*2de3b87aSKai Wang.Fa "Dwarf_Half *code" 42*2de3b87aSKai Wang.Fa "Dwarf_Signed *form" 43*2de3b87aSKai Wang.Fa "Dwarf_Off *offset" 44*2de3b87aSKai Wang.Fa "Dwarf_Error *err" 45*2de3b87aSKai Wang.Fc 46*2de3b87aSKai Wang.Sh DESCRIPTION 47*2de3b87aSKai WangFunction 48*2de3b87aSKai Wang.Fn dwarf_get_abbrev_entry 49*2de3b87aSKai Wangretrieves attribute information from a DWARF abbreviation descriptor. 50*2de3b87aSKai Wang.Pp 51*2de3b87aSKai WangArgument 52*2de3b87aSKai Wang.Ar abbrev 53*2de3b87aSKai Wangshould be a valid abbreviation descriptor, as returned by function 54*2de3b87aSKai Wang.Xr dwarf_get_abbrev 3 . 55*2de3b87aSKai Wang.Pp 56*2de3b87aSKai WangArgument 57*2de3b87aSKai Wang.Ar ndx 58*2de3b87aSKai Wangspecifies the 0-based index of the attribute. 59*2de3b87aSKai WangThe total count of the attributes contained in the abbreviation 60*2de3b87aSKai Wangentry can be retrieved using the function 61*2de3b87aSKai Wang.Xr dwarf_get_abbrev 3 . 62*2de3b87aSKai Wang.Pp 63*2de3b87aSKai WangArgument 64*2de3b87aSKai Wang.Ar code 65*2de3b87aSKai Wangshould point to a location which will hold a returned 66*2de3b87aSKai Wangattribute code. 67*2de3b87aSKai Wang.Pp 68*2de3b87aSKai WangArgument 69*2de3b87aSKai Wang.Ar form 70*2de3b87aSKai Wangshould point to a location which will hold the returned 71*2de3b87aSKai Wangform of the attribute. 72*2de3b87aSKai Wang.Pp 73*2de3b87aSKai WangArgument 74*2de3b87aSKai Wang.Ar offset 75*2de3b87aSKai Wangshould point to a location which will hold a returned offset, relative 76*2de3b87aSKai Wangto the 77*2de3b87aSKai Wang.Dq ".debug_abbrev" 78*2de3b87aSKai Wangsection, for the specified attribute. 79*2de3b87aSKai Wang.Pp 80*2de3b87aSKai WangIf argument 81*2de3b87aSKai Wang.Ar err 82*2de3b87aSKai Wangis not NULL, it will be used to return an error descriptor in case 83*2de3b87aSKai Wangof an error. 84*2de3b87aSKai Wang.Sh RETURN VALUES 85*2de3b87aSKai WangFunction 86*2de3b87aSKai Wang.Fn dwarf_get_abbrev_entry 87*2de3b87aSKai Wangreturns 88*2de3b87aSKai Wang.Dv DW_DLV_OK 89*2de3b87aSKai Wangwhen it succeeds. 90*2de3b87aSKai WangIt returns 91*2de3b87aSKai Wang.Dv DW_DLV_NO_ENTRY 92*2de3b87aSKai Wangif the attribute index specified by argument 93*2de3b87aSKai Wang.Ar ndx 94*2de3b87aSKai Wangis out of range. 95*2de3b87aSKai WangIn case of an error, it returns 96*2de3b87aSKai Wang.Dv DW_DLV_ERROR 97*2de3b87aSKai Wangand sets the argument 98*2de3b87aSKai Wang.Ar err . 99*2de3b87aSKai Wang.Sh ERRORS 100*2de3b87aSKai WangFunction 101*2de3b87aSKai Wang.Fn dwarf_get_abbrev_entry 102*2de3b87aSKai Wangcan fail with: 103*2de3b87aSKai Wang.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY" 104*2de3b87aSKai Wang.It Bq Er DW_DLE_ARGUMENT 105*2de3b87aSKai WangOne of the arguments 106*2de3b87aSKai Wang.Ar abbrev , 107*2de3b87aSKai Wang.Ar code , 108*2de3b87aSKai Wang.Ar form 109*2de3b87aSKai Wangor 110*2de3b87aSKai Wang.Ar offset 111*2de3b87aSKai Wangwas NULL. 112*2de3b87aSKai Wang.It Bq Er DW_DLE_NO_ENTRY 113*2de3b87aSKai WangThe attribute index specified by argument 114*2de3b87aSKai Wang.Ar ndx 115*2de3b87aSKai Wangwas out of range. 116*2de3b87aSKai Wang.El 117*2de3b87aSKai Wang.Sh EXAMPLE 118*2de3b87aSKai WangTo loop through all the attribute entries contained in the 119*2de3b87aSKai Wangabbreviation section, use: 120*2de3b87aSKai Wang.Bd -literal -offset indent 121*2de3b87aSKai WangDwarf_Debug dbg; 122*2de3b87aSKai WangDwarf_Abbrev ab; 123*2de3b87aSKai WangDwarf_Off aboff, atoff; 124*2de3b87aSKai WangDwarf_Signed form; 125*2de3b87aSKai WangDwarf_Half attr; 126*2de3b87aSKai WangDwarf_Unsigned length, attr_count; 127*2de3b87aSKai WangDwarf_Error de; 128*2de3b87aSKai Wangint i, ret; 129*2de3b87aSKai Wang 130*2de3b87aSKai Wang/* ...allocate 'dbg' using dwarf_init(3) ... */ 131*2de3b87aSKai Wang 132*2de3b87aSKai Wangwhile ((ret = dwarf_next_cu_header(dbg, NULL, NULL, &aboff, 133*2de3b87aSKai Wang NULL, NULL, &de)) == DW_DLV_OK) { 134*2de3b87aSKai Wang while ((ret = dwarf_get_abbrev(dbg, aboff, &ab, &length, 135*2de3b87aSKai Wang &attr_count, &de)) == DW_DLV_OK) { 136*2de3b87aSKai Wang if (length == 1) /* Last entry. */ 137*2de3b87aSKai Wang break; 138*2de3b87aSKai Wang aboff += length; 139*2de3b87aSKai Wang for (i = 0; (Dwarf_Unsigned) i < attr_count; i++) { 140*2de3b87aSKai Wang if (dwarf_get_abbrev_entry(ab, i, 141*2de3b87aSKai Wang &attr, &form, &atoff, &de) != DW_DLV_OK) { 142*2de3b87aSKai Wang warnx("dwarf_get_abbrev_entry failed:" 143*2de3b87aSKai Wang " %s", dwarf_errmsg(de)); 144*2de3b87aSKai Wang continue; 145*2de3b87aSKai Wang } 146*2de3b87aSKai Wang /* .. use the retrieved information ... */ 147*2de3b87aSKai Wang } 148*2de3b87aSKai Wang } 149*2de3b87aSKai Wang 150*2de3b87aSKai Wang if (ret != DW_DLV_OK) 151*2de3b87aSKai Wang warnx("dwarf_get_abbrev: %s", dwarf_errmsg(de)); 152*2de3b87aSKai Wang} 153*2de3b87aSKai Wang 154*2de3b87aSKai Wangif (ret == DW_DLV_ERROR) 155*2de3b87aSKai Wang warnx("dwarf_next_cu_header: %s", dwarf_errmsg(de)); 156*2de3b87aSKai Wang.Ed 157*2de3b87aSKai Wang.Sh SEE ALSO 158*2de3b87aSKai Wang.Xr dwarf 3 , 159*2de3b87aSKai Wang.Xr dwarf_get_abbrev 3 160