]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/elftoolchain/libdwarf/dwarf_new_die.3
Upgrade Unbound to 1.8.0. More to follow.
[FreeBSD/FreeBSD.git] / contrib / elftoolchain / libdwarf / dwarf_new_die.3
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
48 Function
49 .Fn dwarf_new_die
50 allocates a new DWARF debugging information entry and links it
51 to another debugging information entry.
52 .Pp
53 Argument
54 .Ar dbg
55 should reference a DWARF producer instance allocated using
56 .Xr dwarf_producer_init 3
57 or
58 .Xr dwarf_producer_init_b 3 .
59 .Pp
60 Argument
61 .Ar tag
62 should specify the tag of the newly created debugging information entry.
63 Valid values for this argument are those for the
64 .Dv DW_TAG_ Ns *
65 symbols defined in
66 .In libdwarf.h .
67 .Pp
68 Argument
69 .Ar parent
70 specifies the parent link of the debugging information entry.
71 .Pp
72 Argument
73 .Ar child
74 specifies the first child link of the debugging information entry.
75 .Pp
76 Argument
77 .Ar left
78 specifies the left sibling link of the debugging information entry.
79 .Pp
80 Argument
81 .Ar right
82 specifies the right sibling link of the debugging information entry.
83 .Pp
84 Only one of arguments
85 .Ar parent ,
86 .Ar child ,
87 .Ar left
88 and
89 .Ar right
90 is allowed to be non-NULL.
91 Application code can subsequently call the function
92 .Xr dwarf_die_link 3
93 to change the links for the created debugging information entry.
94 .Pp
95 If argument
96 .Ar err
97 is not NULL, it will be used to store error information in case
98 of an error.
99 .Sh RETURN VALUES
100 On success, function
101 .Fn dwarf_new_die
102 returns the newly created debugging information entry.
103 In case of an error, function
104 .Fn dwarf_new_die
105 returns
106 .Dv DW_DLV_BADADDR
107 and sets the argument
108 .Ar err .
109 .Sh ERRORS
110 Function
111 .Fn dwarf_new_die
112 can fail with:
113 .Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
114 .It Bq Er DW_DLE_ARGUMENT
115 Argument
116 .Ar dbg
117 was NULL.
118 .It Bq Er DW_DLE_ARGUMENT
119 More than one of the arguments
120 .Ar parent ,
121 .Ar child ,
122 .Ar left
123 and
124 .Ar right
125 were non-NULL.
126 .It Bq Er DW_DLE_MEMORY
127 An out of memory condition was encountered during the execution of the
128 function.
129 .El
130 .Sh EXAMPLES
131 To create debugging information entries and add them to the producer
132 instance, use:
133 .Bd -literal -offset indent
134 Dwarf_P_Debug dbg;
135 Dwarf_P_Die die1, die2;
136 Dwarf_Error de;
137
138 /* ... assume dbg refers to a DWARF producer instance ... */
139
140 die1 = dwarf_new_die(dbg, DW_TAG_compilation_unit, NULL, NULL, NULL,
141     NULL, &de);
142 if (die1 == NULL) {
143         warnx("dwarf_new_die failed: %s", dwarf_errmsg(-1));
144         return;
145 }
146
147 die2 = dwarf_new_die(dbg, DW_TAG_base_type, die1, NULL, NULL,
148     NULL, &de);
149 if (die1 == NULL) {
150         warnx("dwarf_new_die failed: %s", dwarf_errmsg(-1));
151         return;
152 }
153
154 if (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