blob: 9ea83881b3b0125b89577704cb8a3b01ce046a24 [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001/* Iterate through DWARF compilation units across all modules.
Roland McGrath1743d7f2010-11-12 16:46:47 -08002 Copyright (C) 2005-2010 Red Hat, Inc.
Mark Wielaardde2ed972012-06-05 17:15:16 +02003 This file is part of elfutils.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00004
Mark Wielaardde2ed972012-06-05 17:15:16 +02005 This file is free software; you can redistribute it and/or modify
6 it under the terms of either
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00007
Mark Wielaardde2ed972012-06-05 17:15:16 +02008 * the GNU Lesser General Public License as published by the Free
9 Software Foundation; either version 3 of the License, or (at
10 your option) any later version
11
12 or
13
14 * the GNU General Public License as published by the Free
15 Software Foundation; either version 2 of the License, or (at
16 your option) any later version
17
18 or both in parallel, as here.
19
20 elfutils is distributed in the hope that it will be useful, but
Ulrich Drepper361df7d2006-04-04 21:38:57 +000021 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
24
Mark Wielaardde2ed972012-06-05 17:15:16 +020025 You should have received copies of the GNU General Public License and
26 the GNU Lesser General Public License along with this program. If
27 not, see <http://www.gnu.org/licenses/>. */
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000028
29#include "libdwflP.h"
30
31Dwarf_Die *
32dwfl_nextcu (Dwfl *dwfl, Dwarf_Die *lastcu, Dwarf_Addr *bias)
33{
34 if (dwfl == NULL)
35 return NULL;
36
37 struct dwfl_cu *cu = (struct dwfl_cu *) lastcu;
38 Dwfl_Module *mod;
39
40 if (cu == NULL)
41 {
42 mod = dwfl->modulelist;
43 goto nextmod;
44 }
45 else
46 mod = cu->mod;
47
48 Dwfl_Error error;
Roland McGrath995f92d2005-08-26 05:55:04 +000049 do
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000050 {
Roland McGrath995f92d2005-08-26 05:55:04 +000051 error = __libdwfl_nextcu (mod, cu, &cu);
52 if (error != DWFL_E_NOERROR)
53 break;
54
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000055 if (cu != NULL)
56 {
Roland McGrath1743d7f2010-11-12 16:46:47 -080057 *bias = dwfl_adjusted_dwarf_addr (mod, 0);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000058 return &cu->die;
59 }
60
Roland McGrath995f92d2005-08-26 05:55:04 +000061 do
62 {
63 mod = mod->next;
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000064
Roland McGrath995f92d2005-08-26 05:55:04 +000065 nextmod:
66 if (mod == NULL)
67 return NULL;
68
Roland McGrathfceb7b42005-12-23 01:45:21 +000069 if (mod->dwerr == DWFL_E_NOERROR
Roland McGrath995f92d2005-08-26 05:55:04 +000070 && (mod->dw != NULL
71 || INTUSE(dwfl_module_getdwarf) (mod, bias) != NULL))
72 break;
73 }
Roland McGrathfceb7b42005-12-23 01:45:21 +000074 while (mod->dwerr == DWFL_E_NO_DWARF);
75 error = mod->dwerr;
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000076 }
Roland McGrath995f92d2005-08-26 05:55:04 +000077 while (error == DWFL_E_NOERROR);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000078
79 __libdwfl_seterrno (error);
80 return NULL;
81}
82INTDEF (dwfl_nextcu)