1*5ac3bc71Schristos.\" $NetBSD: dwarf_def_macro.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_def_macro.3 3961 2022-03-12 15:13:22Z jkoshy 289dd9d0cfSchristos.\" 299dd9d0cfSchristos.Dd November 9, 2011 309dd9d0cfSchristos.Dt DWARF_DEF_MACRO 3 31604b0842Sjkoshy.Os 329dd9d0cfSchristos.Sh NAME 339dd9d0cfSchristos.Nm dwarf_def_macro 349dd9d0cfSchristos.Nd add a macro definition to a DWARF producer instance 359dd9d0cfSchristos.Sh LIBRARY 369dd9d0cfSchristos.Lb libdwarf 379dd9d0cfSchristos.Sh SYNOPSIS 389dd9d0cfSchristos.In libdwarf.h 399dd9d0cfSchristos.Ft "int" 409dd9d0cfSchristos.Fo dwarf_def_macro 419dd9d0cfSchristos.Fa "Dwarf_P_Debug dbg" 429dd9d0cfSchristos.Fa "Dwarf_Unsigned lineno" 439dd9d0cfSchristos.Fa "char *name" 449dd9d0cfSchristos.Fa "char *value" 459dd9d0cfSchristos.Fa "Dwarf_Error *err" 469dd9d0cfSchristos.Fc 479dd9d0cfSchristos.Sh DESCRIPTION 489dd9d0cfSchristosFunction 499dd9d0cfSchristos.Fn dwarf_def_macro 509dd9d0cfSchristosadds a macro definition to a DWARF producer instance. 519dd9d0cfSchristos.Pp 529dd9d0cfSchristosArgument 53cdbf1fe1Sjkoshy.Fa dbg 549dd9d0cfSchristosshould reference a DWARF producer instance allocated using 559dd9d0cfSchristos.Xr dwarf_producer_init 3 569dd9d0cfSchristosor 579dd9d0cfSchristos.Xr dwarf_producer_init_b 3 . 589dd9d0cfSchristos.Pp 599dd9d0cfSchristosArgument 60cdbf1fe1Sjkoshy.Fa lineno 619dd9d0cfSchristosspecifies the line number of the source line where the macro is 629dd9d0cfSchristosdefined. 639dd9d0cfSchristosA line number of zero is used for macros that are defined 649dd9d0cfSchristosbefore any source file is read. 659dd9d0cfSchristos.Pp 669dd9d0cfSchristosArgument 67cdbf1fe1Sjkoshy.Fa name 689dd9d0cfSchristosshould point to a NUL-terminated string containing the name 699dd9d0cfSchristosof the macro. 709dd9d0cfSchristosFor function-like macros this parameter should also include 719dd9d0cfSchristosparentheses and parameter names if any. 729dd9d0cfSchristos.Pp 739dd9d0cfSchristosArgument 74cdbf1fe1Sjkoshy.Fa value 759dd9d0cfSchristosshould point to a NUL-terminated string containing the value 769dd9d0cfSchristosof the macro. 7742bd3019SchristosIf the macro does not have a value, argument 78cdbf1fe1Sjkoshy.Fa value 79cdbf1fe1Sjkoshyshould be set to 80cdbf1fe1Sjkoshy.Dv NULL . 819dd9d0cfSchristos.Pp 829dd9d0cfSchristosIf argument 83cdbf1fe1Sjkoshy.Fa err 84cdbf1fe1Sjkoshyis not 85cdbf1fe1Sjkoshy.Dv NULL , 86cdbf1fe1Sjkoshyit will be used to store error information in case of an error. 879dd9d0cfSchristos.Sh RETURN VALUES 889dd9d0cfSchristosOn success, function 899dd9d0cfSchristos.Fn dwarf_def_macro 909dd9d0cfSchristosreturns 919dd9d0cfSchristos.Dv DW_DLV_OK . 929dd9d0cfSchristosIn case of an error, function 939dd9d0cfSchristos.Fn dwarf_def_macro 949dd9d0cfSchristosreturns 959dd9d0cfSchristos.Dv DW_DLV_ERROR 969dd9d0cfSchristosand sets the argument 97cdbf1fe1Sjkoshy.Fa err . 98604b0842Sjkoshy.Sh EXAMPLES 999dd9d0cfSchristosTo record the fact that a macro named 1009dd9d0cfSchristos.Dv _STDIO_H_ 1019dd9d0cfSchristoswas defined at line 20 of the current macro file, use: 1029dd9d0cfSchristos.Bd -literal -offset indent 1039dd9d0cfSchristosDwarf_P_Debug dbg; 1049dd9d0cfSchristosDwarf_Error de; 1059dd9d0cfSchristos 1069dd9d0cfSchristos/* ... Assume 'dbg' refers to a DWARF producer instance... */ 1079dd9d0cfSchristosif (dwarf_def_macro(dbg, 20, "_STDIO_H_", NULL, &de) != DW_DLV_OK) 1089dd9d0cfSchristos errx(EXIT_FAILURE, "dwarf_def_macro failed: %s", 1099dd9d0cfSchristos dwarf_errmsg(-1)); 1109dd9d0cfSchristos.Ed 1119dd9d0cfSchristos.Sh ERRORS 1129dd9d0cfSchristosFunction 1139dd9d0cfSchristos.Fn dwarf_def_macro 1149dd9d0cfSchristoscan fail with: 1159dd9d0cfSchristos.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT" 1169dd9d0cfSchristos.It Bq Er DW_DLE_ARGUMENT 1179dd9d0cfSchristosEither arguments 118cdbf1fe1Sjkoshy.Fa dbg 1199dd9d0cfSchristosor 120cdbf1fe1Sjkoshy.Fa name 121cdbf1fe1Sjkoshywas 122cdbf1fe1Sjkoshy.Dv NULL . 1239dd9d0cfSchristos.It Bq Er DW_DLE_MEMORY 1249dd9d0cfSchristosAn out of memory condition was encountered during the execution of the 1259dd9d0cfSchristosfunction. 1269dd9d0cfSchristos.El 1279dd9d0cfSchristos.Sh SEE ALSO 1289dd9d0cfSchristos.Xr dwarf 3 , 1299dd9d0cfSchristos.Xr dwarf_end_macro_file 3 , 1309dd9d0cfSchristos.Xr dwarf_producer_init 3 , 1319dd9d0cfSchristos.Xr dwarf_producer_init_b 3 , 1329dd9d0cfSchristos.Xr dwarf_start_macro_file 3 , 1339dd9d0cfSchristos.Xr dwarf_undef_macro 3 , 1349dd9d0cfSchristos.Xr dwarf_vendor_ext 3 135