1.\" $NetBSD: dwarf_add_line_entry.3,v 1.2 2014/03/09 16:58:03 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 2953 2013-06-30 20:21:38Z kaiwang27 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. The ELF symbol to be used 72for relocation is set by a prior call to the function 73.Xr dwarf_lne_set_address 3 . 74.Pp 75Argument 76.Ar lineno 77specifies the line number of the source line. 78.Pp 79Argument 80.Ar column 81specifies the column number within the source line. 82.Pp 83If the argument 84.Ar is_stmt 85is set to true, it indicates that the instruction at the address 86specified by argument 87.Ar off 88is a recommended breakpoint location, i.e., the first instruction in 89the instruction sequence generated by the source line. 90.Pp 91If the argument 92.Ar basic_block 93is set to true, it indicates that the instruction at the address 94specified by argument 95.Ar off 96is the first instruction of a basic block. 97.Pp 98If argument 99.Ar err 100is not NULL, it will be used to store error information in case 101of an error. 102.Sh RETURN VALUES 103On success, function 104.Fn dwarf_add_line_entry 105returns 106.Dv DW_DLV_OK . 107In case of an error, function 108.Fn dwarf_add_line_entry 109returns 110.Dv DW_DLV_NOCOUNT 111and sets the argument 112.Ar err . 113.Sh ERRORS 114Function 115.Fn dwarf_add_line_entry 116can fail with: 117.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT" 118.It Bq Er DW_DLE_ARGUMENT 119Argument 120.Ar dbg 121was NULL. 122.It Bq Er DW_DLE_ARGUMENT 123The function 124.Xr dwarf_lne_set_address 3 125was not called before calling this function. 126.It Bq Er DW_DLE_MEMORY 127An out of memory condition was encountered during the execution of the 128function. 129.El 130.Sh EXAMPLE 131To add line number information to the producer instance, use: 132.Bd -literal -offset indent 133Dwarf_P_Debug dbg; 134Dwarf_Error de; 135Dwarf_Unsigned dir, filendx; 136 137/* ... assume dbg refers to a DWARF producer instance ... */ 138 139dir = dwarf_add_directory_decl(dbg, "/home/foo", &de); 140if (dir == DW_DLV_NOCOUNT) 141 errx(EXIT_FAILURE, "dwarf_add_directory_decl failed: %s", 142 dwarf_errmsg(-1)); 143 144filendx = dwarf_add_file_decl(dbg, "bar.c", dir, 0, 1234, &de); 145if (filendx == DW_DLV_NOCOUNT) 146 errx(EXIT_FAILURE, "dwarf_add_file_decl failed: %s", 147 dwarf_errmsg(-1)); 148 149if (dwarf_lne_set_address(dbg, 0x4012b0, 12, &de) != DW_DLV_OK) 150 errx(EXIT_FAILURE, "dwarf_lne_set_address failed: %s", 151 dwarf_errmsg(-1)); 152 153if (dwarf_add_line_entry(dbg, filendx, 10, 258, 0, 1, 1, &de) != 154 DW_DLV_OK) 155 errx(EXIT_FAILURE, "dwarf_add_line_entry failed: %s", 156 dwarf_errmsg(-1)); 157.Ed 158.Sh SEE ALSO 159.Xr dwarf 3 , 160.Xr dwarf_add_directory_decl 3 , 161.Xr dwarf_add_file_decl 3 , 162.Xr dwarf_lne_end_sequence 3 , 163.Xr dwarf_lne_set_address 3 , 164.Xr dwarf_producer_init 3 , 165.Xr dwarf_producer_init_b 3 166