1*5ac3bc71Schristosdnl $NetBSD: dwarf_nametbl.m4,v 1.4 2024/03/03 17:37:31 christos Exp $ 29dd9d0cfSchristos/*- 39dd9d0cfSchristos * Copyright (c) 2009,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 * 279dd9d0cfSchristos * Id: dwarf_nametbl.m4 2074 2011-10-27 03:34:33Z jkoshy 289dd9d0cfSchristos */ 299dd9d0cfSchristos 309dd9d0cfSchristosdefine(`MAKE_NAMETBL_API',` 319dd9d0cfSchristosint 329dd9d0cfSchristosdwarf_get_$1s(Dwarf_Debug dbg, Dwarf_$2 **$1s, 339dd9d0cfSchristos Dwarf_Signed *ret_count, Dwarf_Error *error) 349dd9d0cfSchristos{ 359dd9d0cfSchristos Dwarf_Section *ds; 369dd9d0cfSchristos int ret; 379dd9d0cfSchristos 389dd9d0cfSchristos if (dbg == NULL || $1s == NULL || ret_count == NULL) { 399dd9d0cfSchristos DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT); 409dd9d0cfSchristos return (DW_DLV_ERROR); 419dd9d0cfSchristos } 429dd9d0cfSchristos 439dd9d0cfSchristos if (dbg->dbg_$1s == NULL) { 449dd9d0cfSchristos if ((ds = _dwarf_find_section(dbg, ".debug_$4")) != NULL) { 459dd9d0cfSchristos ret = _dwarf_nametbl_init(dbg, &dbg->dbg_$1s, ds, 469dd9d0cfSchristos error); 479dd9d0cfSchristos if (ret != DW_DLE_NONE) 489dd9d0cfSchristos return (DW_DLV_ERROR); 499dd9d0cfSchristos } 509dd9d0cfSchristos if (dbg->dbg_$1s == NULL) { 519dd9d0cfSchristos DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY); 529dd9d0cfSchristos return (DW_DLV_NO_ENTRY); 539dd9d0cfSchristos } 549dd9d0cfSchristos } 559dd9d0cfSchristos 569dd9d0cfSchristos *$1s = dbg->dbg_$1s->ns_array; 579dd9d0cfSchristos *ret_count = dbg->dbg_$1s->ns_len; 589dd9d0cfSchristos 599dd9d0cfSchristos return (DW_DLV_OK); 609dd9d0cfSchristos} 619dd9d0cfSchristos 629dd9d0cfSchristosint 639dd9d0cfSchristosdwarf_$3name(Dwarf_$2 $1, char **ret_name, Dwarf_Error *error) 649dd9d0cfSchristos{ 659dd9d0cfSchristos Dwarf_Debug dbg; 669dd9d0cfSchristos 679dd9d0cfSchristos dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL; 689dd9d0cfSchristos 699dd9d0cfSchristos if ($1 == NULL || ret_name == NULL) { 709dd9d0cfSchristos DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT); 719dd9d0cfSchristos return (DW_DLV_ERROR); 729dd9d0cfSchristos } 739dd9d0cfSchristos 749dd9d0cfSchristos *ret_name = $1->np_name; 759dd9d0cfSchristos 769dd9d0cfSchristos return (DW_DLV_OK); 779dd9d0cfSchristos} 789dd9d0cfSchristos 799dd9d0cfSchristosint 809dd9d0cfSchristosdwarf_$1_die_offset(Dwarf_$2 $1, Dwarf_Off *ret_offset, 819dd9d0cfSchristos Dwarf_Error *error) 829dd9d0cfSchristos{ 839dd9d0cfSchristos Dwarf_NameTbl nt; 849dd9d0cfSchristos Dwarf_Debug dbg; 859dd9d0cfSchristos 869dd9d0cfSchristos dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL; 879dd9d0cfSchristos 889dd9d0cfSchristos if ($1 == NULL || ret_offset == NULL) { 899dd9d0cfSchristos DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT); 909dd9d0cfSchristos return (DW_DLV_ERROR); 919dd9d0cfSchristos } 929dd9d0cfSchristos 939dd9d0cfSchristos nt = $1->np_nt; 949dd9d0cfSchristos assert(nt != NULL); 959dd9d0cfSchristos 969dd9d0cfSchristos *ret_offset = nt->nt_cu_offset + $1->np_offset; 979dd9d0cfSchristos 989dd9d0cfSchristos return (DW_DLV_OK); 999dd9d0cfSchristos} 1009dd9d0cfSchristos 1019dd9d0cfSchristosint 1029dd9d0cfSchristosdwarf_$1_cu_offset(Dwarf_$2 $1, Dwarf_Off *ret_offset, 1039dd9d0cfSchristos Dwarf_Error *error) 1049dd9d0cfSchristos{ 1059dd9d0cfSchristos Dwarf_NameTbl nt; 1069dd9d0cfSchristos Dwarf_Debug dbg; 1079dd9d0cfSchristos 1089dd9d0cfSchristos dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL; 1099dd9d0cfSchristos 1109dd9d0cfSchristos if ($1 == NULL || ret_offset == NULL) { 1119dd9d0cfSchristos DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT); 1129dd9d0cfSchristos return (DW_DLV_ERROR); 1139dd9d0cfSchristos } 1149dd9d0cfSchristos 1159dd9d0cfSchristos nt = $1->np_nt; 1169dd9d0cfSchristos assert(nt != NULL); 1179dd9d0cfSchristos 1189dd9d0cfSchristos *ret_offset = nt->nt_cu_offset; 1199dd9d0cfSchristos 1209dd9d0cfSchristos return (DW_DLV_OK); 1219dd9d0cfSchristos} 1229dd9d0cfSchristos 1239dd9d0cfSchristosint 1249dd9d0cfSchristosdwarf_$1_name_offsets(Dwarf_$2 $1, char **ret_name, Dwarf_Off *die_offset, 1259dd9d0cfSchristos Dwarf_Off *cu_offset, Dwarf_Error *error) 1269dd9d0cfSchristos{ 1279dd9d0cfSchristos Dwarf_CU cu; 1289dd9d0cfSchristos Dwarf_Debug dbg; 1299dd9d0cfSchristos Dwarf_NameTbl nt; 1309dd9d0cfSchristos 1319dd9d0cfSchristos dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL; 1329dd9d0cfSchristos 1339dd9d0cfSchristos if ($1 == NULL || ret_name == NULL || die_offset == NULL || 1349dd9d0cfSchristos cu_offset == NULL) { 1359dd9d0cfSchristos DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT); 1369dd9d0cfSchristos return (DW_DLV_ERROR); 1379dd9d0cfSchristos } 1389dd9d0cfSchristos 1399dd9d0cfSchristos nt = $1->np_nt; 1409dd9d0cfSchristos assert(nt != NULL); 1419dd9d0cfSchristos 1429dd9d0cfSchristos cu = nt->nt_cu; 1439dd9d0cfSchristos assert(cu != NULL); 1449dd9d0cfSchristos 1459dd9d0cfSchristos *ret_name = $1->np_name; 1469dd9d0cfSchristos *die_offset = nt->nt_cu_offset + $1->np_offset; 1479dd9d0cfSchristos *cu_offset = cu->cu_1st_offset; 1489dd9d0cfSchristos 1499dd9d0cfSchristos return (DW_DLV_OK); 1509dd9d0cfSchristos} 1519dd9d0cfSchristos 1529dd9d0cfSchristosvoid 1539dd9d0cfSchristosdwarf_$1s_dealloc(Dwarf_Debug dbg, Dwarf_$2 *$1s, Dwarf_Signed count) 1549dd9d0cfSchristos{ 1559dd9d0cfSchristos 1569dd9d0cfSchristos (void) dbg; 1579dd9d0cfSchristos (void) $1s; 1589dd9d0cfSchristos (void) count; 1599dd9d0cfSchristos} 1609dd9d0cfSchristos') 161