2 * Copyright (c) 2009,2011 Kai Wang
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $Id: dwarf_nametbl.m4 2074 2011-10-27 03:34:33Z jkoshy $
29 define(`MAKE_NAMETBL_API',`
31 dwarf_get_$1s(Dwarf_Debug dbg, Dwarf_$2 **$1s,
32 Dwarf_Signed *ret_count, Dwarf_Error *error)
37 if (dbg == NULL || $1s == NULL || ret_count == NULL) {
38 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
39 return (DW_DLV_ERROR);
42 if (dbg->dbg_$1s == NULL) {
43 if ((ds = _dwarf_find_section(dbg, ".debug_$4")) != NULL) {
44 ret = _dwarf_nametbl_init(dbg, &dbg->dbg_$1s, ds,
46 if (ret != DW_DLE_NONE)
47 return (DW_DLV_ERROR);
49 if (dbg->dbg_$1s == NULL) {
50 DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
51 return (DW_DLV_NO_ENTRY);
55 *$1s = dbg->dbg_$1s->ns_array;
56 *ret_count = dbg->dbg_$1s->ns_len;
62 dwarf_$3name(Dwarf_$2 $1, char **ret_name, Dwarf_Error *error)
66 dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
68 if ($1 == NULL || ret_name == NULL) {
69 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
70 return (DW_DLV_ERROR);
73 *ret_name = $1->np_name;
79 dwarf_$1_die_offset(Dwarf_$2 $1, Dwarf_Off *ret_offset,
85 dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
87 if ($1 == NULL || ret_offset == NULL) {
88 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
89 return (DW_DLV_ERROR);
95 *ret_offset = nt->nt_cu_offset + $1->np_offset;
101 dwarf_$1_cu_offset(Dwarf_$2 $1, Dwarf_Off *ret_offset,
107 dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
109 if ($1 == NULL || ret_offset == NULL) {
110 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
111 return (DW_DLV_ERROR);
117 *ret_offset = nt->nt_cu_offset;
123 dwarf_$1_name_offsets(Dwarf_$2 $1, char **ret_name, Dwarf_Off *die_offset,
124 Dwarf_Off *cu_offset, Dwarf_Error *error)
130 dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
132 if ($1 == NULL || ret_name == NULL || die_offset == NULL ||
134 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
135 return (DW_DLV_ERROR);
144 *ret_name = $1->np_name;
145 *die_offset = nt->nt_cu_offset + $1->np_offset;
146 *cu_offset = cu->cu_1st_offset;
152 dwarf_$1s_dealloc(Dwarf_Debug dbg, Dwarf_$2 *$1s, Dwarf_Signed count)