1*5ac3bc71Schristos.\" $NetBSD: dwarf_get_aranges.3,v 1.6 2024/03/03 17:37:31 christos Exp $ 2e81373b4Schristos.\" 39dd9d0cfSchristos.\" Copyright (c) 2011 Kai Wang 49dd9d0cfSchristos.\" All rights reserved. 59dd9d0cfSchristos.\" 69dd9d0cfSchristos.\" Redistribution and use in source and binary forms, with or without 79dd9d0cfSchristos.\" modification, are permitted provided that the following conditions 89dd9d0cfSchristos.\" are met: 99dd9d0cfSchristos.\" 1. Redistributions of source code must retain the above copyright 109dd9d0cfSchristos.\" notice, this list of conditions and the following disclaimer. 119dd9d0cfSchristos.\" 2. Redistributions in binary form must reproduce the above copyright 129dd9d0cfSchristos.\" notice, this list of conditions and the following disclaimer in the 139dd9d0cfSchristos.\" documentation and/or other materials provided with the distribution. 149dd9d0cfSchristos.\" 159dd9d0cfSchristos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 169dd9d0cfSchristos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 179dd9d0cfSchristos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 189dd9d0cfSchristos.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 199dd9d0cfSchristos.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 209dd9d0cfSchristos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 219dd9d0cfSchristos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 229dd9d0cfSchristos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 239dd9d0cfSchristos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 249dd9d0cfSchristos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 259dd9d0cfSchristos.\" SUCH DAMAGE. 269dd9d0cfSchristos.\" 27cdbf1fe1Sjkoshy.\" Id: dwarf_get_aranges.3 3962 2022-03-12 15:56:10Z jkoshy 289dd9d0cfSchristos.\" 299dd9d0cfSchristos.Dd November 9, 2011 309dd9d0cfSchristos.Dt DWARF_GET_ARANGES 3 31604b0842Sjkoshy.Os 329dd9d0cfSchristos.Sh NAME 339dd9d0cfSchristos.Nm dwarf_get_aranges 349dd9d0cfSchristos.Nd retrieve program address space mappings 359dd9d0cfSchristos.Sh LIBRARY 369dd9d0cfSchristos.Lb libdwarf 379dd9d0cfSchristos.Sh SYNOPSIS 389dd9d0cfSchristos.In libdwarf.h 399dd9d0cfSchristos.Ft int 409dd9d0cfSchristos.Fo dwarf_get_aranges 419dd9d0cfSchristos.Fa "Dwarf_Debug dbg" 429dd9d0cfSchristos.Fa "Dwarf_Arange **ar_list" 439dd9d0cfSchristos.Fa "Dwarf_Signed *ar_cnt" 449dd9d0cfSchristos.Fa "Dwarf_Error *err" 459dd9d0cfSchristos.Fc 469dd9d0cfSchristos.Sh DESCRIPTION 479dd9d0cfSchristosThe function 489dd9d0cfSchristos.Fn dwarf_get_aranges 499dd9d0cfSchristosretrieves address range information from the 509dd9d0cfSchristos.Dq ".debug_aranges" 519dd9d0cfSchristosDWARF section. 529dd9d0cfSchristosInformation about address ranges is returned using opaque descriptors 539dd9d0cfSchristosof type 549dd9d0cfSchristos.Vt Dwarf_Arange , 559dd9d0cfSchristos.Pp 569dd9d0cfSchristosArgument 57cdbf1fe1Sjkoshy.Fa dbg 589dd9d0cfSchristosshould reference a DWARF debug context allocated using 599dd9d0cfSchristos.Xr dwarf_init 3 . 609dd9d0cfSchristos.Pp 619dd9d0cfSchristosArgument 62cdbf1fe1Sjkoshy.Fa ar_list 639dd9d0cfSchristosshould point to a location which will be set to a pointer to an array 649dd9d0cfSchristosof 659dd9d0cfSchristos.Vt Dwarf_Arange 669dd9d0cfSchristosdescriptors. 679dd9d0cfSchristos.Pp 689dd9d0cfSchristosArgument 69cdbf1fe1Sjkoshy.Fa ar_cnt 709dd9d0cfSchristosshould point to a location which will be set to the number of 719dd9d0cfSchristosdescriptors returned. 729dd9d0cfSchristos.Pp 739dd9d0cfSchristosIf argument 74cdbf1fe1Sjkoshy.Fa err 75cdbf1fe1Sjkoshyis not 76cdbf1fe1Sjkoshy.Dv NULL , 77cdbf1fe1Sjkoshyit will be used to store error information in case of an error. 789dd9d0cfSchristos.Ss Memory Management 799dd9d0cfSchristosThe memory area used for the array returned in argument 80cdbf1fe1Sjkoshy.Fa ar_list 819dd9d0cfSchristosis owned by 829dd9d0cfSchristos.Lb libdwarf . 839dd9d0cfSchristosApplication code should not attempt to directly free this area. 849dd9d0cfSchristosPortable applications should instead use 859dd9d0cfSchristos.Xr dwarf_dealloc 3 869dd9d0cfSchristosto indicate that the memory area may be freed. 879dd9d0cfSchristos.Sh RETURN VALUES 889dd9d0cfSchristosFunction 899dd9d0cfSchristos.Fn dwarf_get_aranges 909dd9d0cfSchristosreturns 919dd9d0cfSchristos.Dv DW_DLV_OK 929dd9d0cfSchristoswhen it succeeds. 939dd9d0cfSchristosIt returns 949dd9d0cfSchristos.Dv DW_DLV_NO_ENTRY 959dd9d0cfSchristosif there is no 969dd9d0cfSchristos.Dq ".debug_aranges" 979dd9d0cfSchristossection associated with the specified debugging context. 989dd9d0cfSchristosIn case of an error, it returns 999dd9d0cfSchristos.Dv DW_DLV_ERROR 1009dd9d0cfSchristosand sets the argument 101cdbf1fe1Sjkoshy.Fa err . 102604b0842Sjkoshy.Sh EXAMPLES 1039dd9d0cfSchristosTo loop through all the address lookup table entries, use: 1049dd9d0cfSchristos.Bd -literal -offset indent 1059dd9d0cfSchristosDwarf_Debug dbg; 1069dd9d0cfSchristosDwarf_Addr start; 1079dd9d0cfSchristosDwarf_Arange *aranges; 1089dd9d0cfSchristosDwarf_Off die_off; 1099dd9d0cfSchristosDwarf_Signed i, cnt; 1109dd9d0cfSchristosDwarf_Unsigned length; 1119dd9d0cfSchristosDwarf_Error de; 1129dd9d0cfSchristos 1139dd9d0cfSchristosif (dwarf_get_aranges(dbg, &aranges, &cnt, &de) != DW_DLV_OK) 1149dd9d0cfSchristos errx(EXIT_FAILURE, "dwarf_get_aranges: %s", 1159dd9d0cfSchristos dwarf_errmsg(de)); 1169dd9d0cfSchristos 1179dd9d0cfSchristosfor (i = 0; i < cnt; i++) { 1189dd9d0cfSchristos if (dwarf_get_arange_info(aranges[i], &start, &length, 1199dd9d0cfSchristos &die_off, &de) != DW_DLV_OK) { 1209dd9d0cfSchristos warnx("dwarf_get_arange_info: %s", 1219dd9d0cfSchristos dwarf_errmsg(de)); 1229dd9d0cfSchristos continue; 1239dd9d0cfSchristos } 1249dd9d0cfSchristos /* Do something with the returned information. */ 1259dd9d0cfSchristos} 1269dd9d0cfSchristos.Ed 127604b0842Sjkoshy.Sh ERRORS 128604b0842SjkoshyFunction 129604b0842Sjkoshy.Fn dwarf_get_aranges 130604b0842Sjkoshycan fail with: 131604b0842Sjkoshy.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY" 132604b0842Sjkoshy.It Bq Er DW_DLE_ARGUMENT 133604b0842SjkoshyOne of the arguments 134cdbf1fe1Sjkoshy.Fa dbg , 135cdbf1fe1Sjkoshy.Fa ar_list 136604b0842Sjkoshyor 137cdbf1fe1Sjkoshy.Fa ar_cnt 138cdbf1fe1Sjkoshywas 139cdbf1fe1Sjkoshy.Dv NULL . 140604b0842Sjkoshy.It Bq Er DW_DLE_NO_ENTRY 141604b0842SjkoshyThe debugging context 142cdbf1fe1Sjkoshy.Fa dbg 143604b0842Sjkoshydid not contain a 144604b0842Sjkoshy.Dq ".debug_aranges" 145604b0842Sjkoshystring section. 146604b0842Sjkoshy.El 1479dd9d0cfSchristos.Sh SEE ALSO 1489dd9d0cfSchristos.Xr dwarf 3 , 1499dd9d0cfSchristos.Xr dwarf_get_arange 3 , 1509dd9d0cfSchristos.Xr dwarf_get_arange_cu_header_offset 3 , 1519dd9d0cfSchristos.Xr dwarf_get_arange_info 3 , 1529dd9d0cfSchristos.Xr dwarf_get_cu_die_offset 3 153