blob: 7224bb35fa6011324832b5e1694285b2a6d2a9dc [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001/* Iterate through DWARF compilation units across all modules.
2 Copyright (C) 2005 Red Hat, Inc.
3
4 This program is Open Source software; you can redistribute it and/or
5 modify it under the terms of the Open Software License version 1.0 as
6 published by the Open Source Initiative.
7
8 You should have received a copy of the Open Software License along
9 with this program; if not, you may obtain a copy of the Open Software
10 License version 1.0 from http://www.opensource.org/licenses/osl.php or
11 by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
12 3001 King Ranch Road, Ukiah, CA 95482. */
13
14#include "libdwflP.h"
15
16Dwarf_Die *
17dwfl_nextcu (Dwfl *dwfl, Dwarf_Die *lastcu, Dwarf_Addr *bias)
18{
19 if (dwfl == NULL)
20 return NULL;
21
22 struct dwfl_cu *cu = (struct dwfl_cu *) lastcu;
23 Dwfl_Module *mod;
24
25 if (cu == NULL)
26 {
27 mod = dwfl->modulelist;
28 goto nextmod;
29 }
30 else
31 mod = cu->mod;
32
33 Dwfl_Error error;
Roland McGrath995f92d2005-08-26 05:55:04 +000034 do
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000035 {
Roland McGrath995f92d2005-08-26 05:55:04 +000036 error = __libdwfl_nextcu (mod, cu, &cu);
37 if (error != DWFL_E_NOERROR)
38 break;
39
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000040 if (cu != NULL)
41 {
42 *bias = mod->debug.bias;
43 return &cu->die;
44 }
45
Roland McGrath995f92d2005-08-26 05:55:04 +000046 do
47 {
48 mod = mod->next;
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000049
Roland McGrath995f92d2005-08-26 05:55:04 +000050 nextmod:
51 if (mod == NULL)
52 return NULL;
53
54 error = mod->dwerr;
55 if (error == DWFL_E_NOERROR
56 && (mod->dw != NULL
57 || INTUSE(dwfl_module_getdwarf) (mod, bias) != NULL))
58 break;
59 }
60 while (error == DWFL_E_NO_DWARF);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000061 }
Roland McGrath995f92d2005-08-26 05:55:04 +000062 while (error == DWFL_E_NOERROR);
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000063
64 __libdwfl_seterrno (error);
65 return NULL;
66}
67INTDEF (dwfl_nextcu)