xref: /netbsd-src/external/bsd/elftoolchain/dist/libdwarf/dwarf_new_die.3 (revision 5ac3bc719ce6e70593039505b491894133237d12)
1*5ac3bc71Schristos.\"	$NetBSD: dwarf_new_die.3,v 1.6 2024/03/03 17:37:31 christos Exp $
2e81373b4Schristos.\"
39dd9d0cfSchristos.\" Copyright (c) 2011 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_new_die.3 3963 2022-03-12 16:07:32Z jkoshy
289dd9d0cfSchristos.\"
299dd9d0cfSchristos.Dd September 4, 2011
309dd9d0cfSchristos.Dt DWARF_NEW_DIE 3
31604b0842Sjkoshy.Os
329dd9d0cfSchristos.Sh NAME
339dd9d0cfSchristos.Nm dwarf_new_die
349dd9d0cfSchristos.Nd allocate a new debugging information entry
359dd9d0cfSchristos.Sh LIBRARY
369dd9d0cfSchristos.Lb libdwarf
379dd9d0cfSchristos.Sh SYNOPSIS
389dd9d0cfSchristos.In libdwarf.h
399dd9d0cfSchristos.Ft Dwarf_P_Die
409dd9d0cfSchristos.Fo dwarf_new_die
419dd9d0cfSchristos.Fa "Dwarf_P_Debug dbg"
429dd9d0cfSchristos.Fa "Dwarf_Tag tag"
439dd9d0cfSchristos.Fa "Dwarf_P_Die parent"
449dd9d0cfSchristos.Fa "Dwarf_P_Die child"
459dd9d0cfSchristos.Fa "Dwarf_P_Die left"
469dd9d0cfSchristos.Fa "Dwarf_P_Die right"
479dd9d0cfSchristos.Fa "Dwarf_Error *err"
489dd9d0cfSchristos.Fc
499dd9d0cfSchristos.Sh DESCRIPTION
509dd9d0cfSchristosFunction
519dd9d0cfSchristos.Fn dwarf_new_die
529dd9d0cfSchristosallocates a new DWARF debugging information entry and links it
539dd9d0cfSchristosto another debugging information entry.
549dd9d0cfSchristos.Pp
559dd9d0cfSchristosArgument
56cdbf1fe1Sjkoshy.Fa dbg
579dd9d0cfSchristosshould reference a DWARF producer instance allocated using
589dd9d0cfSchristos.Xr dwarf_producer_init 3
599dd9d0cfSchristosor
609dd9d0cfSchristos.Xr dwarf_producer_init_b 3 .
619dd9d0cfSchristos.Pp
629dd9d0cfSchristosArgument
63cdbf1fe1Sjkoshy.Fa tag
649dd9d0cfSchristosshould specify the tag of the newly created debugging information entry.
659dd9d0cfSchristosValid values for this argument are those for the
669dd9d0cfSchristos.Dv DW_TAG_ Ns *
679dd9d0cfSchristossymbols defined in
689dd9d0cfSchristos.In libdwarf.h .
699dd9d0cfSchristos.Pp
709dd9d0cfSchristosArgument
71cdbf1fe1Sjkoshy.Fa parent
729dd9d0cfSchristosspecifies the parent link of the debugging information entry.
739dd9d0cfSchristos.Pp
749dd9d0cfSchristosArgument
75cdbf1fe1Sjkoshy.Fa child
769dd9d0cfSchristosspecifies the first child link of the debugging information entry.
779dd9d0cfSchristos.Pp
789dd9d0cfSchristosArgument
79cdbf1fe1Sjkoshy.Fa left
809dd9d0cfSchristosspecifies the left sibling link of the debugging information entry.
819dd9d0cfSchristos.Pp
829dd9d0cfSchristosArgument
83cdbf1fe1Sjkoshy.Fa right
849dd9d0cfSchristosspecifies the right sibling link of the debugging information entry.
859dd9d0cfSchristos.Pp
869dd9d0cfSchristosOnly one of arguments
87cdbf1fe1Sjkoshy.Fa parent ,
88cdbf1fe1Sjkoshy.Fa child ,
89cdbf1fe1Sjkoshy.Fa left
909dd9d0cfSchristosand
91cdbf1fe1Sjkoshy.Fa right
92cdbf1fe1Sjkoshyis allowed to be
93cdbf1fe1Sjkoshy.No non- Ns Dv NULL .
949dd9d0cfSchristosApplication code can subsequently call the function
959dd9d0cfSchristos.Xr dwarf_die_link 3
969dd9d0cfSchristosto change the links for the created debugging information entry.
979dd9d0cfSchristos.Pp
989dd9d0cfSchristosIf argument
99cdbf1fe1Sjkoshy.Fa err
100cdbf1fe1Sjkoshyis not
101cdbf1fe1Sjkoshy.Dv NULL ,
102cdbf1fe1Sjkoshyit will be used to store error information in case of an error.
1039dd9d0cfSchristos.Sh RETURN VALUES
1049dd9d0cfSchristosOn success, function
1059dd9d0cfSchristos.Fn dwarf_new_die
1069dd9d0cfSchristosreturns the newly created debugging information entry.
1079dd9d0cfSchristosIn case of an error, function
1089dd9d0cfSchristos.Fn dwarf_new_die
1099dd9d0cfSchristosreturns
1109dd9d0cfSchristos.Dv DW_DLV_BADADDR
1119dd9d0cfSchristosand sets the argument
112cdbf1fe1Sjkoshy.Fa err .
1139dd9d0cfSchristos.Sh EXAMPLES
1149dd9d0cfSchristosTo create debugging information entries and add them to the producer
1159dd9d0cfSchristosinstance, use:
1169dd9d0cfSchristos.Bd -literal -offset indent
1179dd9d0cfSchristosDwarf_P_Debug dbg;
1189dd9d0cfSchristosDwarf_P_Die die1, die2;
1199dd9d0cfSchristosDwarf_Error de;
1209dd9d0cfSchristos
1219dd9d0cfSchristos/* ... assume dbg refers to a DWARF producer instance ... */
1229dd9d0cfSchristos
1239dd9d0cfSchristosdie1 = dwarf_new_die(dbg, DW_TAG_compilation_unit, NULL, NULL, NULL,
1249dd9d0cfSchristos    NULL, &de);
1259dd9d0cfSchristosif (die1 == NULL) {
1269dd9d0cfSchristos	warnx("dwarf_new_die failed: %s", dwarf_errmsg(-1));
1279dd9d0cfSchristos	return;
1289dd9d0cfSchristos}
1299dd9d0cfSchristos
1309dd9d0cfSchristosdie2 = dwarf_new_die(dbg, DW_TAG_base_type, die1, NULL, NULL,
1319dd9d0cfSchristos    NULL, &de);
1329dd9d0cfSchristosif (die1 == NULL) {
1339dd9d0cfSchristos	warnx("dwarf_new_die failed: %s", dwarf_errmsg(-1));
1349dd9d0cfSchristos	return;
1359dd9d0cfSchristos}
1369dd9d0cfSchristos
1379dd9d0cfSchristosif (dwarf_add_die_to_debug(dbg, die1, &de) != DW_DLV_OK) {
1389dd9d0cfSchristos	warnx("dwarf_add_die_to_debug failed: %s", dwarf_errmsg(-1));
1399dd9d0cfSchristos	return;
1409dd9d0cfSchristos}
1419dd9d0cfSchristos.Ed
142604b0842Sjkoshy.Sh ERRORS
143604b0842SjkoshyFunction
144604b0842Sjkoshy.Fn dwarf_new_die
145604b0842Sjkoshycan fail with:
146604b0842Sjkoshy.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
147604b0842Sjkoshy.It Bq Er DW_DLE_ARGUMENT
148604b0842SjkoshyArgument
149cdbf1fe1Sjkoshy.Fa dbg
150cdbf1fe1Sjkoshywas
151cdbf1fe1Sjkoshy.Dv NULL .
152604b0842Sjkoshy.It Bq Er DW_DLE_ARGUMENT
153604b0842SjkoshyMore than one of the arguments
154cdbf1fe1Sjkoshy.Fa parent ,
155cdbf1fe1Sjkoshy.Fa child ,
156cdbf1fe1Sjkoshy.Fa left
157604b0842Sjkoshyand
158cdbf1fe1Sjkoshy.Fa right
159cdbf1fe1Sjkoshywere
160cdbf1fe1Sjkoshy.No non- Ns Dv NULL .
161604b0842Sjkoshy.It Bq Er DW_DLE_MEMORY
162604b0842SjkoshyAn out of memory condition was encountered during the execution of the
163604b0842Sjkoshyfunction.
164604b0842Sjkoshy.El
1659dd9d0cfSchristos.Sh SEE ALSO
1669dd9d0cfSchristos.Xr dwarf 3 ,
1679dd9d0cfSchristos.Xr dwarf_add_die_to_debug 3 ,
1689dd9d0cfSchristos.Xr dwarf_die_link 3 ,
1699dd9d0cfSchristos.Xr dwarf_producer_init 3 ,
1709dd9d0cfSchristos.Xr dwarf_producer_init_b 3
171