dwarf_diecu.c revision 3e0f7d1d1b817040cef82f41879f471ab59b663e
107d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath/* Return CU DIE containing given DIE. 23e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath Copyright (C) 2005-2010 Red Hat, Inc. 3361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper This file is part of Red Hat elfutils. 407d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath 5361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper Red Hat elfutils is free software; you can redistribute it and/or modify 6361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper it under the terms of the GNU General Public License as published by the 7361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper Free Software Foundation; version 2 of the License. 807d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath 9361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper Red Hat elfutils is distributed in the hope that it will be useful, but 10361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper WITHOUT ANY WARRANTY; without even the implied warranty of 11361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper General Public License for more details. 13361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper 14361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper You should have received a copy of the GNU General Public License along 15361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper with Red Hat elfutils; if not, write to the Free Software Foundation, 161e9ef50681e20ef14c2ba38aef37a71ff148be08Ulrich Drepper Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. 17361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper 18361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper In addition, as a special exception, Red Hat, Inc. gives You the 19361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper additional right to link the code of Red Hat elfutils with code licensed 20361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper under any Open Source Initiative certified open source license 21361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper (http://www.opensource.org/licenses/index.php) which requires the 22361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper distribution of source code with any binary distribution and to 23361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper distribute linked combinations of the two. Non-GPL Code permitted under 24361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper this exception must only link to the code of Red Hat elfutils through 25361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper those well defined interfaces identified in the file named EXCEPTION 26361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper found in the source code files (the "Approved Interfaces"). The files 27361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper of Non-GPL Code may instantiate templates or use macros or inline 28361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper functions from the Approved Interfaces without causing the resulting 29361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper work to be covered by the GNU General Public License. Only Red Hat, 30361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper Inc. may make changes or additions to the list of Approved Interfaces. 31361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper Red Hat's grant of this exception is conditioned upon your not adding 32361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper any new exceptions. If you wish to add a new Approved Interface or 33361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper exception, please contact Red Hat. You must obey the GNU General Public 34361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper License in all respects for all of the Red Hat elfutils code and other 35361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper code used in conjunction with Red Hat elfutils except the Non-GPL Code 36361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper covered by this exception. If you modify this file, you may extend this 37361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper exception to your version of the file, but you are not obligated to do 38361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper so. If you do not wish to provide this exception without modification, 39361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper you must delete this exception statement from your version and license 40361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper this file solely under the GPL without exception. 41361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper 42361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper Red Hat elfutils is an included package of the Open Invention Network. 43361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper An included package of the Open Invention Network is a package for which 44361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper Open Invention Network licensees cross-license their patents. No patent 45361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper license is granted, either expressly or impliedly, by designation as an 46361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper included package. Should you wish to participate in the Open Invention 47361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper Network licensing program, please visit www.openinventionnetwork.com 48361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper <http://www.openinventionnetwork.com>. */ 4907d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath 5007d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath#ifdef HAVE_CONFIG_H 5107d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath# include <config.h> 5207d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath#endif 5307d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath 5407d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath#include <string.h> 5507d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath#include "libdwP.h" 5607d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath 5707d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath 5807d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrathDwarf_Die * 5907d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrathdwarf_diecu (die, result, address_sizep, offset_sizep) 6007d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath Dwarf_Die *die; 6107d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath Dwarf_Die *result; 6207d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath uint8_t *address_sizep; 6307d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath uint8_t *offset_sizep; 6407d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath{ 6507d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath if (die == NULL) 6607d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath return NULL; 6707d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath 6807d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath /* Clear the entire DIE structure. This signals we have not yet 6907d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath determined any of the information. */ 7007d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath memset (result, '\0', sizeof (Dwarf_Die)); 7107d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath 7207d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath result->addr = ((char *) die->cu->dbg->sectiondata[IDX_debug_info]->d_buf 73c57b65cf3b1a7a19b25fdac91e83c514fd93e565Ulrich Drepper + DIE_OFFSET_FROM_CU_OFFSET (die->cu->start, 743e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath die->cu->offset_size, 753e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath die->cu->type_offset != 0)); 7607d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath result->cu = die->cu; 7707d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath 7807d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath if (address_sizep != NULL) 7907d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath *address_sizep = die->cu->address_size; 8007d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath if (offset_sizep != NULL) 8107d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath *offset_sizep = die->cu->offset_size; 8207d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath 8307d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath return result; 8407d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath} 85