Branch data Line data Source code
1 : : /* Return tag of given DIE.
2 : : Copyright (C) 2003-2011, 2014 Red Hat, Inc.
3 : : This file is part of elfutils.
4 : : Written by Ulrich Drepper <drepper@redhat.com>, 2003.
5 : :
6 : : This file is free software; you can redistribute it and/or modify
7 : : it under the terms of either
8 : :
9 : : * the GNU Lesser General Public License as published by the Free
10 : : Software Foundation; either version 3 of the License, or (at
11 : : your option) any later version
12 : :
13 : : or
14 : :
15 : : * the GNU General Public License as published by the Free
16 : : Software Foundation; either version 2 of the License, or (at
17 : : your option) any later version
18 : :
19 : : or both in parallel, as here.
20 : :
21 : : elfutils is distributed in the hope that it will be useful, but
22 : : WITHOUT ANY WARRANTY; without even the implied warranty of
23 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 : : General Public License for more details.
25 : :
26 : : You should have received copies of the GNU General Public License and
27 : : the GNU Lesser General Public License along with this program. If
28 : : not, see <http://www.gnu.org/licenses/>. */
29 : :
30 : : #ifdef HAVE_CONFIG_H
31 : : # include <config.h>
32 : : #endif
33 : :
34 : : #include "libdwP.h"
35 : :
36 : :
37 : : Dwarf_Abbrev *
38 : : internal_function
39 : 34389238 : __libdw_findabbrev (struct Dwarf_CU *cu, unsigned int code)
40 : : {
41 : 34389238 : Dwarf_Abbrev *abb;
42 : :
43 : : /* Abbreviation code can never have a value of 0. */
44 [ + + ]: 34389238 : if (unlikely (code == 0))
45 : : return DWARF_END_ABBREV;
46 : :
47 : : /* See whether the entry is already in the hash table. */
48 : 34389232 : abb = Dwarf_Abbrev_Hash_find (&cu->abbrev_hash, code);
49 [ + + ]: 34389232 : if (abb == NULL)
50 [ + + ]: 2599390 : while (cu->last_abbrev_offset != (size_t) -1l)
51 : : {
52 : 2599386 : size_t length;
53 : :
54 : : /* Find the next entry. It gets automatically added to the
55 : : hash table. */
56 : 2599386 : mutex_lock (cu->abbrev_lock);
57 : 2599386 : abb = __libdw_getabbrev (cu->dbg, cu, cu->last_abbrev_offset, &length);
58 : :
59 [ + + ]: 2599386 : if (abb == NULL || abb == DWARF_END_ABBREV)
60 : : {
61 : : /* Make sure we do not try to search for it again. */
62 : 2 : cu->last_abbrev_offset = (size_t) -1l;
63 : 2 : mutex_unlock (cu->abbrev_lock);
64 : 2 : return DWARF_END_ABBREV;
65 : : }
66 : :
67 : 2599384 : cu->last_abbrev_offset += length;
68 : 2599384 : mutex_unlock (cu->abbrev_lock);
69 : :
70 : : /* Is this the code we are looking for? */
71 [ + + ]: 2599384 : if (abb->code == code)
72 : : break;
73 : : }
74 : :
75 : : /* This is our second (or third, etc.) call to __libdw_findabbrev
76 : : and the code is invalid. */
77 [ + + ]: 534986 : if (unlikely (abb == NULL))
78 : 12 : abb = DWARF_END_ABBREV;
79 : :
80 : : return abb;
81 : : }
82 : :
83 : :
84 : : int
85 : 53429404 : dwarf_tag (Dwarf_Die *die)
86 : : {
87 : : /* Find the abbreviation entry. */
88 : 53429404 : Dwarf_Abbrev *abbrevp = __libdw_dieabbrev (die, NULL);
89 [ + + ]: 53429404 : if (unlikely (abbrevp == DWARF_END_ABBREV))
90 : : {
91 : 12138 : __libdw_seterrno (DWARF_E_INVALID_DWARF);
92 : 12138 : return DW_TAG_invalid;
93 : : }
94 : :
95 : 53417266 : return abbrevp->tag;
96 : : }
97 : : INTDEF(dwarf_tag)
|