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