1.\" $NetBSD: dwarf_new_die.3,v 1.4 2020/11/26 22:51:35 jkoshy Exp $ 2.\" 3.\" Copyright (c) 2011 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_new_die.3 3644 2018-10-15 19:55:01Z jkoshy 28.\" 29.Dd September 4, 2011 30.Dt DWARF_NEW_DIE 3 31.Os 32.Sh NAME 33.Nm dwarf_new_die 34.Nd allocate a new debugging information entry 35.Sh LIBRARY 36.Lb libdwarf 37.Sh SYNOPSIS 38.In libdwarf.h 39.Ft Dwarf_P_Die 40.Fo dwarf_new_die 41.Fa "Dwarf_P_Debug dbg" 42.Fa "Dwarf_Tag tag" 43.Fa "Dwarf_P_Die parent" 44.Fa "Dwarf_P_Die child" 45.Fa "Dwarf_P_Die left" 46.Fa "Dwarf_P_Die right" 47.Fa "Dwarf_Error *err" 48.Fc 49.Sh DESCRIPTION 50Function 51.Fn dwarf_new_die 52allocates a new DWARF debugging information entry and links it 53to another debugging information entry. 54.Pp 55Argument 56.Ar dbg 57should reference a DWARF producer instance allocated using 58.Xr dwarf_producer_init 3 59or 60.Xr dwarf_producer_init_b 3 . 61.Pp 62Argument 63.Ar tag 64should specify the tag of the newly created debugging information entry. 65Valid values for this argument are those for the 66.Dv DW_TAG_ Ns * 67symbols defined in 68.In libdwarf.h . 69.Pp 70Argument 71.Ar parent 72specifies the parent link of the debugging information entry. 73.Pp 74Argument 75.Ar child 76specifies the first child link of the debugging information entry. 77.Pp 78Argument 79.Ar left 80specifies the left sibling link of the debugging information entry. 81.Pp 82Argument 83.Ar right 84specifies the right sibling link of the debugging information entry. 85.Pp 86Only one of arguments 87.Ar parent , 88.Ar child , 89.Ar left 90and 91.Ar right 92is allowed to be non-NULL. 93Application code can subsequently call the function 94.Xr dwarf_die_link 3 95to change the links for the created debugging information entry. 96.Pp 97If argument 98.Ar err 99is not NULL, it will be used to store error information in case 100of an error. 101.Sh RETURN VALUES 102On success, function 103.Fn dwarf_new_die 104returns the newly created debugging information entry. 105In case of an error, function 106.Fn dwarf_new_die 107returns 108.Dv DW_DLV_BADADDR 109and sets the argument 110.Ar err . 111.Sh EXAMPLES 112To create debugging information entries and add them to the producer 113instance, use: 114.Bd -literal -offset indent 115Dwarf_P_Debug dbg; 116Dwarf_P_Die die1, die2; 117Dwarf_Error de; 118 119/* ... assume dbg refers to a DWARF producer instance ... */ 120 121die1 = dwarf_new_die(dbg, DW_TAG_compilation_unit, NULL, NULL, NULL, 122 NULL, &de); 123if (die1 == NULL) { 124 warnx("dwarf_new_die failed: %s", dwarf_errmsg(-1)); 125 return; 126} 127 128die2 = dwarf_new_die(dbg, DW_TAG_base_type, die1, NULL, NULL, 129 NULL, &de); 130if (die1 == NULL) { 131 warnx("dwarf_new_die failed: %s", dwarf_errmsg(-1)); 132 return; 133} 134 135if (dwarf_add_die_to_debug(dbg, die1, &de) != DW_DLV_OK) { 136 warnx("dwarf_add_die_to_debug failed: %s", dwarf_errmsg(-1)); 137 return; 138} 139.Ed 140.Sh ERRORS 141Function 142.Fn dwarf_new_die 143can fail with: 144.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT" 145.It Bq Er DW_DLE_ARGUMENT 146Argument 147.Ar dbg 148was NULL. 149.It Bq Er DW_DLE_ARGUMENT 150More than one of the arguments 151.Ar parent , 152.Ar child , 153.Ar left 154and 155.Ar right 156were non-NULL. 157.It Bq Er DW_DLE_MEMORY 158An out of memory condition was encountered during the execution of the 159function. 160.El 161.Sh SEE ALSO 162.Xr dwarf 3 , 163.Xr dwarf_add_die_to_debug 3 , 164.Xr dwarf_die_link 3 , 165.Xr dwarf_producer_init 3 , 166.Xr dwarf_producer_init_b 3 167