dwarf_string.c revision 49d3bc91e27cd871b950d56c01398fa2f2e12ab4
2N/A/*
2N/A
2N/A Copyright (C) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved.
2N/A
2N/A This program is free software; you can redistribute it and/or modify it
2N/A under the terms of version 2.1 of the GNU Lesser General Public License
2N/A as published by the Free Software Foundation.
2N/A
2N/A This program is distributed in the hope that it would be useful, but
2N/A WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2N/A
2N/A Further, this software is distributed without any warranty that it is
2N/A free of the rightful claim of any third person regarding infringement
2N/A or the like. Any license provided herein, whether implied or
2N/A otherwise, applies only to this software file. Patent licenses, if
2N/A any, provided herein do not apply to combinations of this program with
2N/A other software, or any other product whatsoever.
2N/A
2N/A You should have received a copy of the GNU Lesser General Public
2N/A License along with this program; if not, write the Free Software
2N/A Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307,
2N/A USA.
2N/A
2N/A Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky,
2N/A Mountain View, CA 94043, or:
2N/A
2N/A http://www.sgi.com
2N/A
2N/A For further information regarding this notice, see:
2N/A
2N/A http://oss.sgi.com/projects/GenInfo/NoticeExplan
2N/A
2N/A*/
2N/A
2N/A
2N/A
2N/A#include "config.h"
2N/A#include "dwarf_incl.h"
2N/A
2N/Aint
2N/Adwarf_get_str(Dwarf_Debug dbg,
2N/A Dwarf_Off offset,
2N/A char **string,
2N/A Dwarf_Signed * returned_str_len, Dwarf_Error * error)
2N/A{
2N/A int res;
2N/A
2N/A if (dbg == NULL) {
2N/A _dwarf_error(NULL, error, DW_DLE_DBG_NULL);
2N/A return (DW_DLV_ERROR);
2N/A }
2N/A
2N/A if (offset == dbg->de_debug_str_size) {
2N/A /* Normal (if we've iterated thru the set of strings
2N/A using dwarf_get_str and are at the end). */
2N/A return DW_DLV_NO_ENTRY;
2N/A }
2N/A if (offset > dbg->de_debug_str_size) {
2N/A _dwarf_error(dbg, error, DW_DLE_DEBUG_STR_OFFSET_BAD);
2N/A return (DW_DLV_ERROR);
2N/A }
2N/A
2N/A if (string == NULL) {
2N/A _dwarf_error(dbg, error, DW_DLE_STRING_PTR_NULL);
2N/A return (DW_DLV_ERROR);
2N/A }
2N/A
2N/A res =
2N/A _dwarf_load_section(dbg,
2N/A dbg->de_debug_str_index,
2N/A &dbg->de_debug_str,
2N/A error);
2N/A if (res != DW_DLV_OK) {
2N/A return res;
2N/A }
2N/A
2N/A *string = (char *) dbg->de_debug_str + offset;
2N/A
2N/A *returned_str_len = (strlen(*string));
2N/A return DW_DLV_OK;
2N/A}
2N/A