1.\" $NetBSD: dwarf_add_line_entry.3,v 1.3 2016/02/20 02:43:41 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_add_line_entry.3 3182 2015-04-10 16:08:10Z emaste 28.\" 29.Dd June 30, 2013 30.Os 31.Dt DWARF_ADD_LINE_ENTRY 3 32.Sh NAME 33.Nm dwarf_add_line_entry 34.Nd add a line number information entry to a producer instance 35.Sh LIBRARY 36.Lb libdwarf 37.Sh SYNOPSIS 38.In libdwarf.h 39.Ft "Dwarf_Unsigned" 40.Fo dwarf_add_line_entry 41.Fa "Dwarf_P_Debug dbg" 42.Fa "Dwarf_Unsigned filendx" 43.Fa "Dwarf_Addr off" 44.Fa "Dwarf_Unsigned lineno" 45.Fa "Dwarf_Signed column" 46.Fa "Dwarf_Bool is_stmt" 47.Fa "Dwarf_Bool basic_block" 48.Fa "Dwarf_Error *err" 49.Fc 50.Sh DESCRIPTION 51Function 52.Fn dwarf_add_line_entry 53adds a line number information entry to a DWARF producer instance. 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 filendx 64specifies the index of the source file that contains the source line 65in question. 66Valid source file indices are those returned by the function 67.Xr dwarf_add_file_decl 3 . 68.Pp 69Argument 70.Ar off 71specifies a relocatable program address. 72The ELF symbol to be used 73for relocation is set by a prior call to the function 74.Xr dwarf_lne_set_address 3 . 75.Pp 76Argument 77.Ar lineno 78specifies the line number of the source line. 79.Pp 80Argument 81.Ar column 82specifies the column number within the source line. 83.Pp 84If the argument 85.Ar is_stmt 86is set to true, it indicates that the instruction at the address 87specified by argument 88.Ar off 89is a recommended breakpoint location, i.e., the first instruction in 90the instruction sequence generated by the source line. 91.Pp 92If the argument 93.Ar basic_block 94is set to true, it indicates that the instruction at the address 95specified by argument 96.Ar off 97is the first instruction of a basic block. 98.Pp 99If argument 100.Ar err 101is not NULL, it will be used to store error information in case 102of an error. 103.Sh RETURN VALUES 104On success, function 105.Fn dwarf_add_line_entry 106returns 107.Dv DW_DLV_OK . 108In case of an error, function 109.Fn dwarf_add_line_entry 110returns 111.Dv DW_DLV_NOCOUNT 112and sets the argument 113.Ar err . 114.Sh ERRORS 115Function 116.Fn dwarf_add_line_entry 117can fail with: 118.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT" 119.It Bq Er DW_DLE_ARGUMENT 120Argument 121.Ar dbg 122was NULL. 123.It Bq Er DW_DLE_ARGUMENT 124The function 125.Xr dwarf_lne_set_address 3 126was not called before calling this function. 127.It Bq Er DW_DLE_MEMORY 128An out of memory condition was encountered during the execution of the 129function. 130.El 131.Sh EXAMPLE 132To add line number information to the producer instance, use: 133.Bd -literal -offset indent 134Dwarf_P_Debug dbg; 135Dwarf_Error de; 136Dwarf_Unsigned dir, filendx; 137 138/* ... assume dbg refers to a DWARF producer instance ... */ 139 140dir = dwarf_add_directory_decl(dbg, "/home/foo", &de); 141if (dir == DW_DLV_NOCOUNT) 142 errx(EXIT_FAILURE, "dwarf_add_directory_decl failed: %s", 143 dwarf_errmsg(-1)); 144 145filendx = dwarf_add_file_decl(dbg, "bar.c", dir, 0, 1234, &de); 146if (filendx == DW_DLV_NOCOUNT) 147 errx(EXIT_FAILURE, "dwarf_add_file_decl failed: %s", 148 dwarf_errmsg(-1)); 149 150if (dwarf_lne_set_address(dbg, 0x4012b0, 12, &de) != DW_DLV_OK) 151 errx(EXIT_FAILURE, "dwarf_lne_set_address failed: %s", 152 dwarf_errmsg(-1)); 153 154if (dwarf_add_line_entry(dbg, filendx, 10, 258, 0, 1, 1, &de) != 155 DW_DLV_OK) 156 errx(EXIT_FAILURE, "dwarf_add_line_entry failed: %s", 157 dwarf_errmsg(-1)); 158.Ed 159.Sh SEE ALSO 160.Xr dwarf 3 , 161.Xr dwarf_add_directory_decl 3 , 162.Xr dwarf_add_file_decl 3 , 163.Xr dwarf_lne_end_sequence 3 , 164.Xr dwarf_lne_set_address 3 , 165.Xr dwarf_producer_init 3 , 166.Xr dwarf_producer_init_b 3 167