xref: /netbsd-src/external/bsd/elftoolchain/dist/libdwarf/dwarf_add_line_entry.3 (revision 5ac3bc719ce6e70593039505b491894133237d12)
1*5ac3bc71Schristos.\"	$NetBSD: dwarf_add_line_entry.3,v 1.6 2024/03/03 17:37:30 christos Exp $
2e81373b4Schristos.\"
39dd9d0cfSchristos.\" Copyright (c) 2011 Kai Wang
49dd9d0cfSchristos.\" All rights reserved.
59dd9d0cfSchristos.\"
69dd9d0cfSchristos.\" Redistribution and use in source and binary forms, with or without
79dd9d0cfSchristos.\" modification, are permitted provided that the following conditions
89dd9d0cfSchristos.\" are met:
99dd9d0cfSchristos.\" 1. Redistributions of source code must retain the above copyright
109dd9d0cfSchristos.\"    notice, this list of conditions and the following disclaimer.
119dd9d0cfSchristos.\" 2. Redistributions in binary form must reproduce the above copyright
129dd9d0cfSchristos.\"    notice, this list of conditions and the following disclaimer in the
139dd9d0cfSchristos.\"    documentation and/or other materials provided with the distribution.
149dd9d0cfSchristos.\"
159dd9d0cfSchristos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
169dd9d0cfSchristos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
179dd9d0cfSchristos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
189dd9d0cfSchristos.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
199dd9d0cfSchristos.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
209dd9d0cfSchristos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
219dd9d0cfSchristos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
229dd9d0cfSchristos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
239dd9d0cfSchristos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
249dd9d0cfSchristos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
259dd9d0cfSchristos.\" SUCH DAMAGE.
269dd9d0cfSchristos.\"
27cdbf1fe1Sjkoshy.\" Id: dwarf_add_line_entry.3 3961 2022-03-12 15:13:22Z jkoshy
289dd9d0cfSchristos.\"
299dd9d0cfSchristos.Dd June 30, 2013
309dd9d0cfSchristos.Dt DWARF_ADD_LINE_ENTRY 3
31604b0842Sjkoshy.Os
329dd9d0cfSchristos.Sh NAME
339dd9d0cfSchristos.Nm dwarf_add_line_entry
349dd9d0cfSchristos.Nd add a line number information entry to a producer instance
359dd9d0cfSchristos.Sh LIBRARY
369dd9d0cfSchristos.Lb libdwarf
379dd9d0cfSchristos.Sh SYNOPSIS
389dd9d0cfSchristos.In libdwarf.h
399dd9d0cfSchristos.Ft "Dwarf_Unsigned"
409dd9d0cfSchristos.Fo dwarf_add_line_entry
419dd9d0cfSchristos.Fa "Dwarf_P_Debug dbg"
429dd9d0cfSchristos.Fa "Dwarf_Unsigned filendx"
439dd9d0cfSchristos.Fa "Dwarf_Addr off"
449dd9d0cfSchristos.Fa "Dwarf_Unsigned lineno"
459dd9d0cfSchristos.Fa "Dwarf_Signed column"
469dd9d0cfSchristos.Fa "Dwarf_Bool is_stmt"
479dd9d0cfSchristos.Fa "Dwarf_Bool basic_block"
489dd9d0cfSchristos.Fa "Dwarf_Error *err"
499dd9d0cfSchristos.Fc
509dd9d0cfSchristos.Sh DESCRIPTION
519dd9d0cfSchristosFunction
529dd9d0cfSchristos.Fn dwarf_add_line_entry
539dd9d0cfSchristosadds a line number information entry to a DWARF producer instance.
549dd9d0cfSchristos.Pp
559dd9d0cfSchristosArgument
56cdbf1fe1Sjkoshy.Fa dbg
579dd9d0cfSchristosshould reference a DWARF producer instance allocated using
589dd9d0cfSchristos.Xr dwarf_producer_init 3
599dd9d0cfSchristosor
609dd9d0cfSchristos.Xr dwarf_producer_init_b 3 .
619dd9d0cfSchristos.Pp
629dd9d0cfSchristosArgument
63cdbf1fe1Sjkoshy.Fa filendx
649dd9d0cfSchristosspecifies the index of the source file that contains the source line
659dd9d0cfSchristosin question.
669dd9d0cfSchristosValid source file indices are those returned by the function
679dd9d0cfSchristos.Xr dwarf_add_file_decl 3 .
689dd9d0cfSchristos.Pp
699dd9d0cfSchristosArgument
70cdbf1fe1Sjkoshy.Fa off
7142bd3019Schristosspecifies a relocatable program address.
7242bd3019SchristosThe ELF symbol to be used
739dd9d0cfSchristosfor relocation is set by a prior call to the function
749dd9d0cfSchristos.Xr dwarf_lne_set_address 3 .
759dd9d0cfSchristos.Pp
769dd9d0cfSchristosArgument
77cdbf1fe1Sjkoshy.Fa lineno
789dd9d0cfSchristosspecifies the line number of the source line.
799dd9d0cfSchristos.Pp
809dd9d0cfSchristosArgument
81cdbf1fe1Sjkoshy.Fa column
829dd9d0cfSchristosspecifies the column number within the source line.
839dd9d0cfSchristos.Pp
849dd9d0cfSchristosIf the argument
85cdbf1fe1Sjkoshy.Fa is_stmt
869dd9d0cfSchristosis set to true, it indicates that the instruction at the address
879dd9d0cfSchristosspecified by argument
88cdbf1fe1Sjkoshy.Fa off
899dd9d0cfSchristosis a recommended breakpoint location, i.e., the first instruction in
909dd9d0cfSchristosthe instruction sequence generated by the source line.
919dd9d0cfSchristos.Pp
929dd9d0cfSchristosIf the argument
93cdbf1fe1Sjkoshy.Fa basic_block
949dd9d0cfSchristosis set to true, it indicates that the instruction at the address
959dd9d0cfSchristosspecified by argument
96cdbf1fe1Sjkoshy.Fa off
979dd9d0cfSchristosis the first instruction of a basic block.
989dd9d0cfSchristos.Pp
999dd9d0cfSchristosIf argument
100cdbf1fe1Sjkoshy.Fa err
101cdbf1fe1Sjkoshyis not
102cdbf1fe1Sjkoshy.Dv NULL ,
103cdbf1fe1Sjkoshyit will be used to store error information in case of an error.
1049dd9d0cfSchristos.Sh RETURN VALUES
1059dd9d0cfSchristosOn success, function
1069dd9d0cfSchristos.Fn dwarf_add_line_entry
1079dd9d0cfSchristosreturns
1089dd9d0cfSchristos.Dv DW_DLV_OK .
1099dd9d0cfSchristosIn case of an error, function
1109dd9d0cfSchristos.Fn dwarf_add_line_entry
1119dd9d0cfSchristosreturns
1129dd9d0cfSchristos.Dv DW_DLV_NOCOUNT
1139dd9d0cfSchristosand sets the argument
114cdbf1fe1Sjkoshy.Fa err .
115604b0842Sjkoshy.Sh EXAMPLES
1169dd9d0cfSchristosTo add line number information to the producer instance, use:
1179dd9d0cfSchristos.Bd -literal -offset indent
1189dd9d0cfSchristosDwarf_P_Debug dbg;
1199dd9d0cfSchristosDwarf_Error de;
1209dd9d0cfSchristosDwarf_Unsigned dir, filendx;
1219dd9d0cfSchristos
1229dd9d0cfSchristos/* ... assume dbg refers to a DWARF producer instance ... */
1239dd9d0cfSchristos
1249dd9d0cfSchristosdir = dwarf_add_directory_decl(dbg, "/home/foo", &de);
1259dd9d0cfSchristosif (dir == DW_DLV_NOCOUNT)
1269dd9d0cfSchristos	errx(EXIT_FAILURE, "dwarf_add_directory_decl failed: %s",
1279dd9d0cfSchristos	    dwarf_errmsg(-1));
1289dd9d0cfSchristos
1299dd9d0cfSchristosfilendx = dwarf_add_file_decl(dbg, "bar.c", dir, 0, 1234, &de);
1309dd9d0cfSchristosif (filendx == DW_DLV_NOCOUNT)
1319dd9d0cfSchristos	errx(EXIT_FAILURE, "dwarf_add_file_decl failed: %s",
1329dd9d0cfSchristos	    dwarf_errmsg(-1));
1339dd9d0cfSchristos
1349dd9d0cfSchristosif (dwarf_lne_set_address(dbg, 0x4012b0, 12, &de) != DW_DLV_OK)
1359dd9d0cfSchristos	errx(EXIT_FAILURE, "dwarf_lne_set_address failed: %s",
1369dd9d0cfSchristos	    dwarf_errmsg(-1));
1379dd9d0cfSchristos
1389dd9d0cfSchristosif (dwarf_add_line_entry(dbg, filendx, 10, 258, 0, 1, 1, &de) !=
1399dd9d0cfSchristos    DW_DLV_OK)
1409dd9d0cfSchristos	errx(EXIT_FAILURE, "dwarf_add_line_entry failed: %s",
1419dd9d0cfSchristos	    dwarf_errmsg(-1));
1429dd9d0cfSchristos.Ed
143604b0842Sjkoshy.Sh ERRORS
144604b0842SjkoshyFunction
145604b0842Sjkoshy.Fn dwarf_add_line_entry
146604b0842Sjkoshycan fail with:
147604b0842Sjkoshy.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
148604b0842Sjkoshy.It Bq Er DW_DLE_ARGUMENT
149604b0842SjkoshyArgument
150cdbf1fe1Sjkoshy.Fa dbg
151cdbf1fe1Sjkoshywas
152cdbf1fe1Sjkoshy.Dv NULL .
153604b0842Sjkoshy.It Bq Er DW_DLE_ARGUMENT
154604b0842SjkoshyThe function
155604b0842Sjkoshy.Xr dwarf_lne_set_address 3
156604b0842Sjkoshywas not called before calling this function.
157604b0842Sjkoshy.It Bq Er DW_DLE_MEMORY
158604b0842SjkoshyAn out of memory condition was encountered during the execution of the
159604b0842Sjkoshyfunction.
160604b0842Sjkoshy.El
1619dd9d0cfSchristos.Sh SEE ALSO
1629dd9d0cfSchristos.Xr dwarf 3 ,
1639dd9d0cfSchristos.Xr dwarf_add_directory_decl 3 ,
1649dd9d0cfSchristos.Xr dwarf_add_file_decl 3 ,
1659dd9d0cfSchristos.Xr dwarf_lne_end_sequence 3 ,
1669dd9d0cfSchristos.Xr dwarf_lne_set_address 3 ,
1679dd9d0cfSchristos.Xr dwarf_producer_init 3 ,
1689dd9d0cfSchristos.Xr dwarf_producer_init_b 3
169