|
1 /* |
|
2 |
|
3 Copyright (C) 2000,2002,2004 Silicon Graphics, Inc. All Rights Reserved. |
|
4 |
|
5 This program is free software; you can redistribute it and/or modify it |
|
6 under the terms of version 2.1 of the GNU Lesser General Public License |
|
7 as published by the Free Software Foundation. |
|
8 |
|
9 This program is distributed in the hope that it would be useful, but |
|
10 WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
12 |
|
13 Further, this software is distributed without any warranty that it is |
|
14 free of the rightful claim of any third person regarding infringement |
|
15 or the like. Any license provided herein, whether implied or |
|
16 otherwise, applies only to this software file. Patent licenses, if |
|
17 any, provided herein do not apply to combinations of this program with |
|
18 other software, or any other product whatsoever. |
|
19 |
|
20 You should have received a copy of the GNU Lesser General Public |
|
21 License along with this program; if not, write the Free Software |
|
22 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301, |
|
23 USA. |
|
24 |
|
25 Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane, |
|
26 Mountain View, CA 94043, or: |
|
27 |
|
28 http://www.sgi.com |
|
29 |
|
30 For further information regarding this notice, see: |
|
31 |
|
32 http://oss.sgi.com/projects/GenInfo/NoticeExplan |
|
33 |
|
34 */ |
|
35 |
|
36 |
|
37 |
|
38 #include "config.h" |
|
39 #include "dwarf_incl.h" |
|
40 |
|
41 int |
|
42 dwarf_get_str(Dwarf_Debug dbg, |
|
43 Dwarf_Off offset, |
|
44 char **string, |
|
45 Dwarf_Signed * returned_str_len, Dwarf_Error * error) |
|
46 { |
|
47 int res; |
|
48 |
|
49 if (dbg == NULL) { |
|
50 _dwarf_error(NULL, error, DW_DLE_DBG_NULL); |
|
51 return (DW_DLV_ERROR); |
|
52 } |
|
53 |
|
54 if (offset == dbg->de_debug_str_size) { |
|
55 /* Normal (if we've iterated thru the set of strings using |
|
56 dwarf_get_str and are at the end). */ |
|
57 return DW_DLV_NO_ENTRY; |
|
58 } |
|
59 if (offset > dbg->de_debug_str_size) { |
|
60 _dwarf_error(dbg, error, DW_DLE_DEBUG_STR_OFFSET_BAD); |
|
61 return (DW_DLV_ERROR); |
|
62 } |
|
63 |
|
64 if (string == NULL) { |
|
65 _dwarf_error(dbg, error, DW_DLE_STRING_PTR_NULL); |
|
66 return (DW_DLV_ERROR); |
|
67 } |
|
68 |
|
69 res = |
|
70 _dwarf_load_section(dbg, |
|
71 dbg->de_debug_str_index, |
|
72 &dbg->de_debug_str, error); |
|
73 if (res != DW_DLV_OK) { |
|
74 return res; |
|
75 } |
|
76 |
|
77 *string = (char *) dbg->de_debug_str + offset; |
|
78 |
|
79 *returned_str_len = (strlen(*string)); |
|
80 return DW_DLV_OK; |
|
81 } |