Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 1 | /* 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 | |
| 16 | Dwarf_Die * |
| 17 | dwfl_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 McGrath | 995f92d | 2005-08-26 05:55:04 +0000 | [diff] [blame] | 34 | do |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 35 | { |
Roland McGrath | 995f92d | 2005-08-26 05:55:04 +0000 | [diff] [blame] | 36 | error = __libdwfl_nextcu (mod, cu, &cu); |
| 37 | if (error != DWFL_E_NOERROR) |
| 38 | break; |
| 39 | |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 40 | if (cu != NULL) |
| 41 | { |
| 42 | *bias = mod->debug.bias; |
| 43 | return &cu->die; |
| 44 | } |
| 45 | |
Roland McGrath | 995f92d | 2005-08-26 05:55:04 +0000 | [diff] [blame] | 46 | do |
| 47 | { |
| 48 | mod = mod->next; |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 49 | |
Roland McGrath | 995f92d | 2005-08-26 05:55:04 +0000 | [diff] [blame] | 50 | 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 Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 61 | } |
Roland McGrath | 995f92d | 2005-08-26 05:55:04 +0000 | [diff] [blame] | 62 | while (error == DWFL_E_NOERROR); |
Ulrich Drepper | b08d5a8 | 2005-07-26 05:00:05 +0000 | [diff] [blame] | 63 | |
| 64 | __libdwfl_seterrno (error); |
| 65 | return NULL; |
| 66 | } |
| 67 | INTDEF (dwfl_nextcu) |