1*5ac3bc71Schristos.\" $NetBSD: dwarf_finish.3,v 1.6 2024/03/03 17:37:30 christos Exp $ 2e81373b4Schristos.\" 39dd9d0cfSchristos.\" Copyright (c) 2009,2011 Joseph Koshy. All rights reserved. 49dd9d0cfSchristos.\" 59dd9d0cfSchristos.\" Redistribution and use in source and binary forms, with or without 69dd9d0cfSchristos.\" modification, are permitted provided that the following conditions 79dd9d0cfSchristos.\" are met: 89dd9d0cfSchristos.\" 1. Redistributions of source code must retain the above copyright 99dd9d0cfSchristos.\" notice, this list of conditions and the following disclaimer. 109dd9d0cfSchristos.\" 2. Redistributions in binary form must reproduce the above copyright 119dd9d0cfSchristos.\" notice, this list of conditions and the following disclaimer in the 129dd9d0cfSchristos.\" documentation and/or other materials provided with the distribution. 139dd9d0cfSchristos.\" 149dd9d0cfSchristos.\" This software is provided by Joseph Koshy ``as is'' and 159dd9d0cfSchristos.\" any express or implied warranties, including, but not limited to, the 169dd9d0cfSchristos.\" implied warranties of merchantability and fitness for a particular purpose 179dd9d0cfSchristos.\" are disclaimed. in no event shall Joseph Koshy be liable 189dd9d0cfSchristos.\" for any direct, indirect, incidental, special, exemplary, or consequential 199dd9d0cfSchristos.\" damages (including, but not limited to, procurement of substitute goods 209dd9d0cfSchristos.\" or services; loss of use, data, or profits; or business interruption) 219dd9d0cfSchristos.\" however caused and on any theory of liability, whether in contract, strict 229dd9d0cfSchristos.\" liability, or tort (including negligence or otherwise) arising in any way 239dd9d0cfSchristos.\" out of the use of this software, even if advised of the possibility of 249dd9d0cfSchristos.\" such damage. 259dd9d0cfSchristos.\" 26cdbf1fe1Sjkoshy.\" Id: dwarf_finish.3 3962 2022-03-12 15:56:10Z jkoshy 279dd9d0cfSchristos.\" 289dd9d0cfSchristos.Dd November 9, 2011 299dd9d0cfSchristos.Dt DWARF_FINISH 3 30604b0842Sjkoshy.Os 319dd9d0cfSchristos.Sh NAME 329dd9d0cfSchristos.Nm dwarf_finish , 339dd9d0cfSchristos.Nm dwarf_object_finish 349dd9d0cfSchristos.Nd free resources associated with a debug descriptor 359dd9d0cfSchristos.Sh LIBRARY 369dd9d0cfSchristos.Lb libdwarf 379dd9d0cfSchristos.Sh SYNOPSIS 389dd9d0cfSchristos.In libdwarf.h 399dd9d0cfSchristos.Ft int 409dd9d0cfSchristos.Fn dwarf_finish "Dwarf_Debug dbg" "Dwarf_Error *err" 419dd9d0cfSchristos.Ft int 429dd9d0cfSchristos.Fn dwarf_object_finish "Dwarf_Debug dbg" "Dwarf_Error *err" 439dd9d0cfSchristos.Sh DESCRIPTION 449dd9d0cfSchristosThe 459dd9d0cfSchristos.Fn dwarf_finish 469dd9d0cfSchristosand 479dd9d0cfSchristos.Fn dwarf_object_finish 489dd9d0cfSchristosfunctions are used to release the resources associated with a debug 499dd9d0cfSchristosdescriptor allocated by a prior call to 509dd9d0cfSchristos.Xr dwarf_init 3 519dd9d0cfSchristosand 529dd9d0cfSchristos.Xr dwarf_object_init 3 539dd9d0cfSchristosrespectively. 549dd9d0cfSchristos.Pp 559dd9d0cfSchristosArgument 56cdbf1fe1Sjkoshy.Fa dbg 579dd9d0cfSchristosdenotes a valid 589dd9d0cfSchristos.Vt Dwarf_Debug 599dd9d0cfSchristosinstance. 609dd9d0cfSchristosArgument 61cdbf1fe1Sjkoshy.Fa err 629dd9d0cfSchristoswill be used to record error information in case of an error. 639dd9d0cfSchristos.Pp 649dd9d0cfSchristosAfter a call to 659dd9d0cfSchristos.Fn dwarf_finish 669dd9d0cfSchristosor 679dd9d0cfSchristos.Fn dwarf_object_finish , 689dd9d0cfSchristosthe argument 69cdbf1fe1Sjkoshy.Fa dbg 709dd9d0cfSchristoswill be invalid and should not be used further. 719dd9d0cfSchristos.Pp 729dd9d0cfSchristosFor 739dd9d0cfSchristos.Vt Dwarf_Debug 749dd9d0cfSchristosdescriptors opened using 759dd9d0cfSchristos.Xr dwarf_init 3 , 769dd9d0cfSchristosthe application would need to explicitly release the 779dd9d0cfSchristos.Vt Elf 789dd9d0cfSchristosinstance associated with the descriptor by first retrieving 799dd9d0cfSchristosthe instance using 809dd9d0cfSchristos.Xr dwarf_get_elf 3 819dd9d0cfSchristosand closing it using 829dd9d0cfSchristos.Xr elf_end 3 . 839dd9d0cfSchristos.Sh RETURN VALUES 849dd9d0cfSchristosThese functions return 859dd9d0cfSchristos.Dv DW_DLV_OK 869dd9d0cfSchristosif successful. 879dd9d0cfSchristosIn case of an error, the functions return 889dd9d0cfSchristos.Dv DW_DLV_ERROR 899dd9d0cfSchristosand record additional information in argument 90cdbf1fe1Sjkoshy.Fa err . 919dd9d0cfSchristos.Sh EXAMPLES 929dd9d0cfSchristosTo deallocate a 939dd9d0cfSchristos.Vt Dwarf_Debug 949dd9d0cfSchristosinstance allocated using 959dd9d0cfSchristos.Xr dwarf_elf_init 3 969dd9d0cfSchristosuse: 979dd9d0cfSchristos.Bd -literal -offset indent 989dd9d0cfSchristosDwarf_Debug dbg; 999dd9d0cfSchristosDwarf_Error de; 1009dd9d0cfSchristos 1019dd9d0cfSchristosif (dwarf_finish(dbg, &de) != DW_DLV_OK) 1029dd9d0cfSchristos errx(EXIT_FAILURE, "dwarf_finish: %s", dwarf_errmsg(de)); 1039dd9d0cfSchristos.Ed 1049dd9d0cfSchristos.Pp 1059dd9d0cfSchristosTo deallocate a 1069dd9d0cfSchristos.Vt Dwarf_Debug 1079dd9d0cfSchristosinstance allocated using 1089dd9d0cfSchristos.Xr dwarf_object_init 3 1099dd9d0cfSchristosuse: 1109dd9d0cfSchristos.Bd -literal -offset indent 1119dd9d0cfSchristosDwarf_Debug dbg; 1129dd9d0cfSchristosDwarf_Error de; 1139dd9d0cfSchristos 1149dd9d0cfSchristosif (dwarf_object_finish(dbg, &de) != DW_DLV_OK) 1159dd9d0cfSchristos errx(EXIT_FAILURE, "dwarf_object_finish: %s", 1169dd9d0cfSchristos dwarf_errmsg(de)); 1179dd9d0cfSchristos.Ed 1189dd9d0cfSchristos.Pp 1199dd9d0cfSchristosTo deallocate a 1209dd9d0cfSchristos.Vt Dwarf_Debug 1219dd9d0cfSchristosinstance allocated using 1229dd9d0cfSchristos.Xr dwarf_init 3 1239dd9d0cfSchristosuse: 1249dd9d0cfSchristos.Bd -literal -offset indent 1259dd9d0cfSchristosDwarf_Debug dbg; 1269dd9d0cfSchristosDward_Error de; 1279dd9d0cfSchristosElf *e; 1289dd9d0cfSchristos 1299dd9d0cfSchristosif (dwarf_get_elf(dbg, &e, &de) != DW_DLV_OK) 1309dd9d0cfSchristos errx(EXIT_FAILURE, "dwarf_get_elf: %s", dwarf_errmsg(&de)); 1319dd9d0cfSchristos 1329dd9d0cfSchristosif (dwarf_finish(dbg, &de) != DW_DLV_OK) 1339dd9d0cfSchristos errx(EXIT_FAILURE, "dwarf_finish: %s", dwarf_errmsg(de)); 1349dd9d0cfSchristos 1359dd9d0cfSchristos(void) elf_end(e); 1369dd9d0cfSchristos.Ed 1379dd9d0cfSchristos.Sh SEE ALSO 1389dd9d0cfSchristos.Xr dwarf_elf_init 3 , 1399dd9d0cfSchristos.Xr dwarf_get_elf 3 , 1409dd9d0cfSchristos.Xr dwarf_init 3 , 141604b0842Sjkoshy.Xr dwarf_object_init 3 , 142604b0842Sjkoshy.Xr elf_end 3 143