107d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath/* Return CU DIE containing given DIE.
23e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath   Copyright (C) 2005-2010 Red Hat, Inc.
3de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   This file is part of elfutils.
407d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
5de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   This file is free software; you can redistribute it and/or modify
6de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   it under the terms of either
707d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
8de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard     * the GNU Lesser General Public License as published by the Free
9de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       Software Foundation; either version 3 of the License, or (at
10de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       your option) any later version
11de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
12de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   or
13de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
14de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard     * the GNU General Public License as published by the Free
15de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       Software Foundation; either version 2 of the License, or (at
16de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       your option) any later version
17de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
18de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   or both in parallel, as here.
19de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
20de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   elfutils is distributed in the hope that it will be useful, but
21361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper   WITHOUT ANY WARRANTY; without even the implied warranty of
22361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper   General Public License for more details.
24361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper
25de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   You should have received copies of the GNU General Public License and
26de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   the GNU Lesser General Public License along with this program.  If
27de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   not, see <http://www.gnu.org/licenses/>.  */
2807d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
2907d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath#ifdef HAVE_CONFIG_H
3007d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath# include <config.h>
3107d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath#endif
3207d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
3307d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath#include <string.h>
3407d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath#include "libdwP.h"
3507d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
3607d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
3707d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrathDwarf_Die *
381ccdfb683ad6c7e59793136c3a657ddf131cafd1Mark Wielaarddwarf_diecu (Dwarf_Die *die, Dwarf_Die *result, uint8_t *address_sizep,
391ccdfb683ad6c7e59793136c3a657ddf131cafd1Mark Wielaard	     uint8_t *offset_sizep)
4007d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath{
4107d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath  if (die == NULL)
4207d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath    return NULL;
4307d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
445cc030d6169713ff4711c28a6ce1250b142cd5b3Roland McGrath  *result = CUDIE (die->cu);
4507d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
4607d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath  if (address_sizep != NULL)
4707d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath    *address_sizep = die->cu->address_size;
4807d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath  if (offset_sizep != NULL)
4907d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath    *offset_sizep = die->cu->offset_size;
5007d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath
5107d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath  return result;
5207d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrath}
53