1 /* $NetBSD: dwarf_nametbl.m4,v 1.2 2014/03/09 16:58:04 christos Exp $ */
4 * Copyright (c) 2009,2011 Kai Wang
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * Id: dwarf_nametbl.m4 2074 2011-10-27 03:34:33Z jkoshy
31 define(`MAKE_NAMETBL_API',`
33 dwarf_get_$1s(Dwarf_Debug dbg, Dwarf_$2 **$1s,
34 Dwarf_Signed *ret_count, Dwarf_Error *error)
39 if (dbg == NULL || $1s == NULL || ret_count == NULL) {
40 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
41 return (DW_DLV_ERROR);
44 if (dbg->dbg_$1s == NULL) {
45 if ((ds = _dwarf_find_section(dbg, ".debug_$4")) != NULL) {
46 ret = _dwarf_nametbl_init(dbg, &dbg->dbg_$1s, ds,
48 if (ret != DW_DLE_NONE)
49 return (DW_DLV_ERROR);
51 if (dbg->dbg_$1s == NULL) {
52 DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
53 return (DW_DLV_NO_ENTRY);
57 *$1s = dbg->dbg_$1s->ns_array;
58 *ret_count = dbg->dbg_$1s->ns_len;
64 dwarf_$3name(Dwarf_$2 $1, char **ret_name, Dwarf_Error *error)
68 dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
70 if ($1 == NULL || ret_name == NULL) {
71 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
72 return (DW_DLV_ERROR);
75 *ret_name = $1->np_name;
81 dwarf_$1_die_offset(Dwarf_$2 $1, Dwarf_Off *ret_offset,
87 dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
89 if ($1 == NULL || ret_offset == NULL) {
90 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
91 return (DW_DLV_ERROR);
97 *ret_offset = nt->nt_cu_offset + $1->np_offset;
103 dwarf_$1_cu_offset(Dwarf_$2 $1, Dwarf_Off *ret_offset,
109 dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
111 if ($1 == NULL || ret_offset == NULL) {
112 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
113 return (DW_DLV_ERROR);
119 *ret_offset = nt->nt_cu_offset;
125 dwarf_$1_name_offsets(Dwarf_$2 $1, char **ret_name, Dwarf_Off *die_offset,
126 Dwarf_Off *cu_offset, Dwarf_Error *error)
132 dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
134 if ($1 == NULL || ret_name == NULL || die_offset == NULL ||
136 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
137 return (DW_DLV_ERROR);
146 *ret_name = $1->np_name;
147 *die_offset = nt->nt_cu_offset + $1->np_offset;
148 *cu_offset = cu->cu_1st_offset;
154 dwarf_$1s_dealloc(Dwarf_Debug dbg, Dwarf_$2 *$1s, Dwarf_Signed count)