1.\" $NetBSD: dwarf_get_aranges.3,v 1.6 2024/03/03 17:37:31 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 3962 2022-03-12 15:56:10Z jkoshy 28.\" 29.Dd November 9, 2011 30.Dt DWARF_GET_ARANGES 3 31.Os 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.Fa dbg 58should reference a DWARF debug context allocated using 59.Xr dwarf_init 3 . 60.Pp 61Argument 62.Fa 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.Fa ar_cnt 70should point to a location which will be set to the number of 71descriptors returned. 72.Pp 73If argument 74.Fa err 75is not 76.Dv NULL , 77it will be used to store error information in case of an error. 78.Ss Memory Management 79The memory area used for the array returned in argument 80.Fa ar_list 81is owned by 82.Lb libdwarf . 83Application code should not attempt to directly free this area. 84Portable applications should instead use 85.Xr dwarf_dealloc 3 86to indicate that the memory area may be freed. 87.Sh RETURN VALUES 88Function 89.Fn dwarf_get_aranges 90returns 91.Dv DW_DLV_OK 92when it succeeds. 93It returns 94.Dv DW_DLV_NO_ENTRY 95if there is no 96.Dq ".debug_aranges" 97section associated with the specified debugging context. 98In case of an error, it returns 99.Dv DW_DLV_ERROR 100and sets the argument 101.Fa err . 102.Sh EXAMPLES 103To loop through all the address lookup table entries, use: 104.Bd -literal -offset indent 105Dwarf_Debug dbg; 106Dwarf_Addr start; 107Dwarf_Arange *aranges; 108Dwarf_Off die_off; 109Dwarf_Signed i, cnt; 110Dwarf_Unsigned length; 111Dwarf_Error de; 112 113if (dwarf_get_aranges(dbg, &aranges, &cnt, &de) != DW_DLV_OK) 114 errx(EXIT_FAILURE, "dwarf_get_aranges: %s", 115 dwarf_errmsg(de)); 116 117for (i = 0; i < cnt; i++) { 118 if (dwarf_get_arange_info(aranges[i], &start, &length, 119 &die_off, &de) != DW_DLV_OK) { 120 warnx("dwarf_get_arange_info: %s", 121 dwarf_errmsg(de)); 122 continue; 123 } 124 /* Do something with the returned information. */ 125} 126.Ed 127.Sh ERRORS 128Function 129.Fn dwarf_get_aranges 130can fail with: 131.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY" 132.It Bq Er DW_DLE_ARGUMENT 133One of the arguments 134.Fa dbg , 135.Fa ar_list 136or 137.Fa ar_cnt 138was 139.Dv NULL . 140.It Bq Er DW_DLE_NO_ENTRY 141The debugging context 142.Fa dbg 143did not contain a 144.Dq ".debug_aranges" 145string section. 146.El 147.Sh SEE ALSO 148.Xr dwarf 3 , 149.Xr dwarf_get_arange 3 , 150.Xr dwarf_get_arange_cu_header_offset 3 , 151.Xr dwarf_get_arange_info 3 , 152.Xr dwarf_get_cu_die_offset 3 153