xref: /netbsd-src/external/bsd/elftoolchain/dist/libdwarf/dwarf_dieoffset.3 (revision 5ac3bc719ce6e70593039505b491894133237d12)
1*5ac3bc71Schristos.\"	$NetBSD: dwarf_dieoffset.3,v 1.6 2024/03/03 17:37:30 christos Exp $
2e81373b4Schristos.\"
342bd3019Schristos.\" Copyright (c) 2010,2014 Kai Wang
49dd9d0cfSchristos.\" All rights reserved.
59dd9d0cfSchristos.\"
69dd9d0cfSchristos.\" Redistribution and use in source and binary forms, with or without
79dd9d0cfSchristos.\" modification, are permitted provided that the following conditions
89dd9d0cfSchristos.\" are met:
99dd9d0cfSchristos.\" 1. Redistributions of source code must retain the above copyright
109dd9d0cfSchristos.\"    notice, this list of conditions and the following disclaimer.
119dd9d0cfSchristos.\" 2. Redistributions in binary form must reproduce the above copyright
129dd9d0cfSchristos.\"    notice, this list of conditions and the following disclaimer in the
139dd9d0cfSchristos.\"    documentation and/or other materials provided with the distribution.
149dd9d0cfSchristos.\"
159dd9d0cfSchristos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
169dd9d0cfSchristos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
179dd9d0cfSchristos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
189dd9d0cfSchristos.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
199dd9d0cfSchristos.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
209dd9d0cfSchristos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
219dd9d0cfSchristos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
229dd9d0cfSchristos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
239dd9d0cfSchristos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
249dd9d0cfSchristos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
259dd9d0cfSchristos.\" SUCH DAMAGE.
269dd9d0cfSchristos.\"
27cdbf1fe1Sjkoshy.\" Id: dwarf_dieoffset.3 3962 2022-03-12 15:56:10Z jkoshy
289dd9d0cfSchristos.\"
2942bd3019Schristos.Dd December 21, 2014
309dd9d0cfSchristos.Dt DWARF_DIEOFFSET 3
31604b0842Sjkoshy.Os
329dd9d0cfSchristos.Sh NAME
339dd9d0cfSchristos.Nm dwarf_die_CU_offset ,
349dd9d0cfSchristos.Nm dwarf_die_CU_offset_range ,
359dd9d0cfSchristos.Nm dwarf_dieoffset ,
3642bd3019Schristos.Nm dwarf_get_cu_die_offset_given_cu_header_offset ,
3742bd3019Schristos.Nm dwarf_get_cu_die_offset_given_cu_header_offset_b
389dd9d0cfSchristos.Nd return offsets of DWARF debugging information entries
399dd9d0cfSchristos.Sh LIBRARY
409dd9d0cfSchristos.Lb libdwarf
419dd9d0cfSchristos.Sh SYNOPSIS
429dd9d0cfSchristos.In libdwarf.h
439dd9d0cfSchristos.Ft int
449dd9d0cfSchristos.Fo dwarf_die_CU_offset
459dd9d0cfSchristos.Fa "Dwarf_Die die"
469dd9d0cfSchristos.Fa "Dwarf_Off *ret_offset"
479dd9d0cfSchristos.Fa "Dwarf_Error *err"
489dd9d0cfSchristos.Fc
499dd9d0cfSchristos.Ft int
509dd9d0cfSchristos.Fo dwarf_die_CU_offset_range
519dd9d0cfSchristos.Fa "Dwarf_Die die"
529dd9d0cfSchristos.Fa "Dwarf_Off *cu_offset"
539dd9d0cfSchristos.Fa "Dwarf_Off *cu_length"
549dd9d0cfSchristos.Fa "Dwarf_Error *err"
559dd9d0cfSchristos.Fc
569dd9d0cfSchristos.Ft int
579dd9d0cfSchristos.Fo dwarf_dieoffset
589dd9d0cfSchristos.Fa "Dwarf_Die die"
599dd9d0cfSchristos.Fa "Dwarf_Off *ret_offset"
609dd9d0cfSchristos.Fa "Dwarf_Error *err"
619dd9d0cfSchristos.Fc
629dd9d0cfSchristos.Ft int
639dd9d0cfSchristos.Fo dwarf_get_cu_die_offset_given_cu_header_offset
649dd9d0cfSchristos.Fa "Dwarf_Debug dbg"
659dd9d0cfSchristos.Fa "Dwarf_Off in_cu_header_offset"
669dd9d0cfSchristos.Fa "Dwarf_Off *out_cu_die_offset"
679dd9d0cfSchristos.Fa "Dwarf_Error *err"
689dd9d0cfSchristos.Fc
6942bd3019Schristos.Ft int
7042bd3019Schristos.Fo dwarf_get_cu_die_offset_given_cu_header_offset_b
7142bd3019Schristos.Fa "Dwarf_Debug dbg"
7242bd3019Schristos.Fa "Dwarf_Off in_cu_header_offset"
7342bd3019Schristos.Fa "Dwarf_Bool is_info"
7442bd3019Schristos.Fa "Dwarf_Off *out_cu_die_offset"
7542bd3019Schristos.Fa "Dwarf_Error *err"
7642bd3019Schristos.Fc
779dd9d0cfSchristos.Sh DESCRIPTION
789dd9d0cfSchristosThese functions are used to retrieve offsets for DWARF debugging
799dd9d0cfSchristosinformation entries.
809dd9d0cfSchristos.Pp
819dd9d0cfSchristosFunction
829dd9d0cfSchristos.Fn dwarf_die_CU_offset
839dd9d0cfSchristosreturns the offset of the debugging information entry referenced by
849dd9d0cfSchristosargument
85cdbf1fe1Sjkoshy.Fa die
869dd9d0cfSchristosrelative to the start of its containing compilation unit.
879dd9d0cfSchristosArgument
88cdbf1fe1Sjkoshy.Fa ret_offset
899dd9d0cfSchristosshould point to the location that is to hold the returned offset.
909dd9d0cfSchristosIf argument
91cdbf1fe1Sjkoshy.Fa err
92cdbf1fe1Sjkoshyis
93cdbf1fe1Sjkoshy.No non- Ns Dv NULL ,
94cdbf1fe1Sjkoshyit will be used to return an error descriptor in case of an error.
959dd9d0cfSchristos.Pp
969dd9d0cfSchristosFunction
979dd9d0cfSchristos.Fn dwarf_die_CU_offset_range
989dd9d0cfSchristosreturns the section-relative offset and length of the compilation unit
999dd9d0cfSchristoscontaining the debugging information entry referenced by argument
100cdbf1fe1Sjkoshy.Fa die .
1019dd9d0cfSchristosArgument
102cdbf1fe1Sjkoshy.Fa cu_offset
1039dd9d0cfSchristosshould point to a location that will hold the returned offset.
1049dd9d0cfSchristosArgument
105cdbf1fe1Sjkoshy.Fa cu_length
1069dd9d0cfSchristosshould point to a location that will hold the returned length of the
1079dd9d0cfSchristoscompilation unit.
1089dd9d0cfSchristosIf argument
109cdbf1fe1Sjkoshy.Fa err
110cdbf1fe1Sjkoshyis
111cdbf1fe1Sjkoshy.No non- Ns Dv NULL ,
112cdbf1fe1Sjkoshyit will be used to return an error descriptor in case of an error.
1139dd9d0cfSchristos.Pp
1149dd9d0cfSchristosFunction
1159dd9d0cfSchristos.Fn dwarf_dieoffset
1169dd9d0cfSchristosretrieves the section-relative offset of the debugging information
1179dd9d0cfSchristosentry referenced by argument
118cdbf1fe1Sjkoshy.Fa die .
1199dd9d0cfSchristosArgument
120cdbf1fe1Sjkoshy.Fa ret_offset
1219dd9d0cfSchristosshould point to a location that is to hold the returned
1229dd9d0cfSchristossection-relative offset.
1239dd9d0cfSchristosIf argument
124cdbf1fe1Sjkoshy.Fa err
125cdbf1fe1Sjkoshyis
126cdbf1fe1Sjkoshy.No non- Ns Dv NULL ,
127cdbf1fe1Sjkoshyit will be used to return an error descriptor in case of an error.
1289dd9d0cfSchristos.Pp
1299dd9d0cfSchristosFunction
1309dd9d0cfSchristos.Fn dwarf_get_cu_die_offset_given_cu_header_offset
13142bd3019Schristosreturns the offset for the first debugging information entry for a
1329dd9d0cfSchristoscompilation unit, given an offset to the header of the compilation
1339dd9d0cfSchristosunit.
1349dd9d0cfSchristosArgument
135cdbf1fe1Sjkoshy.Fa dbg
1369dd9d0cfSchristosshould reference a valid debugging context allocated using
1379dd9d0cfSchristos.Xr dwarf_init 3 .
1389dd9d0cfSchristosArgument
139cdbf1fe1Sjkoshy.Fa in_cu_header_offset
1409dd9d0cfSchristoscontains the offset to the start of a compilation unit.
1419dd9d0cfSchristosArgument
142cdbf1fe1Sjkoshy.Fa out_cu_die_offset
1439dd9d0cfSchristospoints to a location that will hold the returned offset.
1449dd9d0cfSchristosIf argument
145cdbf1fe1Sjkoshy.Fa err
146cdbf1fe1Sjkoshyis
147cdbf1fe1Sjkoshy.No non- Ns Dv NULL ,
148cdbf1fe1Sjkoshyit will be used to return an error descriptor in case of an error.
14942bd3019Schristos.Pp
15042bd3019SchristosFunction
15142bd3019Schristos.Fn dwarf_get_cu_die_offset_given_cu_header_offset_b
15242bd3019Schristosbehaves identically to the function
15342bd3019Schristos.Fn dwarf_get_cu_die_offset_given_cu_header_offset
15442bd3019Schristoswhen the argument
155cdbf1fe1Sjkoshy.Fa is_info
15642bd3019Schristosis non-zero.
15742bd3019SchristosWhen the argument
158cdbf1fe1Sjkoshy.Fa is_info
15942bd3019Schristosis zero, function
16042bd3019Schristos.Fn dwarf_get_cu_die_offset_given_cu_header_offset_b
16142bd3019Schristosreturns the offset for the first debugging information entry for a
16242bd3019Schristostype unit, given an offset to the header of the type unit in argument
163cdbf1fe1Sjkoshy.Fa in_cu_header_offset .
16442bd3019SchristosArgument
165cdbf1fe1Sjkoshy.Fa out_cu_die_offset
16642bd3019Schristospoints to a location that will hold the returned offset.
16742bd3019SchristosIf the argument
168cdbf1fe1Sjkoshy.Fa err
169cdbf1fe1Sjkoshyis
170cdbf1fe1Sjkoshy.No non- Ns Dv NULL ,
171cdbf1fe1Sjkoshyit will be used to return an error descriptor in case of an error.
1729dd9d0cfSchristos.Sh RETURN VALUES
17342bd3019SchristosOn success, these functions return
1749dd9d0cfSchristos.Dv DW_DLV_OK .
1759dd9d0cfSchristosIn case of an error, these functions return
1769dd9d0cfSchristos.Dv DW_DLV_ERROR
1779dd9d0cfSchristosand set argument
178cdbf1fe1Sjkoshy.Fa err .
1799dd9d0cfSchristos.Pp
1809dd9d0cfSchristosFunction
1819dd9d0cfSchristos.Fn dwarf_get_cu_die_offset_given_cu_header_offset
18242bd3019Schristosand
18342bd3019Schristos.Fn dwarf_get_cu_die_offset_given_cu_header_offset_b
1849dd9d0cfSchristosreturns
1859dd9d0cfSchristos.Dv DW_DLV_NO_ENTRY
1869dd9d0cfSchristosand sets argument
187cdbf1fe1Sjkoshy.Fa err
18842bd3019Schristosif there is no compilation or type unit located at the
1899dd9d0cfSchristosoffset specified in argument
190cdbf1fe1Sjkoshy.Fa in_cu_header_offset .
1919dd9d0cfSchristos.Sh ERRORS
1929dd9d0cfSchristosThese functions may fail with the following errors:
1939dd9d0cfSchristos.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
1949dd9d0cfSchristos.It Bq Er DW_DLE_ARGUMENT
1959dd9d0cfSchristosOne of the arguments
1969dd9d0cfSchristos.Va cu_length ,
1979dd9d0cfSchristos.Va cu_offset ,
1989dd9d0cfSchristos.Va dbg ,
1999dd9d0cfSchristos.Va die ,
2009dd9d0cfSchristos.Va out_cu_die_offset
2019dd9d0cfSchristosor
2029dd9d0cfSchristos.Va ret_offset
203cdbf1fe1Sjkoshywas
204cdbf1fe1Sjkoshy.Dv NULL .
2059dd9d0cfSchristos.It Bq Er DW_DLE_NO_ENTRY
2069dd9d0cfSchristosArgument
207cdbf1fe1Sjkoshy.Fa in_cu_header_offset
2089dd9d0cfSchristosspecified an unknown offset.
2099dd9d0cfSchristos.El
2109dd9d0cfSchristos.Sh SEE ALSO
2119dd9d0cfSchristos.Xr dwarf 3 ,
2129dd9d0cfSchristos.Xr dwarf_next_cu_header 3 ,
21342bd3019Schristos.Xr dwarf_offdie 3 ,
21442bd3019Schristos.Xr dwarf_offdie_b 3
215