]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/elftoolchain/libdwarf/dwarf_get_aranges.3
Fix route flags update during RTM_CHANGE.
[FreeBSD/FreeBSD.git] / contrib / elftoolchain / libdwarf / dwarf_get_aranges.3
1 .\" Copyright (c) 2011 Kai Wang
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $Id: dwarf_get_aranges.3 3644 2018-10-15 19:55:01Z jkoshy $
26 .\"
27 .Dd November 9, 2011
28 .Dt DWARF_GET_ARANGES 3
29 .Os
30 .Sh NAME
31 .Nm dwarf_get_aranges
32 .Nd retrieve program address space mappings
33 .Sh LIBRARY
34 .Lb libdwarf
35 .Sh SYNOPSIS
36 .In libdwarf.h
37 .Ft int
38 .Fo dwarf_get_aranges
39 .Fa "Dwarf_Debug dbg"
40 .Fa "Dwarf_Arange **ar_list"
41 .Fa "Dwarf_Signed *ar_cnt"
42 .Fa "Dwarf_Error *err"
43 .Fc
44 .Sh DESCRIPTION
45 The function
46 .Fn dwarf_get_aranges
47 retrieves address range information from the
48 .Dq ".debug_aranges"
49 DWARF section.
50 Information about address ranges is returned using opaque descriptors
51 of type
52 .Vt Dwarf_Arange ,
53 .Pp
54 Argument
55 .Ar dbg
56 should reference a DWARF debug context allocated using
57 .Xr dwarf_init 3 .
58 .Pp
59 Argument
60 .Ar ar_list
61 should point to a location which will be set to a pointer to an array
62 of
63 .Vt Dwarf_Arange
64 descriptors.
65 .Pp
66 Argument
67 .Ar ar_cnt
68 should point to a location which will be set to the number of
69 descriptors returned.
70 .Pp
71 If argument
72 .Ar err
73 is not NULL, it will be used to store error information in case of an
74 error.
75 .Ss Memory Management
76 The memory area used for the array returned in argument
77 .Ar ar_list
78 is owned by
79 .Lb libdwarf .
80 Application code should not attempt to directly free this area.
81 Portable applications should instead use
82 .Xr dwarf_dealloc 3
83 to indicate that the memory area may be freed.
84 .Sh RETURN VALUES
85 Function
86 .Fn dwarf_get_aranges
87 returns
88 .Dv DW_DLV_OK
89 when it succeeds.
90 It returns
91 .Dv DW_DLV_NO_ENTRY
92 if there is no
93 .Dq ".debug_aranges"
94 section associated with the specified debugging context.
95 In case of an error, it returns
96 .Dv DW_DLV_ERROR
97 and sets the argument
98 .Ar err .
99 .Sh EXAMPLES
100 To loop through all the address lookup table entries, use:
101 .Bd -literal -offset indent
102 Dwarf_Debug dbg;
103 Dwarf_Addr start;
104 Dwarf_Arange *aranges;
105 Dwarf_Off die_off;
106 Dwarf_Signed i, cnt;
107 Dwarf_Unsigned length;
108 Dwarf_Error de;
109
110 if (dwarf_get_aranges(dbg, &aranges, &cnt, &de) != DW_DLV_OK)
111         errx(EXIT_FAILURE, "dwarf_get_aranges: %s",
112             dwarf_errmsg(de));
113
114 for (i = 0; i < cnt; i++) {
115         if (dwarf_get_arange_info(aranges[i], &start, &length,
116             &die_off, &de) != DW_DLV_OK) {
117                 warnx("dwarf_get_arange_info: %s",
118                     dwarf_errmsg(de));
119                 continue;
120         }
121         /* Do something with the returned information. */
122 }
123 .Ed
124 .Sh ERRORS
125 Function
126 .Fn dwarf_get_aranges
127 can fail with:
128 .Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
129 .It Bq Er DW_DLE_ARGUMENT
130 One of the arguments
131 .Ar dbg ,
132 .Ar ar_list
133 or
134 .Ar ar_cnt
135 was NULL.
136 .It Bq Er DW_DLE_NO_ENTRY
137 The debugging context
138 .Ar dbg
139 did not contain a
140 .Dq ".debug_aranges"
141 string section.
142 .El
143 .Sh SEE ALSO
144 .Xr dwarf 3 ,
145 .Xr dwarf_get_arange 3 ,
146 .Xr dwarf_get_arange_cu_header_offset 3 ,
147 .Xr dwarf_get_arange_info 3 ,
148 .Xr dwarf_get_cu_die_offset 3