xref: /minix3/external/bsd/elftoolchain/dist/libdwarf/dwarf_finish.3 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: dwarf_finish.3,v 1.2 2014/03/09 16:58:03 christos Exp $
2*0a6a1f1dSLionel Sambuc.\"
3*0a6a1f1dSLionel Sambuc.\" Copyright (c) 2009,2011 Joseph Koshy.  All rights reserved.
4*0a6a1f1dSLionel Sambuc.\"
5*0a6a1f1dSLionel Sambuc.\" Redistribution and use in source and binary forms, with or without
6*0a6a1f1dSLionel Sambuc.\" modification, are permitted provided that the following conditions
7*0a6a1f1dSLionel Sambuc.\" are met:
8*0a6a1f1dSLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright
9*0a6a1f1dSLionel Sambuc.\"    notice, this list of conditions and the following disclaimer.
10*0a6a1f1dSLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright
11*0a6a1f1dSLionel Sambuc.\"    notice, this list of conditions and the following disclaimer in the
12*0a6a1f1dSLionel Sambuc.\"    documentation and/or other materials provided with the distribution.
13*0a6a1f1dSLionel Sambuc.\"
14*0a6a1f1dSLionel Sambuc.\" This software is provided by Joseph Koshy ``as is'' and
15*0a6a1f1dSLionel Sambuc.\" any express or implied warranties, including, but not limited to, the
16*0a6a1f1dSLionel Sambuc.\" implied warranties of merchantability and fitness for a particular purpose
17*0a6a1f1dSLionel Sambuc.\" are disclaimed.  in no event shall Joseph Koshy be liable
18*0a6a1f1dSLionel Sambuc.\" for any direct, indirect, incidental, special, exemplary, or consequential
19*0a6a1f1dSLionel Sambuc.\" damages (including, but not limited to, procurement of substitute goods
20*0a6a1f1dSLionel Sambuc.\" or services; loss of use, data, or profits; or business interruption)
21*0a6a1f1dSLionel Sambuc.\" however caused and on any theory of liability, whether in contract, strict
22*0a6a1f1dSLionel Sambuc.\" liability, or tort (including negligence or otherwise) arising in any way
23*0a6a1f1dSLionel Sambuc.\" out of the use of this software, even if advised of the possibility of
24*0a6a1f1dSLionel Sambuc.\" such damage.
25*0a6a1f1dSLionel Sambuc.\"
26*0a6a1f1dSLionel Sambuc.\" Id: dwarf_finish.3 2122 2011-11-09 15:35:14Z jkoshy
27*0a6a1f1dSLionel Sambuc.\"
28*0a6a1f1dSLionel Sambuc.Dd November 9, 2011
29*0a6a1f1dSLionel Sambuc.Os
30*0a6a1f1dSLionel Sambuc.Dt DWARF_FINISH 3
31*0a6a1f1dSLionel Sambuc.Sh NAME
32*0a6a1f1dSLionel Sambuc.Nm dwarf_finish ,
33*0a6a1f1dSLionel Sambuc.Nm dwarf_object_finish
34*0a6a1f1dSLionel Sambuc.Nd free resources associated with a debug descriptor
35*0a6a1f1dSLionel Sambuc.Sh LIBRARY
36*0a6a1f1dSLionel Sambuc.Lb libdwarf
37*0a6a1f1dSLionel Sambuc.Sh SYNOPSIS
38*0a6a1f1dSLionel Sambuc.In libdwarf.h
39*0a6a1f1dSLionel Sambuc.Ft int
40*0a6a1f1dSLionel Sambuc.Fn dwarf_finish "Dwarf_Debug dbg" "Dwarf_Error *err"
41*0a6a1f1dSLionel Sambuc.Ft int
42*0a6a1f1dSLionel Sambuc.Fn dwarf_object_finish "Dwarf_Debug dbg" "Dwarf_Error *err"
43*0a6a1f1dSLionel Sambuc.Sh DESCRIPTION
44*0a6a1f1dSLionel SambucThe
45*0a6a1f1dSLionel Sambuc.Fn dwarf_finish
46*0a6a1f1dSLionel Sambucand
47*0a6a1f1dSLionel Sambuc.Fn dwarf_object_finish
48*0a6a1f1dSLionel Sambucfunctions are used to release the resources associated with a debug
49*0a6a1f1dSLionel Sambucdescriptor allocated by a prior call to
50*0a6a1f1dSLionel Sambuc.Xr dwarf_init 3
51*0a6a1f1dSLionel Sambucand
52*0a6a1f1dSLionel Sambuc.Xr dwarf_object_init 3
53*0a6a1f1dSLionel Sambucrespectively.
54*0a6a1f1dSLionel Sambuc.Pp
55*0a6a1f1dSLionel SambucArgument
56*0a6a1f1dSLionel Sambuc.Ar dbg
57*0a6a1f1dSLionel Sambucdenotes a valid
58*0a6a1f1dSLionel Sambuc.Vt Dwarf_Debug
59*0a6a1f1dSLionel Sambucinstance.
60*0a6a1f1dSLionel SambucArgument
61*0a6a1f1dSLionel Sambuc.Ar err
62*0a6a1f1dSLionel Sambucwill be used to record error information in case of an error.
63*0a6a1f1dSLionel Sambuc.Pp
64*0a6a1f1dSLionel SambucAfter a call to
65*0a6a1f1dSLionel Sambuc.Fn dwarf_finish
66*0a6a1f1dSLionel Sambucor
67*0a6a1f1dSLionel Sambuc.Fn dwarf_object_finish ,
68*0a6a1f1dSLionel Sambucthe argument
69*0a6a1f1dSLionel Sambuc.Ar dbg
70*0a6a1f1dSLionel Sambucwill be invalid and should not be used further.
71*0a6a1f1dSLionel Sambuc.Pp
72*0a6a1f1dSLionel SambucFor
73*0a6a1f1dSLionel Sambuc.Vt Dwarf_Debug
74*0a6a1f1dSLionel Sambucdescriptors opened using
75*0a6a1f1dSLionel Sambuc.Xr dwarf_init 3 ,
76*0a6a1f1dSLionel Sambucthe application would need to explicitly release the
77*0a6a1f1dSLionel Sambuc.Vt Elf
78*0a6a1f1dSLionel Sambucinstance associated with the descriptor by first retrieving
79*0a6a1f1dSLionel Sambucthe instance using
80*0a6a1f1dSLionel Sambuc.Xr dwarf_get_elf 3
81*0a6a1f1dSLionel Sambucand closing it using
82*0a6a1f1dSLionel Sambuc.Xr elf_end 3 .
83*0a6a1f1dSLionel Sambuc.Sh RETURN VALUES
84*0a6a1f1dSLionel SambucThese functions return
85*0a6a1f1dSLionel Sambuc.Dv DW_DLV_OK
86*0a6a1f1dSLionel Sambucif successful.
87*0a6a1f1dSLionel SambucIn case of an error, the functions return
88*0a6a1f1dSLionel Sambuc.Dv DW_DLV_ERROR
89*0a6a1f1dSLionel Sambucand record additional information in argument
90*0a6a1f1dSLionel Sambuc.Ar err .
91*0a6a1f1dSLionel Sambuc.Sh EXAMPLES
92*0a6a1f1dSLionel SambucTo deallocate a
93*0a6a1f1dSLionel Sambuc.Vt Dwarf_Debug
94*0a6a1f1dSLionel Sambucinstance allocated using
95*0a6a1f1dSLionel Sambuc.Xr dwarf_elf_init 3
96*0a6a1f1dSLionel Sambucuse:
97*0a6a1f1dSLionel Sambuc.Bd -literal -offset indent
98*0a6a1f1dSLionel SambucDwarf_Debug dbg;
99*0a6a1f1dSLionel SambucDwarf_Error de;
100*0a6a1f1dSLionel Sambuc
101*0a6a1f1dSLionel Sambucif (dwarf_finish(dbg, &de) != DW_DLV_OK)
102*0a6a1f1dSLionel Sambuc	errx(EXIT_FAILURE, "dwarf_finish: %s", dwarf_errmsg(de));
103*0a6a1f1dSLionel Sambuc.Ed
104*0a6a1f1dSLionel Sambuc.Pp
105*0a6a1f1dSLionel SambucTo deallocate a
106*0a6a1f1dSLionel Sambuc.Vt Dwarf_Debug
107*0a6a1f1dSLionel Sambucinstance allocated using
108*0a6a1f1dSLionel Sambuc.Xr dwarf_object_init 3
109*0a6a1f1dSLionel Sambucuse:
110*0a6a1f1dSLionel Sambuc.Bd -literal -offset indent
111*0a6a1f1dSLionel SambucDwarf_Debug dbg;
112*0a6a1f1dSLionel SambucDwarf_Error de;
113*0a6a1f1dSLionel Sambuc
114*0a6a1f1dSLionel Sambucif (dwarf_object_finish(dbg, &de) != DW_DLV_OK)
115*0a6a1f1dSLionel Sambuc	errx(EXIT_FAILURE, "dwarf_object_finish: %s",
116*0a6a1f1dSLionel Sambuc	    dwarf_errmsg(de));
117*0a6a1f1dSLionel Sambuc.Ed
118*0a6a1f1dSLionel Sambuc.Pp
119*0a6a1f1dSLionel SambucTo deallocate a
120*0a6a1f1dSLionel Sambuc.Vt Dwarf_Debug
121*0a6a1f1dSLionel Sambucinstance allocated using
122*0a6a1f1dSLionel Sambuc.Xr dwarf_init 3
123*0a6a1f1dSLionel Sambucuse:
124*0a6a1f1dSLionel Sambuc.Bd -literal -offset indent
125*0a6a1f1dSLionel SambucDwarf_Debug dbg;
126*0a6a1f1dSLionel SambucDward_Error de;
127*0a6a1f1dSLionel SambucElf *e;
128*0a6a1f1dSLionel Sambuc
129*0a6a1f1dSLionel Sambucif (dwarf_get_elf(dbg, &e, &de) != DW_DLV_OK)
130*0a6a1f1dSLionel Sambuc	errx(EXIT_FAILURE, "dwarf_get_elf: %s", dwarf_errmsg(&de));
131*0a6a1f1dSLionel Sambuc
132*0a6a1f1dSLionel Sambucif (dwarf_finish(dbg, &de) != DW_DLV_OK)
133*0a6a1f1dSLionel Sambuc	errx(EXIT_FAILURE, "dwarf_finish: %s", dwarf_errmsg(de));
134*0a6a1f1dSLionel Sambuc
135*0a6a1f1dSLionel Sambuc(void) elf_end(e);
136*0a6a1f1dSLionel Sambuc.Ed
137*0a6a1f1dSLionel Sambuc.Sh SEE ALSO
138*0a6a1f1dSLionel Sambuc.Xr elf_end 3 ,
139*0a6a1f1dSLionel Sambuc.Xr dwarf_elf_init 3 ,
140*0a6a1f1dSLionel Sambuc.Xr dwarf_get_elf 3 ,
141*0a6a1f1dSLionel Sambuc.Xr dwarf_init 3 ,
142*0a6a1f1dSLionel Sambuc.Xr dwarf_object_init 3
143