xref: /netbsd-src/external/bsd/elftoolchain/dist/libdwarf/dwarf_lineno.3 (revision 5ac3bc719ce6e70593039505b491894133237d12)
1.\"	$NetBSD: dwarf_lineno.3,v 1.6 2024/03/03 17:37:31 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_lineno.3 3963 2022-03-12 16:07:32Z jkoshy
28.\"
29.Dd February 5, 2011
30.Dt DWARF_LINENO 3
31.Os
32.Sh NAME
33.Nm dwarf_lineaddr ,
34.Nm dwarf_linebeginstatement ,
35.Nm dwarf_lineblock ,
36.Nm dwarf_lineendsequence ,
37.Nm dwarf_lineno ,
38.Nm dwarf_lineoff ,
39.Nm dwarf_linesrc ,
40.Nm dwarf_line_srcfileno
41.Nd retrieve information associated with a DWARF line descriptor
42.Sh LIBRARY
43.Lb libdwarf
44.Sh SYNOPSIS
45.In libdwarf.h
46.Ft int
47.Fo dwarf_lineaddr
48.Fa "Dwarf_Line ln"
49.Fa "Dwarf_Addr *ret"
50.Fa "Dwarf_Error *err"
51.Fc
52.Ft int
53.Fo dwarf_linebeginstatement
54.Fa "Dwarf_Line ln"
55.Fa "Dwarf_Bool *ret"
56.Fa "Dwarf_Error *err"
57.Fc
58.Ft int
59.Fo dwarf_lineblock
60.Fa "Dwarf_Line ln"
61.Fa "Dwarf_Bool *ret"
62.Fa "Dwarf_Error *err"
63.Fc
64.Ft int
65.Fo dwarf_lineendsequence
66.Fa "Dwarf_Line ln"
67.Fa "Dwarf_Bool *ret"
68.Fa "Dwarf_Error *err"
69.Fc
70.Ft int
71.Fo dwarf_lineno
72.Fa "Dwarf_Line ln"
73.Fa "Dwarf_Unsigned *ret"
74.Fa "Dwarf_Error *err"
75.Fc
76.Ft int
77.Fo dwarf_lineoff
78.Fa "Dwarf_Line ln"
79.Fa "Dwarf_Signed *ret"
80.Fa "Dwarf_Error *err"
81.Fc
82.Ft int
83.Fo dwarf_linesrc
84.Fa "Dwarf_Line ln"
85.Fa "char **ret"
86.Fa "Dwarf_Error *err"
87.Fc
88.Ft int
89.Fo dwarf_line_srcfileno
90.Fa "Dwarf_Line ln"
91.Fa "Dwarf_Unsigned *ret"
92.Fa "Dwarf_Error *err"
93.Fc
94.Sh DESCRIPTION
95These functions retrieve specific line information associated with
96the line descriptor specified by argument
97.Fa ln ,
98and stores it in the location pointed to by argument
99.Fa ret .
100If argument
101.Fa err
102is not
103.Dv NULL ,
104it will be used to store error information in case of an error.
105.Pp
106Function
107.Fn dwarf_lineaddr
108stores the program address corresponding to the source line specified
109in argument
110.Fa ln
111into the location pointed to by argument
112.Fa ret .
113.Pp
114Function
115.Fn dwarf_linebeginstatement
116sets the location pointed to by argument
117.Fa ret
118to 1 if the source line specified by the line descriptor
119.Fa ln
120is the beginning of a statement, or to 0 otherwise.
121.Pp
122Function
123.Fn dwarf_lineblock
124sets the location pointed to by argument
125.Fa ret
126to 1 if the source line specified by the line descriptor
127.Fa ln
128is the beginning of a basic block, or to 0 otherwise.
129.Pp
130Function
131.Fn dwarf_lineendsequence
132sets the location pointed to by argument
133.Fa ret
134to 1 if the program address associated with the line descriptor
135.Fa ln
136is the address immediately following the end of a sequence of target
137machine instructions, or to 0 otherwise.
138.Pp
139Function
140.Fn dwarf_lineno
141stores the line number of the source line associated with the line
142descriptor
143.Fa ln
144into the location pointed to by argument
145.Fa ret .
146.Pp
147Function
148.Fn dwarf_lineoff
149stores the column number within a line associated with descriptor
150.Fa ln
151into the location pointed to by argument
152.Fa ret .
153The retrieved column numbers are 1-based, with the value -1 indicating
154that column number information was not available.
155.Pp
156Function
157.Fn dwarf_linesrc
158stores a pointer to a NUL-terminated string containing the source file
159name associated with line descriptor
160.Fa ln
161into the location pointed to by argument
162.Fa ret .
163The full path of the source file is returned if possible.
164The memory used for the source file name string is managed by the DWARF(3)
165library and should not be directly freed by application code.
166Instead, portable code should use
167.Xr dwarf_dealloc 3
168to indicate that the string should be freed.
169.Pp
170Function
171.Fn dwarf_line_srcfileno
172stores the index of the source file associated with the line descriptor
173.Fa ln
174in the location pointed to by argument
175.Fa ret .
176The returned value is 1-based index into the array of source file
177names returned by
178.Xr dwarf_srcfiles 3 .
179.Sh RETURN VALUES
180On success, these functions returns
181.Dv DW_DLV_OK .
182In case of an error, they return
183.Dv DW_DLV_ERROR
184and set the argument
185.Fa err .
186.Sh ERRORS
187These functions may fail with the following errors:
188.Bl -tag -width ".Bq Er DW_DLE_LINE_FILE_NUM_BAD"
189.It Bq Er DW_DLE_ARGUMENT
190Either of the arguments
191.Va ln
192or
193.Va ret
194was
195.Dv NULL .
196.It Bq Er DW_DLE_LINE_FILE_NUM_BAD
197The source file name associated with the line descriptor
198.Fa ln
199could not be retrieved by function
200.Fn dwarf_linesrc .
201.El
202.Sh SEE ALSO
203.Xr dwarf 3 ,
204.Xr dwarf_dealloc 3 ,
205.Xr dwarf_srcfiles 3 ,
206.Xr dwarf_srclines 3
207