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