xref: /illumos-gate/usr/src/lib/libdwarf/common/pro_vars.c (revision 9b9d39d2a32ff806d2431dbcc50968ef1e6d46b2)
1 /*
2 
3   Copyright (C) 2000,2004 Silicon Graphics, Inc.  All Rights Reserved.
4   Portions Copyright 2011  David Anderson. All Rights Reserved.
5 
6   This program is free software; you can redistribute it and/or modify it
7   under the terms of version 2.1 of the GNU Lesser General Public License
8   as published by the Free Software Foundation.
9 
10   This program is distributed in the hope that it would be useful, but
11   WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 
14   Further, this software is distributed without any warranty that it is
15   free of the rightful claim of any third person regarding infringement
16   or the like.  Any license provided herein, whether implied or
17   otherwise, applies only to this software file.  Patent licenses, if
18   any, provided herein do not apply to combinations of this program with
19   other software, or any other product whatsoever.
20 
21   You should have received a copy of the GNU Lesser General Public
22   License along with this program; if not, write the Free Software
23   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
24   USA.
25 
26 */
27 
28 #include "config.h"
29 #include "libdwarfdefs.h"
30 #include <stdio.h>
31 #ifdef HAVE_STRING_H
32 #include <string.h>
33 #endif /* HAVE_STRING_H */
34 #ifdef HAVE_ELFACCESS_H
35 #include <elfaccess.h>
36 #endif
37 #include "pro_incl.h"
38 #ifdef HAVE_STDDEF_H
39 #include <stddef.h>
40 #endif /* HAVE_STDDEF_H */
41 #include "dwarf.h"
42 #include "libdwarf.h"
43 #include "pro_opaque.h"
44 #include "pro_error.h"
45 #include "pro_section.h"
46 
47 /*
48     This function adds another variable name to the
49     list of variable names for the given Dwarf_P_Debug.
50     It returns 0 on error, and 1 otherwise.
51 */
52 Dwarf_Unsigned
53 dwarf_add_varname(Dwarf_P_Debug dbg,
54     Dwarf_P_Die die, char *var_name, Dwarf_Error * error)
55 {
56     int res = 0;
57     res = _dwarf_add_simple_name_entry(dbg, die, var_name,
58         dwarf_snk_varname, error);
59     if (res != DW_DLV_OK) {
60         return 0;
61     }
62     return 1;
63 }
64 
65 
66 int
67 dwarf_add_varname_a(Dwarf_P_Debug dbg,
68     Dwarf_P_Die die, char *var_name, Dwarf_Error * error)
69 {
70     int res = 0;
71     res = _dwarf_add_simple_name_entry(dbg, die, var_name,
72         dwarf_snk_varname, error);
73     return res;
74 }
75