]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/elftoolchain/libdwarf/dwarf_new_die.3
sysctl(9): Fix a few mandoc related issues
[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 3644 2018-10-15 19:55:01Z jkoshy $
26 .\"
27 .Dd September 4, 2011
28 .Dt DWARF_NEW_DIE 3
29 .Os
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 EXAMPLES
110 To create debugging information entries and add them to the producer
111 instance, use:
112 .Bd -literal -offset indent
113 Dwarf_P_Debug dbg;
114 Dwarf_P_Die die1, die2;
115 Dwarf_Error de;
116
117 /* ... assume dbg refers to a DWARF producer instance ... */
118
119 die1 = dwarf_new_die(dbg, DW_TAG_compilation_unit, NULL, NULL, NULL,
120     NULL, &de);
121 if (die1 == NULL) {
122         warnx("dwarf_new_die failed: %s", dwarf_errmsg(-1));
123         return;
124 }
125
126 die2 = dwarf_new_die(dbg, DW_TAG_base_type, die1, NULL, NULL,
127     NULL, &de);
128 if (die1 == NULL) {
129         warnx("dwarf_new_die failed: %s", dwarf_errmsg(-1));
130         return;
131 }
132
133 if (dwarf_add_die_to_debug(dbg, die1, &de) != DW_DLV_OK) {
134         warnx("dwarf_add_die_to_debug failed: %s", dwarf_errmsg(-1));
135         return;
136 }
137 .Ed
138 .Sh ERRORS
139 Function
140 .Fn dwarf_new_die
141 can fail with:
142 .Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
143 .It Bq Er DW_DLE_ARGUMENT
144 Argument
145 .Ar dbg
146 was NULL.
147 .It Bq Er DW_DLE_ARGUMENT
148 More than one of the arguments
149 .Ar parent ,
150 .Ar child ,
151 .Ar left
152 and
153 .Ar right
154 were non-NULL.
155 .It Bq Er DW_DLE_MEMORY
156 An out of memory condition was encountered during the execution of the
157 function.
158 .El
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