1 .\" $NetBSD: dwarf_object_init.3,v 1.2 2014/03/09 16:58:04 christos Exp $
3 .\" Copyright (c) 2011 Joseph Koshy
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
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.
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
27 .\" Id: dwarf_object_init.3 2074 2011-10-27 03:34:33Z jkoshy
29 .Dd September 29, 2011
31 .Dt DWARF_OBJECT_INIT 3
34 .Nd allocate a DWARF debug descriptor with application-specific file \
42 .Fa "Dwarf_Obj_Access_Interface *iface"
43 .Fa "Dwarf_Handler errhand"
44 .Fa "Dwarf_Ptr errarg"
45 .Fa "Dwarf_Debug *dbg"
46 .Fa "Dwarf_Error *err"
52 function allocates and returns a
54 instance that uses application-supplied access methods to read file
59 should point to a populated
60 .Vt Dwarf_Obj_Access_Interface
63 .Vt Dwarf_Obj_Access_Interface
64 structure are described in the section
65 .Sx "Object Access Functions"
70 should point to a function to be called in case of an error.
73 then a default error handling scheme is used.
76 for a description of the error handling schemes available.
80 will be passed to the error handler function pointed to by argument
85 should point to a memory location that will be set to a reference to
92 will be used to return a
94 descriptor in case of an error.
95 .Ss Object Access Functions
96 The data structures used to specify object access methods are defined
99 .Bl -tag -width indent
100 .It Vt "Dwarf_Obj_Access_Interface"
101 This structure bundles together a set of file access methods along
102 with a pointer to application-private state.
103 .Bd -literal -offset indent
106 const Dwarf_Obj_Access_Methods *methods;
107 } Dwarf_Obj_Access_Interface;
110 .Bl -tag -width ".Ar methods" -compact
112 This field points to application-specific state that will be passed as
113 the first parameter to the actual access object methods.
115 This structure contains pointers to the functions implementing the
116 access methods, as described below.
118 .It Vt Dwarf_Obj_Access_Methods
119 This structure specifies the functions implementing low-level access.
120 .Bd -literal -offset indent
122 int (*get_section_info)(void *obj, Dwarf_Half index,
123 Dwarf_Obj_Access_Section *ret, int *error);
124 Dwarf_Endianness (*get_byte_order)(void *obj);
125 Dwarf_Small (*get_length_size)(void *obj);
126 Dwarf_Small (*get_pointer_size)(void *obj);
127 Dwarf_Unsigned (*get_section_count)(void *obj);
128 int (*load_section)(void *obj, Dwarf_Half ndx,
129 Dwarf_Small **ret_data, int *error);
130 } Dwarf_Obj_Access_Methods;
133 .Bl -tag -width ".Ar get_section_count" -compact
134 .It Ar get_byte_order
135 This function should return the endianness of the DWARF object by
136 returning one of the constants
140 .It Ar get_length_size
141 This function should return the number of bytes needed to represent a
142 DWARF offset in the object being debugged.
143 .It Ar get_pointer_size
144 This function should return the size in bytes, in the object being
145 debugged, of a memory address.
146 .It Ar get_section_count
147 This function should return the number of sections in the object being
149 .It Ar get_section_info
150 This function should return information about the section at the
153 by filling in the structure of type
154 .Vt Dwarf_Obj_Access_Section
155 pointed to by argument
158 .Vt Dwarf_Obj_Access_Section
159 structure is described below.
161 This function should load the section specified by argument
163 into memory and place a pointer to the section's data into
164 the location pointed to by argument
170 passed to these functions will be set to the pointer value in the
172 field of the associated
173 .Vt Dwarf_Obj_Access_Interface
178 is used to return an error code in case of an error.
179 .It Vt Dwarf_Obj_Access_Section
180 This structure describes the layout of a section in the DWARF object.
181 .Bd -literal -offset indent
186 } Dwarf_Obj_Access_Section;
189 .Bl -tag -width ".Ar name" -compact
191 A pointer to the start of the section's data.
193 The size of the section in bytes.
195 A pointer to a NUL-terminated string containing the name of the
201 .Fn dwarf_object_init
204 In case of an error, the function returns
206 and sets the argument
210 .Fn dwarf_object_init
211 function may fail with the following errors:
212 .Bl -tag -width ".Bq Er DW_DLE_DEBUG_INFO_NULL"
213 .It Bq Er DW_DLE_ARGUMENT
219 .It Bq Er DW_DLE_DEBUG_INFO_NULL
220 The underlying object did not contain debugging information.
221 .It Bq Er DW_DLE_MEMORY
222 An out of memory condition was encountered during the execution of the
228 .Xr dwarf_init_elf 3 ,
229 .Xr dwarf_object_finish 3