1.\" $NetBSD: dwarf_new_die.3,v 1.2 2014/03/09 16:58:04 christos 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 2074 2011-10-27 03:34:33Z jkoshy 28.\" 29.Dd September 4, 2011 30.Os 31.Dt DWARF_NEW_DIE 3 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 ERRORS 112Function 113.Fn dwarf_new_die 114can fail with: 115.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT" 116.It Bq Er DW_DLE_ARGUMENT 117Argument 118.Ar dbg 119was NULL. 120.It Bq Er DW_DLE_ARGUMENT 121More than one of the arguments 122.Ar parent , 123.Ar child , 124.Ar left 125and 126.Ar right 127were non-NULL. 128.It Bq Er DW_DLE_MEMORY 129An out of memory condition was encountered during the execution of the 130function. 131.El 132.Sh EXAMPLES 133To create debugging information entries and add them to the producer 134instance, use: 135.Bd -literal -offset indent 136Dwarf_P_Debug dbg; 137Dwarf_P_Die die1, die2; 138Dwarf_Error de; 139 140/* ... assume dbg refers to a DWARF producer instance ... */ 141 142die1 = dwarf_new_die(dbg, DW_TAG_compilation_unit, NULL, NULL, NULL, 143 NULL, &de); 144if (die1 == NULL) { 145 warnx("dwarf_new_die failed: %s", dwarf_errmsg(-1)); 146 return; 147} 148 149die2 = dwarf_new_die(dbg, DW_TAG_base_type, die1, NULL, NULL, 150 NULL, &de); 151if (die1 == NULL) { 152 warnx("dwarf_new_die failed: %s", dwarf_errmsg(-1)); 153 return; 154} 155 156if (dwarf_add_die_to_debug(dbg, die1, &de) != DW_DLV_OK) { 157 warnx("dwarf_add_die_to_debug failed: %s", dwarf_errmsg(-1)); 158 return; 159} 160.Ed 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