1.\" Copyright (c) 2011 Kai Wang 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $Id: dwarf_new_die.3 2074 2011-10-27 03:34:33Z jkoshy $ 26.\" 27.Dd September 4, 2011 28.Os 29.Dt DWARF_NEW_DIE 3 30.Sh NAME 31.Nm dwarf_new_die 32.Nd allocate a new debugging information entry 33.Sh LIBRARY 34.Lb libdwarf 35.Sh SYNOPSIS 36.In libdwarf.h 37.Ft Dwarf_P_Die 38.Fo dwarf_new_die 39.Fa "Dwarf_P_Debug dbg" 40.Fa "Dwarf_Tag tag" 41.Fa "Dwarf_P_Die parent" 42.Fa "Dwarf_P_Die child" 43.Fa "Dwarf_P_Die left" 44.Fa "Dwarf_P_Die right" 45.Fa "Dwarf_Error *err" 46.Fc 47.Sh DESCRIPTION 48Function 49.Fn dwarf_new_die 50allocates a new DWARF debugging information entry and links it 51to another debugging information entry. 52.Pp 53Argument 54.Ar dbg 55should reference a DWARF producer instance allocated using 56.Xr dwarf_producer_init 3 57or 58.Xr dwarf_producer_init_b 3 . 59.Pp 60Argument 61.Ar tag 62should specify the tag of the newly created debugging information entry. 63Valid values for this argument are those for the 64.Dv DW_TAG_ Ns * 65symbols defined in 66.In libdwarf.h . 67.Pp 68Argument 69.Ar parent 70specifies the parent link of the debugging information entry. 71.Pp 72Argument 73.Ar child 74specifies the first child link of the debugging information entry. 75.Pp 76Argument 77.Ar left 78specifies the left sibling link of the debugging information entry. 79.Pp 80Argument 81.Ar right 82specifies the right sibling link of the debugging information entry. 83.Pp 84Only one of arguments 85.Ar parent , 86.Ar child , 87.Ar left 88and 89.Ar right 90is allowed to be non-NULL. 91Application code can subsequently call the function 92.Xr dwarf_die_link 3 93to change the links for the created debugging information entry. 94.Pp 95If argument 96.Ar err 97is not NULL, it will be used to store error information in case 98of an error. 99.Sh RETURN VALUES 100On success, function 101.Fn dwarf_new_die 102returns the newly created debugging information entry. 103In case of an error, function 104.Fn dwarf_new_die 105returns 106.Dv DW_DLV_BADADDR 107and sets the argument 108.Ar err . 109.Sh ERRORS 110Function 111.Fn dwarf_new_die 112can fail with: 113.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT" 114.It Bq Er DW_DLE_ARGUMENT 115Argument 116.Ar dbg 117was NULL. 118.It Bq Er DW_DLE_ARGUMENT 119More than one of the arguments 120.Ar parent , 121.Ar child , 122.Ar left 123and 124.Ar right 125were non-NULL. 126.It Bq Er DW_DLE_MEMORY 127An out of memory condition was encountered during the execution of the 128function. 129.El 130.Sh EXAMPLES 131To create debugging information entries and add them to the producer 132instance, use: 133.Bd -literal -offset indent 134Dwarf_P_Debug dbg; 135Dwarf_P_Die die1, die2; 136Dwarf_Error de; 137 138/* ... assume dbg refers to a DWARF producer instance ... */ 139 140die1 = dwarf_new_die(dbg, DW_TAG_compilation_unit, NULL, NULL, NULL, 141 NULL, &de); 142if (die1 == NULL) { 143 warnx("dwarf_new_die failed: %s", dwarf_errmsg(-1)); 144 return; 145} 146 147die2 = dwarf_new_die(dbg, DW_TAG_base_type, die1, NULL, NULL, 148 NULL, &de); 149if (die1 == NULL) { 150 warnx("dwarf_new_die failed: %s", dwarf_errmsg(-1)); 151 return; 152} 153 154if (dwarf_add_die_to_debug(dbg, die1, &de) != DW_DLV_OK) { 155 warnx("dwarf_add_die_to_debug failed: %s", dwarf_errmsg(-1)); 156 return; 157} 158.Ed 159.Sh SEE ALSO 160.Xr dwarf 3 , 161.Xr dwarf_add_die_to_debug 3 , 162.Xr dwarf_die_link 3 , 163.Xr dwarf_producer_init 3 , 164.Xr dwarf_producer_init_b 3 165