source: rtems-tools/rtemstoolkit/elftoolchain/libdwarf/dwarf_get_abbrev.3 @ 4bb3996

5
Last change on this file since 4bb3996 was 4bb3996, checked in by Chris Johns <chrisj@…>, on 04/30/18 at 05:34:48

rtemstoolkit: Add libdwarf from elftoolchain.

The code is taken from:

https://svn.code.sf.net/p/elftoolchain/code/trunk

Update #3417

  • Property mode set to 100644
File size: 4.9 KB
Line 
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_abbrev.3 2071 2011-10-27 03:20:00Z jkoshy $
26.\"
27.Dd March 27, 2011
28.Os
29.Dt DWARF_GET_ABBREV 3
30.Sh NAME
31.Nm dwarf_get_abbrev
32.Nd retrieve abbreviation information
33.Sh LIBRARY
34.Lb libdwarf
35.Sh SYNOPSIS
36.In libdwarf.h
37.Ft int
38.Fo dwarf_get_abbrev
39.Fa "Dwarf_Debug dbg"
40.Fa "Dwarf_Unsigned offset"
41.Fa "Dwarf_Abbrev *ret_abbrev"
42.Fa "Dwarf_Unsigned *length"
43.Fa "Dwarf_Unsigned *attr_count"
44.Fa "Dwarf_Error *err"
45.Fc
46.Sh DESCRIPTION
47Function
48.Fn dwarf_get_abbrev
49retrieves information about an abbreviation from the DWARF abbreviations
50section,
51.Dq ".debug_abbrev" .
52Abbreviation information is returned using an opaque descriptor
53of type
54.Vt Dwarf_Abbrev .
55The returned
56.Vt Dwarf_Abbrev
57descriptor may then be passed to the other abbreviation related APIs
58in the DWARF(3) API to retrieve specific information about the
59abbreviation.
60.Pp
61Argument
62.Ar dbg
63should reference a DWARF debug context allocated using
64.Xr dwarf_init 3 .
65.Pp
66Argument
67.Ar offset
68should be an offset, relative to the
69.Dq ".debug_abbrev"
70section, to the start of an abbreviation entry.
71.Pp
72Argument
73.Ar ret_abbrev
74should point to a location that will hold a pointer to the
75returned
76.Vt Dwarf_Abbrev
77descriptor.
78.Pp
79Argument
80.Ar length
81should point to a location that will hold the number of bytes used
82by the abbrevation in the DWARF
83.Dq ".debug_abbrev"
84section.
85.Pp
86Argument
87.Ar attr_count
88should point to a location that will hold the number of
89attributes in the abbrevation.
90.Pp
91If argument
92.Ar err
93is not NULL, it will be used to store error information in case of an
94error.
95.Ss Memory Management
96The memory area used for the
97.Vt Dwarf_Abbrev
98descriptor returned in argument
99.Ar ret_abbrev
100is allocated by the
101.Lb libdwarf .
102Application code should use function
103.Fn dwarf_dealloc
104with the allocation type
105.Dv DW_DLA_ABBREV
106to free the memory area when the
107.Vt Dwarf_Abbrev
108descriptor is no longer needed.
109.Ss Application Programming Notes
110The last abbreviation entry in a standard DWARF abbreviation section
111will have a special length value of 1.
112.Sh RETURN VALUES
113Function
114.Fn dwarf_get_abbrev
115returns
116.Dv DW_DLV_OK
117when it succeeds.
118It returns
119.Dv DW_DLV_NO_ENTRY
120if there is no abbreviation information at offset
121.Ar offset .
122In case of an error, it returns
123.Dv DW_DLV_ERROR
124and sets the argument
125.Ar err .
126.Sh ERRORS
127Function
128.Fn dwarf_get_abbrev
129can fail with:
130.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
131.It Bq Er DW_DLE_ARGUMENT
132One of the arguments
133.Ar dbg ,
134.Ar ret_abbrev ,
135.Ar length
136or
137.Ar attr_count
138was NULL.
139.It Bq Er DW_DLE_NO_ENTRY
140There is no abbreviation information at offset
141.Ar offset .
142.El
143.Sh EXAMPLE
144To loop through all the abbreviation information associated with
145a DWARF debug context, use:
146.Bd -literal -offset indent
147Dwarf_Debug dbg;
148Dwarf_Abbrev ab;
149Dwarf_Off aboff;
150Dwarf_Unsigned length, attr_count;
151Dwarf_Half tag;
152Dwarf_Error de;
153int ret;
154
155while ((ret = dwarf_next_cu_header(dbg, NULL, NULL, &aboff,
156    NULL, NULL, &de)) ==  DW_DLV_OK) {
157        while ((ret = dwarf_get_abbrev(re->dbg, aboff, &ab, &length,
158            &attr_count, &de)) == DW_DLV_OK) {
159                if (length == 1)        /* Last entry. */
160                        break;
161                aboff += length;
162                if (dwarf_get_abbrev_tag(ab, &tag, &de) != DW_DLV_OK) {
163                        warnx("dwarf_get_abbrev_tag failed: %s",
164                            dwarf_errmsg(de));
165                        continue;
166                }
167        if (ret != DW_DLV_OK)
168                warnx("dwarf_get_abbrev: %s", dwarf_errmsg(de));
169}
170if (ret == DW_DLV_ERROR)
171        warnx("dwarf_next_cu_header: %s", dwarf_errmsg(de));
172.Ed
173.Sh SEE ALSO
174.Xr dwarf 3 ,
175.Xr dwarf_dealloc 3 ,
176.Xr dwarf_get_abbrev_tag 3 ,
177.Xr dwarf_get_abbrev_code 3 ,
178.Xr dwarf_get_abbrev_children_flag 3 ,
179.Xr dwarf_get_abbrev_entry 3
Note: See TracBrowser for help on using the repository browser.