1.\" Copyright (c) 2010 Kai Wang 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $Id: dwarf_next_cu_header.3 2074 2011-10-27 03:34:33Z jkoshy $ 26.\" 27.Dd July 24, 2010 28.Os 29.Dt DWARF_NEXT_CU_HEADER 3 30.Sh NAME 31.Nm dwarf_next_cu_header , 32.Nm dwarf_next_cu_header_b 33.Nd step through compilation units in a DWARF debug context 34.Sh LIBRARY 35.Lb libdwarf 36.Sh SYNOPSIS 37.In libdwarf.h 38.Ft int 39.Fo dwarf_next_cu_header 40.Fa "Dwarf_Debug dbg" 41.Fa "Dwarf_Unsigned *cu_length" 42.Fa "Dwarf_Half *cu_version" 43.Fa "Dwarf_Off *cu_abbrev_offset" 44.Fa "Dwarf_Half *cu_pointer_size" 45.Fa "Dwarf_Unsigned *cu_next_offset" 46.Fa "Dwarf_Error *err" 47.Fc 48.Ft int 49.Fo dwarf_next_cu_header_b 50.Fa "Dwarf_Debug dbg" 51.Fa "Dwarf_Unsigned *cu_length" 52.Fa "Dwarf_Half *cu_version" 53.Fa "Dwarf_Off *cu_abbrev_offset" 54.Fa "Dwarf_Half *cu_pointer_size" 55.Fa "Dwarf_Half *cu_offset_size" 56.Fa "Dwarf_Half *cu_extension_size" 57.Fa "Dwarf_Unsigned *cu_next_offset" 58.Fa "Dwarf_Error *err" 59.Fc 60.Sh DESCRIPTION 61These functions are used to step through compilation unit contexts 62associated with a DWARF debug context, optionally returning information 63about the unit. 64.Pp 65Function 66.Fn dwarf_next_cu_header_b 67is the API recommended for new application code. 68Argument 69.Ar dbg 70should reference a DWARF debug context allocated using 71.Xr dwarf_init 3 . 72Argument 73.Ar cu_length 74should point to a location that will be set to the 75length of the compilation unit. 76Argument 77.Ar cu_version 78should point to a location that will be set to the 79version number for the compilation unit. 80Argument 81.Ar cu_abbrev_offset 82should point to a location that will be set to the 83starting offset (in the 84.Dq .debug_abbrev 85section) of the set of debugging information entry abbreviations 86associated with this compilation unit. 87Argument 88.Ar cu_pointer_size 89should point to a location that will be set to the 90size in bytes of an address for the machine architecture of the 91underlying object being debugged. 92Argument 93.Ar cu_offset_size 94should point to a location that will be set to the 95size in bytes for a DWARF offset in the compilation unit. 96Argument 97.Ar cu_extension_size 98is only needed for processing MIPS/IRIX objects that use 99a non-standard DWARF format. 100It should point to a location that will be set to 4 for normal 101objects and to 0 for non-standard ones. 102Argument 103.Ar cu_next_offset 104should point to a location that will be set to the 105offset of the next compilation unit header in the 106.Dq \&.debug_info 107section. 108Argument 109.Ar err 110should point to a location that will hold an error descriptor in case 111of an error. 112.Pp 113Function 114.Fn dwarf_next_cu_header 115is less general than 116.Fn dwarf_next_cu_header_b , 117and is deprecated for use by new application code. 118Argument 119.Ar dbg 120should reference a DWARF debug context allocated using 121.Xr dwarf_init 3 . 122Argument 123.Ar cu_length 124should point to a location that will be set to the 125length of the compilation unit. 126Argument 127.Ar cu_version 128should point to a location that will be set to the 129version number for the compilation unit. 130Argument 131.Ar cu_abbrev_offset 132should point to a location that will be set to the 133starting offset in the 134.Dq .debug_abbrev 135section of the set of debugging information entry abbreviations 136associated with this compilation unit. 137Argument 138.Ar cu_pointer_size 139should point to a location that will be set to the 140size of an address in bytes for the machine architecture of the 141underlying debugging object. 142Argument 143.Ar cu_next_offset 144should point to a location that will be set to the 145offset of the next compilation unit. 146Argument 147.Ar err 148should point to a location that will hold an error descriptor in case 149of an error. 150.Pp 151A value of NULL may be used for any of the arguments 152.Ar cu_length , 153.Ar cu_version , 154.Ar cu_abbrev_offset , 155.Ar cu_pointer_size , 156.Ar cu_offset_size , 157.Ar cu_extension_size , 158.Ar cu_next_offset 159and 160.Ar err 161if the caller is not interested in the respective value. 162.Ss Iterating Through Compilation Units in a Debug Context 163.Pp 164The first call to functions 165.Fn dwarf_next_cu_header_b 166and 167.Fn dwarf_next_cu_header 168for a given debug context will return information about the first 169compilation unit in the debug context. 170Subsequent calls to these functions will iterate through the remaining 171compilation units in the debug context. 172On stepping past the last compilation unit in the debug context, 173functions 174.Fn dwarf_next_cu_header 175and 176.Fn dwarf_next_cu_header_b 177return 178.Dv DW_DLV_NO_ENTRY 179and reset their internal state. 180The next call to these functions will restart from the first compilation 181unit in the debug context. 182.Sh RETURN VALUES 183On success, these functions return 184.Dv DW_DLV_OK . 185In case of an error, they return 186.Dv DW_DLV_ERROR 187and set argument 188.Ar err . 189When there are no more compilation units left to traverse, they return 190.Dv DW_DLV_NO_ENTRY . 191.Sh ERRORS 192These functions can fail with the following error: 193.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT" 194.It Bq Er DW_DLE_ARGUMENT 195Argument 196.Va dbg 197was NULL. 198.El 199.Sh SEE ALSO 200.Xr dwarf 3 , 201.Xr dwarf_get_cu_die_offset_given_cu_header_offset 3 , 202.Xr dwarf_init 3 , 203.Xr dwarf_siblingof 3 204