1 .\" $NetBSD: dwarf_srclines.3,v 1.2 2014/03/09 16:58:04 christos Exp $
3 .\" Copyright (c) 2010 Joseph Koshy. All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" This software is provided by Joseph Koshy ``as is'' and
15 .\" any express or implied warranties, including, but not limited to, the
16 .\" implied warranties of merchantability and fitness for a particular purpose
17 .\" are disclaimed. in no event shall Joseph Koshy be liable
18 .\" for any direct, indirect, incidental, special, exemplary, or consequential
19 .\" damages (including, but not limited to, procurement of substitute goods
20 .\" or services; loss of use, data, or profits; or business interruption)
21 .\" however caused and on any theory of liability, whether in contract, strict
22 .\" liability, or tort (including negligence or otherwise) arising in any way
23 .\" out of the use of this software, even if advised of the possibility of
26 .\" Id: dwarf_srclines.3 2122 2011-11-09 15:35:14Z jkoshy
33 .Nd retrieve line number information for a debugging information entry
41 .Fa "Dwarf_Line **lines"
42 .Fa "Dwarf_Signed *nlines"
43 .Fa "Dwarf_Error *err"
48 returns line number information associated with a compilation unit.
49 Line number information is returned as an array of
55 should reference a DWARF debugging information entry descriptor
56 with line number information, see
60 should point to a location that will hold a pointer to the returned array
66 should point to a location that will hold the number of descriptors
70 is not NULL, it will be used to store error information in case of an
75 descriptors may be passed to the other line number functions in the
76 API set to retrieve specific information about each source line.
78 The memory area used for the array of
80 descriptors returned in argument
84 The application should not attempt to free this pointer.
85 Portable code should instead use
86 .Fn dwarf_srclines_dealloc
87 to indicate that the memory may be freed.
94 In case of an error, it returns
102 .Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
103 .It Bq Er DW_DLE_ARGUMENT
110 .It Bq Er DW_DLE_NO_ENTRY
111 The compilation unit referenced by argument
113 does not have associated line number information.
114 .It Bq Er DW_DLE_MEMORY
115 An out of memory condition was encountered during the execution of
119 To obtain an array of
121 descriptors and to retrieve the source file, line number, and virtual address
122 associated with each descriptor:
123 .Bd -literal -offset indent
131 Dwarf_Unsigned lineno;
133 /* variable "die" should reference a DIE for a compilation unit */
135 if (dwarf_srclines(die, &lines, &nlines, &de) != DW_DLV_OK)
136 errx(EXIT_FAILURE, "dwarf_srclines: %s", dwarf_errmsg(de));
138 for (n = 0; n < nlines; n++) {
139 /* Retrieve the file name for this descriptor. */
140 if (dwarf_linesrc(lines[n], &filename, &de))
141 errx(EXIT_FAILURE, "dwarf_linesrc: %s",
144 /* Retrieve the line number in the source file. */
145 if (dwarf_lineno(lines[n], &lineno, &de))
146 errx(EXIT_FAILURE, "dwarf_lineno: %s",
148 /* Retrieve the virtual address for this line. */
149 if (dwarf_lineaddr(lines[n], &lineaddr, &de))
150 errx(EXIT_FAILURE, "dwarf_lineaddr: %s",
156 .Xr dwarf_line_srcfileno 3 ,
157 .Xr dwarf_lineaddr 3 ,
158 .Xr dwarf_linebeginstatement 3 ,
159 .Xr dwarf_lineblock 3 ,
160 .Xr dwarf_lineendsequence 3 ,
162 .Xr dwarf_lineoff 3 ,
163 .Xr dwarf_linesrc 3 ,
164 .Xr dwarf_srcfiles 3 ,
165 .Xr dwarf_srclines_dealloc 3